Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions lib/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,14 @@ async function getMetaplexMetadataForToken(
const decodedMetadata = deserializeMetadata(
tokenMetaDataAccount as unknown as RpcAccount
);
const uriRes = await fetch(decodedMetadata.uri);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually needed as the URI contains parts of the data not just the token metadata. Its actually the URI that contains the image url.
Screenshot 2024-06-07 at 9 34 43 PM

Screenshot 2024-06-07 at 9 34 58 PM Screenshot 2024-06-07 at 9 35 03 PM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And ONLY for the image is why we do it this way..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the uri is actually only the image link, so we were trying to parse the png format as json (what's inside the image url)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@swaggymarie swaggymarie Jun 7, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

you can see here uri is the right url

@swaggymarie swaggymarie Jun 7, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the standard and should we change our way to create metadata to align?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metadata there isn't standard... So it's not following it, yes I'd encourage our adherence to the metadata standard.

const jsonMetadata = (await uriRes.json()) as JsonMetadata;
return !!jsonMetadata
? {
symbol: jsonMetadata.symbol ?? "",
publicKey: tokenAddress.toString(),
url: jsonMetadata.image ?? null,
decimals: mint.decimals ?? 6,
name: jsonMetadata.name ?? null
}
: null;
return (
{
symbol: decodedMetadata.symbol ?? "",
publicKey: tokenAddress.toString(),
url: decodedMetadata.uri ?? null,
decimals: mint.decimals ?? 6,
name: decodedMetadata.name ?? null
})
}
return null;
} catch (e) {
Expand Down