mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
refactor: Enhance currency matching logic for address book and fix overlap for eth and base. (#2883)
This commit is contained in:
@@ -6,13 +6,13 @@ import 'package:cake_wallet/entities/contact_base.dart';
|
||||
import 'package:cake_wallet/entities/contact_record.dart';
|
||||
import 'package:cake_wallet/entities/wallet_contact.dart';
|
||||
import 'package:cake_wallet/entities/wallet_list_order_types.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/evm/evm.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/mobx.dart';
|
||||
import 'package:cake_wallet/utils/token_utilities.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -150,10 +150,29 @@ abstract class ContactListViewModelBase with Store {
|
||||
isWalletContact &&
|
||||
(element.type == CryptoCurrency.btc || element.type == CryptoCurrency.ltc)) return false;
|
||||
|
||||
return element.type == _currency ||
|
||||
(element.type.tag != null && _currency.tag != null && element.type.tag == _currency.tag) ||
|
||||
_currency.toString() == element.type.tag ||
|
||||
_currency.tag == element.type.toString();
|
||||
final currencyMatches = element.type == _currency;
|
||||
|
||||
final tagsMatch =
|
||||
element.type.tag != null && _currency.tag != null && element.type.tag == _currency.tag;
|
||||
|
||||
final tagMatchesTitle = _currency.tag != null && _currency.tag == element.type.title;
|
||||
|
||||
final titleMatchesTag = _currency.title == element.type.tag;
|
||||
|
||||
var matches = currencyMatches || tagsMatch || tagMatchesTitle || titleMatchesTag;
|
||||
|
||||
if (matches && isWalletContact && element is WalletContact && element.walletType != null) {
|
||||
final walletType = element.walletType!;
|
||||
|
||||
if (isEVMCompatibleChain(walletType)) {
|
||||
final currencyChainId = TokenUtilities.getChainId(_currency);
|
||||
final walletChainId = evm!.getChainIdByWalletType(walletType);
|
||||
|
||||
if (currencyChainId != walletChainId) matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
void dispose() => _subscription?.cancel();
|
||||
|
||||
Reference in New Issue
Block a user