Skip to content

Commit

Permalink
fix: add logo support for PYUSD & USDP
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinred committed Jun 11, 2024
1 parent 06b1864 commit 03d7b2e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/address/[address]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ function AccountHeader({
tokenInfo?: FullTokenInfo;
isTokenInfoLoading: boolean;
}) {
const [tokenData, setTokenData] = React.useState("");
const mintInfo = useMintAccountInfo(address);

const parsedData = account?.data.parsed;
Expand All @@ -283,10 +284,19 @@ function AccountHeader({
const tokenMetadata = create(metadataExtension.state, TokenMetadata);
const { metadataAddress } = create(metadataPointerExtension.state, MetadataPointer);

(async () => {
// Avoid re-renders once tokenData has been set
if (typeof tokenData !== 'object') {
const response = await fetch(tokenMetadata.uri);
setTokenData(await response.json());
}
})();

// Handles the basic case where MetadataPointer is reference the Token Metadata extension directly
// Does not handle the case where MetadataPointer is pointing at a separate account.
if (metadataAddress?.toString() === address) {
token.name = tokenMetadata.name
token.name = tokenData?.name;
token.logoURI = tokenData?.image;
}
}
// Fall back to legacy token list when there is stub metadata (blank uri), updatable by default by the mint authority
Expand Down

0 comments on commit 03d7b2e

Please sign in to comment.