From 9c8cd568fd00fd30a646fa8c6ac39c67d6f492e5 Mon Sep 17 00:00:00 2001 From: Christophe Le Bars Date: Tue, 18 Apr 2023 15:06:10 +0200 Subject: [PATCH] getChainDataByChainId accept BigInt --- README.md | 2 +- src/stores.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9853620..d1ba8f0 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ import { - connected: store value is true if a connection has been set up. - provider: store value is an Ethers.js Provider instance when connected. -- chainId: store value is the current chainId when connected (always BigInt) +- chainId: store value is the current chainId when connected (** always a BigInt **) - chainData: store value is the current blokchain CAIP-2 data (when connected), see below. - signer: store value is an Ethers.js Signer instance when connected. - signerAddress: store value is a shortcut to get `$signer.getAddress()` when connected. diff --git a/src/stores.js b/src/stores.js index 55d2c12..8efb41b 100644 --- a/src/stores.js +++ b/src/stores.js @@ -303,8 +303,9 @@ export const getChainStore = (name) => { export { chains as allChainsData }; +// chains.js only support number chainId export const getChainDataByChainId = (id) => - (chains.filter((o) => o.chainId === id) || [{}])[0]; +(chains.filter((o) => o.chainId === Number(BigInt(id))) || [{}])[0]; export const defaultEvmStores = makeEvmStores("default");