Skip to content

Commit 3137bf1

Browse files
author
Giannis Chatziveroglou
committed
ReadMe changes
1 parent c3bed95 commit 3137bf1

3 files changed

Lines changed: 22777 additions & 16 deletions

File tree

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ Dynamic attributes have a separate parameters that allows for generic setting of
6060
This is a summary of logic in the metadata-generator handler
6161

6262
Example getting “stakeBoost” from this staked NFT
63-
https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.stakeBoost
63+
https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.stakeBoost
6464

6565
Example getting “stakeBoost” from this staked NFT and naming it Boost
66-
https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.Boost:stakeBoost
66+
https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.Boost:stakeBoost
6767

6868
Example getting all fields from this staked NFT account
69-
https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.\*
69+
[https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.\*](https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.*)
7070

7171
Example getting multiple fields from this staked NFT account
7272
https://nft.cardinal.so/metadata/9Pt7GiyL5N4Zc2cEcLd112GpZhCD9KWxnYE4h9DmRpDo?uri=https://arweave.net/BpIxD8LTr4934uk237kdc4QvCD_PWrY-51Dayh7h5V0&attrs=9kRs4BPUqYh3Vk1v1J8WE694afGFjfi4QeF3AfVUbfMn.StakeEntry.Boost:stakeBoost,Seconds%20staked:totalStakeSeconds
@@ -79,23 +79,23 @@ Styles
7979

8080
- None
8181
- Basic white test
82-
- e.g. https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=TEXT
82+
- e.g. https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=none:TEXT
8383

8484
<div style="text-align: center; width: 100%;">
8585
<img style="height: 250px" src="https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=none:TEXT" />
8686
</div>
8787

8888
- Overlay
8989
- Overlay text centered over the image with a partially transparent background and border
90-
- e.g. https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=TEXT
90+
- e.g. https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=overlay:TEXT
9191

9292
<div style="text-align: center; width: 100%;">
9393
<img style="height: 250px" src="https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=overlay:TEXT" />
9494
</div>
9595

9696
- Header
9797
- Header text at the top of the image
98-
- e.g https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=TEXT
98+
- e.g https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=header:HEADER
9999

100100
<div style="text-align: center; width: 100%;">
101101
<img style="height: 250px" src="https://nft.cardinal.so/img/D4vFpxAi9JFC5KaFyM3R92BbxP1Fu1daKSay53Uo9cgF?uri=https://arweave.net/QPsEEJ-YpRjF35LzHWGhuknJ0tdN7n0ehjxpvpwFYmE?ext=jpg&text=header:HEADER" />
@@ -114,7 +114,3 @@ For issues please, file a GitHub issue.
114114
Cardinal generators is licensed under the GNU Affero General Public License v3.0.
115115

116116
In short, this means that any changes to this code must be made open source and available under the AGPL-v3.0 license, even if only used privately.
117-
118-
```
119-
120-
```

api/metadata-generator/generator.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ export async function getMetadata(
6969
}
7070
}
7171

72-
// get originalMint uri if present
73-
const originalMint = tokenData?.certificateData?.parsed
74-
.originalMint as web3.PublicKey;
75-
7672
const dynamicAttributes: {
7773
display_type: string;
7874
value: string;
@@ -89,7 +85,9 @@ export async function getMetadata(
8985
// scoped fields
9086
const [address, accountType, fieldGroupParam] = scopes;
9187
const accountInfo = await connection.getAccountInfo(
92-
new web3.PublicKey(address)
88+
address.includes("attrs")
89+
? new web3.PublicKey(address.split("=")[1])
90+
: new web3.PublicKey(address)
9391
);
9492
const programId = accountInfo?.owner!;
9593
const IDL = (await import(
@@ -129,6 +127,9 @@ export async function getMetadata(
129127
}
130128
}
131129

130+
// ovverride uri with originalMint uri if present
131+
const originalMint = tokenData?.certificateData?.parsed
132+
.originalMint as web3.PublicKey;
132133
let originalTokenData: TokenData | null = null;
133134
if (originalMint) {
134135
try {
@@ -148,7 +149,6 @@ export async function getMetadata(
148149
const [namespace, _entryName] = namespaces.breakName(
149150
fullName || textParam || ""
150151
);
151-
console.log(tokenData);
152152
if (namespace === "twitter") {
153153
const owner = await getOwner(secondaryConnectionFor(cluster), mintId);
154154
return getTwitterMetadata(fullName, mintId, owner.toString(), cluster);

0 commit comments

Comments
 (0)