diff --git a/lib/dto/ethereum/eth_token_tx_dto.dart b/lib/dto/ethereum/eth_token_tx_dto.dart index f305cc2df..51a9a7449 100644 --- a/lib/dto/ethereum/eth_token_tx_dto.dart +++ b/lib/dto/ethereum/eth_token_tx_dto.dart @@ -26,7 +26,6 @@ class EthTokenTxDto { required this.topics, required this.data, required this.articulatedLog, - required this.compressedLog, required this.transactionHash, required this.transactionIndex, }); @@ -44,7 +43,6 @@ class EthTokenTxDto { map['articulatedLog'] as Map, ), ), - compressedLog = map['compressedLog'] as String, transactionHash = map['transactionHash'] as String, transactionIndex = map['transactionIndex'] as int; @@ -54,7 +52,6 @@ class EthTokenTxDto { final List topics; final String data; final ArticulatedLog? articulatedLog; - final String compressedLog; final String transactionHash; final int transactionIndex; @@ -76,7 +73,6 @@ class EthTokenTxDto { topics: topics ?? this.topics, data: data ?? this.data, articulatedLog: articulatedLog ?? this.articulatedLog, - compressedLog: compressedLog ?? this.compressedLog, transactionHash: transactionHash ?? this.transactionHash, transactionIndex: transactionIndex ?? this.transactionIndex, ); @@ -89,7 +85,6 @@ class EthTokenTxDto { map['topics'] = topics; map['data'] = data; map['articulatedLog'] = articulatedLog?.toMap(); - map['compressedLog'] = compressedLog; map['transactionHash'] = transactionHash; map['transactionIndex'] = transactionIndex; return map; diff --git a/lib/dto/ethereum/eth_tx_dto.dart b/lib/dto/ethereum/eth_tx_dto.dart index 260675cf9..e0708646d 100644 --- a/lib/dto/ethereum/eth_tx_dto.dart +++ b/lib/dto/ethereum/eth_tx_dto.dart @@ -29,7 +29,6 @@ class EthTxDTO { required this.maxPriorityFeePerGas, required this.isError, required this.hasToken, - required this.compressedTx, required this.gasCost, required this.gasUsed, }); @@ -42,16 +41,15 @@ class EthTxDTO { timestamp: map['timestamp'] as int, from: map['from'] as String, to: map['to'] as String, - value: _amountFromJsonNum(map['value']), - gas: _amountFromJsonNum(map['gas']), - gasPrice: _amountFromJsonNum(map['gasPrice']), + value: _amountFromJsonNum(map['value'])!, + gas: _amountFromJsonNum(map['gas'])!, + gasPrice: _amountFromJsonNum(map['gasPrice'])!, maxFeePerGas: _amountFromJsonNum(map['maxFeePerGas']), maxPriorityFeePerGas: _amountFromJsonNum(map['maxPriorityFeePerGas']), - isError: map['isError'] as int, - hasToken: map['hasToken'] as int, - compressedTx: map['compressedTx'] as String, - gasCost: _amountFromJsonNum(map['gasCost']), - gasUsed: _amountFromJsonNum(map['gasUsed']), + isError: map['isError'] as bool? ?? false, + hasToken: map['hasToken'] as bool? ?? false, + gasCost: _amountFromJsonNum(map['gasCost'])!, + gasUsed: _amountFromJsonNum(map['gasUsed'])!, ); final String hash; @@ -64,17 +62,19 @@ class EthTxDTO { final Amount value; final Amount gas; final Amount gasPrice; - final Amount maxFeePerGas; - final Amount maxPriorityFeePerGas; - final int isError; - final int hasToken; - final String compressedTx; + final Amount? maxFeePerGas; + final Amount? maxPriorityFeePerGas; + final bool isError; + final bool hasToken; final Amount gasCost; final Amount gasUsed; - static Amount _amountFromJsonNum(dynamic json) { + static Amount? _amountFromJsonNum(dynamic json) { + if (json == null) { + return null; + } return Amount( - rawValue: BigInt.from(json as num), + rawValue: BigInt.parse(json.toString()), fractionDigits: Coin.ethereum.decimals, ); } @@ -92,8 +92,8 @@ class EthTxDTO { Amount? gasPrice, Amount? maxFeePerGas, Amount? maxPriorityFeePerGas, - int? isError, - int? hasToken, + bool? isError, + bool? hasToken, String? compressedTx, Amount? gasCost, Amount? gasUsed, @@ -113,7 +113,6 @@ class EthTxDTO { maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas, isError: isError ?? this.isError, hasToken: hasToken ?? this.hasToken, - compressedTx: compressedTx ?? this.compressedTx, gasCost: gasCost ?? this.gasCost, gasUsed: gasUsed ?? this.gasUsed, ); @@ -134,7 +133,6 @@ class EthTxDTO { map['maxPriorityFeePerGas'] = maxPriorityFeePerGas.toString(); map['isError'] = isError; map['hasToken'] = hasToken; - map['compressedTx'] = compressedTx; map['gasCost'] = gasCost.toString(); map['gasUsed'] = gasUsed.toString(); return map; diff --git a/lib/services/coins/ethereum/ethereum_wallet.dart b/lib/services/coins/ethereum/ethereum_wallet.dart index b3800a4e4..367011c51 100644 --- a/lib/services/coins/ethereum/ethereum_wallet.dart +++ b/lib/services/coins/ethereum/ethereum_wallet.dart @@ -227,7 +227,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB { Future updateBalance() async { web3.Web3Client client = getEthClient(); - web3.EtherAmount ethBalance = await client.getBalance(_credentials.address); + + final address = web3.EthereumAddress.fromHex(await currentReceivingAddress); + web3.EtherAmount ethBalance = await client.getBalance(address); _balance = Balance( total: Amount( rawValue: ethBalance.getInWei, diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index 13e11f7ab..8f0024774 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -75,7 +75,7 @@ abstract class EthereumAPI { for (final map in list!) { final txn = EthTxDTO.fromMap(Map.from(map as Map)); - if (txn.hasToken == 0 || includeTokens) { + if (!txn.hasToken || includeTokens) { txns.add(txn); } }