diff --git a/app/address/[address]/layout.tsx b/app/address/[address]/layout.tsx index 0a8f2930..9d42df42 100644 --- a/app/address/[address]/layout.tsx +++ b/app/address/[address]/layout.tsx @@ -257,6 +257,7 @@ function AccountHeader({ tokenInfo?: FullTokenInfo; isTokenInfoLoading: boolean; }) { + const [tokenData, setTokenData] = React.useState(""); const mintInfo = useMintAccountInfo(address); const parsedData = account?.data.parsed; @@ -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