mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02: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/themes/core/theme_extension.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/home_settings_view_model.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/utils/homoglyph_normalizer.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:dotted_border/dotted_border.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -231,20 +232,29 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
|
||||
|
||||
bool isPotentialScam = hasPotentialError && !isWhitelisted;
|
||||
|
||||
// Normalize to catch homoglyph spoofing attacks
|
||||
final tokenSymbol = normalizeHomoglyphs(
|
||||
_tokenSymbolController.text.trim().toUpperCase(),
|
||||
);
|
||||
|
||||
// check if the token symbol is the same as the native token symbol
|
||||
// to prevent token impersonation
|
||||
// (e.g. fake ETH on Ethereum, fake SOL on Solana)
|
||||
final tokenSymbol = _tokenSymbolController.text
|
||||
.trim()
|
||||
.toUpperCase();
|
||||
final nativeSymbol = widget.homeSettingsViewModel
|
||||
.nativeToken
|
||||
.title
|
||||
.toUpperCase();
|
||||
final nativeSymbol =
|
||||
widget.homeSettingsViewModel.nativeToken.title.toUpperCase();
|
||||
if (tokenSymbol == nativeSymbol && !isWhitelisted) {
|
||||
isPotentialScam = true;
|
||||
}
|
||||
|
||||
// check if the token symbol is the same as any of the default token symbols
|
||||
// (e.g. fake USDC, USDT with wrong contract address)
|
||||
if (widget.homeSettingsViewModel.checkIfTokenSymbolMatchesDefaultToken(
|
||||
tokenSymbol,
|
||||
) &&
|
||||
!isWhitelisted) {
|
||||
isPotentialScam = true;
|
||||
}
|
||||
|
||||
final actionCall = () async {
|
||||
try {
|
||||
await widget.homeSettingsViewModel.addToken(
|
||||
|
||||
Reference in New Issue
Block a user