Skip to content

Commit

Permalink
fix: simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pkxro committed May 29, 2024
1 parent 2568db0 commit 9774785
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions app/address/[address]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,25 +266,18 @@ function AccountHeader({ address, account, tokenInfo, isTokenInfoLoading }: { ad


// Checks the uri, if it's json, return the the json's image tag
try {
if (tokenMetadata.uri.endsWith('.json')) {
fetch(tokenMetadata.uri)
.then(response => response.json())
.then(metadata => {
if (metadata && metadata.image) {
token.logoURI = metadata.image;
}
})
.catch(e => {
token.logoURI = tokenMetadata.uri;
});
} else {
token.logoURI = tokenMetadata.uri;
}
} catch {
if (tokenMetadata.uri.endsWith('.json')) {
fetch(tokenMetadata.uri)
.then(response => response.json())
.then(metadata => {
token.logoURI = metadata?.image || tokenMetadata.uri;
})
.catch(() => {
token.logoURI = tokenMetadata.uri;
});
} else {
token.logoURI = tokenMetadata.uri;
}

}

// 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 9774785

Please sign in to comment.