From c303f0282b7304d60a1cde4f65692373df4f2ce2 Mon Sep 17 00:00:00 2001 From: Pegasus <83475418+0xp3gasus@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:35:17 +0200 Subject: [PATCH] Address to lower case (#1268) * Address to lower case * Changeset version file --- .changeset/neat-humans-argue.md | 5 +++++ .../src/providers/etherscan/etherscan-data-provider.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/neat-humans-argue.md diff --git a/.changeset/neat-humans-argue.md b/.changeset/neat-humans-argue.md new file mode 100644 index 000000000..0a3b9cd5f --- /dev/null +++ b/.changeset/neat-humans-argue.md @@ -0,0 +1,5 @@ +--- +'@xchainjs/xchain-evm-providers': patch +--- + +Bug fix with addresses in Etherscan provider when trying to retrieve balances and the addresses are in upper case diff --git a/packages/xchain-evm-providers/src/providers/etherscan/etherscan-data-provider.ts b/packages/xchain-evm-providers/src/providers/etherscan/etherscan-data-provider.ts index ad41ac181..295038e10 100644 --- a/packages/xchain-evm-providers/src/providers/etherscan/etherscan-data-provider.ts +++ b/packages/xchain-evm-providers/src/providers/etherscan/etherscan-data-provider.ts @@ -76,7 +76,7 @@ export class EtherscanProvider implements EvmOnlineDataProvider { return balances } private async getNativeAssetBalance(address: Address): Promise<{ asset: Asset; amount: BaseAmount }> { - const gasAssetBalance: BigNumber = await this.provider.getBalance(address) + const gasAssetBalance: BigNumber = await this.provider.getBalance(address.toLowerCase()) const amount = baseAmount(gasAssetBalance.toString(), this.nativeAssetDecimals) return { asset: this.nativeAsset, @@ -95,8 +95,8 @@ export class EtherscanProvider implements EvmOnlineDataProvider { type: AssetType.TOKEN, } - const contract: ethers.Contract = new ethers.Contract(contractAddress, erc20ABI, this.provider) - const balance = (await contract.balanceOf(address)).toString() + const contract: ethers.Contract = new ethers.Contract(contractAddress.toLowerCase(), erc20ABI, this.provider) + const balance = (await contract.balanceOf(address.toLowerCase())).toString() const decimals = (await contract.decimals()).toString() const amount = baseAmount(balance, Number.parseInt(decimals))