From b29f266b8cbbff54cfe0a5da2461e90de67bdc2c Mon Sep 17 00:00:00 2001 From: smart_ex Date: Mon, 18 Apr 2022 16:45:34 +1000 Subject: [PATCH] fix hash map key --- src/utils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils.js b/src/utils.js index f9b4cb2..7c2b6ae 100644 --- a/src/utils.js +++ b/src/utils.js @@ -15,8 +15,7 @@ for (const [key, value] of Object.entries(instances)) { const netId = Number(key.substring(5)) for (const [currency, { instanceAddress, symbol, decimals }] of Object.entries(value)) { Object.entries(instanceAddress).forEach(([amount, address]) => - addressMap.set( - { netId, address }, + addressMap.set(`${netId}_${address}`, { currency, amount, @@ -31,9 +30,9 @@ for (const [key, value] of Object.entries(instances)) { const sleep = ms => new Promise(res => setTimeout(res, ms)) function getInstance(address) { - address = toChecksumAddress(address) - if (addressMap.has({ netId, address })) { - return addressMap.get({ netId, address }) + const key = `${netId}_${toChecksumAddress(address)}` + if (addressMap.has(key)) { + return addressMap.get(key) } else { throw new Error('Unknown contact address') }