mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Fix Scam tokens handling and make it persistent (#2138)
* Fix Scam tokens handling and make it persistent * Add potential scam text next to scam tokens * change UI of potential scam text
This commit is contained in:
@@ -99,6 +99,7 @@ class CWSolana extends Solana {
|
||||
mint: token.name.toUpperCase(),
|
||||
enabled: token.enabled,
|
||||
iconPath: token.iconPath,
|
||||
isPotentialScam: token.isPotentialScam,
|
||||
);
|
||||
|
||||
await (wallet as SolanaWallet).addSPLToken(splToken);
|
||||
|
||||
@@ -217,12 +217,13 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
|
||||
|
||||
bool isPotentialScam = hasPotentialError;
|
||||
final tokenSymbol = _tokenSymbolController.text.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
|
||||
final baseCurrencySymbols =
|
||||
CryptoCurrency.all.map((e) => e.title.toUpperCase()).toList();
|
||||
if (baseCurrencySymbols.contains(tokenSymbol) && !isWhitelisted) {
|
||||
if (baseCurrencySymbols.contains(tokenSymbol.trim().toUpperCase()) &&
|
||||
!isWhitelisted) {
|
||||
isPotentialScam = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import 'package:cw_core/unspent_coin_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
|
||||
class BalanceRowWidget extends StatelessWidget {
|
||||
BalanceRowWidget({
|
||||
@@ -66,8 +65,6 @@ class BalanceRowWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool brightThemeType = false;
|
||||
if (dashboardViewModel.settingsStore.currentTheme.type == ThemeType.bright) brightThemeType = true;
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
@@ -221,7 +218,33 @@ class BalanceRowWidget extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
//),
|
||||
if (currency.isPotentialScam)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
margin: EdgeInsets.only(top: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red[800],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_outlined,
|
||||
size: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
S.of(context).potential_scam,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (frozenBalance.isNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -84,6 +84,7 @@ class CWTron extends Tron {
|
||||
decimal: token.decimals,
|
||||
enabled: token.enabled,
|
||||
iconPath: token.iconPath,
|
||||
isPotentialScam: token.isPotentialScam,
|
||||
);
|
||||
await (wallet as TronWallet).addTronToken(tronToken);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
formattedAssetTitle: _formatterAsset(key)));
|
||||
}
|
||||
final fiatCurrency = settingsStore.fiatCurrency;
|
||||
final price = fiatConvertationStore.prices[key] ?? 0;
|
||||
final price = key.isPotentialScam ? 0.0 : fiatConvertationStore.prices[key] ?? 0;
|
||||
|
||||
// if (price == null) {
|
||||
// throw Exception('Price is null for: $key');
|
||||
|
||||
@@ -83,6 +83,7 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
decimal: token.decimals,
|
||||
contractAddress: contractAddress,
|
||||
iconPath: token.iconPath,
|
||||
isPotentialScam: token.isPotentialScam,
|
||||
);
|
||||
|
||||
await ethereum!.addErc20Token(_balanceViewModel.wallet, erc20token);
|
||||
@@ -95,6 +96,7 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
decimal: token.decimals,
|
||||
contractAddress: contractAddress,
|
||||
iconPath: token.iconPath,
|
||||
isPotentialScam: token.isPotentialScam,
|
||||
);
|
||||
await polygon!.addErc20Token(_balanceViewModel.wallet, polygonToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user