diff --git a/src/pages/InventoryDetailsPage/InventoryDetailsPage.tsx b/src/pages/InventoryDetailsPage/InventoryDetailsPage.tsx index f8d9350..1a207d9 100644 --- a/src/pages/InventoryDetailsPage/InventoryDetailsPage.tsx +++ b/src/pages/InventoryDetailsPage/InventoryDetailsPage.tsx @@ -15,7 +15,7 @@ import { linkedContractsMap, config } from '../../config' import {ERC1155Icon} from "../../components/ui/ERC1155Icon"; import dayjs from "dayjs"; import {CopyBtn} from "../../components/ui/CopyBtn"; -import {OneCountryTLD} from "../../utils/oneCountry"; +import {convertErc721TokenId, OneCountryTLD} from "../../utils/oneCountry"; const AddressLink = styled.a` text-decoration: none; @@ -157,25 +157,12 @@ const NFTDetails = (props: NFTInfoProps) => { const EmptyValue = isLoading ? '' : NotAvailable const tokenStandard = tokenID ? tokenERC721 ? 'ERC721' : 'ERC1155' : EmptyValue - const linkedContract = linkedContractsMap[tokenAddressParam.toLowerCase()] return Details - {linkedContract && - - - Linked page: - - - - {linkedContract.name} NFT - - - - } Owner: @@ -259,7 +246,7 @@ const NFTDetails = (props: NFTInfoProps) => { } const NFTInfo = (props: NFTInfoProps) => { - const { tokenERC721, tokenERC1155, asset, isLoading } = props + const { tokenAddressParam, tokenIDParam, tokenERC721, tokenERC1155, asset, isLoading } = props const { meta, tokenID } = asset const EmptyValue = isLoading ? '' : NotAvailable @@ -270,6 +257,11 @@ const NFTInfo = (props: NFTInfoProps) => { : EmptyValue; const erc1155Image = tokenERC1155 && tokenERC1155.meta ? tokenERC1155.meta.image : '' + const linkedContract = linkedContractsMap[tokenAddressParam] + const linkTokenId = linkedContract && linkedContract.address === config.oneCountryNFTContractAddress + ? convertErc721TokenId(tokenIDParam) + : tokenIDParam + return @@ -280,6 +272,13 @@ const NFTInfo = (props: NFTInfoProps) => { {token.name} + {linkedContract && + + + Show this NFT on {linkedContract.name} page + + + } @@ -336,7 +335,7 @@ export function InventoryDetailsPage() { { const record = await oneCountry.getRecord(name) return record ? record.renter : '' } + +export const convertErc721TokenId = (erc721TokenId: string) => { + const labelHashReverse = '0x' + BigInt(erc721TokenId).toString(16) + const encodePacked = Web3.utils.encodePacked( + {value: OneCountryTLDNode, type: 'bytes32'}, + {value: labelHashReverse, type: 'bytes32'}, + ) || ''; + return BigInt(keccak256(encodePacked)).toString() +}