mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
Cw 870 ethereum enhancements (#1951)
* fix evm balance display issues * fix adding token * fix tab controller issue * Update cw_evm/lib/evm_chain_client.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
f35c20203e
commit
7cc9e36016
6 changed files with 60 additions and 24 deletions
|
@ -268,12 +268,18 @@ abstract class EVMChainClient {
|
|||
|
||||
Future<EVMChainERC20Balance> fetchERC20Balances(
|
||||
EthereumAddress userAddress, String contractAddress) async {
|
||||
final erc20 = ERC20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
|
||||
final balance = await erc20.balanceOf(userAddress);
|
||||
try {
|
||||
final erc20 = ERC20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
|
||||
final balance = await erc20.balanceOf(userAddress);
|
||||
|
||||
int exponent = (await erc20.decimals()).toInt();
|
||||
|
||||
return EVMChainERC20Balance(balance, exponent: exponent);
|
||||
return EVMChainERC20Balance(balance, exponent: exponent);
|
||||
} on RangeError catch (_) {
|
||||
throw Exception('Invalid token contract for this network.');
|
||||
} catch (e) {
|
||||
throw Exception('Could not fetch balances: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Erc20Token?> getErc20Token(String contractAddress, String chainName) async {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue