2023-06-23 01:47:24 +00:00
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2023-06-21 00:46:58 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
|
|
|
part 'erc20_token.g.dart';
|
|
|
|
|
|
|
|
@HiveType(typeId: Erc20Token.typeId)
|
2023-06-23 17:21:28 +00:00
|
|
|
class Erc20Token extends CryptoCurrency with HiveObjectMixin {
|
2023-06-21 00:46:58 +00:00
|
|
|
@HiveField(0)
|
|
|
|
final String name;
|
|
|
|
@HiveField(1)
|
|
|
|
final String symbol;
|
|
|
|
@HiveField(2)
|
|
|
|
final String contractAddress;
|
2023-06-22 21:17:54 +00:00
|
|
|
@HiveField(3)
|
|
|
|
final int decimal;
|
2023-07-03 17:18:24 +00:00
|
|
|
@HiveField(4, defaultValue: true)
|
2023-06-23 01:47:24 +00:00
|
|
|
bool _enabled;
|
2023-06-23 17:21:28 +00:00
|
|
|
@HiveField(5)
|
|
|
|
final String? iconPath;
|
2023-06-23 01:47:24 +00:00
|
|
|
|
|
|
|
bool get enabled => _enabled;
|
|
|
|
|
2023-07-04 01:09:17 +00:00
|
|
|
set enabled(bool value) => _enabled = value;
|
2023-06-22 21:17:54 +00:00
|
|
|
|
|
|
|
Erc20Token({
|
|
|
|
required this.name,
|
|
|
|
required this.symbol,
|
|
|
|
required this.contractAddress,
|
|
|
|
required this.decimal,
|
2023-07-03 17:18:24 +00:00
|
|
|
bool enabled = true,
|
2023-06-23 17:21:28 +00:00
|
|
|
this.iconPath,
|
2023-06-23 01:47:24 +00:00
|
|
|
}) : _enabled = enabled,
|
|
|
|
super(
|
|
|
|
name: symbol.toLowerCase(),
|
|
|
|
title: symbol.toUpperCase(),
|
|
|
|
fullName: name,
|
|
|
|
tag: "ETH",
|
|
|
|
iconPath: iconPath,
|
|
|
|
);
|
2023-06-21 00:46:58 +00:00
|
|
|
|
2023-07-06 14:34:13 +00:00
|
|
|
Erc20Token.copyWith(Erc20Token other, String? icon)
|
|
|
|
: this.name = other.name,
|
|
|
|
this.symbol = other.symbol,
|
|
|
|
this.contractAddress = other.contractAddress,
|
|
|
|
this.decimal = other.decimal,
|
|
|
|
this._enabled = other.enabled,
|
|
|
|
this.iconPath = icon,
|
|
|
|
super(
|
|
|
|
name: other.name,
|
|
|
|
title: other.symbol.toUpperCase(),
|
|
|
|
fullName: other.name,
|
|
|
|
tag: "ETH",
|
|
|
|
iconPath: icon,
|
|
|
|
);
|
|
|
|
|
2023-06-21 00:46:58 +00:00
|
|
|
static const typeId = 12;
|
|
|
|
static const boxName = 'Erc20Tokens';
|
|
|
|
|
|
|
|
@override
|
2023-06-23 01:47:24 +00:00
|
|
|
bool operator ==(other) => other is Erc20Token && other.contractAddress == contractAddress;
|
2023-06-21 00:46:58 +00:00
|
|
|
|
|
|
|
@override
|
2023-06-23 01:47:24 +00:00
|
|
|
int get hashCode => contractAddress.hashCode;
|
2023-06-21 00:46:58 +00:00
|
|
|
}
|