mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
CW-1228: Automatically detect wallet tokens for EVM chains (#2827)
* 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
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/// Normalizes homoglyph characters (Cyrillic, Greek, etc.) to their ASCII equivalents
|
||||
/// to detect spoofing attacks like "UЅDС" (Cyrillic) vs "USDC" (ASCII)
|
||||
String normalizeHomoglyphs(String text) {
|
||||
final homoglyphMap = {
|
||||
// Cyrillic letters that look like Latin
|
||||
'А': 'A', // Cyrillic A
|
||||
'В': 'B', // Cyrillic Ve
|
||||
'Е': 'E', // Cyrillic Ie
|
||||
'К': 'K', // Cyrillic Ka
|
||||
'М': 'M', // Cyrillic Em
|
||||
'Н': 'H', // Cyrillic En
|
||||
'О': 'O', // Cyrillic O
|
||||
'Р': 'P', // Cyrillic Er
|
||||
'С': 'C', // Cyrillic Es
|
||||
'Т': 'T', // Cyrillic Te
|
||||
'У': 'Y', // Cyrillic U
|
||||
'Х': 'X', // Cyrillic Kha
|
||||
'а': 'a',
|
||||
'в': 'b',
|
||||
'е': 'e',
|
||||
'к': 'k',
|
||||
'м': 'm',
|
||||
'н': 'h',
|
||||
'о': 'o',
|
||||
'р': 'p',
|
||||
'с': 'c',
|
||||
'т': 't',
|
||||
'у': 'y',
|
||||
'х': 'x',
|
||||
'Ѕ': 'S', // Cyrillic Dze (looks like S)
|
||||
'ѕ': 's',
|
||||
'І': 'I', // Cyrillic I
|
||||
'і': 'i',
|
||||
'Ј': 'J', // Cyrillic Je
|
||||
'ј': 'j',
|
||||
// Greek letters that look like Latin
|
||||
'Α': 'A', // Alpha
|
||||
'Β': 'B', // Beta
|
||||
'Ε': 'E', // Epsilon
|
||||
'Ζ': 'Z', // Zeta
|
||||
'Η': 'H', // Eta
|
||||
'Ι': 'I', // Iota
|
||||
'Κ': 'K', // Kappa
|
||||
'Μ': 'M', // Mu
|
||||
'Ν': 'N', // Nu
|
||||
'Ο': 'O', // Omicron
|
||||
'Ρ': 'P', // Rho
|
||||
'Τ': 'T', // Tau
|
||||
'Υ': 'Y', // Upsilon
|
||||
'Χ': 'X', // Chi
|
||||
'α': 'a',
|
||||
'β': 'b',
|
||||
'ε': 'e',
|
||||
'ζ': 'z',
|
||||
'η': 'h',
|
||||
'ι': 'i',
|
||||
'κ': 'k',
|
||||
'μ': 'm',
|
||||
'ν': 'n',
|
||||
'ο': 'o',
|
||||
'ρ': 'p',
|
||||
'τ': 't',
|
||||
'υ': 'y',
|
||||
'χ': 'x',
|
||||
};
|
||||
|
||||
return text.split('').map((char) => homoglyphMap[char] ?? char).join('');
|
||||
}
|
||||
Reference in New Issue
Block a user