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
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue