2020-01-04 19:31:52 +00:00
|
|
|
import 'package:cake_wallet/src/domain/common/enumerable_item.dart';
|
|
|
|
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-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.nano,
|
|
|
|
CryptoCurrency.trx,
|
|
|
|
CryptoCurrency.usdt,
|
|
|
|
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);
|
|
|
|
static const bnb = CryptoCurrency(title: 'BNB', raw: 3);
|
|
|
|
static const btc = CryptoCurrency(title: 'BTC', raw: 4);
|
2020-01-04 19:31:52 +00:00
|
|
|
static const dash = CryptoCurrency(title: 'DASH', raw: 5);
|
2020-01-10 15:24:44 +00:00
|
|
|
static const eos = CryptoCurrency(title: 'EOS', raw: 6);
|
|
|
|
static const eth = CryptoCurrency(title: 'ETH', raw: 7);
|
|
|
|
static const ltc = CryptoCurrency(title: 'LTC', raw: 8);
|
|
|
|
static const nano = CryptoCurrency(title: 'NANO', raw: 9);
|
|
|
|
static const trx = CryptoCurrency(title: 'TRX', raw: 10);
|
|
|
|
static const usdt = CryptoCurrency(title: 'USDT', raw: 11);
|
|
|
|
static const xlm = CryptoCurrency(title: 'XLM', raw: 12);
|
|
|
|
static const xrp = CryptoCurrency(title: 'XRP', raw: 13);
|
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-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.dash;
|
|
|
|
case 6:
|
|
|
|
return CryptoCurrency.eos;
|
|
|
|
case 7:
|
|
|
|
return CryptoCurrency.eth;
|
|
|
|
case 8:
|
|
|
|
return CryptoCurrency.ltc;
|
|
|
|
case 9:
|
|
|
|
return CryptoCurrency.nano;
|
|
|
|
case 10:
|
|
|
|
return CryptoCurrency.trx;
|
|
|
|
case 11:
|
|
|
|
return CryptoCurrency.usdt;
|
|
|
|
case 12:
|
|
|
|
return CryptoCurrency.xlm;
|
|
|
|
case 13:
|
|
|
|
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;
|
|
|
|
case 'bnb':
|
|
|
|
return CryptoCurrency.bnb;
|
2020-01-04 19:31:52 +00:00
|
|
|
case 'btc':
|
2020-01-10 15:24:44 +00:00
|
|
|
return CryptoCurrency.btc;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|