mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 19:39:22 +00:00
script generated app_config.g.dart file
This commit is contained in:
parent
bc785e13fc
commit
cc7b958c5a
52 changed files with 462 additions and 358 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -63,3 +63,4 @@ libtor_ffi.dll
|
|||
flutter_libsparkmobile.dll
|
||||
secp256k1.dll
|
||||
/libisar.so
|
||||
/lib/app_config.g.dart
|
||||
|
|
|
@ -1,34 +1,43 @@
|
|||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart';
|
||||
|
||||
part 'app_config.g.dart';
|
||||
|
||||
abstract class AppConfig {
|
||||
static const appName = prefix + _separator + suffix;
|
||||
static const appName = _prefix + _separator + suffix;
|
||||
|
||||
static const prefix = "Stack";
|
||||
static const prefix = _prefix;
|
||||
static const suffix = _suffix;
|
||||
|
||||
static const _separator = " ";
|
||||
static List<CryptoCurrency> get coins => _supportedCoins;
|
||||
|
||||
static const suffix = "Wallet";
|
||||
static CryptoCurrency getCryptoCurrencyFor(String coinIdentifier) =>
|
||||
coins.firstWhere(
|
||||
(e) => e.identifier == coinIdentifier,
|
||||
);
|
||||
|
||||
// comment out coins to disable them
|
||||
static const supportedCoins = [
|
||||
Bitcoin,
|
||||
BitcoinFrost,
|
||||
Litecoin,
|
||||
Bitcoincash,
|
||||
Dogecoin,
|
||||
Epiccash,
|
||||
Ecash,
|
||||
Ethereum,
|
||||
Firo,
|
||||
Monero,
|
||||
Particl,
|
||||
Peercoin,
|
||||
Solana,
|
||||
Stellar,
|
||||
Tezos,
|
||||
Wownero,
|
||||
Namecoin,
|
||||
Nano,
|
||||
Banano,
|
||||
];
|
||||
static CryptoCurrency getCryptoCurrencyForTicker(
|
||||
final String ticker, {
|
||||
bool caseInsensitive = true,
|
||||
}) {
|
||||
final _ticker = caseInsensitive ? ticker.toLowerCase() : ticker;
|
||||
return coins.firstWhere(
|
||||
caseInsensitive
|
||||
? (e) => e.ticker.toLowerCase() == _ticker && e is! FrostCurrency
|
||||
: (e) => e.ticker == _ticker && e is! FrostCurrency,
|
||||
);
|
||||
}
|
||||
|
||||
/// Fuzzy logic. Use with caution!!
|
||||
@Deprecated("dangerous")
|
||||
static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) {
|
||||
final name = prettyName.replaceAll(" ", "").toLowerCase();
|
||||
try {
|
||||
return coins.firstWhere(
|
||||
(e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName,
|
||||
);
|
||||
} catch (_) {
|
||||
throw Exception("getCryptoCurrencyByPrettyName($prettyName) failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/db/migrate_wallets_to_isar.dart';
|
||||
|
@ -26,15 +27,11 @@ import 'package:stackwallet/models/node_model.dart';
|
|||
import 'package:stackwallet/services/mixins/wallet_db.dart';
|
||||
import 'package:stackwallet/services/node_service.dart';
|
||||
import 'package:stackwallet/services/wallets_service.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
|
@ -560,7 +557,7 @@ class DbVersionMigrator with WalletDB {
|
|||
|
||||
final count = await MainDB.instance.getTransactions(walletId).count();
|
||||
|
||||
final crypto = Coins.getCryptoCurrencyFor(info.coinIdentifier);
|
||||
final crypto = AppConfig.getCryptoCurrencyFor(info.coinIdentifier);
|
||||
|
||||
for (var i = 0; i < count; i += 50) {
|
||||
final txns = await MainDB.instance
|
||||
|
|
|
@ -13,14 +13,13 @@ import 'dart:isolate';
|
|||
import 'package:cw_core/wallet_info.dart' as xmr;
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
import 'package:stackwallet/models/notification_model.dart';
|
||||
import 'package:stackwallet/models/trade_wallet_lookup.dart';
|
||||
import 'package:stackwallet/services/wallets_service.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
||||
class DB {
|
||||
|
@ -164,7 +163,7 @@ class DB {
|
|||
names.removeWhere((name, dyn) {
|
||||
final jsonObject = Map<String, dynamic>.from(dyn as Map);
|
||||
try {
|
||||
Coins.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
return false;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
|
|
|
@ -2,16 +2,12 @@ import 'dart:convert';
|
|||
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/stellar.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/tezos.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/token_wallet_info.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
|
@ -171,8 +167,8 @@ Future<void> migrateWalletsToIsar({
|
|||
coinName: old.coinIdentifier,
|
||||
walletId: old.walletId,
|
||||
name: old.name,
|
||||
mainAddressType: Coins.getCryptoCurrencyFor(old.coinIdentifier)
|
||||
.primaryAddressType,
|
||||
mainAddressType:
|
||||
AppConfig.getCryptoCurrencyFor(old.coinIdentifier).primaryAddressType,
|
||||
favouriteOrderIndex: favourites.indexOf(old.walletId),
|
||||
cachedChainHeight: walletBox.get(
|
||||
DBKeys.storedChainHeight,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
||||
@Deprecated("Use lib/models/isar/models/contact_entry.dart instead")
|
||||
|
@ -43,7 +43,7 @@ class ContactAddressEntry {
|
|||
|
||||
factory ContactAddressEntry.fromJson(Map<String, dynamic> jsonObject) {
|
||||
return ContactAddressEntry(
|
||||
coin: Coins.getCryptoCurrencyFor(jsonObject["coin"] as String),
|
||||
coin: AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String),
|
||||
address: jsonObject["address"] as String,
|
||||
label: jsonObject["label"] as String,
|
||||
other: jsonObject["other"] as String?,
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
*/
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
|
||||
part 'currency.g.dart';
|
||||
|
||||
|
@ -161,7 +161,7 @@ class Currency {
|
|||
|
||||
static bool checkIsStackCoin(String ticker) {
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
||||
part 'block_explorer.g.dart';
|
||||
|
@ -31,7 +31,7 @@ class TransactionBlockExplorer {
|
|||
@ignore
|
||||
CryptoCurrency? get coin {
|
||||
try {
|
||||
return Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
||||
part 'contact_entry.g.dart';
|
||||
|
@ -37,7 +37,7 @@ class ContactEntry {
|
|||
@ignore
|
||||
List<ContactAddressEntry> get addressesSorted {
|
||||
final List<ContactAddressEntry> sorted = [];
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
final slice = addresses.where((e) => e.coin == coin).toList();
|
||||
if (slice.isNotEmpty) {
|
||||
slice.sort(
|
||||
|
@ -102,7 +102,7 @@ class ContactAddressEntry {
|
|||
late final String? other;
|
||||
|
||||
@ignore
|
||||
CryptoCurrency get coin => Coins.getCryptoCurrencyFor(coinName);
|
||||
CryptoCurrency get coin => AppConfig.getCryptoCurrencyFor(coinName);
|
||||
|
||||
ContactAddressEntry();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart';
|
||||
import 'package:stackwallet/utilities/extensions/impl/gradient.dart';
|
||||
import 'package:stackwallet/utilities/extensions/impl/string.dart';
|
||||
|
@ -1878,7 +1878,7 @@ class StackTheme {
|
|||
|
||||
final Map<String, Color> result = {};
|
||||
|
||||
for (final mainNetId in Coins.enabled.map((e) => e.mainNetId)) {
|
||||
for (final mainNetId in AppConfig.coins.map((e) => e.mainNetId)) {
|
||||
if (map[mainNetId] is String) {
|
||||
result[mainNetId] = Color(
|
||||
(map[mainNetId] as String).toBigIntFromHex.toInt(),
|
||||
|
@ -2196,7 +2196,7 @@ class ThemeAssetsV2 implements IThemeAssets {
|
|||
|
||||
final Map<String, String> result = {};
|
||||
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder;
|
||||
}
|
||||
|
||||
|
@ -2531,7 +2531,7 @@ class ThemeAssetsV3 implements IThemeAssets {
|
|||
|
||||
final Map<String, String> result = {};
|
||||
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder;
|
||||
result[coin.mainNetId] = prependIfNeeded(result[coin.mainNetId]!);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/isar/stack_theme.dart';
|
||||
import 'package:stackwallet/models/notification_model.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
|
@ -44,7 +44,8 @@ class NotificationCard extends ConsumerWidget {
|
|||
|
||||
String coinIconPath(IThemeAssets assets, WidgetRef ref) {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
final coin =
|
||||
AppConfig.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
return ref.read(coinIconProvider(coin));
|
||||
} catch (_) {
|
||||
return notification.iconAssetName;
|
||||
|
|
|
@ -28,7 +28,7 @@ import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/e
|
|||
import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/next_button.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -63,10 +63,10 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
|
|||
String _searchTerm = "";
|
||||
|
||||
final _coinsTestnet = [
|
||||
...Coins.enabled.where((e) => e.network == CryptoCurrencyNetwork.test),
|
||||
...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.test),
|
||||
];
|
||||
final _coins = [
|
||||
...Coins.enabled.where((e) => e.network == CryptoCurrencyNetwork.main),
|
||||
...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.main),
|
||||
];
|
||||
final List<AddWalletListEntity> coinEntities = [];
|
||||
final List<EthTokenEntity> tokenEntities = [];
|
||||
|
@ -147,7 +147,7 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
|
|||
coinEntities.addAll(_coinsTestnet.map((e) => CoinEntity(e)));
|
||||
}
|
||||
|
||||
if (Coins.enabled.whereType<Ethereum>().isNotEmpty) {
|
||||
if (AppConfig.coins.whereType<Ethereum>().isNotEmpty) {
|
||||
final contracts =
|
||||
MainDB.instance.getEthContracts().sortByName().findAllSync();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import 'package:stackwallet/providers/db/main_db_provider.dart';
|
|||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_book_filter_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -66,7 +66,7 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
ref.refresh(addressBookFilterProvider);
|
||||
|
||||
if (widget.coin == null) {
|
||||
final coins = [...Coins.enabled];
|
||||
final coins = [...AppConfig.coins];
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_book_filter_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
|
@ -40,7 +40,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
final coins = [...Coins.enabled];
|
||||
final coins = [...AppConfig.coins];
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_image_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -27,7 +27,7 @@ class CoinSelectSheet extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final maxHeight = MediaQuery.of(context).size.height * 0.60;
|
||||
final coins_ = [...Coins.enabled];
|
||||
final coins_ = [...AppConfig.coins];
|
||||
coins_.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ import 'package:stackwallet/pages/address_book_views/subviews/coin_select_sheet.
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
// import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
|
@ -73,7 +73,7 @@ class _NewContactAddressEntryFormState
|
|||
..text = ref.read(addressEntryDataProvider(widget.id)).address ?? "";
|
||||
addressLabelFocusNode = FocusNode();
|
||||
addressFocusNode = FocusNode();
|
||||
coins = [...Coins.enabled];
|
||||
coins = [...AppConfig.coins];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class _NewContactAddressEntryFormState
|
|||
Widget build(BuildContext context) {
|
||||
final isDesktop = Util.isDesktop;
|
||||
if (isDesktop) {
|
||||
coins = [...Coins.enabled];
|
||||
coins = [...AppConfig.coins];
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/crypto.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/fiat.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/quote.dart';
|
||||
|
@ -30,7 +31,6 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/buy/buy_response.dart';
|
||||
import 'package:stackwallet/services/buy/simplex/simplex_api.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -413,7 +413,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
if (ticker == null) return false;
|
||||
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -1168,7 +1168,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
text: "Choose from Stack",
|
||||
onTap: () {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
selectedCrypto!.ticker,
|
||||
);
|
||||
Navigator.of(context)
|
||||
|
@ -1331,7 +1331,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
),
|
||||
Expanded(
|
||||
child: AddressBookAddressChooser(
|
||||
coin: Coins.enabled.firstWhere(
|
||||
coin: AppConfig.coins.firstWhere(
|
||||
(e) =>
|
||||
e.ticker.toLowerCase() ==
|
||||
selectedCrypto!.ticker
|
||||
|
|
|
@ -13,8 +13,8 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/crypto.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -70,7 +70,7 @@ class _CryptoSelectionViewState extends ConsumerState<CryptoSelectionView> {
|
|||
coins.sort(
|
||||
(a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase()),
|
||||
);
|
||||
for (final coin in Coins.enabled.reversed) {
|
||||
for (final coin in AppConfig.coins.reversed) {
|
||||
final index = coins.indexWhere(
|
||||
(element) => element.ticker.toLowerCase() == coin.ticker.toLowerCase(),
|
||||
);
|
||||
|
@ -270,7 +270,7 @@ bool isStackCoin(String? ticker) {
|
|||
if (ticker == null) return false;
|
||||
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -305,7 +305,7 @@ class CoinIconForTicker extends ConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(ticker);
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return SvgPicture.file(
|
||||
File(
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
|
@ -326,7 +326,7 @@ class CoinIconForTicker extends ConsumerWidget {
|
|||
// }) {
|
||||
// String? iconAsset = /*isStackCoin(ticker)
|
||||
// ?*/
|
||||
// Assets.svg.iconFor(coin: SupportedCoins.getCryptoCurrencyForTicker(ticker));
|
||||
// Assets.svg.iconFor(coin: SupportedAppConfig.getCryptoCurrencyForTicker(ticker));
|
||||
// // : Assets.svg.buyIconFor(ticker);
|
||||
// return (iconAsset != null)
|
||||
// ? SvgPicture.asset(iconAsset, height: size, width: size)
|
||||
|
|
|
@ -22,7 +22,7 @@ import 'package:stackwallet/services/exchange/exchange.dart';
|
|||
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -365,7 +365,7 @@ class _ExchangeCurrencySelectionViewState
|
|||
Flexible(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final coins = Coins.enabled.where(
|
||||
final coins = AppConfig.coins.where(
|
||||
(e) =>
|
||||
e.ticker.toLowerCase() !=
|
||||
widget.pairedTicker?.toLowerCase(),
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/address_book_view.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/contact_popup.dart';
|
||||
|
@ -19,7 +20,6 @@ import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_3_view.
|
|||
import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
|
||||
|
@ -72,7 +72,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
|
||||
bool isStackCoin(String ticker) {
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -207,7 +207,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
text: "Choose from Stack",
|
||||
onTap: () {
|
||||
try {
|
||||
final coin = Coins.enabled.firstWhere(
|
||||
final coin = AppConfig.coins.firstWhere(
|
||||
(e) =>
|
||||
e.ticker.toLowerCase() ==
|
||||
model.receiveTicker.toLowerCase(),
|
||||
|
@ -493,7 +493,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
text: "Choose from Stack",
|
||||
onTap: () {
|
||||
try {
|
||||
final coin = Coins.enabled.firstWhere(
|
||||
final coin = AppConfig.coins.firstWhere(
|
||||
(e) =>
|
||||
e.ticker.toLowerCase() ==
|
||||
model.sendTicker.toLowerCase(),
|
||||
|
|
|
@ -26,7 +26,6 @@ import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dia
|
|||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
|
@ -73,7 +72,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
|
||||
bool _isWalletCoinAndHasWallet(String ticker, WidgetRef ref) {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(ticker);
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return ref
|
||||
.read(pWallets)
|
||||
.wallets
|
||||
|
@ -851,8 +850,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
.useMaterialPageRoute,
|
||||
builder:
|
||||
(BuildContext context) {
|
||||
final coin =
|
||||
Coins.enabled.firstWhere(
|
||||
final coin = AppConfig.coins
|
||||
.firstWhere(
|
||||
(e) =>
|
||||
e.ticker
|
||||
.toLowerCase() ==
|
||||
|
|
|
@ -12,11 +12,11 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/estimate.dart';
|
||||
import 'package:stackwallet/providers/exchange/exchange_form_state_provider.dart';
|
||||
import 'package:stackwallet/providers/global/locale_provider.dart';
|
||||
import 'package:stackwallet/services/exchange/exchange.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
|
@ -26,7 +26,6 @@ import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
|||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/widgets/animated_text.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
|
@ -94,7 +93,7 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
|
|||
|
||||
int decimals;
|
||||
try {
|
||||
decimals = Coins.getCryptoCurrencyForTicker(
|
||||
decimals = AppConfig.getCryptoCurrencyForTicker(
|
||||
receivingCurrency.ticker,
|
||||
).fractionDigits;
|
||||
} catch (_) {
|
||||
|
@ -113,7 +112,7 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
|
|||
|
||||
CryptoCurrency? coin;
|
||||
try {
|
||||
coin = Coins.getCryptoCurrencyForTicker(
|
||||
coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
receivingCurrency.ticker,
|
||||
);
|
||||
} catch (_) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/models/isar/stack_theme.dart';
|
||||
|
@ -33,7 +34,6 @@ import 'package:stackwallet/services/exchange/exchange.dart';
|
|||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
|
||||
import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -88,9 +88,9 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
bool isStackCoin(String ticker) {
|
||||
try {
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
} catch (_) {}
|
||||
Coins.getCryptoCurrencyByPrettyName(ticker);
|
||||
AppConfig.getCryptoCurrencyByPrettyName(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -279,11 +279,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
onPressed: () {
|
||||
CryptoCurrency coin;
|
||||
try {
|
||||
coin = Coins.getCryptoCurrencyForTicker(
|
||||
coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
} catch (_) {
|
||||
coin = Coins.getCryptoCurrencyByPrettyName(
|
||||
coin = AppConfig.getCryptoCurrencyByPrettyName(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
}
|
||||
|
@ -379,7 +379,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
builder: (context) {
|
||||
String text;
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
final coin =
|
||||
AppConfig.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
final amount = sendAmount.toAmount(
|
||||
|
@ -628,7 +629,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
text: "View transaction",
|
||||
onTap: () {
|
||||
final CryptoCurrency coin =
|
||||
Coins.getCryptoCurrencyForTicker(
|
||||
AppConfig.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
|
||||
|
@ -1381,11 +1382,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
onPressed: () {
|
||||
CryptoCurrency coin;
|
||||
try {
|
||||
coin = Coins.getCryptoCurrencyForTicker(
|
||||
coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
} catch (_) {
|
||||
coin = Coins.getCryptoCurrencyByPrettyName(
|
||||
coin = AppConfig.getCryptoCurrencyByPrettyName(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -44,7 +44,7 @@ class ManageCoinUnitsView extends ConsumerWidget {
|
|||
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
|
||||
);
|
||||
|
||||
final _coins = Coins.enabled
|
||||
final _coins = AppConfig.coins
|
||||
.where((e) => e is! Firo && e.network != CryptoCurrencyNetwork.test)
|
||||
.toList();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -37,7 +37,7 @@ class ManageNodesView extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _ManageNodesViewState extends ConsumerState<ManageNodesView> {
|
||||
List<CryptoCurrency> _coins = [...Coins.enabled];
|
||||
List<CryptoCurrency> _coins = [...AppConfig.coins];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -16,6 +16,7 @@ import 'dart:typed_data';
|
|||
import 'package:frostdart/frostdart.dart' as frost;
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stack_wallet_backup/stack_wallet_backup.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart';
|
||||
|
@ -33,7 +34,6 @@ import 'package:stackwallet/services/trade_notes_service.dart';
|
|||
import 'package:stackwallet/services/trade_sent_from_stack_service.dart';
|
||||
import 'package:stackwallet/services/trade_service.dart';
|
||||
import 'package:stackwallet/services/wallets.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||
import 'package:stackwallet/utilities/enums/stack_restoring_status.dart';
|
||||
import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
|
||||
|
@ -774,7 +774,7 @@ abstract class SWB {
|
|||
return false;
|
||||
}
|
||||
|
||||
final coin = Coins.getCryptoCurrencyFor(
|
||||
final coin = AppConfig.getCryptoCurrencyFor(
|
||||
walletbackup['coinName'] as String,
|
||||
);
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ abstract class SWB {
|
|||
for (final node in primaryNodes) {
|
||||
try {
|
||||
await nodeService.setPrimaryNodeFor(
|
||||
coin: Coins.getCryptoCurrencyByPrettyName(
|
||||
coin: AppConfig.getCryptoCurrencyByPrettyName(
|
||||
node['coinName'] as String,
|
||||
),
|
||||
node: nodeService.getNodeById(id: node['id'] as String)!,
|
||||
|
@ -1226,7 +1226,7 @@ abstract class SWB {
|
|||
for (final node in primaryNodes) {
|
||||
try {
|
||||
await nodeService.setPrimaryNodeFor(
|
||||
coin: Coins.getCryptoCurrencyByPrettyName(
|
||||
coin: AppConfig.getCryptoCurrencyByPrettyName(
|
||||
node['coinName'] as String,
|
||||
),
|
||||
node: nodeService.getNodeById(id: node['id'] as String)!,
|
||||
|
|
|
@ -22,7 +22,7 @@ import 'package:stackwallet/providers/db/main_db_provider.dart';
|
|||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_book_filter_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -98,7 +98,7 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
|||
ref.refresh(addressBookFilterProvider);
|
||||
|
||||
// if (widget.coin == null) {
|
||||
final coins = Coins.enabled.toList();
|
||||
final coins = AppConfig.coins.toList();
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -28,7 +28,6 @@ import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
|||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/exchange/exchange_response.dart';
|
||||
import 'package:stackwallet/services/notifications_api.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -194,7 +193,7 @@ class _StepScaffoldState extends ConsumerState<StepScaffold> {
|
|||
void sendFromStack() {
|
||||
final trade = ref.read(desktopExchangeModelProvider)!.trade!;
|
||||
final address = trade.payInAddress;
|
||||
final coin = Coins.getCryptoCurrencyForTicker(trade.payInCurrency);
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(trade.payInCurrency);
|
||||
final amount = Decimal.parse(trade.payInAmount).toAmount(
|
||||
fractionDigits: coin.fractionDigits,
|
||||
);
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/contact_address_entry.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart';
|
||||
import 'package:stackwallet/providers/exchange/exchange_send_from_wallet_id_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -59,7 +59,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
|
||||
bool isStackCoin(String ticker) {
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
|
||||
void selectRecipientAddressFromStack() async {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.receiveTicker,
|
||||
);
|
||||
|
||||
|
@ -101,7 +101,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
|
||||
void selectRefundAddressFromStack() async {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.sendTicker,
|
||||
);
|
||||
|
||||
|
@ -131,7 +131,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
}
|
||||
|
||||
void selectRecipientFromAddressBook() async {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.receiveTicker,
|
||||
);
|
||||
|
||||
|
@ -178,7 +178,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
}
|
||||
|
||||
void selectRefundFromAddressBook() async {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.sendTicker,
|
||||
);
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
|
@ -37,7 +37,7 @@ class _DesktopStep4State extends ConsumerState<DesktopStep4> {
|
|||
|
||||
bool _isWalletCoinAndHasWallet(String ticker) {
|
||||
try {
|
||||
final coin = Coins.getCryptoCurrencyForTicker(ticker);
|
||||
final coin = AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return ref
|
||||
.read(pWallets)
|
||||
.wallets
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -39,7 +39,7 @@ class DesktopManageBlockExplorersDialog extends ConsumerWidget {
|
|||
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
|
||||
);
|
||||
|
||||
final coins = Coins.enabled
|
||||
final coins = AppConfig.coins
|
||||
.where(
|
||||
(e) => showTestNet || e.network == CryptoCurrencyNetwork.main,
|
||||
)
|
||||
|
|
|
@ -16,7 +16,7 @@ import 'package:flutter_svg/svg.dart';
|
|||
import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -39,7 +39,7 @@ class NodesSettings extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _NodesSettings extends ConsumerState<NodesSettings> {
|
||||
List<CryptoCurrency> _coins = [...Coins.enabled];
|
||||
List<CryptoCurrency> _coins = [...AppConfig.coins];
|
||||
|
||||
late final TextEditingController searchNodeController;
|
||||
late final FocusNode searchNodeFocusNode;
|
||||
|
|
|
@ -12,6 +12,7 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:decimal/decimal.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/crypto.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/fiat.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/order.dart';
|
||||
|
@ -19,7 +20,6 @@ import 'package:stackwallet/models/buy/response_objects/quote.dart';
|
|||
import 'package:stackwallet/networking/http.dart';
|
||||
import 'package:stackwallet/services/buy/buy_response.dart';
|
||||
import 'package:stackwallet/services/tor_service.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/enums/fiat_enum.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
|
@ -405,7 +405,7 @@ bool isStackCoin(String? ticker) {
|
|||
if (ticker == null) return false;
|
||||
|
||||
try {
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
AppConfig.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
|
|
@ -12,9 +12,9 @@ import 'dart:convert';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/default_nodes.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
@ -31,7 +31,7 @@ class NodeService extends ChangeNotifier {
|
|||
});
|
||||
|
||||
Future<void> updateDefaults() async {
|
||||
for (final defaultNode in Coins.enabled.map(
|
||||
for (final defaultNode in AppConfig.coins.map(
|
||||
(e) => e.defaultNode,
|
||||
)) {
|
||||
final savedNode = DB.instance
|
||||
|
@ -39,7 +39,7 @@ class NodeService extends ChangeNotifier {
|
|||
if (savedNode == null) {
|
||||
// save the default node to hive only if no other nodes for the specific coin exist
|
||||
if (getNodesFor(
|
||||
Coins.getCryptoCurrencyByPrettyName(
|
||||
AppConfig.getCryptoCurrencyByPrettyName(
|
||||
defaultNode.coinName,
|
||||
),
|
||||
).isEmpty) {
|
||||
|
@ -64,7 +64,8 @@ class NodeService extends ChangeNotifier {
|
|||
|
||||
// check if a default node is the primary node for the crypto currency
|
||||
// and update it if needed
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(defaultNode.coinName);
|
||||
final coin =
|
||||
AppConfig.getCryptoCurrencyByPrettyName(defaultNode.coinName);
|
||||
final primaryNode = getPrimaryNodeFor(currency: coin);
|
||||
if (primaryNode != null && primaryNode.id == defaultNode.id) {
|
||||
await setPrimaryNodeFor(
|
||||
|
@ -205,7 +206,7 @@ class NodeService extends ChangeNotifier {
|
|||
bool shouldNotifyListeners,
|
||||
) async {
|
||||
// check if the node being edited is the primary one; if it is, setPrimaryNodeFor coin
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(editedNode.coinName);
|
||||
final coin = AppConfig.getCryptoCurrencyByPrettyName(editedNode.coinName);
|
||||
final primaryNode = getPrimaryNodeFor(currency: coin);
|
||||
if (primaryNode?.id == editedNode.id) {
|
||||
await setPrimaryNodeFor(
|
||||
|
@ -238,7 +239,7 @@ class NodeService extends ChangeNotifier {
|
|||
final map = jsonDecode(result as String);
|
||||
Logging.instance.log(map, level: LogLevel.Info);
|
||||
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
final nodeList = List<Map<String, dynamic>>.from(
|
||||
map["nodes"][coin.identifier] as List? ?? [],
|
||||
);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx_client.dart';
|
||||
import 'package:stackwallet/exceptions/electrumx/no_such_transaction.dart';
|
||||
|
@ -21,7 +22,6 @@ import 'package:stackwallet/services/node_service.dart';
|
|||
import 'package:stackwallet/services/notifications_api.dart';
|
||||
import 'package:stackwallet/services/trade_service.dart';
|
||||
import 'package:stackwallet/services/wallets.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
@ -129,7 +129,7 @@ class NotificationsService extends ChangeNotifier {
|
|||
for (final notification in _watchedTransactionNotifications) {
|
||||
try {
|
||||
final CryptoCurrency coin =
|
||||
Coins.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
AppConfig.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
final txid = notification.txid!;
|
||||
final wallet = Wallets.sharedInstance.getWallet(notification.walletId);
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ import 'dart:convert';
|
|||
|
||||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/networking/http.dart';
|
||||
import 'package:stackwallet/services/tor_service.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
@ -48,7 +48,7 @@ class PriceAPI {
|
|||
) async {
|
||||
final Map<String, dynamic> map = {};
|
||||
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
final entry = data[coin];
|
||||
if (entry == null) {
|
||||
map[coin.prettyName] = ["0", 0.0];
|
||||
|
@ -68,11 +68,11 @@ class PriceAPI {
|
|||
{};
|
||||
// init with 0
|
||||
final result = {
|
||||
for (final coin in Coins.enabled) coin: Tuple2(Decimal.zero, 0.0),
|
||||
for (final coin in AppConfig.coins) coin: Tuple2(Decimal.zero, 0.0),
|
||||
};
|
||||
|
||||
for (final entry in map.entries) {
|
||||
result[Coins.getCryptoCurrencyByPrettyName(
|
||||
result[AppConfig.getCryptoCurrencyByPrettyName(
|
||||
entry.key as String,
|
||||
)] = Tuple2(
|
||||
Decimal.parse(entry.value[0] as String),
|
||||
|
@ -125,7 +125,7 @@ class PriceAPI {
|
|||
|
||||
for (final map in coinGeckoData) {
|
||||
final String coinName = map["name"] as String;
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(coinName);
|
||||
final coin = AppConfig.getCryptoCurrencyByPrettyName(coinName);
|
||||
|
||||
final price = Decimal.parse(map["current_price"].toString());
|
||||
final change24h = map["price_change_percentage_24h"] != null
|
||||
|
|
|
@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart';
|
|||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/networking/http.dart';
|
||||
import 'package:stackwallet/services/price.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
|
@ -30,7 +30,7 @@ class PriceService extends ChangeNotifier {
|
|||
|
||||
Timer? _timer;
|
||||
final Map<CryptoCurrency, Tuple2<Decimal, double>> _cachedPrices = {
|
||||
for (final coin in Coins.enabled) coin: Tuple2(Decimal.zero, 0.0),
|
||||
for (final coin in AppConfig.coins) coin: Tuple2(Decimal.zero, 0.0),
|
||||
};
|
||||
|
||||
final Map<String, Tuple2<Decimal, double>> _cachedTokenPrices = {};
|
||||
|
|
|
@ -18,7 +18,7 @@ import 'package:stackwallet/db/isar/main_db.dart';
|
|||
import 'package:stackwallet/services/node_service.dart';
|
||||
import 'package:stackwallet/services/notifications_service.dart';
|
||||
import 'package:stackwallet/services/trade_sent_from_stack_service.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
@ -400,7 +400,7 @@ class Wallets {
|
|||
.where()
|
||||
.filter()
|
||||
.anyOf<String, CryptoCurrency>(
|
||||
Coins.enabled.map((e) => e.identifier),
|
||||
AppConfig.coins.map((e) => e.identifier),
|
||||
(q, element) => q.coinNameMatches(element),
|
||||
)
|
||||
.findAll();
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
||||
@Deprecated("Legacy support only. Do not use.")
|
||||
|
@ -90,7 +90,7 @@ class WalletsService extends ChangeNotifier {
|
|||
mapped.removeWhere((name, dyn) {
|
||||
final jsonObject = Map<String, dynamic>.from(dyn as Map);
|
||||
try {
|
||||
Coins.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
return false;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart';
|
||||
|
||||
/// The supported coins. Eventually move away from the Coin enum
|
||||
class Coins {
|
||||
/// A List of enabled coins.
|
||||
static List<CryptoCurrency> get enabled => all
|
||||
.where(
|
||||
(element) => AppConfig.supportedCoins.contains(element.runtimeType))
|
||||
.toList();
|
||||
|
||||
/// A List of all implemented coins.
|
||||
static final List<CryptoCurrency> all = [
|
||||
Bitcoin(CryptoCurrencyNetwork.main),
|
||||
BitcoinFrost(CryptoCurrencyNetwork.main),
|
||||
Litecoin(CryptoCurrencyNetwork.main),
|
||||
Bitcoincash(CryptoCurrencyNetwork.main),
|
||||
Dogecoin(CryptoCurrencyNetwork.main),
|
||||
Epiccash(CryptoCurrencyNetwork.main),
|
||||
Ecash(CryptoCurrencyNetwork.main),
|
||||
Ethereum(CryptoCurrencyNetwork.main),
|
||||
Firo(CryptoCurrencyNetwork.main),
|
||||
Monero(CryptoCurrencyNetwork.main),
|
||||
Particl(CryptoCurrencyNetwork.main),
|
||||
Peercoin(CryptoCurrencyNetwork.main),
|
||||
Solana(CryptoCurrencyNetwork.main),
|
||||
Stellar(CryptoCurrencyNetwork.main),
|
||||
Tezos(CryptoCurrencyNetwork.main),
|
||||
Wownero(CryptoCurrencyNetwork.main),
|
||||
Namecoin(CryptoCurrencyNetwork.main),
|
||||
Nano(CryptoCurrencyNetwork.main),
|
||||
Banano(CryptoCurrencyNetwork.main),
|
||||
Bitcoin(CryptoCurrencyNetwork.test),
|
||||
BitcoinFrost(CryptoCurrencyNetwork.test),
|
||||
Litecoin(CryptoCurrencyNetwork.test),
|
||||
Bitcoincash(CryptoCurrencyNetwork.test),
|
||||
Firo(CryptoCurrencyNetwork.test),
|
||||
Dogecoin(CryptoCurrencyNetwork.test),
|
||||
Stellar(CryptoCurrencyNetwork.test),
|
||||
Peercoin(CryptoCurrencyNetwork.test),
|
||||
];
|
||||
|
||||
static CryptoCurrency getCryptoCurrencyFor(String coinIdentifier) =>
|
||||
all.firstWhere(
|
||||
(e) => e.identifier == coinIdentifier,
|
||||
);
|
||||
|
||||
static CryptoCurrency getCryptoCurrencyForTicker(
|
||||
final String ticker, {
|
||||
bool caseInsensitive = true,
|
||||
}) {
|
||||
final _ticker = caseInsensitive ? ticker.toLowerCase() : ticker;
|
||||
return all.firstWhere(
|
||||
caseInsensitive
|
||||
? (e) => e.ticker.toLowerCase() == _ticker && e is! FrostCurrency
|
||||
: (e) => e.ticker == _ticker && e is! FrostCurrency,
|
||||
);
|
||||
}
|
||||
|
||||
/// Fuzzy logic. Use with caution!!
|
||||
@Deprecated("dangerous")
|
||||
static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) {
|
||||
final name = prettyName.replaceAll(" ", "").toLowerCase();
|
||||
try {
|
||||
return all.firstWhere(
|
||||
(e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName,
|
||||
);
|
||||
} catch (_) {
|
||||
throw Exception("getCryptoCurrencyByPrettyName($prettyName) failed!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import 'package:flutter/cupertino.dart';
|
|||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_unit.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||
|
@ -85,7 +85,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "lastUnlockedTimeout",
|
||||
value: lastUnlockedTimeout,);
|
||||
value: lastUnlockedTimeout,
|
||||
);
|
||||
_lastUnlockedTimeout = lastUnlockedTimeout;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -93,7 +94,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<int> _getLastUnlockedTimeout() async {
|
||||
return (DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "lastUnlockedTimeout",)) as int? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "lastUnlockedTimeout",
|
||||
)) as int? ??
|
||||
60;
|
||||
}
|
||||
|
||||
|
@ -106,7 +109,10 @@ class Prefs extends ChangeNotifier {
|
|||
set lastUnlocked(int lastUnlocked) {
|
||||
if (_lastUnlocked != lastUnlocked) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "lastUnlocked", value: lastUnlocked,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "lastUnlocked",
|
||||
value: lastUnlocked,
|
||||
);
|
||||
_lastUnlocked = lastUnlocked;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -114,7 +120,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<int> _getLastUnlocked() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "lastUnlocked",) as int? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "lastUnlocked",
|
||||
) as int? ??
|
||||
0;
|
||||
}
|
||||
|
||||
|
@ -133,13 +141,16 @@ class Prefs extends ChangeNotifier {
|
|||
await DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "currentNotificationId",
|
||||
value: _currentNotificationId,);
|
||||
value: _currentNotificationId,
|
||||
);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<int> _getCurrentNotificationIndex() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "currentNotificationId",) as int? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "currentNotificationId",
|
||||
) as int? ??
|
||||
0;
|
||||
}
|
||||
|
||||
|
@ -154,7 +165,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "walletIdsSyncOnStartup",
|
||||
value: walletIdsSyncOnStartup,);
|
||||
value: walletIdsSyncOnStartup,
|
||||
);
|
||||
_walletIdsSyncOnStartup = walletIdsSyncOnStartup;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -162,7 +174,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<List<String>> _getWalletIdsSyncOnStartup() async {
|
||||
final list = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "walletIdsSyncOnStartup",) as List? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "walletIdsSyncOnStartup",
|
||||
) as List? ??
|
||||
[];
|
||||
return List<String>.from(list);
|
||||
}
|
||||
|
@ -178,7 +192,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "syncTypeIndex",
|
||||
value: syncType.index,);
|
||||
value: syncType.index,
|
||||
);
|
||||
_syncType = syncType;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -186,7 +201,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<SyncingType> _getSyncType() async {
|
||||
final int index = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "syncTypeIndex",) as int? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "syncTypeIndex",
|
||||
) as int? ??
|
||||
SyncingType.allWalletsOnStartup.index;
|
||||
return SyncingType.values[index];
|
||||
}
|
||||
|
@ -200,7 +217,10 @@ class Prefs extends ChangeNotifier {
|
|||
set wifiOnly(bool wifiOnly) {
|
||||
if (_wifiOnly != wifiOnly) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "wifiOnly", value: wifiOnly,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "wifiOnly",
|
||||
value: wifiOnly,
|
||||
);
|
||||
_wifiOnly = wifiOnly;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -223,7 +243,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "showFavoriteWallets",
|
||||
value: showFavoriteWallets,);
|
||||
value: showFavoriteWallets,
|
||||
);
|
||||
_showFavoriteWallets = showFavoriteWallets;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -231,7 +252,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getShowFavoriteWallets() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "showFavoriteWallets",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "showFavoriteWallets",
|
||||
) as bool? ??
|
||||
true;
|
||||
}
|
||||
|
||||
|
@ -244,7 +267,10 @@ class Prefs extends ChangeNotifier {
|
|||
set language(String newLanguage) {
|
||||
if (_language != newLanguage) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "language", value: newLanguage,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "language",
|
||||
value: newLanguage,
|
||||
);
|
||||
_language = newLanguage;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -252,7 +278,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<String> _getPreferredLanguage() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "language",) as String? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "language",
|
||||
) as String? ??
|
||||
Language.englishUS.description;
|
||||
}
|
||||
|
||||
|
@ -265,7 +293,10 @@ class Prefs extends ChangeNotifier {
|
|||
set currency(String newCurrency) {
|
||||
if (currency != newCurrency) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "currency", value: newCurrency,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "currency",
|
||||
value: newCurrency,
|
||||
);
|
||||
_currency = newCurrency;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -273,7 +304,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<String> _getPreferredCurrency() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "currency",) as String? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "currency",
|
||||
) as String? ??
|
||||
"USD";
|
||||
}
|
||||
|
||||
|
@ -327,7 +360,10 @@ class Prefs extends ChangeNotifier {
|
|||
set randomizePIN(bool randomizePIN) {
|
||||
if (_randomizePIN != randomizePIN) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "randomizePIN", value: randomizePIN,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "randomizePIN",
|
||||
value: randomizePIN,
|
||||
);
|
||||
_randomizePIN = randomizePIN;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -335,7 +371,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getRandomizePIN() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "randomizePIN",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "randomizePIN",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -348,7 +386,10 @@ class Prefs extends ChangeNotifier {
|
|||
set useBiometrics(bool useBiometrics) {
|
||||
if (_useBiometrics != useBiometrics) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "useBiometrics", value: useBiometrics,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "useBiometrics",
|
||||
value: useBiometrics,
|
||||
);
|
||||
_useBiometrics = useBiometrics;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -356,7 +397,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getUseBiometrics() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "useBiometrics",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "useBiometrics",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -390,7 +433,10 @@ class Prefs extends ChangeNotifier {
|
|||
set familiarity(int familiarity) {
|
||||
if (_familiarity != familiarity) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "familiarity", value: familiarity,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "familiarity",
|
||||
value: familiarity,
|
||||
);
|
||||
_familiarity = familiarity;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -398,7 +444,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<int> _getHasFamiliarity() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "familiarity",) as int? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "familiarity",
|
||||
) as int? ??
|
||||
0;
|
||||
}
|
||||
|
||||
|
@ -439,7 +487,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "showTestNetCoins",
|
||||
value: showTestNetCoins,);
|
||||
value: showTestNetCoins,
|
||||
);
|
||||
_showTestNetCoins = showTestNetCoins;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -447,7 +496,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getShowTestNetCoins() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "showTestNetCoins",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "showTestNetCoins",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -463,7 +514,8 @@ class Prefs extends ChangeNotifier {
|
|||
.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "isAutoBackupEnabled",
|
||||
value: isAutoBackupEnabled,)
|
||||
value: isAutoBackupEnabled,
|
||||
)
|
||||
.then((_) {
|
||||
_isAutoBackupEnabled = isAutoBackupEnabled;
|
||||
notifyListeners();
|
||||
|
@ -473,7 +525,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getIsAutoBackupEnabled() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "isAutoBackupEnabled",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "isAutoBackupEnabled",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -488,7 +542,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "autoBackupLocation",
|
||||
value: autoBackupLocation,);
|
||||
value: autoBackupLocation,
|
||||
);
|
||||
_autoBackupLocation = autoBackupLocation;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -496,7 +551,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<String?> _getAutoBackupLocation() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "autoBackupLocation",) as String?;
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "autoBackupLocation",
|
||||
) as String?;
|
||||
}
|
||||
|
||||
// auto backup frequency type
|
||||
|
@ -513,19 +570,22 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "backupFrequencyType",
|
||||
value: "10Min",);
|
||||
value: "10Min",
|
||||
);
|
||||
break;
|
||||
case BackupFrequencyType.everyAppStart:
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "backupFrequencyType",
|
||||
value: "onStart",);
|
||||
value: "onStart",
|
||||
);
|
||||
break;
|
||||
case BackupFrequencyType.afterClosingAWallet:
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "backupFrequencyType",
|
||||
value: "onWalletClose",);
|
||||
value: "onWalletClose",
|
||||
);
|
||||
break;
|
||||
}
|
||||
_backupFrequencyType = backupFrequencyType;
|
||||
|
@ -535,7 +595,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<BackupFrequencyType> _getBackupFrequencyType() async {
|
||||
String? rate = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "backupFrequencyType",) as String?;
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "backupFrequencyType",
|
||||
) as String?;
|
||||
rate ??= "10Min";
|
||||
switch (rate) {
|
||||
case "10Min":
|
||||
|
@ -560,7 +622,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "lastAutoBackup",
|
||||
value: lastAutoBackup,);
|
||||
value: lastAutoBackup,
|
||||
);
|
||||
_lastAutoBackup = lastAutoBackup;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -568,7 +631,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<DateTime?> _getLastAutoBackup() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "autoBackupFileUri",) as DateTime?;
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "autoBackupFileUri",
|
||||
) as DateTime?;
|
||||
}
|
||||
|
||||
// auto backup
|
||||
|
@ -583,7 +648,8 @@ class Prefs extends ChangeNotifier {
|
|||
.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "hideBlockExplorerWarning",
|
||||
value: hideBlockExplorerWarning,)
|
||||
value: hideBlockExplorerWarning,
|
||||
)
|
||||
.then((_) {
|
||||
_hideBlockExplorerWarning = hideBlockExplorerWarning;
|
||||
notifyListeners();
|
||||
|
@ -594,7 +660,8 @@ class Prefs extends ChangeNotifier {
|
|||
Future<bool> _getHideBlockExplorerWarning() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "hideBlockExplorerWarning",) as bool? ??
|
||||
key: "hideBlockExplorerWarning",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -610,7 +677,8 @@ class Prefs extends ChangeNotifier {
|
|||
.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "gotoWalletOnStartup",
|
||||
value: gotoWalletOnStartup,)
|
||||
value: gotoWalletOnStartup,
|
||||
)
|
||||
.then((_) {
|
||||
_gotoWalletOnStartup = gotoWalletOnStartup;
|
||||
notifyListeners();
|
||||
|
@ -620,7 +688,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getGotoWalletOnStartup() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "gotoWalletOnStartup",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "gotoWalletOnStartup",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -635,7 +705,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "startupWalletId",
|
||||
value: startupWalletId,);
|
||||
value: startupWalletId,
|
||||
);
|
||||
_startupWalletId = startupWalletId;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -643,7 +714,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<String?> _getStartupWalletId() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "startupWalletId",) as String?;
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "startupWalletId",
|
||||
) as String?;
|
||||
}
|
||||
|
||||
// incognito mode off by default
|
||||
|
@ -658,7 +731,8 @@ class Prefs extends ChangeNotifier {
|
|||
.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "externalCalls",
|
||||
value: externalCalls,)
|
||||
value: externalCalls,
|
||||
)
|
||||
.then((_) {
|
||||
_externalCalls = externalCalls;
|
||||
notifyListeners();
|
||||
|
@ -668,7 +742,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getHasExternalCalls() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "externalCalls",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "externalCalls",
|
||||
) as bool? ??
|
||||
true;
|
||||
}
|
||||
|
||||
|
@ -718,7 +794,10 @@ class Prefs extends ChangeNotifier {
|
|||
Future<void> saveSignupEpoch(int signupEpoch) async {
|
||||
_signupEpoch = signupEpoch;
|
||||
await DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch,);
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "signupEpoch",
|
||||
value: _signupEpoch,
|
||||
);
|
||||
// notifyListeners();
|
||||
}
|
||||
|
||||
|
@ -733,7 +812,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "enableCoinControl",
|
||||
value: enableCoinControl,);
|
||||
value: enableCoinControl,
|
||||
);
|
||||
_enableCoinControl = enableCoinControl;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -741,7 +821,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getEnableCoinControl() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "enableCoinControl",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "enableCoinControl",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -756,7 +838,8 @@ class Prefs extends ChangeNotifier {
|
|||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "enableSystemBrightness",
|
||||
value: enableSystemBrightness,);
|
||||
value: enableSystemBrightness,
|
||||
);
|
||||
_enableSystemBrightness = enableSystemBrightness;
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -764,7 +847,9 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
Future<bool> _getEnableSystemBrightness() async {
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs, key: "enableSystemBrightness",) as bool? ??
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "enableSystemBrightness",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
|
@ -853,8 +938,10 @@ class Prefs extends ChangeNotifier {
|
|||
AmountUnit amountUnit(CryptoCurrency coin) =>
|
||||
_amountUnits[coin] ?? AmountUnit.normal;
|
||||
|
||||
void updateAmountUnit(
|
||||
{required CryptoCurrency coin, required AmountUnit amountUnit,}) {
|
||||
void updateAmountUnit({
|
||||
required CryptoCurrency coin,
|
||||
required AmountUnit amountUnit,
|
||||
}) {
|
||||
if (this.amountUnit(coin) != amountUnit) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
|
@ -867,7 +954,7 @@ class Prefs extends ChangeNotifier {
|
|||
}
|
||||
|
||||
Future<void> _setAmountUnits() async {
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
final unitIndex = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "amountUnitFor${coin.identifier}",
|
||||
|
@ -900,7 +987,7 @@ class Prefs extends ChangeNotifier {
|
|||
}
|
||||
|
||||
Future<void> _setMaxDecimals() async {
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
final decimals = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "maxDecimalsFor${coin.identifier}",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/isar/isar_id_interface.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info_meta.dart';
|
||||
|
@ -96,7 +96,7 @@ class WalletInfo implements IsarId {
|
|||
}
|
||||
|
||||
@ignore
|
||||
CryptoCurrency get coin => Coins.getCryptoCurrencyFor(coinName);
|
||||
CryptoCurrency get coin => AppConfig.getCryptoCurrencyFor(coinName);
|
||||
|
||||
@ignore
|
||||
Balance get cachedBalance {
|
||||
|
@ -407,7 +407,7 @@ class WalletInfo implements IsarId {
|
|||
this.cachedBalanceTertiaryString,
|
||||
this.otherDataJsonString,
|
||||
}) : assert(
|
||||
Coins.enabled.map((e) => e.identifier).contains(coinName),
|
||||
AppConfig.coins.map((e) => e.identifier).contains(coinName),
|
||||
);
|
||||
|
||||
WalletInfo copyWith({
|
||||
|
@ -464,7 +464,7 @@ class WalletInfo implements IsarId {
|
|||
Map<String, dynamic> jsonObject,
|
||||
AddressType mainAddressType,
|
||||
) {
|
||||
final coin = Coins.getCryptoCurrencyFor(
|
||||
final coin = AppConfig.getCryptoCurrencyFor(
|
||||
jsonObject["coin"] as String,
|
||||
);
|
||||
return WalletInfo(
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
|
||||
|
@ -27,7 +27,7 @@ final pAllWalletsInfoByCoin = Provider((ref) {
|
|||
}
|
||||
|
||||
final List<({CryptoCurrency coin, List<WalletInfo> wallets})> results = [];
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
if (map[coin] != null) {
|
||||
results.add(map[coin]!);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ final _pAllWalletsInfo = ChangeNotifierProvider((ref) {
|
|||
.where()
|
||||
.filter()
|
||||
.anyOf<String, CryptoCurrency>(
|
||||
Coins.enabled.map((e) => e.identifier),
|
||||
AppConfig.coins.map((e) => e.identifier),
|
||||
(q, element) => q.coinNameMatches(element),
|
||||
)
|
||||
.findAllSync(),
|
||||
|
@ -71,7 +71,7 @@ class _WalletInfoWatcher extends ChangeNotifier {
|
|||
.where()
|
||||
.filter()
|
||||
.anyOf<String, CryptoCurrency>(
|
||||
Coins.enabled.map((e) => e.identifier),
|
||||
AppConfig.coins.map((e) => e.identifier),
|
||||
(q, element) => q.coinNameMatches(element),
|
||||
)
|
||||
.findAll()
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
|
||||
|
@ -20,7 +20,7 @@ class _Watcher extends ChangeNotifier {
|
|||
_streamSubscription = isar.walletInfo
|
||||
.filter()
|
||||
.anyOf<String, CryptoCurrency>(
|
||||
Coins.enabled.map((e) => e.identifier),
|
||||
AppConfig.coins.map((e) => e.identifier),
|
||||
(q, element) => q.coinNameMatches(element),
|
||||
)
|
||||
.isFavouriteEqualTo(isFavourite)
|
||||
|
@ -47,7 +47,7 @@ final _wiProvider = ChangeNotifierProvider.family<_Watcher, bool>(
|
|||
isar.walletInfo
|
||||
.filter()
|
||||
.anyOf<String, CryptoCurrency>(
|
||||
Coins.enabled.map((e) => e.identifier),
|
||||
AppConfig.coins.map((e) => e.identifier),
|
||||
(q, element) => q.coinNameMatches(element),
|
||||
)
|
||||
.isFavouriteEqualTo(isFavourite)
|
||||
|
|
|
@ -16,7 +16,7 @@ import 'package:flutter_svg/svg.dart';
|
|||
import 'package:stackwallet/models/isar/models/contact_entry.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/contact_popup.dart';
|
||||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -72,7 +72,7 @@ class _AddressBookCardState extends ConsumerState<AddressBookCard> {
|
|||
|
||||
final List<CryptoCurrency> coins = [];
|
||||
|
||||
for (final coin in Coins.enabled) {
|
||||
for (final coin in AppConfig.coins) {
|
||||
if (contact.addresses.where((e) => e.coin == coin).isNotEmpty) {
|
||||
coins.add(coin);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -51,7 +51,7 @@ class ChooseCoinView extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
|
||||
List<CryptoCurrency> _coins = [...Coins.enabled];
|
||||
List<CryptoCurrency> _coins = [...AppConfig.coins];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: stackwallet
|
||||
description: Stack Wallet
|
||||
name: PLACEHOLDER
|
||||
description: PLACEHOLDER
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x -e
|
||||
|
||||
# Configure files for Duo.
|
||||
ORIGINAL_PUBSPEC_NAME="stackwallet"
|
||||
NEW_PUBSPEC_NAME="stackduo"
|
||||
|
||||
export ORIGINAL_NAME="Stack Wallet"
|
||||
export ORIGINAL_APP_ID="com.cypherstack.stackwallet"
|
||||
|
||||
export NEW_NAME="Stack Duo"
|
||||
export NEW_APP_ID="com.cypherstack.stackduo"
|
||||
|
||||
# String replacements.
|
||||
if [[ "$(uname)" == 'Darwin' ]]; then
|
||||
# macos specific sed
|
||||
sed -i '' 's/Wallet/Duo/g' ../../lib/app_config.dart
|
||||
sed -i '' "s/${ORIGINAL_NAME}/${NEW_NAME}/g" ../../pubspec.yaml
|
||||
sed -i '' "s/${ORIGINAL_PUBSPEC_NAME}/${NEW_PUBSPEC_NAME}/g" ../../pubspec.yaml
|
||||
else
|
||||
sed -i 's/Wallet/Duo/g' ../../lib/app_config.dart
|
||||
sed -i "s/${ORIGINAL_NAME}/${NEW_NAME}/g" ../../pubspec.yaml
|
||||
sed -i "s/${ORIGINAL_PUBSPEC_NAME}/${NEW_PUBSPEC_NAME}/g" ../../pubspec.yaml
|
||||
fi
|
44
scripts/app_config/configure_stack_duo.sh
Executable file
44
scripts/app_config/configure_stack_duo.sh
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x -e
|
||||
|
||||
# Configure files for Duo.
|
||||
|
||||
export ORIGINAL_NAME="Stack Wallet"
|
||||
export ORIGINAL_APP_ID="com.cypherstack.stackwallet"
|
||||
|
||||
export NEW_NAME="Stack Duo"
|
||||
export NEW_APP_ID="com.cypherstack.stackduo"
|
||||
|
||||
PUBSPEC_FILE="${APP_PROJECT_ROOT_DIR}/pubspec.yaml"
|
||||
PUBSPEC_NAME="stackduo"
|
||||
PUBSPEC_DESC="Stack Duo"
|
||||
|
||||
# String replacements.
|
||||
if [[ "$(uname)" == 'Darwin' ]]; then
|
||||
# macos specific sed
|
||||
sed -i '' "s/name: PLACEHOLDER/name: ${PUBSPEC_NAME}/g" "${PUBSPEC_FILE}"
|
||||
sed -i '' "s/description: PLACEHOLDER/description: ${PUBSPEC_DESC}/g" "${PUBSPEC_FILE}"
|
||||
else
|
||||
sed -i "s/name: PLACEHOLDER/name: ${PUBSPEC_NAME}/g" "${PUBSPEC_FILE}"
|
||||
sed -i "s/description: PLACEHOLDER/description: ${PUBSPEC_DESC}/g" "${PUBSPEC_FILE}"
|
||||
fi
|
||||
|
||||
APP_CONFIG_DART_FILE="${APP_PROJECT_ROOT_DIR}/lib/app_config.g.dart"
|
||||
rm -f "$APP_CONFIG_DART_FILE"
|
||||
cat << EOF > "$APP_CONFIG_DART_FILE"
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'app_config.dart';
|
||||
|
||||
const _prefix = "Stack";
|
||||
const _separator = " ";
|
||||
const _suffix = "Duo";
|
||||
|
||||
final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
|
||||
Bitcoin(CryptoCurrencyNetwork.main),
|
||||
Monero(CryptoCurrencyNetwork.main),
|
||||
Bitcoin(CryptoCurrencyNetwork.test),
|
||||
]);
|
||||
|
||||
EOF
|
68
scripts/app_config/configure_stack_wallet.sh
Executable file
68
scripts/app_config/configure_stack_wallet.sh
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x -e
|
||||
|
||||
# Configure files for Stack Wallet.
|
||||
|
||||
# currently unused
|
||||
#export APP_NAME="Stack Wallet"
|
||||
#export APP_ID="com.cypherstack.stackwallet"
|
||||
|
||||
PUBSPEC_FILE="${APP_PROJECT_ROOT_DIR}/pubspec.yaml"
|
||||
PUBSPEC_NAME="stackwallet"
|
||||
PUBSPEC_DESC="Stack Wallet"
|
||||
|
||||
# String replacements.
|
||||
if [[ "$(uname)" == 'Darwin' ]]; then
|
||||
# macos specific sed
|
||||
sed -i '' "s/name: PLACEHOLDER/name: ${PUBSPEC_NAME}/g" "${PUBSPEC_FILE}"
|
||||
sed -i '' "s/description: PLACEHOLDER/description: ${PUBSPEC_DESC}/g" "${PUBSPEC_FILE}"
|
||||
else
|
||||
sed -i "s/name: PLACEHOLDER/name: ${PUBSPEC_NAME}/g" "${PUBSPEC_FILE}"
|
||||
sed -i "s/description: PLACEHOLDER/description: ${PUBSPEC_DESC}/g" "${PUBSPEC_FILE}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
APP_CONFIG_DART_FILE="${APP_PROJECT_ROOT_DIR}/lib/app_config.g.dart"
|
||||
rm -f "$APP_CONFIG_DART_FILE"
|
||||
cat << EOF > "$APP_CONFIG_DART_FILE"
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'app_config.dart';
|
||||
|
||||
const _prefix = "Stack";
|
||||
const _separator = " ";
|
||||
const _suffix = "Wallet";
|
||||
|
||||
final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
|
||||
Bitcoin(CryptoCurrencyNetwork.main),
|
||||
BitcoinFrost(CryptoCurrencyNetwork.main),
|
||||
Litecoin(CryptoCurrencyNetwork.main),
|
||||
Bitcoincash(CryptoCurrencyNetwork.main),
|
||||
Dogecoin(CryptoCurrencyNetwork.main),
|
||||
Epiccash(CryptoCurrencyNetwork.main),
|
||||
Ecash(CryptoCurrencyNetwork.main),
|
||||
Ethereum(CryptoCurrencyNetwork.main),
|
||||
Firo(CryptoCurrencyNetwork.main),
|
||||
Monero(CryptoCurrencyNetwork.main),
|
||||
Particl(CryptoCurrencyNetwork.main),
|
||||
Peercoin(CryptoCurrencyNetwork.main),
|
||||
Solana(CryptoCurrencyNetwork.main),
|
||||
Stellar(CryptoCurrencyNetwork.main),
|
||||
Tezos(CryptoCurrencyNetwork.main),
|
||||
Wownero(CryptoCurrencyNetwork.main),
|
||||
Namecoin(CryptoCurrencyNetwork.main),
|
||||
Nano(CryptoCurrencyNetwork.main),
|
||||
Banano(CryptoCurrencyNetwork.main),
|
||||
Bitcoin(CryptoCurrencyNetwork.test),
|
||||
BitcoinFrost(CryptoCurrencyNetwork.test),
|
||||
Litecoin(CryptoCurrencyNetwork.test),
|
||||
Bitcoincash(CryptoCurrencyNetwork.test),
|
||||
Firo(CryptoCurrencyNetwork.test),
|
||||
Dogecoin(CryptoCurrencyNetwork.test),
|
||||
Stellar(CryptoCurrencyNetwork.test),
|
||||
Peercoin(CryptoCurrencyNetwork.test),
|
||||
]);
|
||||
|
||||
EOF
|
|
@ -42,6 +42,8 @@ else
|
|||
fi
|
||||
|
||||
if printf '%s\0' "${APP_NAMED_IDS[@]}" | grep -Fxqz -- "${APP_NAMED_ID}"; then
|
||||
# shellcheck disable=SC1090
|
||||
source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/configure_${APP_NAMED_ID}.sh"
|
||||
"${APP_PROJECT_ROOT_DIR}/scripts/app_config/update_version.sh" -v "${APP_VERSION_STRING}" -b "${APP_BUILD_NUMBER}"
|
||||
"${APP_PROJECT_ROOT_DIR}/scripts/app_config/shared/link_assets.sh" "${APP_NAMED_ID}"
|
||||
else
|
||||
|
@ -52,7 +54,6 @@ fi
|
|||
if [[ "$APP_NAMED_ID" = "stack_wallet" ]]; then
|
||||
./build_all.sh
|
||||
elif [[ "$APP_NAMED_ID" = "stack_duo" ]]; then
|
||||
"${APP_PROJECT_ROOT_DIR}/scripts/app_config/configure_duo.sh"
|
||||
./build_all_duo.sh
|
||||
else
|
||||
echo "Invalid app id: ${APP_NAMED_ID}"
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:hive_test/hive_test.dart';
|
|||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
import 'package:stackwallet/services/node_service.dart';
|
||||
import 'package:stackwallet/supported_coins.dart';
|
||||
import 'package:stackwallet/app_config.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
||||
|
||||
|
@ -112,7 +112,7 @@ void main() {
|
|||
await service.updateDefaults();
|
||||
expect(
|
||||
service.nodes.length,
|
||||
Coins.enabled.map((e) => e.defaultNode).length,
|
||||
AppConfig.coins.map((e) => e.defaultNode).length,
|
||||
);
|
||||
expect(fakeStore.interactions, 0);
|
||||
});
|
||||
|
@ -205,7 +205,7 @@ void main() {
|
|||
final fakeStore = FakeSecureStorage();
|
||||
final service = NodeService(secureStorageInterface: fakeStore);
|
||||
final nodes = service.nodes;
|
||||
final defaults = Coins.enabled.map((e) => e.defaultNode).toList();
|
||||
final defaults = AppConfig.coins.map((e) => e.defaultNode).toList();
|
||||
|
||||
nodes.sort((a, b) => a.id.compareTo(b.id));
|
||||
defaults.sort((a, b) => a.id.compareTo(b.id));
|
||||
|
@ -221,7 +221,7 @@ void main() {
|
|||
await service.add(nodeA, null, true);
|
||||
expect(
|
||||
service.nodes.length,
|
||||
Coins.enabled.map((e) => e.defaultNode).length + 1,
|
||||
AppConfig.coins.map((e) => e.defaultNode).length + 1,
|
||||
);
|
||||
expect(fakeStore.interactions, 0);
|
||||
});
|
||||
|
@ -232,7 +232,7 @@ void main() {
|
|||
await service.add(nodeA, "some password", true);
|
||||
expect(
|
||||
service.nodes.length,
|
||||
Coins.enabled.map((e) => e.defaultNode).length + 1,
|
||||
AppConfig.coins.map((e) => e.defaultNode).length + 1,
|
||||
);
|
||||
expect(fakeStore.interactions, 1);
|
||||
expect(fakeStore.writes, 1);
|
||||
|
@ -290,7 +290,7 @@ void main() {
|
|||
|
||||
expect(
|
||||
service.nodes.length,
|
||||
Coins.enabled.map((e) => e.defaultNode).length + 2,
|
||||
AppConfig.coins.map((e) => e.defaultNode).length + 2,
|
||||
);
|
||||
expect(
|
||||
service.nodes.where((element) => element.id == nodeB.id).length,
|
||||
|
|
Loading…
Reference in a new issue