Skip to content

Commit

Permalink
Address to lower case (#1268)
Browse files Browse the repository at this point in the history
* Address to lower case

* Changeset version file
  • Loading branch information
0xp3gasus authored Sep 12, 2024
1 parent 5eac63c commit c303f02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-humans-argue.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
Expand Down

0 comments on commit c303f02

Please sign in to comment.