mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00: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:
parent
cbca4c9c77
commit
23a47ed561
41 changed files with 121 additions and 45 deletions
|
@ -25,10 +25,13 @@ class TronToken extends CryptoCurrency with HiveObjectMixin {
|
|||
|
||||
@HiveField(5)
|
||||
final String? iconPath;
|
||||
|
||||
|
||||
@HiveField(6)
|
||||
final String? tag;
|
||||
|
||||
@HiveField(7, defaultValue: false)
|
||||
final bool isPotentialScam;
|
||||
|
||||
bool get enabled => _enabled;
|
||||
|
||||
set enabled(bool value) => _enabled = value;
|
||||
|
@ -41,14 +44,17 @@ class TronToken extends CryptoCurrency with HiveObjectMixin {
|
|||
bool enabled = true,
|
||||
this.iconPath,
|
||||
this.tag = 'TRX',
|
||||
this.isPotentialScam = false,
|
||||
}) : _enabled = enabled,
|
||||
super(
|
||||
name: symbol.toLowerCase(),
|
||||
title: symbol.toUpperCase(),
|
||||
fullName: name,
|
||||
tag: tag,
|
||||
iconPath: iconPath,
|
||||
decimals: decimal);
|
||||
name: symbol.toLowerCase(),
|
||||
title: symbol.toUpperCase(),
|
||||
fullName: name,
|
||||
tag: tag,
|
||||
iconPath: iconPath,
|
||||
decimals: decimal,
|
||||
isPotentialScam: isPotentialScam,
|
||||
);
|
||||
|
||||
TronToken.copyWith(TronToken other, String? icon, String? tag)
|
||||
: name = other.name,
|
||||
|
@ -58,6 +64,7 @@ class TronToken extends CryptoCurrency with HiveObjectMixin {
|
|||
_enabled = other.enabled,
|
||||
tag = tag ?? other.tag,
|
||||
iconPath = icon ?? other.iconPath,
|
||||
isPotentialScam = other.isPotentialScam,
|
||||
super(
|
||||
name: other.name,
|
||||
title: other.symbol.toUpperCase(),
|
||||
|
@ -65,6 +72,7 @@ class TronToken extends CryptoCurrency with HiveObjectMixin {
|
|||
tag: tag ?? other.tag,
|
||||
iconPath: icon ?? other.iconPath,
|
||||
decimals: other.decimal,
|
||||
isPotentialScam: other.isPotentialScam,
|
||||
);
|
||||
|
||||
static const typeId = TRON_TOKEN_TYPE_ID;
|
||||
|
|
|
@ -509,11 +509,15 @@ abstract class TronWalletBase
|
|||
|
||||
Future<void> addTronToken(TronToken token) async {
|
||||
String? iconPath;
|
||||
try {
|
||||
iconPath = CryptoCurrency.all
|
||||
.firstWhere((element) => element.title.toUpperCase() == token.symbol.toUpperCase())
|
||||
.iconPath;
|
||||
} catch (_) {}
|
||||
if ((token.iconPath == null || token.iconPath!.isEmpty) && !token.isPotentialScam) {
|
||||
try {
|
||||
iconPath = CryptoCurrency.all
|
||||
.firstWhere((element) => element.title.toUpperCase() == token.symbol.toUpperCase())
|
||||
.iconPath;
|
||||
} catch (_) {}
|
||||
} else if (!token.isPotentialScam) {
|
||||
iconPath = token.iconPath;
|
||||
}
|
||||
|
||||
final newToken = TronToken(
|
||||
name: token.name,
|
||||
|
@ -523,6 +527,7 @@ abstract class TronWalletBase
|
|||
enabled: token.enabled,
|
||||
tag: token.tag ?? "TRX",
|
||||
iconPath: iconPath,
|
||||
isPotentialScam: token.isPotentialScam,
|
||||
);
|
||||
|
||||
await tronTokensBox.put(newToken.contractAddress, newToken);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue