mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Generic Token Fixes (#2874)
* feat: Automatically detect wallet tokens for EVM chains * feat: Disable potential tg scam tokens by default * feat: Add homoglyph normalization to detect spoofing attacks in token symbols * refactor: Improve scam token detection and apply to automatically fetched EVM tokens * refactor: Enhance scam detection for automatically detected tokens in evm wallets * feat: Add fiat check to scam checks on automatically imported token and disable tokens that fail the check * feat: Add fiat check to scam checks on automatically imported token and disable tokens that fail the check * feat: Add fiat check to scam checks on automatically imported token and disable tokens that fail the check * feat: Enable whitelisted tokens with balance when importing wallet tokens * feat: Disable imported tokens with balance less than 0.1 usd * feat: Disable imported tokens with balance less than 0.1 usd - Update configure file * fixes: - default tokens marked as potential scam - ui overflow for token name on balance page - add more filters for spam tokens * - detect and flag default token impersonators - add homoglyph normalization to prevent spoofing attacks on new token symbols - fix bnb not coming up in receive currency list for swap page * - detect and flag default token impersonators - add homoglyph normalization to prevent spoofing attacks on new token symbols - fix bnb not coming up in receive currency list for swap page * Revert Exclude BNB from receive currencies list [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Omar Hatem
parent
174216df17
commit
326ef316c3
@@ -14,6 +14,7 @@ import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
import 'package:cw_core/utils/homoglyph_normalizer.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
@@ -242,6 +243,44 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
return isInWhitelist;
|
||||
}
|
||||
|
||||
bool checkIfTokenSymbolMatchesDefaultToken(String symbol) {
|
||||
final normalizedSymbol = normalizeHomoglyphs(symbol.trim().toUpperCase());
|
||||
if (normalizedSymbol.isEmpty) return false;
|
||||
|
||||
List<String> defaultTokenSymbols = [];
|
||||
switch (_balanceViewModel.wallet.type) {
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
defaultTokenSymbols = evm!.getDefaultTokenSymbols(_balanceViewModel.wallet);
|
||||
break;
|
||||
case WalletType.solana:
|
||||
defaultTokenSymbols = solana!.getDefaultTokenSymbols();
|
||||
break;
|
||||
case WalletType.tron:
|
||||
defaultTokenSymbols = tron!.getDefaultTokenSymbols();
|
||||
break;
|
||||
case WalletType.zano:
|
||||
case WalletType.banano:
|
||||
case WalletType.monero:
|
||||
case WalletType.none:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.haven:
|
||||
case WalletType.nano:
|
||||
case WalletType.wownero:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.decred:
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.zcash:
|
||||
return false;
|
||||
}
|
||||
|
||||
return defaultTokenSymbols.any((s) => s.toUpperCase() == normalizedSymbol);
|
||||
}
|
||||
|
||||
Future<bool> _isPotentialScamTokenViaMoralis(
|
||||
String contractAddress,
|
||||
String chainName,
|
||||
|
||||
Reference in New Issue
Block a user