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:
Omar Hatem 2025-04-03 03:32:00 +02:00 committed by GitHub
parent cbca4c9c77
commit 23a47ed561
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 121 additions and 45 deletions

View file

@ -6,6 +6,7 @@ part 'spl_token.g.dart';
@HiveType(typeId: SPLToken.typeId)
class SPLToken extends CryptoCurrency with HiveObjectMixin {
@override
@HiveField(0)
final String name;
@ -24,12 +25,18 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
@HiveField(5)
final String mint;
@override
@HiveField(6)
final String? iconPath;
@override
@HiveField(7)
final String? tag;
@override
@HiveField(8, defaultValue: false)
final bool isPotentialScam;
SPLToken({
required this.name,
required this.symbol,
@ -39,6 +46,7 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
this.iconPath,
this.tag = 'SOL',
bool enabled = true,
this.isPotentialScam = false,
}) : _enabled = enabled,
super(
name: mint.toLowerCase(),
@ -47,6 +55,7 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
tag: tag,
iconPath: iconPath,
decimals: decimal,
isPotentialScam: isPotentialScam,
);
factory SPLToken.fromMetadata({
@ -55,6 +64,7 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
required String symbol,
required String mintAddress,
String? iconPath,
bool isPotentialScam = false,
}) {
return SPLToken(
name: name,
@ -63,28 +73,14 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
decimal: 0,
mint: mint,
iconPath: iconPath,
isPotentialScam: isPotentialScam,
);
}
factory SPLToken.cryptoCurrency({
required String name,
required String symbol,
required int decimals,
required String iconPath,
required String mint,
}) {
return SPLToken(
name: name,
symbol: symbol,
decimal: decimals,
mint: mint,
iconPath: iconPath,
mintAddress: '',
);
}
@override
bool get enabled => _enabled;
@override
set enabled(bool value) => _enabled = value;
SPLToken.copyWith(SPLToken other, String? icon, String? tag)
@ -96,6 +92,7 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
mint = other.mint,
tag = other.tag,
iconPath = icon,
isPotentialScam = other.isPotentialScam,
super(
title: other.symbol.toUpperCase(),
name: other.symbol.toLowerCase(),
@ -103,6 +100,7 @@ class SPLToken extends CryptoCurrency with HiveObjectMixin {
fullName: other.name,
tag: other.tag,
iconPath: icon,
isPotentialScam: other.isPotentialScam,
);
static const typeId = SPL_TOKEN_TYPE_ID;