Skip to content

Commit

Permalink
Fix casting in Web3BalancesProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
maxima-net committed Aug 18, 2022
1 parent b3a83d5 commit d1ea821
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/evm/balancesProviders/web3BalancesProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type BigNumber from 'bignumber.js';
import BigNumber from 'bignumber.js';
import type Web3 from 'web3';

import type { AtomexBlockchainProvider, BalancesProvider } from '../../blockchain/index';
Expand Down Expand Up @@ -33,13 +33,13 @@ export class Web3BalancesProvider implements BalancesProvider {
private async getNativeTokenBalance(address: string, currency: NativeEthereumCurrency, toolkit: Web3): Promise<BigNumber> {
const balance = await toolkit.eth.getBalance(address);

return numberToTokensAmount(+balance, currency.decimals);
return numberToTokensAmount(new BigNumber(balance), currency.decimals);
}

private async getTokenBalance(address: string, currency: ERC20EthereumCurrency, toolkit: Web3): Promise<BigNumber> {
const contract = await new toolkit.eth.Contract(erc20Abi, currency.contractAddress);
const contract = new toolkit.eth.Contract(erc20Abi, currency.contractAddress);
const balance = await contract.methods.balanceOf(address).call() as string;

return numberToTokensAmount(+balance, currency.decimals);
return numberToTokensAmount(new BigNumber(balance), currency.decimals);
}
}

0 comments on commit d1ea821

Please sign in to comment.