Skip to content

Commit

Permalink
fix: correctly parse bns names on testnet (#679)
Browse files Browse the repository at this point in the history
Co-authored-by: Den <36603049+dhriaznov@users.noreply.github.com>
  • Loading branch information
teebszet and dhriaznov committed Nov 29, 2023
1 parent 326bbbd commit cb43e8d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/screens/nftDashboard/nft.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NftUser from '@assets/img/nftDashboard/bns.svg';
import useNftDetail from '@hooks/queries/useNftDetail';
import { NonFungibleToken } from '@secretkeylabs/xverse-core';
import { BNS_CONTRACT } from '@utils/constants';
import { isBnsContract } from '@utils/nfts';
import styled from 'styled-components';
import NftImage from './nftImage';

Expand Down Expand Up @@ -48,7 +48,7 @@ function Nft({ asset, isGalleryOpen }: Props) {
return (
<GridItemContainer>
<NftImageContainer isGalleryView={isGalleryOpen}>
{asset.asset_identifier === BNS_CONTRACT ? (
{isBnsContract(asset?.asset_identifier) ? (
<BnsImage src={NftUser} alt="user" />
) : (
<NftImage metadata={data?.data?.token_metadata} isInCollage />
Expand Down
1 change: 0 additions & 1 deletion src/app/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
HIRO_TESTNET_DEFAULT,
} from '@secretkeylabs/xverse-core';

export const BNS_CONTRACT = 'SP000000000000000000002Q6VF78.bns::names';
export const GAMMA_URL = 'https://gamma.io/';
export const TERMS_LINK = 'https://xverse.app/terms';
export const PRIVACY_POLICY_LINK = 'https://xverse.app/privacy';
Expand Down
7 changes: 6 additions & 1 deletion src/app/utils/nfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ export const getNftsTabGridItemSubText = (collection: StacksCollectionData) =>
collection?.all_nfts?.length > 1 ? `${collection.all_nfts.length} Items` : '1 Item';

export const isBnsCollection = (collectionId?: string | null): boolean =>
collectionId === 'SP000000000000000000002Q6VF78.bns';
collectionId === 'SP000000000000000000002Q6VF78.bns' ||
collectionId === 'ST000000000000000000002AMW42H.bns'; // testnet

export const isBnsContract = (assetIdentifier?: string): boolean =>
assetIdentifier === 'SP000000000000000000002Q6VF78.bns::names' ||
assetIdentifier === 'ST000000000000000000002AMW42H.bns::names'; // testnet

// fully_qualified_token_id like:
// SP1E1RNN4JZ7T6Y0JVCSY2TH4918Z590P8JAB9HZM.radboy-first-feat::radboy-first-feat:64
Expand Down

0 comments on commit cb43e8d

Please sign in to comment.