stack_wallet/lib/utilities/enums/coin_enum.dart

578 lines
12 KiB
Dart
Raw Normal View History

/*
2023-05-26 21:21:16 +00:00
* This file is part of Stack Wallet.
*
2023-05-26 21:21:16 +00:00
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
2023-11-09 22:27:17 +00:00
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
2023-03-06 18:11:13 +00:00
import 'package:stackwallet/utilities/constants.dart';
2022-08-26 08:11:35 +00:00
enum Coin {
bitcoin,
2024-01-18 23:47:06 +00:00
bitcoinFrost,
2023-06-08 16:54:22 +00:00
monero,
banano,
2022-09-26 20:32:53 +00:00
bitcoincash,
2022-08-26 08:11:35 +00:00
dogecoin,
2023-04-17 13:53:39 +00:00
eCash,
2022-08-26 08:11:35 +00:00
epicCash,
2022-12-13 17:39:19 +00:00
ethereum,
2022-08-26 08:11:35 +00:00
firo,
2022-10-29 15:14:59 +00:00
litecoin,
2022-09-23 21:02:53 +00:00
namecoin,
2023-06-07 19:19:22 +00:00
nano,
2022-10-25 15:06:37 +00:00
particl,
2023-07-19 17:08:46 +00:00
stellar,
2023-06-12 19:03:32 +00:00
tezos,
2022-10-29 15:14:59 +00:00
wownero,
2022-08-26 08:11:35 +00:00
///
2022-10-28 18:03:52 +00:00
2022-08-26 08:11:35 +00:00
///
///
bitcoinTestNet,
2024-01-18 23:47:06 +00:00
bitcoinFrostTestNet,
2022-09-26 20:32:53 +00:00
bitcoincashTestnet,
2022-08-26 08:11:35 +00:00
dogecoinTestNet,
firoTestNet,
2023-06-07 19:19:22 +00:00
litecoinTestNet,
2023-08-23 17:29:10 +00:00
stellarTestnet,
2022-08-26 08:11:35 +00:00
}
extension CoinExt on Coin {
String get prettyName {
switch (this) {
case Coin.bitcoin:
return "Bitcoin";
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
return "Bitcoin Frost";
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
return "Litecoin";
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
return "Bitcoin Cash";
2022-08-26 08:11:35 +00:00
case Coin.dogecoin:
return "Dogecoin";
case Coin.epicCash:
return "Epic Cash";
2023-04-17 13:53:39 +00:00
case Coin.eCash:
2023-05-24 16:51:57 +00:00
return "eCash";
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
return "Ethereum";
2022-08-26 08:11:35 +00:00
case Coin.firo:
return "Firo";
case Coin.monero:
return "Monero";
2022-10-25 15:06:37 +00:00
case Coin.particl:
return "Particl";
2023-07-19 17:08:46 +00:00
case Coin.stellar:
return "Stellar";
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return "Tezos";
2022-09-27 08:09:31 +00:00
case Coin.wownero:
return "Wownero";
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
return "Namecoin";
2023-05-19 10:20:16 +00:00
case Coin.nano:
return "Nano";
2023-05-30 23:19:31 +00:00
case Coin.banano:
return "Banano";
2022-08-26 08:11:35 +00:00
case Coin.bitcoinTestNet:
return "tBitcoin";
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrostTestNet:
return "tBitcoin Frost";
2022-10-28 18:03:52 +00:00
case Coin.litecoinTestNet:
return "tLitecoin";
2022-09-26 20:32:53 +00:00
case Coin.bitcoincashTestnet:
return "tBitcoin Cash";
2022-08-26 08:11:35 +00:00
case Coin.firoTestNet:
return "tFiro";
case Coin.dogecoinTestNet:
return "tDogecoin";
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
return "tStellar";
2022-08-26 08:11:35 +00:00
}
}
String get ticker {
switch (this) {
case Coin.bitcoin:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
2022-08-26 08:11:35 +00:00
return "BTC";
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
return "LTC";
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
return "BCH";
2022-08-26 08:11:35 +00:00
case Coin.dogecoin:
return "DOGE";
case Coin.epicCash:
return "EPIC";
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
return "ETH";
2023-04-17 13:53:39 +00:00
case Coin.eCash:
return "XEC";
2022-08-26 08:11:35 +00:00
case Coin.firo:
return "FIRO";
case Coin.monero:
return "XMR";
2022-10-25 15:06:37 +00:00
case Coin.particl:
return "PART";
2023-07-19 17:08:46 +00:00
case Coin.stellar:
return "XLM";
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return "XTZ";
2022-09-27 08:09:31 +00:00
case Coin.wownero:
return "WOW";
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
return "NMC";
2023-05-19 10:20:16 +00:00
case Coin.nano:
return "XNO";
2023-05-30 23:19:31 +00:00
case Coin.banano:
return "BAN";
2022-08-26 08:11:35 +00:00
case Coin.bitcoinTestNet:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrostTestNet:
2022-08-26 08:11:35 +00:00
return "tBTC";
2022-10-28 18:03:52 +00:00
case Coin.litecoinTestNet:
return "tLTC";
2022-09-26 20:32:53 +00:00
case Coin.bitcoincashTestnet:
return "tBCH";
2022-08-26 08:11:35 +00:00
case Coin.firoTestNet:
return "tFIRO";
case Coin.dogecoinTestNet:
return "tDOGE";
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-07-27 11:09:56 +00:00
return "tXLM";
2022-08-26 08:11:35 +00:00
}
}
String get uriScheme {
switch (this) {
case Coin.bitcoin:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
2022-08-26 08:11:35 +00:00
return "bitcoin";
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
return "litecoin";
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
return "bitcoincash";
2022-08-26 08:11:35 +00:00
case Coin.dogecoin:
return "dogecoin";
case Coin.epicCash:
// TODO: is this actually the right one?
return "epic";
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
return "ethereum";
2023-04-17 13:53:39 +00:00
case Coin.eCash:
return "ecash";
2022-08-26 08:11:35 +00:00
case Coin.firo:
return "firo";
case Coin.monero:
return "monero";
2022-10-25 15:06:37 +00:00
case Coin.particl:
return "particl";
2023-07-19 17:08:46 +00:00
case Coin.stellar:
return "stellar";
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return "tezos";
2022-09-27 08:09:31 +00:00
case Coin.wownero:
return "wownero";
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
return "namecoin";
2023-05-19 10:20:16 +00:00
case Coin.nano:
return "nano";
2023-05-30 23:19:31 +00:00
case Coin.banano:
return "ban";
2022-08-26 08:11:35 +00:00
case Coin.bitcoinTestNet:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrostTestNet:
2022-08-26 08:11:35 +00:00
return "bitcoin";
2022-10-28 18:03:52 +00:00
case Coin.litecoinTestNet:
return "litecoin";
2022-09-26 20:32:53 +00:00
case Coin.bitcoincashTestnet:
return "bchtest";
2022-08-26 08:11:35 +00:00
case Coin.firoTestNet:
return "firo";
case Coin.dogecoinTestNet:
return "dogecoin";
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-07-27 11:09:56 +00:00
return "stellar";
2022-08-26 08:11:35 +00:00
}
}
bool get hasMnemonicPassphraseSupport {
switch (this) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.dogecoinTestNet:
case Coin.firo:
case Coin.firoTestNet:
case Coin.namecoin:
case Coin.particl:
case Coin.ethereum:
case Coin.eCash:
case Coin.stellar:
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
return true;
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
case Coin.bitcoinFrostTestNet:
case Coin.epicCash:
case Coin.monero:
case Coin.wownero:
case Coin.nano:
case Coin.banano:
case Coin.tezos:
return false;
}
}
bool get hasBuySupport {
switch (this) {
case Coin.bitcoin:
case Coin.litecoin:
case Coin.bitcoincash:
case Coin.dogecoin:
case Coin.ethereum:
return true;
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
case Coin.bitcoinFrostTestNet:
case Coin.firo:
case Coin.namecoin:
case Coin.particl:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
case Coin.epicCash:
case Coin.monero:
2023-06-12 19:03:32 +00:00
case Coin.tezos:
case Coin.wownero:
case Coin.dogecoinTestNet:
case Coin.bitcoinTestNet:
case Coin.litecoinTestNet:
case Coin.bitcoincashTestnet:
case Coin.firoTestNet:
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-05-30 23:19:31 +00:00
case Coin.banano:
2023-07-19 17:08:46 +00:00
case Coin.stellar:
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
return false;
}
}
2023-03-10 22:46:51 +00:00
bool get isTestNet {
switch (this) {
case Coin.bitcoin:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
2023-03-10 22:46:51 +00:00
case Coin.litecoin:
case Coin.bitcoincash:
case Coin.dogecoin:
case Coin.firo:
case Coin.namecoin:
case Coin.particl:
case Coin.epicCash:
2023-03-22 15:25:21 +00:00
case Coin.ethereum:
2023-03-10 22:46:51 +00:00
case Coin.monero:
2023-06-12 19:03:32 +00:00
case Coin.tezos:
2023-03-10 22:46:51 +00:00
case Coin.wownero:
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-05-30 23:19:31 +00:00
case Coin.banano:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
2023-07-19 17:08:46 +00:00
case Coin.stellar:
2023-03-10 22:46:51 +00:00
return false;
case Coin.dogecoinTestNet:
case Coin.bitcoinTestNet:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrostTestNet:
2023-03-10 22:46:51 +00:00
case Coin.litecoinTestNet:
case Coin.bitcoincashTestnet:
case Coin.firoTestNet:
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-03-10 22:46:51 +00:00
return true;
}
}
2024-01-19 23:44:01 +00:00
bool get isFrost {
switch (this) {
case Coin.bitcoinFrost:
case Coin.bitcoinFrostTestNet:
return true;
default:
return false;
}
}
Coin get mainNetVersion {
switch (this) {
case Coin.bitcoin:
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
case Coin.litecoin:
case Coin.bitcoincash:
case Coin.dogecoin:
case Coin.firo:
case Coin.namecoin:
case Coin.particl:
case Coin.epicCash:
2023-03-22 15:25:21 +00:00
case Coin.ethereum:
case Coin.monero:
2023-06-12 19:03:32 +00:00
case Coin.tezos:
case Coin.wownero:
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-05-30 23:19:31 +00:00
case Coin.banano:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
2023-07-19 17:08:46 +00:00
case Coin.stellar:
return this;
case Coin.dogecoinTestNet:
return Coin.dogecoin;
case Coin.bitcoinTestNet:
return Coin.bitcoin;
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrostTestNet:
return Coin.bitcoinFrost;
case Coin.litecoinTestNet:
return Coin.litecoin;
case Coin.bitcoincashTestnet:
return Coin.bitcoincash;
case Coin.firoTestNet:
return Coin.firo;
2023-07-27 11:09:56 +00:00
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-07-27 11:09:56 +00:00
return Coin.stellar;
}
}
2023-03-06 18:11:13 +00:00
int get decimals => Constants.decimalPlacesForCoin(this);
2023-11-09 22:27:17 +00:00
2024-01-11 02:46:43 +00:00
// Note: this must relate to DerivePathType for certain coins!
2023-11-09 22:27:17 +00:00
AddressType get primaryAddressType {
switch (this) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
case Coin.litecoin:
case Coin.litecoinTestNet:
2024-01-11 02:46:43 +00:00
case Coin.namecoin:
case Coin.particl:
2023-11-09 22:27:17 +00:00
return AddressType.p2wpkh;
2024-01-18 23:47:06 +00:00
case Coin.bitcoinFrost:
case Coin.bitcoinFrostTestNet:
return AddressType.frostMS;
2023-11-09 22:27:17 +00:00
case Coin.eCash:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.firo:
case Coin.firoTestNet:
case Coin.dogecoinTestNet:
return AddressType.p2pkh;
case Coin.monero:
case Coin.wownero:
return AddressType.cryptonote;
case Coin.epicCash:
return AddressType.mimbleWimble;
case Coin.ethereum:
return AddressType.ethereum;
case Coin.tezos:
return AddressType.tezos;
2023-11-09 22:27:17 +00:00
case Coin.nano:
return AddressType.nano;
case Coin.banano:
return AddressType.banano;
case Coin.stellar:
case Coin.stellarTestnet:
2024-01-11 23:18:58 +00:00
return AddressType.stellar;
2023-11-09 22:27:17 +00:00
}
}
2022-08-26 08:11:35 +00:00
}
Coin coinFromPrettyName(String name) {
switch (name) {
case "Bitcoin":
case "bitcoin":
return Coin.bitcoin;
2022-10-28 18:03:52 +00:00
case "Litecoin":
case "litecoin":
return Coin.litecoin;
2022-09-26 20:32:53 +00:00
case "Bitcoincash":
case "bitcoincash":
case "Bitcoin Cash":
return Coin.bitcoincash;
2022-08-26 08:11:35 +00:00
case "Dogecoin":
case "dogecoin":
return Coin.dogecoin;
2022-08-26 08:11:35 +00:00
case "Epic Cash":
case "epicCash":
return Coin.epicCash;
2022-12-13 17:39:19 +00:00
case "Ethereum":
case "ethereum":
return Coin.ethereum;
2022-08-26 08:11:35 +00:00
case "Firo":
case "firo":
return Coin.firo;
2023-04-17 13:53:39 +00:00
case "E-Cash":
case "ecash":
case "eCash":
return Coin.eCash;
2022-08-26 08:11:35 +00:00
case "Monero":
case "monero":
return Coin.monero;
2022-10-25 15:06:37 +00:00
case "Particl":
case "particl":
return Coin.particl;
2023-07-19 17:08:46 +00:00
case "Stellar":
case "stellar":
return Coin.stellar;
2023-06-12 19:03:32 +00:00
case "Tezos":
case "tezos":
return Coin.tezos;
2022-09-23 21:02:53 +00:00
case "Namecoin":
case "namecoin":
return Coin.namecoin;
2022-08-26 08:11:35 +00:00
case "Bitcoin Testnet":
case "tBitcoin":
case "bitcoinTestNet":
return Coin.bitcoinTestNet;
2022-10-28 18:03:52 +00:00
case "Litecoin Testnet":
case "tlitecoin":
case "litecoinTestNet":
case "tLitecoin":
return Coin.litecoinTestNet;
2022-09-26 20:32:53 +00:00
case "Bitcoincash Testnet":
case "tBitcoin Cash":
case "Bitcoin Cash Testnet":
case "bitcoincashTestnet":
2022-09-26 20:32:53 +00:00
return Coin.bitcoincashTestnet;
2022-08-26 08:11:35 +00:00
case "Firo Testnet":
case "tFiro":
case "firoTestNet":
return Coin.firoTestNet;
2022-08-26 08:11:35 +00:00
case "Dogecoin Testnet":
case "tDogecoin":
case "dogecoinTestNet":
return Coin.dogecoinTestNet;
2022-09-27 16:27:51 +00:00
case "Wownero":
case "tWownero":
case "wownero":
return Coin.wownero;
2023-05-19 10:20:16 +00:00
case "Nano":
case "nano":
return Coin.nano;
2023-05-30 23:19:31 +00:00
case "Banano":
case "banano":
return Coin.banano;
2023-07-27 11:09:56 +00:00
case "Stellar Testnet":
case "stellarTestnet":
case "stellarTestNet":
2023-07-27 11:09:56 +00:00
case "tStellar":
2023-08-23 17:29:10 +00:00
return Coin.stellarTestnet;
2023-07-27 11:09:56 +00:00
2024-01-19 23:44:01 +00:00
case "Bitcoin Frost":
case "bitcoinFrost":
return Coin.bitcoinFrost;
case "Bitcoin Frost Testnet":
case "tBitcoin Frost":
case "bitcoinFrostTestNet":
return Coin.bitcoinFrostTestNet;
2022-08-26 08:11:35 +00:00
default:
throw ArgumentError.value(
2022-10-29 15:14:59 +00:00
name,
"name",
"No Coin enum value with that prettyName",
);
2022-08-26 08:11:35 +00:00
}
}
Coin coinFromTickerCaseInsensitive(String ticker) {
switch (ticker.toLowerCase()) {
case "btc":
return Coin.bitcoin;
2022-10-28 18:03:52 +00:00
case "ltc":
return Coin.litecoin;
2022-09-26 20:32:53 +00:00
case "bch":
return Coin.bitcoincash;
2022-08-26 08:11:35 +00:00
case "doge":
return Coin.dogecoin;
case "epic":
return Coin.epicCash;
2023-05-18 13:41:26 +00:00
case "xec":
return Coin.eCash;
2022-12-13 17:39:19 +00:00
case "eth":
return Coin.ethereum;
2022-08-26 08:11:35 +00:00
case "firo":
return Coin.firo;
case "xmr":
return Coin.monero;
2022-09-23 21:02:53 +00:00
case "nmc":
return Coin.namecoin;
2022-10-25 15:06:37 +00:00
case "part":
return Coin.particl;
2023-07-19 17:08:46 +00:00
case "xlm":
return Coin.stellar;
2023-06-12 19:03:32 +00:00
case "xtz":
return Coin.tezos;
2022-10-29 15:14:59 +00:00
case "tltc":
return Coin.litecoinTestNet;
2022-08-26 08:11:35 +00:00
case "tbtc":
return Coin.bitcoinTestNet;
2022-09-26 20:32:53 +00:00
case "tbch":
return Coin.bitcoincashTestnet;
2022-08-26 08:11:35 +00:00
case "tfiro":
return Coin.firoTestNet;
case "tdoge":
return Coin.dogecoinTestNet;
2022-09-27 16:27:51 +00:00
case "wow":
return Coin.wownero;
2023-05-19 10:20:16 +00:00
case "xno":
return Coin.nano;
2023-05-30 23:19:31 +00:00
case "ban":
return Coin.banano;
2023-07-27 11:09:56 +00:00
case "txlm":
2023-08-23 17:29:10 +00:00
return Coin.stellarTestnet;
2022-08-26 08:11:35 +00:00
default:
throw ArgumentError.value(
ticker, "name", "No Coin enum value with that ticker");
}
}