Skip to content

Commit

Permalink
fix: account for disparities in nft_token response
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Haynes committed Mar 7, 2022
1 parent d620cfa commit 4cf6874
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/frontend/src/services/NonFungibleTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ export default class NonFungibleTokens {

static getToken = async (contractName, tokenId, base_uri) => {
const token = await this.viewFunctionAccount.viewFunction(contractName, 'nft_token', { token_id: tokenId });

// need to restructure response for Mintbase NFTs for consistency with NFT spec
if (token.id && !token.token_id) {
token.token_id = token.id.toString();
delete token.id;
}

if (token.owner_id && token.owner_id.Account) {
token.owner_id = token.owner_id.Account;
}

if (!token.metadata || !token.metadata.media) {
token.metadata = {
...token.metadata,
...(await this.getTokenMetadata(contractName, tokenId, base_uri)),
};
}

return this.mapTokenMediaUrl(token, base_uri);
}

Expand Down

0 comments on commit 4cf6874

Please sign in to comment.