stack_wallet/lib/utilities/enums/coin_enum.dart

595 lines
13 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
*
*/
2022-09-26 20:32:53 +00:00
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'
as bch;
2023-04-17 13:53:39 +00:00
import 'package:stackwallet/services/coins/ecash/ecash_wallet.dart' as ecash;
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'
as epic;
2022-12-13 17:39:19 +00:00
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart'
as eth;
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as firo;
2022-10-29 15:14:59 +00:00
import 'package:stackwallet/services/coins/litecoin/litecoin_wallet.dart'
as ltc;
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/services/coins/monero/monero_wallet.dart' as xmr;
2022-09-23 21:02:53 +00:00
import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'
as nmc;
2023-05-24 18:08:32 +00:00
import 'package:stackwallet/services/coins/nano/nano_wallet.dart' as nano;
2022-10-25 15:06:37 +00:00
import 'package:stackwallet/services/coins/particl/particl_wallet.dart'
as particl;
2023-07-19 17:08:46 +00:00
import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart' as xlm;
2023-06-12 19:03:32 +00:00
import 'package:stackwallet/services/coins/tezos/tezos_wallet.dart' as tezos;
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,
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,
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
}
final int kTestNetCoinCount = 5; // Util.isDesktop ? 5 : 4;
// remove firotestnet for now
2022-08-26 08:11:35 +00:00
extension CoinExt on Coin {
String get prettyName {
switch (this) {
case Coin.bitcoin:
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 "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";
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:
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:
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:
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:
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 isElectrumXCoin {
switch (this) {
case Coin.bitcoin:
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
2022-08-26 08:11:35 +00:00
case Coin.dogecoin:
case Coin.firo:
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
2022-10-25 15:06:37 +00:00
case Coin.particl:
2022-08-26 08:11:35 +00:00
case Coin.bitcoinTestNet:
2022-10-28 18:03:52 +00:00
case Coin.litecoinTestNet:
2022-09-26 20:32:53 +00:00
case Coin.bitcoincashTestnet:
2022-08-26 08:11:35 +00:00
case Coin.firoTestNet:
case Coin.dogecoinTestNet:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
2022-08-26 08:11:35 +00:00
return true;
case Coin.epicCash:
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
2022-08-26 08:11:35 +00:00
case Coin.monero:
2023-06-12 19:03:32 +00:00
case Coin.tezos:
2022-09-27 08:09:31 +00:00
case Coin.wownero:
2023-05-30 23:19:31 +00:00
case Coin.nano:
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:
2022-08-26 08:11:35 +00:00
return false;
}
}
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;
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;
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:
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:
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;
}
}
Coin get mainNetVersion {
switch (this) {
case Coin.bitcoin:
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;
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;
}
}
2022-08-26 08:11:35 +00:00
int get requiredConfirmations {
switch (this) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
2023-11-06 21:37:18 +00:00
throw UnimplementedError("moved");
2022-08-26 08:11:35 +00:00
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
case Coin.litecoinTestNet:
return ltc.MINIMUM_CONFIRMATIONS;
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
return bch.MINIMUM_CONFIRMATIONS;
2022-09-09 10:59:40 +00:00
2022-08-26 08:11:35 +00:00
case Coin.firo:
case Coin.firoTestNet:
return firo.MINIMUM_CONFIRMATIONS;
case Coin.dogecoin:
case Coin.dogecoinTestNet:
throw UnimplementedError("moved");
2022-08-26 08:11:35 +00:00
case Coin.epicCash:
return epic.MINIMUM_CONFIRMATIONS;
2023-04-17 13:53:39 +00:00
case Coin.eCash:
return ecash.MINIMUM_CONFIRMATIONS;
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
return eth.MINIMUM_CONFIRMATIONS;
2022-08-26 08:11:35 +00:00
case Coin.monero:
return xmr.MINIMUM_CONFIRMATIONS;
2022-09-27 08:09:31 +00:00
2022-10-25 15:06:37 +00:00
case Coin.particl:
return particl.MINIMUM_CONFIRMATIONS;
2023-07-19 17:08:46 +00:00
case Coin.stellar:
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-07-19 17:08:46 +00:00
return xlm.MINIMUM_CONFIRMATIONS;
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return tezos.MINIMUM_CONFIRMATIONS;
2022-09-27 08:09:31 +00:00
case Coin.wownero:
2023-11-06 21:37:18 +00:00
throw UnimplementedError("moved");
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
return nmc.MINIMUM_CONFIRMATIONS;
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-05-30 23:19:31 +00:00
case Coin.banano:
2023-05-19 10:20:16 +00:00
return nano.MINIMUM_CONFIRMATIONS;
2022-08-26 08:11:35 +00:00
}
}
2023-03-06 18:11:13 +00:00
int get decimals => Constants.decimalPlacesForCoin(this);
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
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");
}
}