From 7bb8948d730179aec77322f42830659ad43dce47 Mon Sep 17 00:00:00 2001 From: julian Date: Sun, 14 Jan 2024 16:38:59 -0600 Subject: [PATCH] fix eth token balance not updating --- lib/wallets/isar/models/token_wallet_info.dart | 7 +++---- lib/wallets/wallet/impl/ethereum_wallet.dart | 12 +++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/wallets/isar/models/token_wallet_info.dart b/lib/wallets/isar/models/token_wallet_info.dart index 45c4747a3..4725a29a6 100644 --- a/lib/wallets/isar/models/token_wallet_info.dart +++ b/lib/wallets/isar/models/token_wallet_info.dart @@ -75,9 +75,8 @@ class TokenWalletInfo implements IsarId { ); } else { await isar.writeTxn(() async { - await isar.tokenWalletInfo.deleteByWalletIdTokenAddress( - walletId, - tokenAddress, + await isar.tokenWalletInfo.delete( + thisEntry.id, ); await isar.tokenWalletInfo.put( TokenWalletInfo( @@ -85,7 +84,7 @@ class TokenWalletInfo implements IsarId { tokenAddress: tokenAddress, tokenFractionDigits: tokenFractionDigits, cachedBalanceJsonString: balance.toJsonIgnoreCoin(), - ), + )..id = thisEntry.id, ); }); } diff --git a/lib/wallets/wallet/impl/ethereum_wallet.dart b/lib/wallets/wallet/impl/ethereum_wallet.dart index a03f648c2..4f0198637 100644 --- a/lib/wallets/wallet/impl/ethereum_wallet.dart +++ b/lib/wallets/wallet/impl/ethereum_wallet.dart @@ -116,8 +116,14 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { FilterGroup.and(standardReceivingAddressFilters); @override - Future init({bool? isRestore}) { - // TODO: implement init + Future init({bool? isRestore}) async { + final address = await getCurrentReceivingAddress(); + if (address == null) { + await _generateAndSaveAddress( + await getMnemonic(), + await getMnemonicPassphrase(), + ); + } return super.init(); } @@ -205,7 +211,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { @override Future updateTransactions({bool isRescan = false}) async { - String thisAddress = (await getCurrentReceivingAddress())!.value; + final thisAddress = (await getCurrentReceivingAddress())!.value; int firstBlock = 0;