diff --git a/lib/providers/my_wallets.dart b/lib/providers/my_wallets.dart index 33a93b3..1d144a9 100644 --- a/lib/providers/my_wallets.dart +++ b/lib/providers/my_wallets.dart @@ -207,6 +207,7 @@ class MyWalletsProvider with ChangeNotifier { isOwned: true); await walletBox.put(newWallet.address, newWallet); + await readAllWallets(); isNewDerivationLoading = false; notifyListeners(); @@ -260,15 +261,15 @@ class MyWalletsProvider with ChangeNotifier { chestNumber ??= getCurrentChest(); - List walletConfig = await readAllWallets(chestNumber); - walletConfig.sort((p1, p2) { + // List walletConfig = await readAllWallets(chestNumber); + listWallets.sort((p1, p2) { return Comparable.compare(p1.number!, p2.number!); }); - if (walletConfig.isEmpty) { + if (listWallets.isEmpty) { newDerivationNbr = 2; } else { - WalletData lastWallet = walletConfig.reduce( + WalletData lastWallet = listWallets.reduce( (curr, next) => curr.derivation! > next.derivation! ? curr : next); if (lastWallet.derivation == -1) { @@ -277,7 +278,7 @@ class MyWalletsProvider with ChangeNotifier { newDerivationNbr = lastWallet.derivation! + (isOneshoot ? 1 : 2); } - newWalletNbr = walletConfig.last.number! + 1; + newWalletNbr = listWallets.last.number! + 1; } return [newWalletNbr, newDerivationNbr]; diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index ada4324..edea07b 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -37,7 +37,8 @@ class _WalletsHomeState extends State { @override Widget build(BuildContext context) { - final myWalletProvider = Provider.of(context); + final myWalletProvider = + Provider.of(context, listen: false); final currentChestNumber = myWalletProvider.getCurrentChest(); final ChestData currentChest = chestBox.get(currentChestNumber)!;