2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/enumerable_item.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
|
|
|
part 'crypto_currency.g.dart';
|
|
|
|
|
2020-05-26 15:27:10 +00:00
|
|
|
@HiveType(typeId: 0)
|
2020-01-04 19:31:52 +00:00
|
|
|
class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
|
2020-01-08 12:26:34 +00:00
|
|
|
const CryptoCurrency({final String title, final int raw})
|
|
|
|
: super(title: title, raw: raw);
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
static const all = [
|
|
|
|
CryptoCurrency.xmr,
|
2020-01-10 15:24:44 +00:00
|
|
|
CryptoCurrency.ada,
|
|
|
|
CryptoCurrency.bch,
|
|
|
|
CryptoCurrency.bnb,
|
2020-01-04 19:31:52 +00:00
|
|
|
CryptoCurrency.btc,
|
2020-09-24 18:58:07 +00:00
|
|
|
CryptoCurrency.dai,
|
2020-01-10 15:24:44 +00:00
|
|
|
CryptoCurrency.dash,
|
|
|
|
CryptoCurrency.eos,
|
2020-01-04 19:31:52 +00:00
|
|
|
CryptoCurrency.eth,
|
|
|
|
CryptoCurrency.ltc,
|
2020-01-10 15:24:44 +00:00
|
|
|
CryptoCurrency.trx,
|
|
|
|
CryptoCurrency.usdt,
|
2020-09-25 13:30:39 +00:00
|
|
|
CryptoCurrency.usdterc20,
|
2020-01-10 15:24:44 +00:00
|
|
|
CryptoCurrency.xlm,
|
|
|
|
CryptoCurrency.xrp
|
2020-01-04 19:31:52 +00:00
|
|
|
];
|
|
|
|
static const xmr = CryptoCurrency(title: 'XMR', raw: 0);
|
2020-01-10 15:24:44 +00:00
|
|
|
static const ada = CryptoCurrency(title: 'ADA', raw: 1);
|
|
|
|
static const bch = CryptoCurrency(title: 'BCH', raw: 2);
|
2021-04-30 09:46:15 +00:00
|
|
|
static const bnb = CryptoCurrency(title: 'BNB BEP2', raw: 3);
|
2020-01-10 15:24:44 +00:00
|
|
|
static const btc = CryptoCurrency(title: 'BTC', raw: 4);
|
2020-09-24 18:58:07 +00:00
|
|
|
static const dai = CryptoCurrency(title: 'DAI', raw: 5);
|
|
|
|
static const dash = CryptoCurrency(title: 'DASH', raw: 6);
|
|
|
|
static const eos = CryptoCurrency(title: 'EOS', raw: 7);
|
|
|
|
static const eth = CryptoCurrency(title: 'ETH', raw: 8);
|
|
|
|
static const ltc = CryptoCurrency(title: 'LTC', raw: 9);
|
|
|
|
static const nano = CryptoCurrency(title: 'NANO', raw: 10);
|
|
|
|
static const trx = CryptoCurrency(title: 'TRX', raw: 11);
|
|
|
|
static const usdt = CryptoCurrency(title: 'USDT', raw: 12);
|
2020-09-25 13:30:39 +00:00
|
|
|
static const usdterc20 = CryptoCurrency(title: 'USDTERC20', raw: 13);
|
|
|
|
static const xlm = CryptoCurrency(title: 'XLM', raw: 14);
|
|
|
|
static const xrp = CryptoCurrency(title: 'XRP', raw: 15);
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
static CryptoCurrency deserialize({int raw}) {
|
|
|
|
switch (raw) {
|
|
|
|
case 0:
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.xmr;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 1:
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.ada;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 2:
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.bch;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 3:
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.bnb;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 4:
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.btc;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 5:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.dai;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 6:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.dash;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 7:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.eos;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 8:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.eth;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 9:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.ltc;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 10:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.nano;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 11:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.trx;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 12:
|
2020-09-24 18:58:07 +00:00
|
|
|
return CryptoCurrency.usdt;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 13:
|
2020-09-25 13:30:39 +00:00
|
|
|
return CryptoCurrency.usdterc20;
|
2020-09-24 18:58:07 +00:00
|
|
|
case 14:
|
2020-09-25 13:30:39 +00:00
|
|
|
return CryptoCurrency.xlm;
|
|
|
|
case 15:
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.xrp;
|
2020-01-04 19:31:52 +00:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static CryptoCurrency fromString(String raw) {
|
|
|
|
switch (raw.toLowerCase()) {
|
|
|
|
case 'xmr':
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.xmr;
|
|
|
|
case 'ada':
|
|
|
|
return CryptoCurrency.ada;
|
|
|
|
case 'bch':
|
|
|
|
return CryptoCurrency.bch;
|
2021-04-30 09:46:15 +00:00
|
|
|
case 'bnbmainnet':
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.bnb;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 'btc':
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.btc;
|
2020-09-24 18:58:07 +00:00
|
|
|
case 'dai':
|
|
|
|
return CryptoCurrency.dai;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 'dash':
|
|
|
|
return CryptoCurrency.dash;
|
|
|
|
case 'eos':
|
|
|
|
return CryptoCurrency.eos;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 'eth':
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.eth;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 'ltc':
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.ltc;
|
|
|
|
case 'nano':
|
|
|
|
return CryptoCurrency.nano;
|
|
|
|
case 'trx':
|
|
|
|
return CryptoCurrency.trx;
|
|
|
|
case 'usdt':
|
|
|
|
return CryptoCurrency.usdt;
|
2020-09-25 13:30:39 +00:00
|
|
|
case 'usdterc20':
|
|
|
|
return CryptoCurrency.usdterc20;
|
2020-01-10 15:24:44 +00:00
|
|
|
case 'xlm':
|
|
|
|
return CryptoCurrency.xlm;
|
|
|
|
case 'xrp':
|
|
|
|
return CryptoCurrency.xrp;
|
2020-01-04 19:31:52 +00:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => title;
|
|
|
|
}
|