diff --git a/lib/db/migrate_wallets_to_isar.dart b/lib/db/migrate_wallets_to_isar.dart index 893a85094..50ead2110 100644 --- a/lib/db/migrate_wallets_to_isar.dart +++ b/lib/db/migrate_wallets_to_isar.dart @@ -8,6 +8,7 @@ import 'package:stackwallet/models/isar/models/transaction_note.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; +import 'package:stackwallet/wallets/isar/models/wallet_info_meta.dart'; import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; Future migrateWalletsToIsar({ @@ -47,7 +48,7 @@ Future migrateWalletsToIsar({ final List favourites = (await Hive.openBox(DB.boxNameFavoriteWallets)).values.toList(); - final List newInfo = []; + final List<(WalletInfo, WalletInfoMeta)> newInfo = []; final List migratedNotes = []; // @@ -113,15 +114,19 @@ Future migrateWalletsToIsar({ // otherData.removeWhere((key, value) => value == null); + final infoMeta = WalletInfoMeta( + walletId: old.walletId, + isMnemonicVerified: allWalletsBox + .get("${old.walletId}_mnemonicHasBeenVerified") as bool? ?? + false, + ); + final info = WalletInfo( coinName: old.coin.name, walletId: old.walletId, name: old.name, mainAddressType: old.coin.primaryAddressType, favouriteOrderIndex: favourites.indexOf(old.walletId), - isMnemonicVerified: allWalletsBox - .get("${old.walletId}_mnemonicHasBeenVerified") as bool? ?? - false, cachedChainHeight: walletBox.get( DBKeys.storedChainHeight, ) as int? ?? @@ -135,7 +140,7 @@ Future migrateWalletsToIsar({ otherDataJsonString: jsonEncode(otherData), ); - newInfo.add(info); + newInfo.add((info, infoMeta)); } if (migratedNotes.isNotEmpty) { @@ -145,10 +150,14 @@ Future migrateWalletsToIsar({ } await MainDB.instance.isar.writeTxn(() async { - await MainDB.instance.isar.walletInfo.putAll(newInfo); + await MainDB.instance.isar.walletInfo + .putAll(newInfo.map((e) => e.$1).toList()); + await MainDB.instance.isar.walletInfoMeta + .putAll(newInfo.map((e) => e.$2).toList()); }); - await _cleanupOnSuccess(walletIds: newInfo.map((e) => e.walletId).toList()); + await _cleanupOnSuccess( + walletIds: newInfo.map((e) => e.$1.walletId).toList()); } Future _cleanupOnSuccess({required List walletIds}) async {