2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* 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 'dart:io';
|
|
|
|
|
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
2022-10-24 22:30:38 +00:00
|
|
|
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();
|
|
|
|
|
2022-10-24 22:30:38 +00:00
|
|
|
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,
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-05-24 18:08:32 +00:00
|
|
|
static final BigInt _satsPerCoinECash = BigInt.from(100);
|
2023-05-24 15:56:44 +00:00
|
|
|
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 =
|
2023-06-08 14:54:29 +00:00
|
|
|
BigInt.parse("1000000000000000000000000000000"); // 1*10^30
|
2023-05-30 23:19:31 +00:00
|
|
|
static final BigInt _satsPerCoinBanano =
|
2023-06-08 14:54:29 +00:00
|
|
|
BigInt.parse("100000000000000000000000000000"); // 1*10^29
|
2023-05-24 15:56:44 +00:00
|
|
|
static final BigInt _satsPerCoin = BigInt.from(100000000);
|
2022-11-23 18:31:31 +00:00
|
|
|
static const int _decimalPlaces = 8;
|
2023-05-26 18:47:50 +00:00
|
|
|
static const int _decimalPlacesNano = 30;
|
2023-05-30 23:19:31 +00:00
|
|
|
static const int _decimalPlacesBanano = 29;
|
2022-11-23 18:31:31 +00:00
|
|
|
static const int _decimalPlacesWownero = 11;
|
|
|
|
static const int _decimalPlacesMonero = 12;
|
2023-02-14 17:43:48 +00:00
|
|
|
static const int _decimalPlacesEthereum = 18;
|
2023-04-17 18:56:35 +00:00
|
|
|
static const int _decimalPlacesECash = 2;
|
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-05-15 20:21:09 +00:00
|
|
|
static const int currentDataVersion = 10;
|
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
|
|
|
|
2023-05-24 15:56:44 +00:00
|
|
|
static BigInt satsPerCoin(Coin coin) {
|
2022-11-23 18:31:31 +00:00
|
|
|
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:
|
2022-11-23 18:31:31 +00:00
|
|
|
return _satsPerCoin;
|
|
|
|
|
2023-05-24 15:56:44 +00:00
|
|
|
case Coin.nano:
|
|
|
|
return _satsPerCoinNano;
|
|
|
|
|
2023-05-30 23:19:31 +00:00
|
|
|
case Coin.banano:
|
|
|
|
return _satsPerCoinBanano;
|
|
|
|
|
2022-11-23 18:31:31 +00:00
|
|
|
case Coin.wownero:
|
|
|
|
return _satsPerCoinWownero;
|
|
|
|
|
|
|
|
case Coin.monero:
|
|
|
|
return _satsPerCoinMonero;
|
2023-02-14 17:43:48 +00:00
|
|
|
|
|
|
|
case Coin.ethereum:
|
|
|
|
return _satsPerCoinEthereum;
|
2023-04-17 18:56:35 +00:00
|
|
|
|
|
|
|
case Coin.eCash:
|
|
|
|
return _satsPerCoinECash;
|
2022-11-23 18:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-22 13:15:08 +00:00
|
|
|
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:
|
2022-11-23 18:31:31 +00:00
|
|
|
return _decimalPlaces;
|
2022-11-22 13:15:08 +00:00
|
|
|
|
2023-05-24 15:56:44 +00:00
|
|
|
case Coin.nano:
|
|
|
|
return _decimalPlacesNano;
|
|
|
|
|
2023-05-30 23:19:31 +00:00
|
|
|
case Coin.banano:
|
|
|
|
return _decimalPlacesBanano;
|
|
|
|
|
2022-11-22 13:15:08 +00:00
|
|
|
case Coin.wownero:
|
2022-11-23 18:31:31 +00:00
|
|
|
return _decimalPlacesWownero;
|
2022-11-22 13:15:08 +00:00
|
|
|
|
|
|
|
case Coin.monero:
|
2022-11-23 18:31:31 +00:00
|
|
|
return _decimalPlacesMonero;
|
2023-02-14 17:43:48 +00:00
|
|
|
|
|
|
|
case Coin.ethereum:
|
|
|
|
return _decimalPlacesEthereum;
|
2023-04-17 18:56:35 +00:00
|
|
|
|
|
|
|
case Coin.eCash:
|
|
|
|
return _decimalPlacesECash;
|
2022-11-22 13:15:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-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;
|
|
|
|
|
|
|
|
case Coin.monero:
|
|
|
|
values.addAll([25]);
|
|
|
|
break;
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
2022-11-08 19:35:27 +00:00
|
|
|
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-27 08:16:20 +00:00
|
|
|
|
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;
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-08 14:54:29 +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.epicCash:
|
|
|
|
case Coin.namecoin:
|
|
|
|
case Coin.particl:
|
|
|
|
case Coin.ethereum:
|
|
|
|
return 12;
|
|
|
|
|
|
|
|
case Coin.wownero:
|
|
|
|
return 14;
|
|
|
|
|
|
|
|
case Coin.nano:
|
|
|
|
case Coin.banano:
|
|
|
|
return 24;
|
|
|
|
|
|
|
|
case Coin.monero:
|
|
|
|
return 25;
|
|
|
|
}
|
|
|
|
}
|
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',
|
|
|
|
};
|
|
|
|
}
|