From 4a95884e4df4e8c82cf0fde45ece4f3e2dc3fe18 Mon Sep 17 00:00:00 2001 From: artemkolodko Date: Tue, 28 Mar 2023 21:12:02 +0100 Subject: [PATCH] Fix converting large integers to hex --- src/utils/oneCountry.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/oneCountry.ts b/src/utils/oneCountry.ts index ae1b412..9ffa82b 100644 --- a/src/utils/oneCountry.ts +++ b/src/utils/oneCountry.ts @@ -17,10 +17,11 @@ export const getAddressByName = async (name: string) => { } export const convertErc721TokenId = (erc721TokenId: string) => { - const labelHashReverse = '0x' + BigInt(erc721TokenId).toString(16) + let labelHash = Web3.utils.toBN(erc721TokenId).toString('hex', 64) + labelHash = '0x' + labelHash const encodePacked = Web3.utils.encodePacked( {value: OneCountryTLDNode, type: 'bytes32'}, - {value: labelHashReverse, type: 'bytes32'}, + {value: labelHash, type: 'bytes32'}, ) || ''; - return BigInt(keccak256(encodePacked)).toString() + return Web3.utils.toBN(keccak256(encodePacked)).toString() }