stack_wallet/lib/utilities/enums/coin_enum.dart

488 lines
11 KiB
Dart
Raw Normal View History

/*
* This file is part of Stack Wallet.
*
* 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-08-26 08:11:35 +00:00
import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as btc;
2022-09-26 20:32:53 +00:00
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'
as bch;
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'
as doge;
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;
2022-09-27 16:27:51 +00:00
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow;
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,
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-08-26 08:11:35 +00:00
monero,
2022-09-23 21:02:53 +00:00
namecoin,
2022-10-25 15:06:37 +00:00
particl,
2022-10-29 15:14:59 +00:00
wownero,
2023-05-19 10:20:16 +00:00
nano,
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-10-28 18:03:52 +00:00
litecoinTestNet,
2022-09-26 20:32:53 +00:00
bitcoincashTestnet,
2022-08-26 08:11:35 +00:00
dogecoinTestNet,
firoTestNet,
}
2022-12-29 19:38:39 +00:00
final int kTestNetCoinCount = 4; // 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:
return "E-Cash";
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";
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";
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";
}
}
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";
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";
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";
}
}
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";
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";
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";
}
}
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:
2022-09-27 08:09:31 +00:00
case Coin.wownero:
2023-05-19 10:20:16 +00:00
case Coin.nano: // TODO: Check this
2022-08-26 08:11:35 +00:00
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:
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:
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:
case Coin.wownero:
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
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:
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:
case Coin.wownero:
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
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;
}
}
2022-08-26 08:11:35 +00:00
int get requiredConfirmations {
switch (this) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
return btc.MINIMUM_CONFIRMATIONS;
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:
return doge.MINIMUM_CONFIRMATIONS;
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;
2022-09-27 08:09:31 +00:00
case Coin.wownero:
return wow.MINIMUM_CONFIRMATIONS;
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:
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;
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;
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;
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;
2022-08-26 08:11:35 +00:00
default:
throw ArgumentError.value(
ticker, "name", "No Coin enum value with that ticker");
}
}