diff --git a/.gitignore b/.gitignore index 3e7bee013..4b76ab9da 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ libtor_ffi.dll flutter_libsparkmobile.dll secp256k1.dll /libisar.so +/lib/app_config.g.dart diff --git a/lib/app_config.dart b/lib/app_config.dart index 2b83a7868..998fae02d 100644 --- a/lib/app_config.dart +++ b/lib/app_config.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 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!"); + } + } } diff --git a/lib/db/db_version_migration.dart b/lib/db/db_version_migration.dart index ed69c0bbc..333ddfabc 100644 --- a/lib/db/db_version_migration.dart +++ b/lib/db/db_version_migration.dart @@ -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 diff --git a/lib/db/hive/db.dart b/lib/db/hive/db.dart index 25a793219..22722d6af 100644 --- a/lib/db/hive/db.dart +++ b/lib/db/hive/db.dart @@ -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.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( diff --git a/lib/db/migrate_wallets_to_isar.dart b/lib/db/migrate_wallets_to_isar.dart index c222bed57..810185463 100644 --- a/lib/db/migrate_wallets_to_isar.dart +++ b/lib/db/migrate_wallets_to_isar.dart @@ -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 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, diff --git a/lib/models/contact_address_entry.dart b/lib/models/contact_address_entry.dart index 764212330..9e64e4f1e 100644 --- a/lib/models/contact_address_entry.dart +++ b/lib/models/contact_address_entry.dart @@ -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 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?, diff --git a/lib/models/isar/exchange_cache/currency.dart b/lib/models/isar/exchange_cache/currency.dart index 86236a685..d206d3326 100644 --- a/lib/models/isar/exchange_cache/currency.dart +++ b/lib/models/isar/exchange_cache/currency.dart @@ -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; diff --git a/lib/models/isar/models/block_explorer.dart b/lib/models/isar/models/block_explorer.dart index da0e2b527..ed16c995b 100644 --- a/lib/models/isar/models/block_explorer.dart +++ b/lib/models/isar/models/block_explorer.dart @@ -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; } diff --git a/lib/models/isar/models/contact_entry.dart b/lib/models/isar/models/contact_entry.dart index 67eac36df..5ccedd4eb 100644 --- a/lib/models/isar/models/contact_entry.dart +++ b/lib/models/isar/models/contact_entry.dart @@ -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 get addressesSorted { final List 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(); diff --git a/lib/models/isar/stack_theme.dart b/lib/models/isar/stack_theme.dart index b891c288e..32e25dd78 100644 --- a/lib/models/isar/stack_theme.dart +++ b/lib/models/isar/stack_theme.dart @@ -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 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 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 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]!); } diff --git a/lib/notifications/notification_card.dart b/lib/notifications/notification_card.dart index 006d56185..434af20b2 100644 --- a/lib/notifications/notification_card.dart +++ b/lib/notifications/notification_card.dart @@ -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; diff --git a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart index 2179542e3..2d6c27adc 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart @@ -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 { 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 coinEntities = []; final List tokenEntities = []; @@ -147,7 +147,7 @@ class _AddWalletViewState extends ConsumerState { coinEntities.addAll(_coinsTestnet.map((e) => CoinEntity(e))); } - if (Coins.enabled.whereType().isNotEmpty) { + if (AppConfig.coins.whereType().isNotEmpty) { final contracts = MainDB.instance.getEthContracts().sortByName().findAllSync(); diff --git a/lib/pages/address_book_views/address_book_view.dart b/lib/pages/address_book_views/address_book_view.dart index 6cbc86a7f..3dcdcf907 100644 --- a/lib/pages/address_book_views/address_book_view.dart +++ b/lib/pages/address_book_views/address_book_view.dart @@ -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 { 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, ); diff --git a/lib/pages/address_book_views/subviews/address_book_filter_view.dart b/lib/pages/address_book_views/subviews/address_book_filter_view.dart index 2f863f379..8f63ffc15 100644 --- a/lib/pages/address_book_views/subviews/address_book_filter_view.dart +++ b/lib/pages/address_book_views/subviews/address_book_filter_view.dart @@ -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 { @override void initState() { - final coins = [...Coins.enabled]; + final coins = [...AppConfig.coins]; coins.removeWhere( (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, ); diff --git a/lib/pages/address_book_views/subviews/coin_select_sheet.dart b/lib/pages/address_book_views/subviews/coin_select_sheet.dart index f1d474170..c74489fbb 100644 --- a/lib/pages/address_book_views/subviews/coin_select_sheet.dart +++ b/lib/pages/address_book_views/subviews/coin_select_sheet.dart @@ -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, ); diff --git a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart index 33c901527..27995cb04 100644 --- a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart +++ b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart @@ -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, ); diff --git a/lib/pages/buy_view/buy_form.dart b/lib/pages/buy_view/buy_form.dart index 53dcd01f3..c28dd9c6e 100644 --- a/lib/pages/buy_view/buy_form.dart +++ b/lib/pages/buy_view/buy_form.dart @@ -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 { 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 { 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 { ), Expanded( child: AddressBookAddressChooser( - coin: Coins.enabled.firstWhere( + coin: AppConfig.coins.firstWhere( (e) => e.ticker.toLowerCase() == selectedCrypto!.ticker diff --git a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart index 3cff7b1b1..22dedbac8 100644 --- a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart @@ -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 { 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) diff --git a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart index b19057387..2fac1d83d 100644 --- a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart +++ b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart @@ -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(), diff --git a/lib/pages/exchange_view/exchange_step_views/step_2_view.dart b/lib/pages/exchange_view/exchange_step_views/step_2_view.dart index ac5795d27..941707b63 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_2_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_2_view.dart @@ -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 { 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 { 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 { text: "Choose from Stack", onTap: () { try { - final coin = Coins.enabled.firstWhere( + final coin = AppConfig.coins.firstWhere( (e) => e.ticker.toLowerCase() == model.sendTicker.toLowerCase(), diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index d7438668e..b98750816 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -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 { 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 { .useMaterialPageRoute, builder: (BuildContext context) { - final coin = - Coins.enabled.firstWhere( + final coin = AppConfig.coins + .firstWhere( (e) => e.ticker .toLowerCase() == diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart index 3e1f2c2d8..c4d089b55 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart @@ -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 { int decimals; try { - decimals = Coins.getCryptoCurrencyForTicker( + decimals = AppConfig.getCryptoCurrencyForTicker( receivingCurrency.ticker, ).fractionDigits; } catch (_) { @@ -113,7 +112,7 @@ class _ExchangeOptionState extends ConsumerState { CryptoCurrency? coin; try { - coin = Coins.getCryptoCurrencyForTicker( + coin = AppConfig.getCryptoCurrencyForTicker( receivingCurrency.ticker, ); } catch (_) { diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index 8d0a989e0..93cf4cfd2 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -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 { 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 { 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 { 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 { text: "View transaction", onTap: () { final CryptoCurrency coin = - Coins.getCryptoCurrencyForTicker( + AppConfig.getCryptoCurrencyForTicker( trade.payInCurrency, ); @@ -1381,11 +1382,11 @@ class _TradeDetailsViewState extends ConsumerState { onPressed: () { CryptoCurrency coin; try { - coin = Coins.getCryptoCurrencyForTicker( + coin = AppConfig.getCryptoCurrencyForTicker( trade.payInCurrency, ); } catch (_) { - coin = Coins.getCryptoCurrencyByPrettyName( + coin = AppConfig.getCryptoCurrencyByPrettyName( trade.payInCurrency, ); } diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart index 929175498..4e01118af 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart @@ -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(); diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart index 02a8a6799..5849b7987 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart @@ -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 { - List _coins = [...Coins.enabled]; + List _coins = [...AppConfig.coins]; @override void initState() { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index 9e1acb9f2..446d1527c 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -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)!, diff --git a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart index f94e52187..3b24a782b 100644 --- a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart +++ b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart @@ -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 { 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, ); diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart index c144f72ed..4c3f378ac 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart @@ -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 { 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, ); diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart index ae5b46b1f..cf4799255 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart @@ -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 { 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 { void selectRecipientAddressFromStack() async { try { - final coin = Coins.getCryptoCurrencyForTicker( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.receiveTicker, ); @@ -101,7 +101,7 @@ class _DesktopStep2State extends ConsumerState { void selectRefundAddressFromStack() async { try { - final coin = Coins.getCryptoCurrencyForTicker( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.sendTicker, ); @@ -131,7 +131,7 @@ class _DesktopStep2State extends ConsumerState { } void selectRecipientFromAddressBook() async { - final coin = Coins.getCryptoCurrencyForTicker( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.receiveTicker, ); @@ -178,7 +178,7 @@ class _DesktopStep2State extends ConsumerState { } void selectRefundFromAddressBook() async { - final coin = Coins.getCryptoCurrencyForTicker( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.sendTicker, ); diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart index 0c7841c3c..4cd1e98d7 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart @@ -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 { bool _isWalletCoinAndHasWallet(String ticker) { try { - final coin = Coins.getCryptoCurrencyForTicker(ticker); + final coin = AppConfig.getCryptoCurrencyForTicker(ticker); return ref .read(pWallets) .wallets diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart index 623aacdc4..9c00ead29 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart @@ -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, ) diff --git a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart index 6c0537618..f70032049 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart @@ -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 { - List _coins = [...Coins.enabled]; + List _coins = [...AppConfig.coins]; late final TextEditingController searchNodeController; late final FocusNode searchNodeFocusNode; diff --git a/lib/services/buy/simplex/simplex_api.dart b/lib/services/buy/simplex/simplex_api.dart index 3eec5d140..d6d371756 100644 --- a/lib/services/buy/simplex/simplex_api.dart +++ b/lib/services/buy/simplex/simplex_api.dart @@ -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; diff --git a/lib/services/node_service.dart b/lib/services/node_service.dart index 8940964c9..7381ca66b 100644 --- a/lib/services/node_service.dart +++ b/lib/services/node_service.dart @@ -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 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>.from( map["nodes"][coin.identifier] as List? ?? [], ); diff --git a/lib/services/notifications_service.dart b/lib/services/notifications_service.dart index 461b65ae0..b4097131e 100644 --- a/lib/services/notifications_service.dart +++ b/lib/services/notifications_service.dart @@ -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); diff --git a/lib/services/price.dart b/lib/services/price.dart index 4bc02113a..c602fd5f6 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -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 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 diff --git a/lib/services/price_service.dart b/lib/services/price_service.dart index b8d652ff0..0aaede505 100644 --- a/lib/services/price_service.dart +++ b/lib/services/price_service.dart @@ -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> _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> _cachedTokenPrices = {}; diff --git a/lib/services/wallets.dart b/lib/services/wallets.dart index b7f799fcb..67806b99e 100644 --- a/lib/services/wallets.dart +++ b/lib/services/wallets.dart @@ -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( - Coins.enabled.map((e) => e.identifier), + AppConfig.coins.map((e) => e.identifier), (q, element) => q.coinNameMatches(element), ) .findAll(); diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index d2a496956..1f7b3b17c 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -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.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( diff --git a/lib/supported_coins.dart b/lib/supported_coins.dart deleted file mode 100644 index 133ded94a..000000000 --- a/lib/supported_coins.dart +++ /dev/null @@ -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 get enabled => all - .where( - (element) => AppConfig.supportedCoins.contains(element.runtimeType)) - .toList(); - - /// A List of all implemented coins. - static final List 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!"); - } - } -} diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index a83cd802d..060118437 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -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'; @@ -83,9 +83,10 @@ class Prefs extends ChangeNotifier { set lastUnlockedTimeout(int lastUnlockedTimeout) { if (_lastUnlockedTimeout != lastUnlockedTimeout) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "lastUnlockedTimeout", - value: lastUnlockedTimeout,); + boxName: DB.boxNamePrefs, + key: "lastUnlockedTimeout", + value: lastUnlockedTimeout, + ); _lastUnlockedTimeout = lastUnlockedTimeout; notifyListeners(); } @@ -93,7 +94,9 @@ class Prefs extends ChangeNotifier { Future _getLastUnlockedTimeout() async { return (DB.instance.get( - 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( - 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 _getLastUnlocked() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "lastUnlocked",) as int? ?? + boxName: DB.boxNamePrefs, + key: "lastUnlocked", + ) as int? ?? 0; } @@ -131,15 +139,18 @@ class Prefs extends ChangeNotifier { _currentNotificationId = 0; } await DB.instance.put( - boxName: DB.boxNamePrefs, - key: "currentNotificationId", - value: _currentNotificationId,); + boxName: DB.boxNamePrefs, + key: "currentNotificationId", + value: _currentNotificationId, + ); notifyListeners(); } Future _getCurrentNotificationIndex() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "currentNotificationId",) as int? ?? + boxName: DB.boxNamePrefs, + key: "currentNotificationId", + ) as int? ?? 0; } @@ -152,9 +163,10 @@ class Prefs extends ChangeNotifier { set walletIdsSyncOnStartup(List walletIdsSyncOnStartup) { if (_walletIdsSyncOnStartup != walletIdsSyncOnStartup) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "walletIdsSyncOnStartup", - value: walletIdsSyncOnStartup,); + boxName: DB.boxNamePrefs, + key: "walletIdsSyncOnStartup", + value: walletIdsSyncOnStartup, + ); _walletIdsSyncOnStartup = walletIdsSyncOnStartup; notifyListeners(); } @@ -162,7 +174,9 @@ class Prefs extends ChangeNotifier { Future> _getWalletIdsSyncOnStartup() async { final list = await DB.instance.get( - boxName: DB.boxNamePrefs, key: "walletIdsSyncOnStartup",) as List? ?? + boxName: DB.boxNamePrefs, + key: "walletIdsSyncOnStartup", + ) as List? ?? []; return List.from(list); } @@ -176,9 +190,10 @@ class Prefs extends ChangeNotifier { set syncType(SyncingType syncType) { if (_syncType != syncType) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "syncTypeIndex", - value: syncType.index,); + boxName: DB.boxNamePrefs, + key: "syncTypeIndex", + value: syncType.index, + ); _syncType = syncType; notifyListeners(); } @@ -186,7 +201,9 @@ class Prefs extends ChangeNotifier { Future _getSyncType() async { final int index = await DB.instance.get( - 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( - boxName: DB.boxNamePrefs, key: "wifiOnly", value: wifiOnly,); + boxName: DB.boxNamePrefs, + key: "wifiOnly", + value: wifiOnly, + ); _wifiOnly = wifiOnly; notifyListeners(); } @@ -221,9 +241,10 @@ class Prefs extends ChangeNotifier { set showFavoriteWallets(bool showFavoriteWallets) { if (_showFavoriteWallets != showFavoriteWallets) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "showFavoriteWallets", - value: showFavoriteWallets,); + boxName: DB.boxNamePrefs, + key: "showFavoriteWallets", + value: showFavoriteWallets, + ); _showFavoriteWallets = showFavoriteWallets; notifyListeners(); } @@ -231,7 +252,9 @@ class Prefs extends ChangeNotifier { Future _getShowFavoriteWallets() async { return await DB.instance.get( - 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( - 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 _getPreferredLanguage() async { return await DB.instance.get( - 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( - 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 _getPreferredCurrency() async { return await DB.instance.get( - 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( - 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 _getRandomizePIN() async { return await DB.instance.get( - 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( - 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 _getUseBiometrics() async { return await DB.instance.get( - 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( - 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 _getHasFamiliarity() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "familiarity",) as int? ?? + boxName: DB.boxNamePrefs, + key: "familiarity", + ) as int? ?? 0; } @@ -437,9 +485,10 @@ class Prefs extends ChangeNotifier { set showTestNetCoins(bool showTestNetCoins) { if (_showTestNetCoins != showTestNetCoins) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "showTestNetCoins", - value: showTestNetCoins,); + boxName: DB.boxNamePrefs, + key: "showTestNetCoins", + value: showTestNetCoins, + ); _showTestNetCoins = showTestNetCoins; notifyListeners(); } @@ -447,7 +496,9 @@ class Prefs extends ChangeNotifier { Future _getShowTestNetCoins() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "showTestNetCoins",) as bool? ?? + boxName: DB.boxNamePrefs, + key: "showTestNetCoins", + ) as bool? ?? false; } @@ -461,9 +512,10 @@ class Prefs extends ChangeNotifier { if (_isAutoBackupEnabled != isAutoBackupEnabled) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "isAutoBackupEnabled", - value: isAutoBackupEnabled,) + boxName: DB.boxNamePrefs, + key: "isAutoBackupEnabled", + value: isAutoBackupEnabled, + ) .then((_) { _isAutoBackupEnabled = isAutoBackupEnabled; notifyListeners(); @@ -473,7 +525,9 @@ class Prefs extends ChangeNotifier { Future _getIsAutoBackupEnabled() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "isAutoBackupEnabled",) as bool? ?? + boxName: DB.boxNamePrefs, + key: "isAutoBackupEnabled", + ) as bool? ?? false; } @@ -486,9 +540,10 @@ class Prefs extends ChangeNotifier { set autoBackupLocation(String? autoBackupLocation) { if (this.autoBackupLocation != autoBackupLocation) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "autoBackupLocation", - value: autoBackupLocation,); + boxName: DB.boxNamePrefs, + key: "autoBackupLocation", + value: autoBackupLocation, + ); _autoBackupLocation = autoBackupLocation; notifyListeners(); } @@ -496,7 +551,9 @@ class Prefs extends ChangeNotifier { Future _getAutoBackupLocation() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "autoBackupLocation",) as String?; + boxName: DB.boxNamePrefs, + key: "autoBackupLocation", + ) as String?; } // auto backup frequency type @@ -511,21 +568,24 @@ class Prefs extends ChangeNotifier { switch (backupFrequencyType) { case BackupFrequencyType.everyTenMinutes: DB.instance.put( - boxName: DB.boxNamePrefs, - key: "backupFrequencyType", - value: "10Min",); + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + value: "10Min", + ); break; case BackupFrequencyType.everyAppStart: DB.instance.put( - boxName: DB.boxNamePrefs, - key: "backupFrequencyType", - value: "onStart",); + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + value: "onStart", + ); break; case BackupFrequencyType.afterClosingAWallet: DB.instance.put( - boxName: DB.boxNamePrefs, - key: "backupFrequencyType", - value: "onWalletClose",); + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + value: "onWalletClose", + ); break; } _backupFrequencyType = backupFrequencyType; @@ -535,7 +595,9 @@ class Prefs extends ChangeNotifier { Future _getBackupFrequencyType() async { String? rate = await DB.instance.get( - boxName: DB.boxNamePrefs, key: "backupFrequencyType",) as String?; + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + ) as String?; rate ??= "10Min"; switch (rate) { case "10Min": @@ -558,9 +620,10 @@ class Prefs extends ChangeNotifier { set lastAutoBackup(DateTime? lastAutoBackup) { if (this.lastAutoBackup != lastAutoBackup) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "lastAutoBackup", - value: lastAutoBackup,); + boxName: DB.boxNamePrefs, + key: "lastAutoBackup", + value: lastAutoBackup, + ); _lastAutoBackup = lastAutoBackup; notifyListeners(); } @@ -568,7 +631,9 @@ class Prefs extends ChangeNotifier { Future _getLastAutoBackup() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "autoBackupFileUri",) as DateTime?; + boxName: DB.boxNamePrefs, + key: "autoBackupFileUri", + ) as DateTime?; } // auto backup @@ -581,9 +646,10 @@ class Prefs extends ChangeNotifier { if (_hideBlockExplorerWarning != hideBlockExplorerWarning) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "hideBlockExplorerWarning", - value: hideBlockExplorerWarning,) + boxName: DB.boxNamePrefs, + key: "hideBlockExplorerWarning", + value: hideBlockExplorerWarning, + ) .then((_) { _hideBlockExplorerWarning = hideBlockExplorerWarning; notifyListeners(); @@ -593,8 +659,9 @@ class Prefs extends ChangeNotifier { Future _getHideBlockExplorerWarning() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, - key: "hideBlockExplorerWarning",) as bool? ?? + boxName: DB.boxNamePrefs, + key: "hideBlockExplorerWarning", + ) as bool? ?? false; } @@ -608,9 +675,10 @@ class Prefs extends ChangeNotifier { if (_gotoWalletOnStartup != gotoWalletOnStartup) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "gotoWalletOnStartup", - value: gotoWalletOnStartup,) + boxName: DB.boxNamePrefs, + key: "gotoWalletOnStartup", + value: gotoWalletOnStartup, + ) .then((_) { _gotoWalletOnStartup = gotoWalletOnStartup; notifyListeners(); @@ -620,7 +688,9 @@ class Prefs extends ChangeNotifier { Future _getGotoWalletOnStartup() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "gotoWalletOnStartup",) as bool? ?? + boxName: DB.boxNamePrefs, + key: "gotoWalletOnStartup", + ) as bool? ?? false; } @@ -633,9 +703,10 @@ class Prefs extends ChangeNotifier { set startupWalletId(String? startupWalletId) { if (this.startupWalletId != startupWalletId) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "startupWalletId", - value: startupWalletId,); + boxName: DB.boxNamePrefs, + key: "startupWalletId", + value: startupWalletId, + ); _startupWalletId = startupWalletId; notifyListeners(); } @@ -643,7 +714,9 @@ class Prefs extends ChangeNotifier { Future _getStartupWalletId() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "startupWalletId",) as String?; + boxName: DB.boxNamePrefs, + key: "startupWalletId", + ) as String?; } // incognito mode off by default @@ -656,9 +729,10 @@ class Prefs extends ChangeNotifier { if (_externalCalls != externalCalls) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "externalCalls", - value: externalCalls,) + boxName: DB.boxNamePrefs, + key: "externalCalls", + value: externalCalls, + ) .then((_) { _externalCalls = externalCalls; notifyListeners(); @@ -668,7 +742,9 @@ class Prefs extends ChangeNotifier { Future _getHasExternalCalls() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "externalCalls",) as bool? ?? + boxName: DB.boxNamePrefs, + key: "externalCalls", + ) as bool? ?? true; } @@ -718,7 +794,10 @@ class Prefs extends ChangeNotifier { Future saveSignupEpoch(int signupEpoch) async { _signupEpoch = signupEpoch; await DB.instance.put( - boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch,); + boxName: DB.boxNamePrefs, + key: "signupEpoch", + value: _signupEpoch, + ); // notifyListeners(); } @@ -731,9 +810,10 @@ class Prefs extends ChangeNotifier { set enableCoinControl(bool enableCoinControl) { if (_enableCoinControl != enableCoinControl) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "enableCoinControl", - value: enableCoinControl,); + boxName: DB.boxNamePrefs, + key: "enableCoinControl", + value: enableCoinControl, + ); _enableCoinControl = enableCoinControl; notifyListeners(); } @@ -741,7 +821,9 @@ class Prefs extends ChangeNotifier { Future _getEnableCoinControl() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "enableCoinControl",) as bool? ?? + boxName: DB.boxNamePrefs, + key: "enableCoinControl", + ) as bool? ?? false; } @@ -754,9 +836,10 @@ class Prefs extends ChangeNotifier { set enableSystemBrightness(bool enableSystemBrightness) { if (_enableSystemBrightness != enableSystemBrightness) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "enableSystemBrightness", - value: enableSystemBrightness,); + boxName: DB.boxNamePrefs, + key: "enableSystemBrightness", + value: enableSystemBrightness, + ); _enableSystemBrightness = enableSystemBrightness; notifyListeners(); } @@ -764,7 +847,9 @@ class Prefs extends ChangeNotifier { Future _getEnableSystemBrightness() async { return await DB.instance.get( - 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( boxName: DB.boxNamePrefs, @@ -867,7 +954,7 @@ class Prefs extends ChangeNotifier { } Future _setAmountUnits() async { - for (final coin in Coins.enabled) { + for (final coin in AppConfig.coins) { final unitIndex = await DB.instance.get( boxName: DB.boxNamePrefs, key: "amountUnitFor${coin.identifier}", @@ -900,7 +987,7 @@ class Prefs extends ChangeNotifier { } Future _setMaxDecimals() async { - for (final coin in Coins.enabled) { + for (final coin in AppConfig.coins) { final decimals = await DB.instance.get( boxName: DB.boxNamePrefs, key: "maxDecimalsFor${coin.identifier}", diff --git a/lib/wallets/isar/models/wallet_info.dart b/lib/wallets/isar/models/wallet_info.dart index ed61ddede..f7a3692e0 100644 --- a/lib/wallets/isar/models/wallet_info.dart +++ b/lib/wallets/isar/models/wallet_info.dart @@ -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 jsonObject, AddressType mainAddressType, ) { - final coin = Coins.getCryptoCurrencyFor( + final coin = AppConfig.getCryptoCurrencyFor( jsonObject["coin"] as String, ); return WalletInfo( diff --git a/lib/wallets/isar/providers/all_wallets_info_provider.dart b/lib/wallets/isar/providers/all_wallets_info_provider.dart index 15ffaeb38..f2efcc090 100644 --- a/lib/wallets/isar/providers/all_wallets_info_provider.dart +++ b/lib/wallets/isar/providers/all_wallets_info_provider.dart @@ -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 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( - 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( - Coins.enabled.map((e) => e.identifier), + AppConfig.coins.map((e) => e.identifier), (q, element) => q.coinNameMatches(element), ) .findAll() diff --git a/lib/wallets/isar/providers/favourite_wallets_provider.dart b/lib/wallets/isar/providers/favourite_wallets_provider.dart index b09e94c95..889ac396b 100644 --- a/lib/wallets/isar/providers/favourite_wallets_provider.dart +++ b/lib/wallets/isar/providers/favourite_wallets_provider.dart @@ -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( - 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( - Coins.enabled.map((e) => e.identifier), + AppConfig.coins.map((e) => e.identifier), (q, element) => q.coinNameMatches(element), ) .isFavouriteEqualTo(isFavourite) diff --git a/lib/widgets/address_book_card.dart b/lib/widgets/address_book_card.dart index e1411a2fe..f7715410d 100644 --- a/lib/widgets/address_book_card.dart +++ b/lib/widgets/address_book_card.dart @@ -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 { final List 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); } diff --git a/lib/widgets/choose_coin_view.dart b/lib/widgets/choose_coin_view.dart index 3a0f2e1a6..a234d89ef 100644 --- a/lib/widgets/choose_coin_view.dart +++ b/lib/widgets/choose_coin_view.dart @@ -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 { - List _coins = [...Coins.enabled]; + List _coins = [...AppConfig.coins]; @override void initState() { diff --git a/pubspec.yaml b/pubspec.yaml index c9a84bb2d..268fe5e9e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 diff --git a/scripts/app_config/configure_duo.sh b/scripts/app_config/configure_duo.sh deleted file mode 100755 index 3d0792133..000000000 --- a/scripts/app_config/configure_duo.sh +++ /dev/null @@ -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 diff --git a/scripts/app_config/configure_stack_duo.sh b/scripts/app_config/configure_stack_duo.sh new file mode 100755 index 000000000..c910deef8 --- /dev/null +++ b/scripts/app_config/configure_stack_duo.sh @@ -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 _supportedCoins = List.unmodifiable([ + Bitcoin(CryptoCurrencyNetwork.main), + Monero(CryptoCurrencyNetwork.main), + Bitcoin(CryptoCurrencyNetwork.test), +]); + +EOF \ No newline at end of file diff --git a/scripts/app_config/configure_stack_wallet.sh b/scripts/app_config/configure_stack_wallet.sh new file mode 100755 index 000000000..2f698ba6c --- /dev/null +++ b/scripts/app_config/configure_stack_wallet.sh @@ -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 _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 \ No newline at end of file diff --git a/scripts/build_app.sh b/scripts/build_app.sh index 9b1a20158..5d953e9b6 100755 --- a/scripts/build_app.sh +++ b/scripts/build_app.sh @@ -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}" diff --git a/test/services/node_service_test.dart b/test/services/node_service_test.dart index a33d3c982..5b4f1e635 100644 --- a/test/services/node_service_test.dart +++ b/test/services/node_service_test.dart @@ -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,