Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix metaplex metadata already parsed #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Member

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
Member

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
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
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

@swaggymarie swaggymarie Jun 7, 2024

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

Copy link
Contributor Author

@swaggymarie swaggymarie Jun 7, 2024

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
Member

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
Loading