mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
fix: wallet grouping eating wallets (#2203)
This commit is contained in:
parent
5f4dc95ca5
commit
87207c61ba
2 changed files with 9 additions and 40 deletions
|
@ -1,3 +1,5 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:cake_wallet/entities/hash_wallet_identifier.dart';
|
||||
import 'package:cake_wallet/entities/wallet_group.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
|
@ -33,7 +35,11 @@ class WalletManager {
|
|||
}
|
||||
|
||||
// Fallback to old logic
|
||||
return walletInfo.parentAddress ?? walletInfo.address;
|
||||
final address = walletInfo.parentAddress ?? walletInfo.address;
|
||||
if (address.isEmpty) {
|
||||
return Random().nextInt(100000).toString();
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
WalletGroup _getOrCreateGroup(String groupKey) {
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:cake_wallet/entities/wallet_group.dart';
|
|||
import 'package:cake_wallet/entities/wallet_list_order_types.dart';
|
||||
import 'package:cake_wallet/entities/wallet_manager.dart';
|
||||
import 'package:cake_wallet/reactions/bip39_wallet_utils.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
|
@ -109,45 +110,7 @@ abstract class WalletListViewModelBase with Store {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Identify wallets that should be moved to singleWalletsList using the filters: the type/derivation
|
||||
final excludedWallets = <WalletInfo>[];
|
||||
|
||||
for (var wallet in group.wallets) {
|
||||
// Check for non-BIP39 wallet types
|
||||
final isNonBIP39 = !isBIP39Wallet(wallet.type);
|
||||
|
||||
// Check for nano derivation type
|
||||
final isNanoDerivation = wallet.type == WalletType.nano &&
|
||||
wallet.derivationInfo?.derivationType == DerivationType.nano;
|
||||
|
||||
// Check for electrum derivation type
|
||||
final isElectrumDerivation =
|
||||
(wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin) &&
|
||||
wallet.derivationInfo?.derivationType == DerivationType.electrum;
|
||||
|
||||
if (isNonBIP39 || isNanoDerivation || isElectrumDerivation) {
|
||||
excludedWallets.add(wallet);
|
||||
}
|
||||
}
|
||||
|
||||
// Add excluded wallets to singleWalletsList
|
||||
for (var excludedWallet in excludedWallets) {
|
||||
singleWalletsList.add(convertWalletInfoToWalletListItem(excludedWallet));
|
||||
}
|
||||
|
||||
// Remove excluded wallets from the group's wallets to avoid duplication
|
||||
group.wallets.removeWhere((wallet) {
|
||||
return excludedWallets.any((excluded) => excluded.address == wallet.address);
|
||||
});
|
||||
|
||||
// Check if the group has more than one wallet after the excluded wallets are removed.
|
||||
if (group.wallets.length > 1) {
|
||||
//Add the entire group to the multi wallet group list since its still a multi wallet
|
||||
multiWalletGroups.add(group);
|
||||
} else if (group.wallets.length == 1) {
|
||||
// Add the group to the wallet left to the single wallets list
|
||||
singleWalletsList.add(convertWalletInfoToWalletListItem(group.wallets.first));
|
||||
}
|
||||
multiWalletGroups.add(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue