stack_wallet/lib/utilities/constants.dart

316 lines
7.5 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-08-26 08:11:35 +00:00
import 'dart:io';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/util.dart';
2022-08-26 08:11:35 +00:00
class _LayoutSizing {
const _LayoutSizing();
double get circularBorderRadius => 8.0;
double get checkboxBorderRadius => 4.0;
double get standardPadding => 16.0;
}
abstract class Constants {
static const size = _LayoutSizing();
static void exchangeForExperiencedUsers(int count) {
enableExchange =
Util.isDesktop || Platform.isAndroid || count > 5 || !Platform.isIOS;
}
static bool enableExchange = Util.isDesktop || !Platform.isIOS;
2023-03-10 22:47:12 +00:00
// just use enable exchange flag
// static bool enableBuy = enableExchange;
2023-03-10 22:50:06 +00:00
// // true; // true for development,
2023-05-24 18:08:32 +00:00
static final BigInt _satsPerCoinECash = BigInt.from(100);
static final BigInt _satsPerCoinEthereum = BigInt.from(1000000000000000000);
static final BigInt _satsPerCoinMonero = BigInt.from(1000000000000);
static final BigInt _satsPerCoinWownero = BigInt.from(100000000000);
2023-05-24 18:08:32 +00:00
static final BigInt _satsPerCoinNano =
BigInt.parse("1000000000000000000000000000000"); // 1*10^30
2023-05-30 23:19:31 +00:00
static final BigInt _satsPerCoinBanano =
BigInt.parse("100000000000000000000000000000"); // 1*10^29
2023-07-28 16:50:05 +00:00
static final BigInt _satsPerCoinStellar = BigInt.from(
10000000); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision
static final BigInt _satsPerCoin = BigInt.from(100000000);
2023-06-12 19:03:32 +00:00
static final BigInt _satsPerCoinTezos = BigInt.from(1000000);
static const int _decimalPlaces = 8;
static const int _decimalPlacesNano = 30;
2023-05-30 23:19:31 +00:00
static const int _decimalPlacesBanano = 29;
static const int _decimalPlacesWownero = 11;
static const int _decimalPlacesMonero = 12;
static const int _decimalPlacesEthereum = 18;
2023-04-17 18:56:35 +00:00
static const int _decimalPlacesECash = 2;
2023-07-19 17:08:46 +00:00
static const int _decimalPlacesStellar = 7;
2023-06-12 19:03:32 +00:00
static const int _decimalPlacesTezos = 6;
2022-08-26 08:11:35 +00:00
static const int notificationsMax = 0xFFFFFFFF;
static const Duration networkAliveTimerDuration = Duration(seconds: 10);
// Enable Logger.print statements
static const bool disableLogger = false;
2023-11-06 17:24:02 +00:00
static const int currentDataVersion = 12;
2022-08-26 08:11:35 +00:00
2023-02-08 13:29:27 +00:00
static const int rescanV1 = 1;
2022-08-26 08:11:35 +00:00
static BigInt satsPerCoin(Coin coin) {
switch (coin) {
case Coin.bitcoin:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoinTestNet:
case Coin.dogecoinTestNet:
case Coin.firoTestNet:
case Coin.epicCash:
case Coin.namecoin:
2022-11-29 19:41:01 +00:00
case Coin.particl:
return _satsPerCoin;
case Coin.nano:
return _satsPerCoinNano;
2023-05-30 23:19:31 +00:00
case Coin.banano:
return _satsPerCoinBanano;
case Coin.wownero:
return _satsPerCoinWownero;
case Coin.monero:
return _satsPerCoinMonero;
case Coin.ethereum:
return _satsPerCoinEthereum;
2023-04-17 18:56:35 +00:00
case Coin.eCash:
return _satsPerCoinECash;
2023-06-12 19:03:32 +00:00
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 _satsPerCoinStellar;
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return _satsPerCoinTezos;
}
}
static int decimalPlacesForCoin(Coin coin) {
switch (coin) {
case Coin.bitcoin:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoinTestNet:
case Coin.dogecoinTestNet:
case Coin.firoTestNet:
case Coin.epicCash:
case Coin.namecoin:
2022-11-29 19:41:01 +00:00
case Coin.particl:
return _decimalPlaces;
case Coin.nano:
return _decimalPlacesNano;
2023-05-30 23:19:31 +00:00
case Coin.banano:
return _decimalPlacesBanano;
case Coin.wownero:
return _decimalPlacesWownero;
case Coin.monero:
return _decimalPlacesMonero;
case Coin.ethereum:
return _decimalPlacesEthereum;
2023-04-17 18:56:35 +00:00
case Coin.eCash:
return _decimalPlacesECash;
2023-06-12 19:03:32 +00:00
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 _decimalPlacesStellar;
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return _decimalPlacesTezos;
}
}
2022-08-26 08:11:35 +00:00
static List<int> possibleLengthsForCoin(Coin coin) {
final List<int> values = [];
switch (coin) {
case Coin.bitcoin:
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
case Coin.litecoinTestNet:
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
2022-08-26 08:11:35 +00:00
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoinTestNet:
case Coin.dogecoinTestNet:
case Coin.firoTestNet:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
2022-08-26 08:11:35 +00:00
case Coin.epicCash:
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
2022-11-29 19:11:30 +00:00
case Coin.particl:
2023-05-19 10:20:16 +00:00
case Coin.nano:
2023-07-19 17:08:46 +00:00
case Coin.stellar:
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-05-30 23:19:31 +00:00
values.addAll([24, 12]);
break;
case Coin.banano:
values.addAll([24, 12]);
2022-08-26 08:11:35 +00:00
break;
2023-06-12 19:03:32 +00:00
case Coin.tezos:
values.addAll([24, 12]);
2022-08-26 08:11:35 +00:00
case Coin.monero:
values.addAll([25]);
break;
2022-09-27 08:09:31 +00:00
case Coin.wownero:
values.addAll([14, 25]);
2022-09-27 08:09:31 +00:00
break;
2022-08-26 08:11:35 +00:00
}
return values;
}
static int targetBlockTimeInSeconds(Coin coin) {
// TODO verify values
switch (coin) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
2022-09-26 20:32:53 +00:00
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
2023-04-17 13:53:39 +00:00
case Coin.eCash:
2022-09-26 20:32:53 +00:00
return 600;
2022-09-09 10:59:40 +00:00
2022-08-26 08:11:35 +00:00
case Coin.dogecoin:
case Coin.dogecoinTestNet:
return 60;
2022-10-28 18:03:52 +00:00
case Coin.litecoin:
case Coin.litecoinTestNet:
return 150;
2022-08-26 08:11:35 +00:00
case Coin.firo:
case Coin.firoTestNet:
return 150;
case Coin.epicCash:
return 60;
2022-12-13 17:39:19 +00:00
case Coin.ethereum:
2023-03-30 20:50:58 +00:00
return 15;
2022-12-13 17:39:19 +00:00
2022-08-26 08:11:35 +00:00
case Coin.monero:
return 120;
2022-09-27 08:09:31 +00:00
case Coin.wownero:
return 120;
2022-09-23 21:02:53 +00:00
case Coin.namecoin:
return 600;
2022-11-29 19:11:30 +00:00
case Coin.particl:
return 600;
2023-05-19 10:20:16 +00:00
case Coin.nano: // TODO: Verify this
2023-05-30 23:19:31 +00:00
case Coin.banano: // TODO: Verify this
return 1;
2023-06-12 19:03:32 +00:00
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 5;
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return 60;
2022-08-26 08:11:35 +00:00
}
}
static int defaultSeedPhraseLengthFor({required Coin coin}) {
switch (coin) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.eCash:
case Coin.dogecoin:
case Coin.dogecoinTestNet:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.firo:
case Coin.firoTestNet:
case Coin.namecoin:
case Coin.particl:
case Coin.ethereum:
return 12;
case Coin.wownero:
return 14;
case Coin.nano:
case Coin.banano:
2024-01-09 20:43:58 +00:00
case Coin.epicCash:
2023-07-19 17:08:46 +00:00
case Coin.stellar:
2023-08-23 17:29:10 +00:00
case Coin.stellarTestnet:
2023-06-12 19:03:32 +00:00
case Coin.tezos:
return 24;
case Coin.monero:
return 25;
2023-11-15 21:59:01 +00:00
//
// default:
// -1;
}
}
2022-08-26 08:11:35 +00:00
static const Map<int, String> monthMapShort = {
1: 'Jan',
2: 'Feb',
3: 'Mar',
4: 'Apr',
5: 'May',
6: 'Jun',
7: 'Jul',
8: 'Aug',
9: 'Sep',
10: 'Oct',
11: 'Nov',
12: 'Dec',
};
static const Map<int, String> monthMap = {
1: 'January',
2: 'February',
3: 'March',
4: 'April',
5: 'May',
6: 'June',
7: 'July',
8: 'August',
9: 'September',
10: 'October',
11: 'November',
12: 'December',
};
}