mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Label existing scam tokens (#2164)
* label existing scam tokens because users can get scammed twice ¯\_(ツ)_/¯ * minor ui fix [skip ci]
This commit is contained in:
parent
9ac784db5c
commit
88ebba9236
5 changed files with 89 additions and 53 deletions
|
@ -144,6 +144,8 @@ abstract class EVMChainWalletBase
|
|||
// required WalletInfo walletInfo,
|
||||
// });
|
||||
|
||||
List<String> get getDefaultTokenContractAddresses;
|
||||
|
||||
Future<void> initErc20TokensBox();
|
||||
|
||||
String getTransactionHistoryFileName();
|
||||
|
@ -171,6 +173,9 @@ abstract class EVMChainWalletBase
|
|||
await walletAddresses.init();
|
||||
await transactionHistory.init();
|
||||
|
||||
// check for Already existing scam tokens, cuz users can get scammed twice ¯\_(ツ)_/¯
|
||||
await _checkForExistingScamTokens();
|
||||
|
||||
if (walletInfo.isHardwareWallet) {
|
||||
_evmChainPrivateKey = EvmLedgerCredentials(walletInfo.address);
|
||||
walletAddresses.address = walletInfo.address;
|
||||
|
@ -186,6 +191,31 @@ abstract class EVMChainWalletBase
|
|||
await save();
|
||||
}
|
||||
|
||||
Future<void> _checkForExistingScamTokens() async {
|
||||
final baseCurrencySymbols = CryptoCurrency.all.map((e) => e.title.toUpperCase()).toList();
|
||||
|
||||
for (var token in erc20Currencies) {
|
||||
bool isPotentialScam = false;
|
||||
|
||||
bool isWhitelisted =
|
||||
getDefaultTokenContractAddresses.any((element) => element == token.contractAddress);
|
||||
|
||||
final tokenSymbol = token.title.toUpperCase();
|
||||
|
||||
// check if the token symbol is the same as any of the base currencies symbols (ETH, SOL, POL, TRX, etc):
|
||||
// if it is, then it's probably a scam unless it's in the whitelist
|
||||
if (baseCurrencySymbols.contains(tokenSymbol.trim().toUpperCase()) && !isWhitelisted) {
|
||||
isPotentialScam = true;
|
||||
}
|
||||
|
||||
if (isPotentialScam) {
|
||||
token.isPotentialScam = true;
|
||||
token.iconPath = null;
|
||||
await token.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
int calculateEstimatedFee(TransactionPriority priority, int? amount) {
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue