diff --git a/lib/db/db_version_migration.dart b/lib/db/db_version_migration.dart index 3cc9b9c3c..ed69c0bbc 100644 --- a/lib/db/db_version_migration.dart +++ b/lib/db/db_version_migration.dart @@ -560,7 +560,7 @@ class DbVersionMigrator with WalletDB { final count = await MainDB.instance.getTransactions(walletId).count(); - final crypto = SupportedCoins.getCryptoCurrencyFor(info.coinIdentifier); + final crypto = Coins.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 f63c00e94..25a793219 100644 --- a/lib/db/hive/db.dart +++ b/lib/db/hive/db.dart @@ -164,7 +164,7 @@ class DB { names.removeWhere((name, dyn) { final jsonObject = Map.from(dyn as Map); try { - SupportedCoins.getCryptoCurrencyFor(jsonObject["coin"] as String); + Coins.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 72a9b501f..c222bed57 100644 --- a/lib/db/migrate_wallets_to_isar.dart +++ b/lib/db/migrate_wallets_to_isar.dart @@ -171,7 +171,7 @@ Future migrateWalletsToIsar({ coinName: old.coinIdentifier, walletId: old.walletId, name: old.name, - mainAddressType: SupportedCoins.getCryptoCurrencyFor(old.coinIdentifier) + mainAddressType: Coins.getCryptoCurrencyFor(old.coinIdentifier) .primaryAddressType, favouriteOrderIndex: favourites.indexOf(old.walletId), cachedChainHeight: walletBox.get( diff --git a/lib/models/contact_address_entry.dart b/lib/models/contact_address_entry.dart index f57ed6d4b..764212330 100644 --- a/lib/models/contact_address_entry.dart +++ b/lib/models/contact_address_entry.dart @@ -43,7 +43,7 @@ class ContactAddressEntry { factory ContactAddressEntry.fromJson(Map jsonObject) { return ContactAddressEntry( - coin: SupportedCoins.getCryptoCurrencyFor(jsonObject["coin"] as String), + coin: Coins.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 0233cbe98..86236a685 100644 --- a/lib/models/isar/exchange_cache/currency.dart +++ b/lib/models/isar/exchange_cache/currency.dart @@ -161,7 +161,7 @@ class Currency { static bool checkIsStackCoin(String ticker) { try { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.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 411ad4ec3..da0e2b527 100644 --- a/lib/models/isar/models/block_explorer.dart +++ b/lib/models/isar/models/block_explorer.dart @@ -31,7 +31,7 @@ class TransactionBlockExplorer { @ignore CryptoCurrency? get coin { try { - return SupportedCoins.getCryptoCurrencyForTicker(ticker); + return Coins.getCryptoCurrencyForTicker(ticker); } catch (_) { return null; } diff --git a/lib/models/isar/models/contact_entry.dart b/lib/models/isar/models/contact_entry.dart index b3a0fe809..16925ce24 100644 --- a/lib/models/isar/models/contact_entry.dart +++ b/lib/models/isar/models/contact_entry.dart @@ -37,7 +37,7 @@ class ContactEntry { @ignore List get addressesSorted { final List sorted = []; - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { 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 => SupportedCoins.getCryptoCurrencyFor(coinName); + CryptoCurrency get coin => Coins.getCryptoCurrencyFor(coinName); ContactAddressEntry(); diff --git a/lib/models/isar/stack_theme.dart b/lib/models/isar/stack_theme.dart index b33ca274d..3ff54c3b7 100644 --- a/lib/models/isar/stack_theme.dart +++ b/lib/models/isar/stack_theme.dart @@ -1858,7 +1858,7 @@ class StackTheme { final Map result = {}; for (final mainNetId - in SupportedCoins.cryptocurrencies.map((e) => e.mainNetId)) { + in Coins.cryptocurrencies.map((e) => e.mainNetId)) { if (map[mainNetId] is String) { result[mainNetId] = Color( (map[mainNetId] as String).toBigIntFromHex.toInt(), @@ -2176,7 +2176,7 @@ class ThemeAssetsV2 implements IThemeAssets { final Map result = {}; - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder; } @@ -2511,7 +2511,7 @@ class ThemeAssetsV3 implements IThemeAssets { final Map result = {}; - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { 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 1135a478c..006d56185 100644 --- a/lib/notifications/notification_card.dart +++ b/lib/notifications/notification_card.dart @@ -44,8 +44,7 @@ class NotificationCard extends ConsumerWidget { String coinIconPath(IThemeAssets assets, WidgetRef ref) { try { - final coin = - SupportedCoins.getCryptoCurrencyByPrettyName(notification.coinName); + final coin = Coins.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 267358b54..c0f73cee4 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 @@ -66,11 +66,11 @@ class _AddWalletViewState extends ConsumerState { String _searchTerm = ""; final _coinsTestnet = [ - ...SupportedCoins.cryptocurrencies + ...Coins.cryptocurrencies .where((e) => e.network == CryptoCurrencyNetwork.test), ]; final _coins = [ - ...SupportedCoins.cryptocurrencies + ...Coins.cryptocurrencies .where((e) => e.network == CryptoCurrencyNetwork.main), ]; final List coinEntities = []; diff --git a/lib/pages/address_book_views/address_book_view.dart b/lib/pages/address_book_views/address_book_view.dart index 3f47a8cd7..a57ed3622 100644 --- a/lib/pages/address_book_views/address_book_view.dart +++ b/lib/pages/address_book_views/address_book_view.dart @@ -67,7 +67,7 @@ class _AddressBookViewState extends ConsumerState { ref.refresh(addressBookFilterProvider); if (widget.coin == null) { - final coins = [...SupportedCoins.cryptocurrencies]; + final coins = [...Coins.cryptocurrencies]; 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 d973555af..7253d02d1 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 @@ -41,7 +41,7 @@ class _AddressBookFilterViewState extends ConsumerState { @override void initState() { - final coins = [...SupportedCoins.cryptocurrencies]; + final coins = [...Coins.cryptocurrencies]; 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 fe8b91af5..409cb2e7e 100644 --- a/lib/pages/address_book_views/subviews/coin_select_sheet.dart +++ b/lib/pages/address_book_views/subviews/coin_select_sheet.dart @@ -28,7 +28,7 @@ class CoinSelectSheet extends StatelessWidget { @override Widget build(BuildContext context) { final maxHeight = MediaQuery.of(context).size.height * 0.60; - final coins_ = [...SupportedCoins.cryptocurrencies]; + final coins_ = [...Coins.cryptocurrencies]; 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 00a735c93..22433f8dd 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 @@ -74,7 +74,7 @@ class _NewContactAddressEntryFormState ..text = ref.read(addressEntryDataProvider(widget.id)).address ?? ""; addressLabelFocusNode = FocusNode(); addressFocusNode = FocusNode(); - coins = [...SupportedCoins.cryptocurrencies]; + coins = [...Coins.cryptocurrencies]; super.initState(); } @@ -91,7 +91,7 @@ class _NewContactAddressEntryFormState Widget build(BuildContext context) { final isDesktop = Util.isDesktop; if (isDesktop) { - coins = [...SupportedCoins.cryptocurrencies]; + coins = [...Coins.cryptocurrencies]; 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 67021d8f8..d45f7ea76 100644 --- a/lib/pages/buy_view/buy_form.dart +++ b/lib/pages/buy_view/buy_form.dart @@ -413,7 +413,7 @@ class _BuyFormState extends ConsumerState { if (ticker == null) return false; try { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.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 = SupportedCoins.getCryptoCurrencyForTicker( + final coin = Coins.getCryptoCurrencyForTicker( selectedCrypto!.ticker, ); Navigator.of(context) @@ -1331,7 +1331,7 @@ class _BuyFormState extends ConsumerState { ), Expanded( child: AddressBookAddressChooser( - coin: SupportedCoins + coin: Coins .cryptocurrencies .firstWhere( (e) => 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 bf101ec72..beffa27c7 100644 --- a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart @@ -70,7 +70,7 @@ class _CryptoSelectionViewState extends ConsumerState { coins.sort( (a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase()), ); - for (final coin in SupportedCoins.cryptocurrencies.reversed) { + for (final coin in Coins.cryptocurrencies.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 { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.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 = SupportedCoins.getCryptoCurrencyForTicker(ticker); + final coin = Coins.getCryptoCurrencyForTicker(ticker); return SvgPicture.file( File( ref.watch(coinIconProvider(coin)), 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 7698d875b..0ea602e18 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 @@ -365,7 +365,7 @@ class _ExchangeCurrencySelectionViewState Flexible( child: Builder( builder: (context) { - final coins = SupportedCoins.cryptocurrencies.where( + final coins = Coins.cryptocurrencies.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 5f4ed4a6b..7b81b0799 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 @@ -72,7 +72,7 @@ class _Step2ViewState extends ConsumerState { bool isStackCoin(String ticker) { try { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.getCryptoCurrencyForTicker(ticker); return true; } on ArgumentError catch (_) { return false; @@ -207,8 +207,7 @@ class _Step2ViewState extends ConsumerState { text: "Choose from Stack", onTap: () { try { - final coin = SupportedCoins - .cryptocurrencies + final coin = Coins.cryptocurrencies .firstWhere((e) => e.ticker.toLowerCase() == model.receiveTicker @@ -483,8 +482,7 @@ class _Step2ViewState extends ConsumerState { text: "Choose from Stack", onTap: () { try { - final coin = SupportedCoins - .cryptocurrencies + final coin = Coins.cryptocurrencies .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 ba9e37ad6..58f1a0c6c 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 @@ -75,7 +75,7 @@ class _Step4ViewState extends ConsumerState { bool _isWalletCoinAndHasWallet(String ticker, WidgetRef ref) { try { - final coin = SupportedCoins.getCryptoCurrencyForTicker(ticker); + final coin = Coins.getCryptoCurrencyForTicker(ticker); return ref .read(pWallets) .wallets @@ -853,7 +853,7 @@ class _Step4ViewState extends ConsumerState { .useMaterialPageRoute, builder: (BuildContext context) { - final coin = SupportedCoins + final coin = Coins .cryptocurrencies .firstWhere( (e) => 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 926fa5ddb..3e1f2c2d8 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart @@ -94,7 +94,7 @@ class _ExchangeOptionState extends ConsumerState { int decimals; try { - decimals = SupportedCoins.getCryptoCurrencyForTicker( + decimals = Coins.getCryptoCurrencyForTicker( receivingCurrency.ticker, ).fractionDigits; } catch (_) { @@ -113,7 +113,7 @@ class _ExchangeOptionState extends ConsumerState { CryptoCurrency? coin; try { - coin = SupportedCoins.getCryptoCurrencyForTicker( + coin = Coins.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 33d516d8e..8d0a989e0 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -88,9 +88,9 @@ class _TradeDetailsViewState extends ConsumerState { bool isStackCoin(String ticker) { try { try { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.getCryptoCurrencyForTicker(ticker); } catch (_) {} - SupportedCoins.getCryptoCurrencyByPrettyName(ticker); + Coins.getCryptoCurrencyByPrettyName(ticker); return true; } on ArgumentError catch (_) { return false; @@ -279,11 +279,11 @@ class _TradeDetailsViewState extends ConsumerState { onPressed: () { CryptoCurrency coin; try { - coin = SupportedCoins.getCryptoCurrencyForTicker( + coin = Coins.getCryptoCurrencyForTicker( trade.payInCurrency, ); } catch (_) { - coin = SupportedCoins.getCryptoCurrencyByPrettyName( + coin = Coins.getCryptoCurrencyByPrettyName( trade.payInCurrency, ); } @@ -379,8 +379,7 @@ class _TradeDetailsViewState extends ConsumerState { builder: (context) { String text; try { - final coin = - SupportedCoins.getCryptoCurrencyForTicker( + final coin = Coins.getCryptoCurrencyForTicker( trade.payInCurrency, ); final amount = sendAmount.toAmount( @@ -629,7 +628,7 @@ class _TradeDetailsViewState extends ConsumerState { text: "View transaction", onTap: () { final CryptoCurrency coin = - SupportedCoins.getCryptoCurrencyForTicker( + Coins.getCryptoCurrencyForTicker( trade.payInCurrency, ); @@ -1382,11 +1381,11 @@ class _TradeDetailsViewState extends ConsumerState { onPressed: () { CryptoCurrency coin; try { - coin = SupportedCoins.getCryptoCurrencyForTicker( + coin = Coins.getCryptoCurrencyForTicker( trade.payInCurrency, ); } catch (_) { - coin = SupportedCoins.getCryptoCurrencyByPrettyName( + coin = Coins.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 7ec0656c1..0e9444e79 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 @@ -45,7 +45,7 @@ class ManageCoinUnitsView extends ConsumerWidget { prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - final _coins = SupportedCoins.cryptocurrencies + final _coins = Coins.cryptocurrencies .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 74980942b..74c0eaabd 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 @@ -38,7 +38,7 @@ class ManageNodesView extends ConsumerStatefulWidget { } class _ManageNodesViewState extends ConsumerState { - List _coins = [...SupportedCoins.cryptocurrencies]; + List _coins = [...Coins.cryptocurrencies]; @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 6ece250f1..9e1acb9f2 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 @@ -774,7 +774,7 @@ abstract class SWB { return false; } - final coin = SupportedCoins.getCryptoCurrencyFor( + final coin = Coins.getCryptoCurrencyFor( walletbackup['coinName'] as String, ); @@ -1036,7 +1036,7 @@ abstract class SWB { for (final node in primaryNodes) { try { await nodeService.setPrimaryNodeFor( - coin: SupportedCoins.getCryptoCurrencyByPrettyName( + coin: Coins.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: SupportedCoins.getCryptoCurrencyByPrettyName( + coin: Coins.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 7546b84fc..808b3429f 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 @@ -99,7 +99,7 @@ class _DesktopAddressBook extends ConsumerState { ref.refresh(addressBookFilterProvider); // if (widget.coin == null) { - final coins = SupportedCoins.cryptocurrencies.toList(); + final coins = Coins.cryptocurrencies.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 a5c9fa0db..c144f72ed 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 @@ -194,7 +194,7 @@ class _StepScaffoldState extends ConsumerState { void sendFromStack() { final trade = ref.read(desktopExchangeModelProvider)!.trade!; final address = trade.payInAddress; - final coin = SupportedCoins.getCryptoCurrencyForTicker(trade.payInCurrency); + final coin = Coins.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 6f50a7347..ae5b46b1f 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 @@ -59,7 +59,7 @@ class _DesktopStep2State extends ConsumerState { bool isStackCoin(String ticker) { try { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.getCryptoCurrencyForTicker(ticker); return true; } on ArgumentError catch (_) { return false; @@ -68,7 +68,7 @@ class _DesktopStep2State extends ConsumerState { void selectRecipientAddressFromStack() async { try { - final coin = SupportedCoins.getCryptoCurrencyForTicker( + final coin = Coins.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.receiveTicker, ); @@ -101,7 +101,7 @@ class _DesktopStep2State extends ConsumerState { void selectRefundAddressFromStack() async { try { - final coin = SupportedCoins.getCryptoCurrencyForTicker( + final coin = Coins.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.sendTicker, ); @@ -131,7 +131,7 @@ class _DesktopStep2State extends ConsumerState { } void selectRecipientFromAddressBook() async { - final coin = SupportedCoins.getCryptoCurrencyForTicker( + final coin = Coins.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.receiveTicker, ); @@ -178,7 +178,7 @@ class _DesktopStep2State extends ConsumerState { } void selectRefundFromAddressBook() async { - final coin = SupportedCoins.getCryptoCurrencyForTicker( + final coin = Coins.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 4c579647e..0c7841c3c 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 @@ -37,7 +37,7 @@ class _DesktopStep4State extends ConsumerState { bool _isWalletCoinAndHasWallet(String ticker) { try { - final coin = SupportedCoins.getCryptoCurrencyForTicker(ticker); + final coin = Coins.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 0d4d88328..6a5e32248 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 @@ -40,8 +40,8 @@ class DesktopManageBlockExplorersDialog extends ConsumerWidget { ); final coins = showTestNet - ? SupportedCoins.cryptocurrencies - : SupportedCoins.cryptocurrencies + ? Coins.cryptocurrencies + : Coins.cryptocurrencies .where( (e) => 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 53cc15f37..01392b088 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart @@ -42,7 +42,7 @@ class NodesSettings extends ConsumerStatefulWidget { } class _NodesSettings extends ConsumerState { - List _coins = [...SupportedCoins.cryptocurrencies]; + List _coins = [...Coins.cryptocurrencies]; 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 e0e00dd5d..3eec5d140 100644 --- a/lib/services/buy/simplex/simplex_api.dart +++ b/lib/services/buy/simplex/simplex_api.dart @@ -405,7 +405,7 @@ bool isStackCoin(String? ticker) { if (ticker == null) return false; try { - SupportedCoins.getCryptoCurrencyForTicker(ticker); + Coins.getCryptoCurrencyForTicker(ticker); return true; } on ArgumentError catch (_) { return false; diff --git a/lib/services/node_service.dart b/lib/services/node_service.dart index 31e624be5..2e0d692ea 100644 --- a/lib/services/node_service.dart +++ b/lib/services/node_service.dart @@ -31,7 +31,7 @@ class NodeService extends ChangeNotifier { }); Future updateDefaults() async { - for (final defaultNode in SupportedCoins.cryptocurrencies.map( + for (final defaultNode in Coins.cryptocurrencies.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( - SupportedCoins.getCryptoCurrencyByPrettyName( + Coins.getCryptoCurrencyByPrettyName( defaultNode.coinName, ), ).isEmpty) { @@ -64,8 +64,7 @@ class NodeService extends ChangeNotifier { // check if a default node is the primary node for the crypto currency // and update it if needed - final coin = - SupportedCoins.getCryptoCurrencyByPrettyName(defaultNode.coinName); + final coin = Coins.getCryptoCurrencyByPrettyName(defaultNode.coinName); final primaryNode = getPrimaryNodeFor(currency: coin); if (primaryNode != null && primaryNode.id == defaultNode.id) { await setPrimaryNodeFor( @@ -206,8 +205,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 = - SupportedCoins.getCryptoCurrencyByPrettyName(editedNode.coinName); + final coin = Coins.getCryptoCurrencyByPrettyName(editedNode.coinName); final primaryNode = getPrimaryNodeFor(currency: coin); if (primaryNode?.id == editedNode.id) { await setPrimaryNodeFor( @@ -240,7 +238,7 @@ class NodeService extends ChangeNotifier { final map = jsonDecode(result as String); Logging.instance.log(map, level: LogLevel.Info); - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { 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 528fe9ae5..461b65ae0 100644 --- a/lib/services/notifications_service.dart +++ b/lib/services/notifications_service.dart @@ -129,7 +129,7 @@ class NotificationsService extends ChangeNotifier { for (final notification in _watchedTransactionNotifications) { try { final CryptoCurrency coin = - SupportedCoins.getCryptoCurrencyByPrettyName(notification.coinName); + Coins.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 e572f4b3f..e2ff7384b 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -48,7 +48,7 @@ class PriceAPI { ) async { final Map map = {}; - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { final entry = data[coin]; if (entry == null) { map[coin.prettyName] = ["0", 0.0]; @@ -68,12 +68,12 @@ class PriceAPI { {}; // init with 0 final result = { - for (final coin in SupportedCoins.cryptocurrencies) + for (final coin in Coins.cryptocurrencies) coin: Tuple2(Decimal.zero, 0.0), }; for (final entry in map.entries) { - result[SupportedCoins.getCryptoCurrencyByPrettyName( + result[Coins.getCryptoCurrencyByPrettyName( entry.key as String, )] = Tuple2( Decimal.parse(entry.value[0] as String), @@ -126,7 +126,7 @@ class PriceAPI { for (final map in coinGeckoData) { final String coinName = map["name"] as String; - final coin = SupportedCoins.getCryptoCurrencyByPrettyName(coinName); + final coin = Coins.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 15e5dc437..930099d74 100644 --- a/lib/services/price_service.dart +++ b/lib/services/price_service.dart @@ -30,8 +30,7 @@ class PriceService extends ChangeNotifier { Timer? _timer; final Map> _cachedPrices = { - for (final coin in SupportedCoins.cryptocurrencies) - coin: Tuple2(Decimal.zero, 0.0) + for (final coin in Coins.cryptocurrencies) coin: Tuple2(Decimal.zero, 0.0) }; final Map> _cachedTokenPrices = {}; diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index 8aab994d5..d2a496956 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -90,7 +90,7 @@ class WalletsService extends ChangeNotifier { mapped.removeWhere((name, dyn) { final jsonObject = Map.from(dyn as Map); try { - SupportedCoins.getCryptoCurrencyFor(jsonObject["coin"] as String); + Coins.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 index 70b6deae7..aea128b9c 100644 --- a/lib/supported_coins.dart +++ b/lib/supported_coins.dart @@ -21,7 +21,7 @@ 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 SupportedCoins { +class Coins { /// A List of our supported coins. static final List cryptocurrencies = [ Bitcoin(CryptoCurrencyNetwork.main), diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 74453c50c..e14e10dc7 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -867,7 +867,7 @@ class Prefs extends ChangeNotifier { } Future _setAmountUnits() async { - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { final unitIndex = await DB.instance.get( boxName: DB.boxNamePrefs, key: "amountUnitFor${coin.identifier}", @@ -900,7 +900,7 @@ class Prefs extends ChangeNotifier { } Future _setMaxDecimals() async { - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { 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 0e07b6426..b165649ff 100644 --- a/lib/wallets/isar/models/wallet_info.dart +++ b/lib/wallets/isar/models/wallet_info.dart @@ -96,7 +96,7 @@ class WalletInfo implements IsarId { } @ignore - CryptoCurrency get coin => SupportedCoins.getCryptoCurrencyFor(coinName); + CryptoCurrency get coin => Coins.getCryptoCurrencyFor(coinName); @ignore Balance get cachedBalance { @@ -407,7 +407,7 @@ class WalletInfo implements IsarId { this.cachedBalanceTertiaryString, this.otherDataJsonString, }) : assert( - SupportedCoins.cryptocurrencies + Coins.cryptocurrencies .map((e) => e.identifier) .contains(coinName), ); @@ -466,7 +466,7 @@ class WalletInfo implements IsarId { Map jsonObject, AddressType mainAddressType, ) { - final coin = SupportedCoins.getCryptoCurrencyFor( + final coin = Coins.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 a51233a0c..a91a735c5 100644 --- a/lib/wallets/isar/providers/all_wallets_info_provider.dart +++ b/lib/wallets/isar/providers/all_wallets_info_provider.dart @@ -27,7 +27,7 @@ final pAllWalletsInfoByCoin = Provider((ref) { } final List<({CryptoCurrency coin, List wallets})> results = []; - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { if (map[coin] != null) { results.add(map[coin]!); } diff --git a/lib/widgets/address_book_card.dart b/lib/widgets/address_book_card.dart index 8a795437f..f8f23da8d 100644 --- a/lib/widgets/address_book_card.dart +++ b/lib/widgets/address_book_card.dart @@ -72,7 +72,7 @@ class _AddressBookCardState extends ConsumerState { final List coins = []; - for (final coin in SupportedCoins.cryptocurrencies) { + for (final coin in Coins.cryptocurrencies) { 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 862585786..abd63b517 100644 --- a/lib/widgets/choose_coin_view.dart +++ b/lib/widgets/choose_coin_view.dart @@ -52,7 +52,7 @@ class ChooseCoinView extends ConsumerStatefulWidget { } class _ChooseCoinViewState extends ConsumerState { - List _coins = [...SupportedCoins.cryptocurrencies]; + List _coins = [...Coins.cryptocurrencies]; @override void initState() { diff --git a/test/services/node_service_test.dart b/test/services/node_service_test.dart index 78f20b51b..85ee80dbd 100644 --- a/test/services/node_service_test.dart +++ b/test/services/node_service_test.dart @@ -114,7 +114,7 @@ void main() { await service.updateDefaults(); expect( service.nodes.length, - SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length, + Coins.cryptocurrencies.map((e) => e.defaultNode).length, ); expect(fakeStore.interactions, 0); }); @@ -208,7 +208,7 @@ void main() { final service = NodeService(secureStorageInterface: fakeStore); final nodes = service.nodes; final defaults = - SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).toList(); + Coins.cryptocurrencies.map((e) => e.defaultNode).toList(); nodes.sort((a, b) => a.host.compareTo(b.host)); defaults.sort((a, b) => a.host.compareTo(b.host)); @@ -224,7 +224,7 @@ void main() { await service.add(nodeA, null, true); expect( service.nodes.length, - SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length + 1, + Coins.cryptocurrencies.map((e) => e.defaultNode).length + 1, ); expect(fakeStore.interactions, 0); }); @@ -235,7 +235,7 @@ void main() { await service.add(nodeA, "some password", true); expect( service.nodes.length, - SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length + 1, + Coins.cryptocurrencies.map((e) => e.defaultNode).length + 1, ); expect(fakeStore.interactions, 1); expect(fakeStore.writes, 1); @@ -293,7 +293,7 @@ void main() { expect( service.nodes.length, - SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length + 2, + Coins.cryptocurrencies.map((e) => e.defaultNode).length + 2, ); expect( service.nodes.where((element) => element.id == nodeB.id).length,