make it easy to comment out certain coins in app config to disable them

This commit is contained in:
julian 2024-05-21 12:48:48 -06:00
parent c9d4e57d65
commit e0abd97041
33 changed files with 417 additions and 317 deletions

View file

@ -1,3 +1,5 @@
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
abstract class AppConfig { abstract class AppConfig {
static const appName = prefix + _separator + suffix; static const appName = prefix + _separator + suffix;
@ -6,4 +8,27 @@ abstract class AppConfig {
static const _separator = " "; static const _separator = " ";
static const suffix = "Wallet"; static const suffix = "Wallet";
// 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,
];
} }

View file

@ -37,7 +37,7 @@ class ContactEntry {
@ignore @ignore
List<ContactAddressEntry> get addressesSorted { List<ContactAddressEntry> get addressesSorted {
final List<ContactAddressEntry> sorted = []; final List<ContactAddressEntry> sorted = [];
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
final slice = addresses.where((e) => e.coin == coin).toList(); final slice = addresses.where((e) => e.coin == coin).toList();
if (slice.isNotEmpty) { if (slice.isNotEmpty) {
slice.sort( slice.sort(

View file

@ -1548,7 +1548,8 @@ class StackTheme {
json["colors"]["box_shadows"]["home_view_button_bar"] == null json["colors"]["box_shadows"]["home_view_button_bar"] == null
? null ? null
: jsonEncode( : jsonEncode(
json["colors"]["box_shadows"]["home_view_button_bar"] as Map) json["colors"]["box_shadows"]["home_view_button_bar"] as Map,
)
..coinColorsJsonString = jsonEncode(json["colors"]['coin'] as Map) ..coinColorsJsonString = jsonEncode(json["colors"]['coin'] as Map)
..overlayInt = parseColor(json["colors"]["overlay"] as String) ..overlayInt = parseColor(json["colors"]["overlay"] as String)
..accentColorBlueInt = ..accentColorBlueInt =
@ -1587,7 +1588,8 @@ class StackTheme {
..buttonBackBorderSecondaryInt = ..buttonBackBorderSecondaryInt =
parseColor(json["colors"]["button_back_border_secondary"] as String) parseColor(json["colors"]["button_back_border_secondary"] as String)
..buttonBackBorderSecondaryDisabledInt = parseColor( ..buttonBackBorderSecondaryDisabledInt = parseColor(
json["colors"]["button_back_border_secondary_disabled"] as String) json["colors"]["button_back_border_secondary_disabled"] as String,
)
..numberBackDefaultInt = ..numberBackDefaultInt =
parseColor(json["colors"]["number_back_default"] as String) parseColor(json["colors"]["number_back_default"] as String)
..numpadBackDefaultInt = ..numpadBackDefaultInt =
@ -1621,7 +1623,8 @@ class StackTheme {
..buttonTextBorderlessInt = ..buttonTextBorderlessInt =
parseColor(json["colors"]["button_text_borderless"] as String) parseColor(json["colors"]["button_text_borderless"] as String)
..buttonTextBorderlessDisabledInt = parseColor( ..buttonTextBorderlessDisabledInt = parseColor(
json["colors"]["button_text_borderless_disabled"] as String) json["colors"]["button_text_borderless_disabled"] as String,
)
..numberTextDefaultInt = ..numberTextDefaultInt =
parseColor(json["colors"]["number_text_default"] as String) parseColor(json["colors"]["number_text_default"] as String)
..numpadTextDefaultInt = ..numpadTextDefaultInt =
@ -1629,9 +1632,11 @@ class StackTheme {
..bottomNavTextInt = ..bottomNavTextInt =
parseColor(json["colors"]["bottom_nav_text"] as String) parseColor(json["colors"]["bottom_nav_text"] as String)
..customTextButtonEnabledTextInt = parseColor( ..customTextButtonEnabledTextInt = parseColor(
json["colors"]["custom_text_button_enabled_text"] as String) json["colors"]["custom_text_button_enabled_text"] as String,
)
..customTextButtonDisabledTextInt = parseColor( ..customTextButtonDisabledTextInt = parseColor(
json["colors"]["custom_text_button_disabled_text"] as String) json["colors"]["custom_text_button_disabled_text"] as String,
)
..switchBGOnInt = parseColor(json["colors"]["switch_bg_on"] as String) ..switchBGOnInt = parseColor(json["colors"]["switch_bg_on"] as String)
..switchBGOffInt = parseColor(json["colors"]["switch_bg_off"] as String) ..switchBGOffInt = parseColor(json["colors"]["switch_bg_off"] as String)
..switchBGDisabledInt = ..switchBGDisabledInt =
@ -1651,7 +1656,8 @@ class StackTheme {
..stepIndicatorBGLinesInt = ..stepIndicatorBGLinesInt =
parseColor(json["colors"]["step_indicator_bg_lines"] as String) parseColor(json["colors"]["step_indicator_bg_lines"] as String)
..stepIndicatorBGLinesInactiveInt = parseColor( ..stepIndicatorBGLinesInactiveInt = parseColor(
json["colors"]["step_indicator_bg_lines_inactive"] as String) json["colors"]["step_indicator_bg_lines_inactive"] as String,
)
..stepIndicatorIconTextInt = ..stepIndicatorIconTextInt =
parseColor(json["colors"]["step_indicator_icon_text"] as String) parseColor(json["colors"]["step_indicator_icon_text"] as String)
..stepIndicatorIconNumberInt = ..stepIndicatorIconNumberInt =
@ -1687,7 +1693,8 @@ class StackTheme {
..bottomNavIconIconInt = ..bottomNavIconIconInt =
parseColor(json["colors"]["bottom_nav_icon_icon"] as String) parseColor(json["colors"]["bottom_nav_icon_icon"] as String)
..bottomNavIconIconHighlightedInt = parseColor( ..bottomNavIconIconHighlightedInt = parseColor(
json["colors"]["bottom_nav_icon_icon_highlighted"] as String) json["colors"]["bottom_nav_icon_icon_highlighted"] as String,
)
..topNavIconPrimaryInt = ..topNavIconPrimaryInt =
parseColor(json["colors"]["top_nav_icon_primary"] as String) parseColor(json["colors"]["top_nav_icon_primary"] as String)
..topNavIconGreenInt = ..topNavIconGreenInt =
@ -1717,13 +1724,17 @@ class StackTheme {
..textFieldSuccessBorderInt = ..textFieldSuccessBorderInt =
parseColor(json["colors"]["text_field_success_border"] as String) parseColor(json["colors"]["text_field_success_border"] as String)
..textFieldActiveSearchIconLeftInt = parseColor( ..textFieldActiveSearchIconLeftInt = parseColor(
json["colors"]["text_field_active_search_icon_left"] as String) json["colors"]["text_field_active_search_icon_left"] as String,
)
..textFieldDefaultSearchIconLeftInt = parseColor( ..textFieldDefaultSearchIconLeftInt = parseColor(
json["colors"]["text_field_default_search_icon_left"] as String) json["colors"]["text_field_default_search_icon_left"] as String,
)
..textFieldErrorSearchIconLeftInt = parseColor( ..textFieldErrorSearchIconLeftInt = parseColor(
json["colors"]["text_field_error_search_icon_left"] as String) json["colors"]["text_field_error_search_icon_left"] as String,
)
..textFieldSuccessSearchIconLeftInt = parseColor( ..textFieldSuccessSearchIconLeftInt = parseColor(
json["colors"]["text_field_success_search_icon_left"] as String) json["colors"]["text_field_success_search_icon_left"] as String,
)
..textFieldActiveTextInt = ..textFieldActiveTextInt =
parseColor(json["colors"]["text_field_active_text"] as String) parseColor(json["colors"]["text_field_active_text"] as String)
..textFieldDefaultTextInt = ..textFieldDefaultTextInt =
@ -1739,23 +1750,31 @@ class StackTheme {
..textFieldSuccessLabelInt = ..textFieldSuccessLabelInt =
parseColor(json["colors"]["text_field_success_label"] as String) parseColor(json["colors"]["text_field_success_label"] as String)
..textFieldActiveSearchIconRightInt = parseColor( ..textFieldActiveSearchIconRightInt = parseColor(
json["colors"]["text_field_active_search_icon_right"] as String) json["colors"]["text_field_active_search_icon_right"] as String,
)
..textFieldDefaultSearchIconRightInt = parseColor( ..textFieldDefaultSearchIconRightInt = parseColor(
json["colors"]["text_field_default_search_icon_right"] as String) json["colors"]["text_field_default_search_icon_right"] as String,
)
..textFieldErrorSearchIconRightInt = parseColor( ..textFieldErrorSearchIconRightInt = parseColor(
json["colors"]["text_field_error_search_icon_right"] as String) json["colors"]["text_field_error_search_icon_right"] as String,
)
..textFieldSuccessSearchIconRightInt = parseColor( ..textFieldSuccessSearchIconRightInt = parseColor(
json["colors"]["text_field_success_search_icon_right"] as String) json["colors"]["text_field_success_search_icon_right"] as String,
)
..settingsItem2ActiveBGInt = parseColor( ..settingsItem2ActiveBGInt = parseColor(
json["colors"]["settings_item_level_two_active_bg"] as String) json["colors"]["settings_item_level_two_active_bg"] as String,
)
..settingsItem2ActiveTextInt = parseColor( ..settingsItem2ActiveTextInt = parseColor(
json["colors"]["settings_item_level_two_active_text"] as String) json["colors"]["settings_item_level_two_active_text"] as String,
)
..settingsItem2ActiveSubInt = parseColor( ..settingsItem2ActiveSubInt = parseColor(
json["colors"]["settings_item_level_two_active_sub"] as String) json["colors"]["settings_item_level_two_active_sub"] as String,
)
..radioButtonIconBorderInt = ..radioButtonIconBorderInt =
parseColor(json["colors"]["radio_button_icon_border"] as String) parseColor(json["colors"]["radio_button_icon_border"] as String)
..radioButtonIconBorderDisabledInt = parseColor( ..radioButtonIconBorderDisabledInt = parseColor(
json["colors"]["radio_button_icon_border_disabled"] as String) json["colors"]["radio_button_icon_border_disabled"] as String,
)
..radioButtonBorderEnabledInt = ..radioButtonBorderEnabledInt =
parseColor(json["colors"]["radio_button_border_enabled"] as String) parseColor(json["colors"]["radio_button_border_enabled"] as String)
..radioButtonBorderDisabledInt = ..radioButtonBorderDisabledInt =
@ -1809,9 +1828,11 @@ class StackTheme {
..rateTypeToggleColorOffInt = ..rateTypeToggleColorOffInt =
parseColor(json["colors"]["rate_type_toggle_color_off"] as String) parseColor(json["colors"]["rate_type_toggle_color_off"] as String)
..rateTypeToggleDesktopColorOnInt = parseColor( ..rateTypeToggleDesktopColorOnInt = parseColor(
json["colors"]["rate_type_toggle_desktop_color_on"] as String) json["colors"]["rate_type_toggle_desktop_color_on"] as String,
)
..rateTypeToggleDesktopColorOffInt = parseColor( ..rateTypeToggleDesktopColorOffInt = parseColor(
json["colors"]["rate_type_toggle_desktop_color_off"] as String) json["colors"]["rate_type_toggle_desktop_color_off"] as String,
)
..ethTagTextInt = parseColor(json["colors"]["eth_tag_text"] as String) ..ethTagTextInt = parseColor(json["colors"]["eth_tag_text"] as String)
..ethTagBGInt = parseColor(json["colors"]["eth_tag_bg"] as String) ..ethTagBGInt = parseColor(json["colors"]["eth_tag_bg"] as String)
..ethWalletTagTextInt = ..ethWalletTagTextInt =
@ -1857,8 +1878,7 @@ class StackTheme {
final Map<String, Color> result = {}; final Map<String, Color> result = {};
for (final mainNetId for (final mainNetId in Coins.enabled.map((e) => e.mainNetId)) {
in Coins.cryptocurrencies.map((e) => e.mainNetId)) {
if (map[mainNetId] is String) { if (map[mainNetId] is String) {
result[mainNetId] = Color( result[mainNetId] = Color(
(map[mainNetId] as String).toBigIntFromHex.toInt(), (map[mainNetId] as String).toBigIntFromHex.toInt(),
@ -2176,7 +2196,7 @@ class ThemeAssetsV2 implements IThemeAssets {
final Map<String, String> result = {}; final Map<String, String> result = {};
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder; result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder;
} }
@ -2511,7 +2531,7 @@ class ThemeAssetsV3 implements IThemeAssets {
final Map<String, String> result = {}; final Map<String, String> result = {};
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder; result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder;
result[coin.mainNetId] = prependIfNeeded(result[coin.mainNetId]!); result[coin.mainNetId] = prependIfNeeded(result[coin.mainNetId]!);
} }

View file

@ -35,9 +35,6 @@ import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/default_eth_tokens.dart'; import 'package:stackwallet/utilities/default_eth_tokens.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -66,12 +63,10 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
String _searchTerm = ""; String _searchTerm = "";
final _coinsTestnet = [ final _coinsTestnet = [
...Coins.cryptocurrencies ...Coins.enabled.where((e) => e.network == CryptoCurrencyNetwork.test),
.where((e) => e.network == CryptoCurrencyNetwork.test),
]; ];
final _coins = [ final _coins = [
...Coins.cryptocurrencies ...Coins.enabled.where((e) => e.network == CryptoCurrencyNetwork.main),
.where((e) => e.network == CryptoCurrencyNetwork.main),
]; ];
final List<AddWalletListEntity> coinEntities = []; final List<AddWalletListEntity> coinEntities = [];
final List<EthTokenEntity> tokenEntities = []; final List<EthTokenEntity> tokenEntities = [];
@ -152,16 +147,18 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
coinEntities.addAll(_coinsTestnet.map((e) => CoinEntity(e))); coinEntities.addAll(_coinsTestnet.map((e) => CoinEntity(e)));
} }
if (Coins.enabled.whereType<Ethereum>().isNotEmpty) {
final contracts = final contracts =
MainDB.instance.getEthContracts().sortByName().findAllSync(); MainDB.instance.getEthContracts().sortByName().findAllSync();
if (contracts.isEmpty) { if (contracts.isEmpty) {
contracts.addAll(DefaultTokens.list); contracts.addAll(DefaultTokens.list);
MainDB.instance.putEthContracts(contracts).then( MainDB.instance.putEthContracts(contracts).then((value) =>
(value) => ref.read(priceAnd24hChangeNotifierProvider).updatePrice()); ref.read(priceAnd24hChangeNotifierProvider).updatePrice());
} }
tokenEntities.addAll(contracts.map((e) => EthTokenEntity(e))); tokenEntities.addAll(contracts.map((e) => EthTokenEntity(e)));
}
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
ref.refresh(addWalletSelectedEntityStateProvider); ref.refresh(addWalletSelectedEntityStateProvider);
@ -292,6 +289,7 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
initialState: ExpandableState.expanded, initialState: ExpandableState.expanded,
animationDurationMultiplier: 0.5, animationDurationMultiplier: 0.5,
), ),
if (tokenEntities.isNotEmpty)
ExpandingSubListItem( ExpandingSubListItem(
title: "Tokens", title: "Tokens",
entities: filter(_searchTerm, tokenEntities), entities: filter(_searchTerm, tokenEntities),

View file

@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
class AddWalletText extends StatelessWidget { class AddWalletText extends StatelessWidget {
const AddWalletText({Key? key, required this.isDesktop}) : super(key: key); const AddWalletText({super.key, required this.isDesktop});
final bool isDesktop; final bool isDesktop;

View file

@ -26,7 +26,6 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
import 'package:stackwallet/widgets/address_book_card.dart'; import 'package:stackwallet/widgets/address_book_card.dart';
@ -67,7 +66,7 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
ref.refresh(addressBookFilterProvider); ref.refresh(addressBookFilterProvider);
if (widget.coin == null) { if (widget.coin == null) {
final coins = [...Coins.cryptocurrencies]; final coins = [...Coins.enabled];
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
); );

View file

@ -16,7 +16,6 @@ import 'package:stackwallet/supported_coins.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
@ -41,7 +40,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
@override @override
void initState() { void initState() {
final coins = [...Coins.cryptocurrencies]; final coins = [...Coins.enabled];
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
); );

View file

@ -19,7 +19,6 @@ import 'package:stackwallet/themes/coin_image_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
class CoinSelectSheet extends StatelessWidget { class CoinSelectSheet extends StatelessWidget {
@ -28,7 +27,7 @@ class CoinSelectSheet extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final maxHeight = MediaQuery.of(context).size.height * 0.60; final maxHeight = MediaQuery.of(context).size.height * 0.60;
final coins_ = [...Coins.cryptocurrencies]; final coins_ = [...Coins.enabled];
coins_.removeWhere( coins_.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
); );

View file

@ -30,7 +30,6 @@ import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart';
import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart';
@ -40,11 +39,11 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
class NewContactAddressEntryForm extends ConsumerStatefulWidget { class NewContactAddressEntryForm extends ConsumerStatefulWidget {
const NewContactAddressEntryForm({ const NewContactAddressEntryForm({
Key? key, super.key,
required this.id, required this.id,
required this.barcodeScanner, required this.barcodeScanner,
required this.clipboard, required this.clipboard,
}) : super(key: key); });
final int id; final int id;
@ -74,7 +73,7 @@ class _NewContactAddressEntryFormState
..text = ref.read(addressEntryDataProvider(widget.id)).address ?? ""; ..text = ref.read(addressEntryDataProvider(widget.id)).address ?? "";
addressLabelFocusNode = FocusNode(); addressLabelFocusNode = FocusNode();
addressFocusNode = FocusNode(); addressFocusNode = FocusNode();
coins = [...Coins.cryptocurrencies]; coins = [...Coins.enabled];
super.initState(); super.initState();
} }
@ -91,7 +90,7 @@ class _NewContactAddressEntryFormState
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isDesktop = Util.isDesktop; final isDesktop = Util.isDesktop;
if (isDesktop) { if (isDesktop) {
coins = [...Coins.cryptocurrencies]; coins = [...Coins.enabled];
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
); );

View file

@ -1331,9 +1331,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
), ),
Expanded( Expanded(
child: AddressBookAddressChooser( child: AddressBookAddressChooser(
coin: Coins coin: Coins.enabled.firstWhere(
.cryptocurrencies
.firstWhere(
(e) => (e) =>
e.ticker.toLowerCase() == e.ticker.toLowerCase() ==
selectedCrypto!.ticker selectedCrypto!.ticker

View file

@ -32,9 +32,9 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
class CryptoSelectionView extends ConsumerStatefulWidget { class CryptoSelectionView extends ConsumerStatefulWidget {
const CryptoSelectionView({ const CryptoSelectionView({
Key? key, super.key,
required this.coins, required this.coins,
}) : super(key: key); });
final List<Crypto> coins; final List<Crypto> coins;
@ -70,7 +70,7 @@ class _CryptoSelectionViewState extends ConsumerState<CryptoSelectionView> {
coins.sort( coins.sort(
(a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase()), (a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase()),
); );
for (final coin in Coins.cryptocurrencies.reversed) { for (final coin in Coins.enabled.reversed) {
final index = coins.indexWhere( final index = coins.indexWhere(
(element) => element.ticker.toLowerCase() == coin.ticker.toLowerCase(), (element) => element.ticker.toLowerCase() == coin.ticker.toLowerCase(),
); );

View file

@ -44,12 +44,12 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
class ExchangeCurrencySelectionView extends StatefulWidget { class ExchangeCurrencySelectionView extends StatefulWidget {
const ExchangeCurrencySelectionView({ const ExchangeCurrencySelectionView({
Key? key, super.key,
required this.willChangeTicker, required this.willChangeTicker,
required this.pairedTicker, required this.pairedTicker,
required this.isFixedRate, required this.isFixedRate,
required this.willChangeIsSend, required this.willChangeIsSend,
}) : super(key: key); });
final String? willChangeTicker; final String? willChangeTicker;
final String? pairedTicker; final String? pairedTicker;
@ -365,7 +365,7 @@ class _ExchangeCurrencySelectionViewState
Flexible( Flexible(
child: Builder( child: Builder(
builder: (context) { builder: (context) {
final coins = Coins.cryptocurrencies.where( final coins = Coins.enabled.where(
(e) => (e) =>
e.ticker.toLowerCase() != e.ticker.toLowerCase() !=
widget.pairedTicker?.toLowerCase(), widget.pairedTicker?.toLowerCase(),

View file

@ -207,11 +207,11 @@ class _Step2ViewState extends ConsumerState<Step2View> {
text: "Choose from Stack", text: "Choose from Stack",
onTap: () { onTap: () {
try { try {
final coin = Coins.cryptocurrencies final coin = Coins.enabled.firstWhere(
.firstWhere((e) => (e) =>
e.ticker.toLowerCase() == e.ticker.toLowerCase() ==
model.receiveTicker model.receiveTicker.toLowerCase(),
.toLowerCase()); );
Navigator.of(context) Navigator.of(context)
.pushNamed( .pushNamed(
@ -258,7 +258,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
child: TextField( child: TextField(
onTap: () {}, onTap: () {},
key: const Key( key: const Key(
"recipientExchangeStep2ViewAddressFieldKey"), "recipientExchangeStep2ViewAddressFieldKey",
),
controller: _toController, controller: _toController,
readOnly: false, readOnly: false,
autocorrect: false, autocorrect: false,
@ -305,7 +306,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
_toController.text.isNotEmpty _toController.text.isNotEmpty
? TextFieldIconButton( ? TextFieldIconButton(
key: const Key( key: const Key(
"sendViewClearAddressFieldButtonKey"), "sendViewClearAddressFieldButtonKey",
),
onTap: () { onTap: () {
_toController.text = ""; _toController.text = "";
model.recipientAddress = model.recipientAddress =
@ -323,11 +325,13 @@ class _Step2ViewState extends ConsumerState<Step2View> {
) )
: TextFieldIconButton( : TextFieldIconButton(
key: const Key( key: const Key(
"sendViewPasteAddressFieldButtonKey"), "sendViewPasteAddressFieldButtonKey",
),
onTap: () async { onTap: () async {
final ClipboardData? data = final ClipboardData? data =
await clipboard.getData( await clipboard.getData(
Clipboard.kTextPlain); Clipboard.kTextPlain,
);
if (data?.text != null && if (data?.text != null &&
data!.text!.isNotEmpty) { data!.text!.isNotEmpty) {
final content = final content =
@ -357,12 +361,14 @@ class _Step2ViewState extends ConsumerState<Step2View> {
if (_toController.text.isEmpty) if (_toController.text.isEmpty)
TextFieldIconButton( TextFieldIconButton(
key: const Key( key: const Key(
"sendViewAddressBookButtonKey"), "sendViewAddressBookButtonKey",
),
onTap: () { onTap: () {
ref ref
.read( .read(
exchangeFlowIsActiveStateProvider exchangeFlowIsActiveStateProvider
.state) .state,
)
.state = true; .state = true;
Navigator.of(context) Navigator.of(context)
.pushNamed( .pushNamed(
@ -372,13 +378,15 @@ class _Step2ViewState extends ConsumerState<Step2View> {
ref ref
.read( .read(
exchangeFlowIsActiveStateProvider exchangeFlowIsActiveStateProvider
.state) .state,
)
.state = false; .state = false;
final address = ref final address = ref
.read( .read(
exchangeFromAddressBookAddressStateProvider exchangeFromAddressBookAddressStateProvider
.state) .state,
)
.state; .state;
if (address.isNotEmpty) { if (address.isNotEmpty) {
_toController.text = address; _toController.text = address;
@ -387,7 +395,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
ref ref
.read( .read(
exchangeFromAddressBookAddressStateProvider exchangeFromAddressBookAddressStateProvider
.state) .state,
)
.state = ""; .state = "";
} }
setState(() { setState(() {
@ -404,7 +413,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
if (_toController.text.isEmpty) if (_toController.text.isEmpty)
TextFieldIconButton( TextFieldIconButton(
key: const Key( key: const Key(
"sendViewScanQrButtonKey"), "sendViewScanQrButtonKey",
),
onTap: () async { onTap: () async {
try { try {
final qrResult = final qrResult =
@ -412,7 +422,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
final results = final results =
AddressUtils.parseUri( AddressUtils.parseUri(
qrResult.rawContent); qrResult.rawContent,
);
if (results.isNotEmpty) { if (results.isNotEmpty) {
// auto fill address // auto fill address
_toController.text = _toController.text =
@ -482,10 +493,11 @@ class _Step2ViewState extends ConsumerState<Step2View> {
text: "Choose from Stack", text: "Choose from Stack",
onTap: () { onTap: () {
try { try {
final coin = Coins.cryptocurrencies final coin = Coins.enabled.firstWhere(
.firstWhere((e) => (e) =>
e.ticker.toLowerCase() == e.ticker.toLowerCase() ==
model.sendTicker.toLowerCase()); model.sendTicker.toLowerCase(),
);
Navigator.of(context) Navigator.of(context)
.pushNamed( .pushNamed(
@ -512,8 +524,10 @@ class _Step2ViewState extends ConsumerState<Step2View> {
}); });
}); });
} catch (e, s) { } catch (e, s) {
Logging.instance.log("$e\n$s", Logging.instance.log(
level: LogLevel.Info); "$e\n$s",
level: LogLevel.Info,
);
} }
}, },
), ),
@ -530,7 +544,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
), ),
child: TextField( child: TextField(
key: const Key( key: const Key(
"refundExchangeStep2ViewAddressFieldKey"), "refundExchangeStep2ViewAddressFieldKey",
),
controller: _refundController, controller: _refundController,
readOnly: false, readOnly: false,
autocorrect: false, autocorrect: false,
@ -577,7 +592,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
_refundController.text.isNotEmpty _refundController.text.isNotEmpty
? TextFieldIconButton( ? TextFieldIconButton(
key: const Key( key: const Key(
"sendViewClearAddressFieldButtonKey"), "sendViewClearAddressFieldButtonKey",
),
onTap: () { onTap: () {
_refundController.text = ""; _refundController.text = "";
model.refundAddress = model.refundAddress =
@ -595,12 +611,13 @@ class _Step2ViewState extends ConsumerState<Step2View> {
) )
: TextFieldIconButton( : TextFieldIconButton(
key: const Key( key: const Key(
"sendViewPasteAddressFieldButtonKey"), "sendViewPasteAddressFieldButtonKey",
),
onTap: () async { onTap: () async {
final ClipboardData? data = final ClipboardData? data =
await clipboard.getData( await clipboard.getData(
Clipboard Clipboard.kTextPlain,
.kTextPlain); );
if (data?.text != null && if (data?.text != null &&
data! data!
.text!.isNotEmpty) { .text!.isNotEmpty) {
@ -631,12 +648,14 @@ class _Step2ViewState extends ConsumerState<Step2View> {
if (_refundController.text.isEmpty) if (_refundController.text.isEmpty)
TextFieldIconButton( TextFieldIconButton(
key: const Key( key: const Key(
"sendViewAddressBookButtonKey"), "sendViewAddressBookButtonKey",
),
onTap: () { onTap: () {
ref ref
.read( .read(
exchangeFlowIsActiveStateProvider exchangeFlowIsActiveStateProvider
.state) .state,
)
.state = true; .state = true;
Navigator.of(context) Navigator.of(context)
.pushNamed( .pushNamed(
@ -646,12 +665,14 @@ class _Step2ViewState extends ConsumerState<Step2View> {
ref ref
.read( .read(
exchangeFlowIsActiveStateProvider exchangeFlowIsActiveStateProvider
.state) .state,
)
.state = false; .state = false;
final address = ref final address = ref
.read( .read(
exchangeFromAddressBookAddressStateProvider exchangeFromAddressBookAddressStateProvider
.state) .state,
)
.state; .state;
if (address.isNotEmpty) { if (address.isNotEmpty) {
_refundController.text = _refundController.text =
@ -672,7 +693,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
if (_refundController.text.isEmpty) if (_refundController.text.isEmpty)
TextFieldIconButton( TextFieldIconButton(
key: const Key( key: const Key(
"sendViewScanQrButtonKey"), "sendViewScanQrButtonKey",
),
onTap: () async { onTap: () async {
try { try {
final qrResult = final qrResult =
@ -680,7 +702,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
final results = final results =
AddressUtils.parseUri( AddressUtils.parseUri(
qrResult.rawContent); qrResult.rawContent,
);
if (results.isNotEmpty) { if (results.isNotEmpty) {
// auto fill address // auto fill address
_refundController.text = _refundController.text =

View file

@ -35,8 +35,6 @@ import 'package:stackwallet/utilities/clipboard_interface.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.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/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/models/tx_data.dart'; import 'package:stackwallet/wallets/models/tx_data.dart';
@ -853,9 +851,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
.useMaterialPageRoute, .useMaterialPageRoute,
builder: builder:
(BuildContext context) { (BuildContext context) {
final coin = Coins final coin =
.cryptocurrencies Coins.enabled.firstWhere(
.firstWhere(
(e) => (e) =>
e.ticker e.ticker
.toLowerCase() == .toLowerCase() ==

View file

@ -11,7 +11,6 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
@ -45,7 +44,7 @@ class ManageCoinUnitsView extends ConsumerWidget {
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
); );
final _coins = Coins.cryptocurrencies final _coins = Coins.enabled
.where((e) => e is! Firo && e.network != CryptoCurrencyNetwork.test) .where((e) => e is! Firo && e.network != CryptoCurrencyNetwork.test)
.toList(); .toList();

View file

@ -20,7 +20,6 @@ import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -38,7 +37,7 @@ class ManageNodesView extends ConsumerStatefulWidget {
} }
class _ManageNodesViewState extends ConsumerState<ManageNodesView> { class _ManageNodesViewState extends ConsumerState<ManageNodesView> {
List<CryptoCurrency> _coins = [...Coins.cryptocurrencies]; List<CryptoCurrency> _coins = [...Coins.enabled];
@override @override
void initState() { void initState() {

View file

@ -28,7 +28,6 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
import 'package:stackwallet/widgets/address_book_card.dart'; import 'package:stackwallet/widgets/address_book_card.dart';
@ -99,7 +98,7 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
ref.refresh(addressBookFilterProvider); ref.refresh(addressBookFilterProvider);
// if (widget.coin == null) { // if (widget.coin == null) {
final coins = Coins.cryptocurrencies.toList(); final coins = Coins.enabled.toList();
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
); );

View file

@ -39,11 +39,9 @@ class DesktopManageBlockExplorersDialog extends ConsumerWidget {
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
); );
final coins = showTestNet final coins = Coins.enabled
? Coins.cryptocurrencies
: Coins.cryptocurrencies
.where( .where(
(e) => e.network == CryptoCurrencyNetwork.main, (e) => showTestNet || e.network == CryptoCurrencyNetwork.main,
) )
.toList(); .toList();

View file

@ -23,9 +23,6 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -33,7 +30,7 @@ import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:stackwallet/widgets/textfield_icon_button.dart';
class NodesSettings extends ConsumerStatefulWidget { class NodesSettings extends ConsumerStatefulWidget {
const NodesSettings({Key? key}) : super(key: key); const NodesSettings({super.key});
static const String routeName = "/settingsMenuNodes"; static const String routeName = "/settingsMenuNodes";
@ -42,7 +39,7 @@ class NodesSettings extends ConsumerStatefulWidget {
} }
class _NodesSettings extends ConsumerState<NodesSettings> { class _NodesSettings extends ConsumerState<NodesSettings> {
List<CryptoCurrency> _coins = [...Coins.cryptocurrencies]; List<CryptoCurrency> _coins = [...Coins.enabled];
late final TextEditingController searchNodeController; late final TextEditingController searchNodeController;
late final FocusNode searchNodeFocusNode; late final FocusNode searchNodeFocusNode;
@ -56,10 +53,12 @@ class _NodesSettings extends ConsumerState<NodesSettings> {
return coins; return coins;
} }
return coins return coins
.where((coin) => .where(
(coin) =>
coin.prettyName.contains(filter) || coin.prettyName.contains(filter) ||
coin.identifier.contains(filter) || coin.identifier.contains(filter) ||
coin.ticker.toLowerCase().contains(filter.toLowerCase())) coin.ticker.toLowerCase().contains(filter.toLowerCase()),
)
.toList(); .toList();
} }
@ -227,8 +226,10 @@ class _NodesSettings extends ConsumerState<NodesSettings> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final coin = coins[index]; final coin = coins[index];
final count = ref final count = ref
.watch(nodeServiceChangeNotifierProvider .watch(
.select((value) => value.getNodesFor(coin))) nodeServiceChangeNotifierProvider
.select((value) => value.getNodesFor(coin)),
)
.length; .length;
return Padding( return Padding(
@ -290,7 +291,8 @@ class _NodesSettings extends ConsumerState<NodesSettings> {
Text( Text(
"${coin.prettyName} nodes", "${coin.prettyName} nodes",
style: STextStyles.titleBold12( style: STextStyles.titleBold12(
context), context,
),
), ),
Text( Text(
count > 1 count > 1

View file

@ -31,7 +31,7 @@ class NodeService extends ChangeNotifier {
}); });
Future<void> updateDefaults() async { Future<void> updateDefaults() async {
for (final defaultNode in Coins.cryptocurrencies.map( for (final defaultNode in Coins.enabled.map(
(e) => e.defaultNode, (e) => e.defaultNode,
)) { )) {
final savedNode = DB.instance final savedNode = DB.instance
@ -238,7 +238,7 @@ class NodeService extends ChangeNotifier {
final map = jsonDecode(result as String); final map = jsonDecode(result as String);
Logging.instance.log(map, level: LogLevel.Info); Logging.instance.log(map, level: LogLevel.Info);
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
final nodeList = List<Map<String, dynamic>>.from( final nodeList = List<Map<String, dynamic>>.from(
map["nodes"][coin.identifier] as List? ?? [], map["nodes"][coin.identifier] as List? ?? [],
); );

View file

@ -48,7 +48,7 @@ class PriceAPI {
) async { ) async {
final Map<String, dynamic> map = {}; final Map<String, dynamic> map = {};
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
final entry = data[coin]; final entry = data[coin];
if (entry == null) { if (entry == null) {
map[coin.prettyName] = ["0", 0.0]; map[coin.prettyName] = ["0", 0.0];
@ -68,8 +68,7 @@ class PriceAPI {
{}; {};
// init with 0 // init with 0
final result = { final result = {
for (final coin in Coins.cryptocurrencies) for (final coin in Coins.enabled) coin: Tuple2(Decimal.zero, 0.0),
coin: Tuple2(Decimal.zero, 0.0),
}; };
for (final entry in map.entries) { for (final entry in map.entries) {

View file

@ -30,7 +30,7 @@ class PriceService extends ChangeNotifier {
Timer? _timer; Timer? _timer;
final Map<CryptoCurrency, Tuple2<Decimal, double>> _cachedPrices = { final Map<CryptoCurrency, Tuple2<Decimal, double>> _cachedPrices = {
for (final coin in Coins.cryptocurrencies) coin: Tuple2(Decimal.zero, 0.0) for (final coin in Coins.enabled) coin: Tuple2(Decimal.zero, 0.0),
}; };
final Map<String, Tuple2<Decimal, double>> _cachedTokenPrices = {}; final Map<String, Tuple2<Decimal, double>> _cachedTokenPrices = {};

View file

@ -10,19 +10,20 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_libmonero/monero/monero.dart' as monero;
import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:flutter_libmonero/wownero/wownero.dart' as wownero;
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/notifications_service.dart'; import 'package:stackwallet/services/notifications_service.dart';
import 'package:stackwallet/services/trade_sent_from_stack_service.dart'; import 'package:stackwallet/services/trade_sent_from_stack_service.dart';
import 'package:stackwallet/supported_coins.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart'; import 'package:stackwallet/wallets/wallet/wallet.dart';
@ -76,27 +77,31 @@ class Wallets {
await secureStorage.delete(key: Wallet.mnemonicKey(walletId: walletId)); await secureStorage.delete(key: Wallet.mnemonicKey(walletId: walletId));
await secureStorage.delete( await secureStorage.delete(
key: Wallet.mnemonicPassphraseKey(walletId: walletId)); key: Wallet.mnemonicPassphraseKey(walletId: walletId),
);
await secureStorage.delete(key: Wallet.privateKeyKey(walletId: walletId)); await secureStorage.delete(key: Wallet.privateKeyKey(walletId: walletId));
if (info.coin is Wownero) { if (info.coin is Wownero) {
final wowService = final wowService = wownero.wownero
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); .createWowneroWalletService(DB.instance.moneroWalletInfoBox);
await wowService.remove(walletId); await wowService.remove(walletId);
Logging.instance Logging.instance
.log("monero wallet: $walletId deleted", level: LogLevel.Info); .log("monero wallet: $walletId deleted", level: LogLevel.Info);
} else if (info.coin is Monero) { } else if (info.coin is Monero) {
final xmrService = final xmrService = monero.monero
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); .createMoneroWalletService(DB.instance.moneroWalletInfoBox);
await xmrService.remove(walletId); await xmrService.remove(walletId);
Logging.instance Logging.instance
.log("monero wallet: $walletId deleted", level: LogLevel.Info); .log("monero wallet: $walletId deleted", level: LogLevel.Info);
} else if (info.coin is Epiccash) { } else if (info.coin is Epiccash) {
final deleteResult = await deleteEpicWallet( final deleteResult = await deleteEpicWallet(
walletId: walletId, secureStore: secureStorage); walletId: walletId,
secureStore: secureStorage,
);
Logging.instance.log( Logging.instance.log(
"epic wallet: $walletId deleted with result: $deleteResult", "epic wallet: $walletId deleted with result: $deleteResult",
level: LogLevel.Info); level: LogLevel.Info,
);
} }
// delete wallet data in main db // delete wallet data in main db
@ -108,7 +113,9 @@ class Wallets {
// when delete was requested so instead of deleting now we mark the wallet // when delete was requested so instead of deleting now we mark the wallet
// as needs delete by adding it's id to a list which gets checked on app start // as needs delete by adding it's id to a list which gets checked on app start
await DB.instance.add<String>( await DB.instance.add<String>(
boxName: DB.boxNameWalletsToDeleteOnStart, value: walletId); boxName: DB.boxNameWalletsToDeleteOnStart,
value: walletId,
);
final lookupService = TradeSentFromStackService(); final lookupService = TradeSentFromStackService();
for (final lookup in lookupService.all) { for (final lookup in lookupService.all) {
@ -149,10 +156,12 @@ class Wallets {
// clear out any wallet hive boxes where the wallet was deleted in previous app run // clear out any wallet hive boxes where the wallet was deleted in previous app run
for (final walletId in DB.instance for (final walletId in DB.instance
.values<String>(boxName: DB.boxNameWalletsToDeleteOnStart)) { .values<String>(boxName: DB.boxNameWalletsToDeleteOnStart)) {
await mainDB.isar.writeTxn(() async => await mainDB.isar.walletInfo await mainDB.isar.writeTxn(
() async => await mainDB.isar.walletInfo
.where() .where()
.walletIdEqualTo(walletId) .walletIdEqualTo(walletId)
.deleteAll()); .deleteAll(),
);
} }
// clear list // clear list
await DB.instance await DB.instance
@ -210,11 +219,13 @@ class Wallets {
if (wallet is CwBasedInterface) { if (wallet is CwBasedInterface) {
// walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync)); // walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync));
} else { } else {
walletInitFutures.add(wallet.init().then((_) { walletInitFutures.add(
wallet.init().then((_) {
if (shouldSetAutoSync) { if (shouldSetAutoSync) {
wallet.shouldAutoSync = true; wallet.shouldAutoSync = true;
} }
})); }),
);
} }
_wallets[wallet.walletId] = wallet; _wallets[wallet.walletId] = wallet;
@ -251,10 +262,12 @@ class Wallets {
// clear out any wallet hive boxes where the wallet was deleted in previous app run // clear out any wallet hive boxes where the wallet was deleted in previous app run
for (final walletId in DB.instance for (final walletId in DB.instance
.values<String>(boxName: DB.boxNameWalletsToDeleteOnStart)) { .values<String>(boxName: DB.boxNameWalletsToDeleteOnStart)) {
await mainDB.isar.writeTxn(() async => await mainDB.isar.walletInfo await mainDB.isar.writeTxn(
() async => await mainDB.isar.walletInfo
.where() .where()
.walletIdEqualTo(walletId) .walletIdEqualTo(walletId)
.deleteAll()); .deleteAll(),
);
} }
// clear list // clear list
await DB.instance await DB.instance
@ -346,10 +359,12 @@ class Wallets {
.toList(); .toList();
if (walletInitFutures.isNotEmpty && walletsToInitLinearly.isNotEmpty) { if (walletInitFutures.isNotEmpty && walletsToInitLinearly.isNotEmpty) {
unawaited(Future.wait([ unawaited(
Future.wait([
_initLinearly(walletsToInitLinearly), _initLinearly(walletsToInitLinearly),
...walletInitFutures, ...walletInitFutures,
])); ]),
);
} else if (walletInitFutures.isNotEmpty) { } else if (walletInitFutures.isNotEmpty) {
unawaited(Future.wait(walletInitFutures)); unawaited(Future.wait(walletInitFutures));
} else if (walletsToInitLinearly.isNotEmpty) { } else if (walletsToInitLinearly.isNotEmpty) {
@ -370,16 +385,25 @@ class Wallets {
// clear out any wallet hive boxes where the wallet was deleted in previous app run // clear out any wallet hive boxes where the wallet was deleted in previous app run
for (final walletId in DB.instance for (final walletId in DB.instance
.values<String>(boxName: DB.boxNameWalletsToDeleteOnStart)) { .values<String>(boxName: DB.boxNameWalletsToDeleteOnStart)) {
await mainDB.isar.writeTxn(() async => await mainDB.isar.walletInfo await mainDB.isar.writeTxn(
() async => await mainDB.isar.walletInfo
.where() .where()
.walletIdEqualTo(walletId) .walletIdEqualTo(walletId)
.deleteAll()); .deleteAll(),
);
} }
// clear list // clear list
await DB.instance await DB.instance
.deleteAll<String>(boxName: DB.boxNameWalletsToDeleteOnStart); .deleteAll<String>(boxName: DB.boxNameWalletsToDeleteOnStart);
final walletInfoList = await mainDB.isar.walletInfo.where().findAll(); final walletInfoList = await mainDB.isar.walletInfo
.where()
.filter()
.anyOf<String, CryptoCurrency>(
Coins.enabled.map((e) => e.identifier),
(q, element) => q.coinNameMatches(element),
)
.findAll();
if (walletInfoList.isEmpty) { if (walletInfoList.isEmpty) {
return; return;
} }
@ -552,11 +576,13 @@ class Wallets {
if (wallet is CwBasedInterface) { if (wallet is CwBasedInterface) {
// walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync)); // walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync));
} else { } else {
walletInitFutures.add(wallet.init().then((_) { walletInitFutures.add(
wallet.init().then((_) {
// if (shouldSetAutoSync) { // if (shouldSetAutoSync) {
// wallet.shouldAutoSync = true; // wallet.shouldAutoSync = true;
// } // }
})); }),
);
} }
} }
@ -596,6 +622,7 @@ class Wallets {
Future<void> _deleteWallet(String walletId) async { Future<void> _deleteWallet(String walletId) async {
// TODO proper clean up of other wallet data in addition to the following // TODO proper clean up of other wallet data in addition to the following
await mainDB.isar.writeTxn( await mainDB.isar.writeTxn(
() async => await mainDB.isar.walletInfo.deleteByWalletId(walletId)); () async => await mainDB.isar.walletInfo.deleteByWalletId(walletId),
);
} }
} }

View file

@ -1,29 +1,17 @@
import 'package:stackwallet/wallets/crypto_currency/coins/banano.dart'; import 'package:stackwallet/app_config.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/ecash.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/litecoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/namecoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/nano.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/particl.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/peercoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/solana.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/coins/wownero.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart';
/// The supported coins. Eventually move away from the Coin enum /// The supported coins. Eventually move away from the Coin enum
class Coins { class Coins {
/// A List of our supported coins. /// A List of enabled coins.
static final List<CryptoCurrency> cryptocurrencies = [ static List<CryptoCurrency> get enabled => all
.where(
(element) => AppConfig.supportedCoins.contains(element.runtimeType))
.toList();
/// A List of all implemented coins.
static final List<CryptoCurrency> all = [
Bitcoin(CryptoCurrencyNetwork.main), Bitcoin(CryptoCurrencyNetwork.main),
BitcoinFrost(CryptoCurrencyNetwork.main), BitcoinFrost(CryptoCurrencyNetwork.main),
Litecoin(CryptoCurrencyNetwork.main), Litecoin(CryptoCurrencyNetwork.main),
@ -54,7 +42,7 @@ class Coins {
]; ];
static CryptoCurrency getCryptoCurrencyFor(String coinIdentifier) => static CryptoCurrency getCryptoCurrencyFor(String coinIdentifier) =>
cryptocurrencies.firstWhere( all.firstWhere(
(e) => e.identifier == coinIdentifier, (e) => e.identifier == coinIdentifier,
); );
@ -63,7 +51,7 @@ class Coins {
bool caseInsensitive = true, bool caseInsensitive = true,
}) { }) {
final _ticker = caseInsensitive ? ticker.toLowerCase() : ticker; final _ticker = caseInsensitive ? ticker.toLowerCase() : ticker;
return cryptocurrencies.firstWhere( return all.firstWhere(
caseInsensitive caseInsensitive
? (e) => e.ticker.toLowerCase() == _ticker && e is! FrostCurrency ? (e) => e.ticker.toLowerCase() == _ticker && e is! FrostCurrency
: (e) => e.ticker == _ticker && e is! FrostCurrency, : (e) => e.ticker == _ticker && e is! FrostCurrency,
@ -75,7 +63,7 @@ class Coins {
static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) { static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) {
final name = prettyName.replaceAll(" ", "").toLowerCase(); final name = prettyName.replaceAll(" ", "").toLowerCase();
try { try {
return cryptocurrencies.firstWhere( return all.firstWhere(
(e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName, (e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName,
); );
} catch (_) { } catch (_) {

View file

@ -85,7 +85,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "lastUnlockedTimeout", key: "lastUnlockedTimeout",
value: lastUnlockedTimeout); value: lastUnlockedTimeout,);
_lastUnlockedTimeout = lastUnlockedTimeout; _lastUnlockedTimeout = lastUnlockedTimeout;
notifyListeners(); notifyListeners();
} }
@ -93,7 +93,7 @@ class Prefs extends ChangeNotifier {
Future<int> _getLastUnlockedTimeout() async { Future<int> _getLastUnlockedTimeout() async {
return (DB.instance.get<dynamic>( return (DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "lastUnlockedTimeout")) as int? ?? boxName: DB.boxNamePrefs, key: "lastUnlockedTimeout",)) as int? ??
60; 60;
} }
@ -106,7 +106,7 @@ class Prefs extends ChangeNotifier {
set lastUnlocked(int lastUnlocked) { set lastUnlocked(int lastUnlocked) {
if (_lastUnlocked != lastUnlocked) { if (_lastUnlocked != lastUnlocked) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "lastUnlocked", value: lastUnlocked); boxName: DB.boxNamePrefs, key: "lastUnlocked", value: lastUnlocked,);
_lastUnlocked = lastUnlocked; _lastUnlocked = lastUnlocked;
notifyListeners(); notifyListeners();
} }
@ -114,7 +114,7 @@ class Prefs extends ChangeNotifier {
Future<int> _getLastUnlocked() async { Future<int> _getLastUnlocked() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "lastUnlocked") as int? ?? boxName: DB.boxNamePrefs, key: "lastUnlocked",) as int? ??
0; 0;
} }
@ -133,13 +133,13 @@ class Prefs extends ChangeNotifier {
await DB.instance.put<dynamic>( await DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "currentNotificationId", key: "currentNotificationId",
value: _currentNotificationId); value: _currentNotificationId,);
notifyListeners(); notifyListeners();
} }
Future<int> _getCurrentNotificationIndex() async { Future<int> _getCurrentNotificationIndex() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "currentNotificationId") as int? ?? boxName: DB.boxNamePrefs, key: "currentNotificationId",) as int? ??
0; 0;
} }
@ -154,7 +154,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "walletIdsSyncOnStartup", key: "walletIdsSyncOnStartup",
value: walletIdsSyncOnStartup); value: walletIdsSyncOnStartup,);
_walletIdsSyncOnStartup = walletIdsSyncOnStartup; _walletIdsSyncOnStartup = walletIdsSyncOnStartup;
notifyListeners(); notifyListeners();
} }
@ -162,7 +162,7 @@ class Prefs extends ChangeNotifier {
Future<List<String>> _getWalletIdsSyncOnStartup() async { Future<List<String>> _getWalletIdsSyncOnStartup() async {
final list = await DB.instance.get<dynamic>( final list = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "walletIdsSyncOnStartup") as List? ?? boxName: DB.boxNamePrefs, key: "walletIdsSyncOnStartup",) as List? ??
[]; [];
return List<String>.from(list); return List<String>.from(list);
} }
@ -178,7 +178,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "syncTypeIndex", key: "syncTypeIndex",
value: syncType.index); value: syncType.index,);
_syncType = syncType; _syncType = syncType;
notifyListeners(); notifyListeners();
} }
@ -186,7 +186,7 @@ class Prefs extends ChangeNotifier {
Future<SyncingType> _getSyncType() async { Future<SyncingType> _getSyncType() async {
final int index = await DB.instance.get<dynamic>( final int index = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "syncTypeIndex") as int? ?? boxName: DB.boxNamePrefs, key: "syncTypeIndex",) as int? ??
SyncingType.allWalletsOnStartup.index; SyncingType.allWalletsOnStartup.index;
return SyncingType.values[index]; return SyncingType.values[index];
} }
@ -200,7 +200,7 @@ class Prefs extends ChangeNotifier {
set wifiOnly(bool wifiOnly) { set wifiOnly(bool wifiOnly) {
if (_wifiOnly != wifiOnly) { if (_wifiOnly != wifiOnly) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "wifiOnly", value: wifiOnly); boxName: DB.boxNamePrefs, key: "wifiOnly", value: wifiOnly,);
_wifiOnly = wifiOnly; _wifiOnly = wifiOnly;
notifyListeners(); notifyListeners();
} }
@ -223,7 +223,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "showFavoriteWallets", key: "showFavoriteWallets",
value: showFavoriteWallets); value: showFavoriteWallets,);
_showFavoriteWallets = showFavoriteWallets; _showFavoriteWallets = showFavoriteWallets;
notifyListeners(); notifyListeners();
} }
@ -231,7 +231,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getShowFavoriteWallets() async { Future<bool> _getShowFavoriteWallets() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "showFavoriteWallets") as bool? ?? boxName: DB.boxNamePrefs, key: "showFavoriteWallets",) as bool? ??
true; true;
} }
@ -244,7 +244,7 @@ class Prefs extends ChangeNotifier {
set language(String newLanguage) { set language(String newLanguage) {
if (_language != newLanguage) { if (_language != newLanguage) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "language", value: newLanguage); boxName: DB.boxNamePrefs, key: "language", value: newLanguage,);
_language = newLanguage; _language = newLanguage;
notifyListeners(); notifyListeners();
} }
@ -252,7 +252,7 @@ class Prefs extends ChangeNotifier {
Future<String> _getPreferredLanguage() async { Future<String> _getPreferredLanguage() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "language") as String? ?? boxName: DB.boxNamePrefs, key: "language",) as String? ??
Language.englishUS.description; Language.englishUS.description;
} }
@ -265,7 +265,7 @@ class Prefs extends ChangeNotifier {
set currency(String newCurrency) { set currency(String newCurrency) {
if (currency != newCurrency) { if (currency != newCurrency) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "currency", value: newCurrency); boxName: DB.boxNamePrefs, key: "currency", value: newCurrency,);
_currency = newCurrency; _currency = newCurrency;
notifyListeners(); notifyListeners();
} }
@ -273,7 +273,7 @@ class Prefs extends ChangeNotifier {
Future<String> _getPreferredCurrency() async { Future<String> _getPreferredCurrency() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "currency") as String? ?? boxName: DB.boxNamePrefs, key: "currency",) as String? ??
"USD"; "USD";
} }
@ -327,7 +327,7 @@ class Prefs extends ChangeNotifier {
set randomizePIN(bool randomizePIN) { set randomizePIN(bool randomizePIN) {
if (_randomizePIN != randomizePIN) { if (_randomizePIN != randomizePIN) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "randomizePIN", value: randomizePIN); boxName: DB.boxNamePrefs, key: "randomizePIN", value: randomizePIN,);
_randomizePIN = randomizePIN; _randomizePIN = randomizePIN;
notifyListeners(); notifyListeners();
} }
@ -335,7 +335,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getRandomizePIN() async { Future<bool> _getRandomizePIN() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "randomizePIN") as bool? ?? boxName: DB.boxNamePrefs, key: "randomizePIN",) as bool? ??
false; false;
} }
@ -348,7 +348,7 @@ class Prefs extends ChangeNotifier {
set useBiometrics(bool useBiometrics) { set useBiometrics(bool useBiometrics) {
if (_useBiometrics != useBiometrics) { if (_useBiometrics != useBiometrics) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "useBiometrics", value: useBiometrics); boxName: DB.boxNamePrefs, key: "useBiometrics", value: useBiometrics,);
_useBiometrics = useBiometrics; _useBiometrics = useBiometrics;
notifyListeners(); notifyListeners();
} }
@ -356,7 +356,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getUseBiometrics() async { Future<bool> _getUseBiometrics() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "useBiometrics") as bool? ?? boxName: DB.boxNamePrefs, key: "useBiometrics",) as bool? ??
false; false;
} }
@ -390,7 +390,7 @@ class Prefs extends ChangeNotifier {
set familiarity(int familiarity) { set familiarity(int familiarity) {
if (_familiarity != familiarity) { if (_familiarity != familiarity) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "familiarity", value: familiarity); boxName: DB.boxNamePrefs, key: "familiarity", value: familiarity,);
_familiarity = familiarity; _familiarity = familiarity;
notifyListeners(); notifyListeners();
} }
@ -398,7 +398,7 @@ class Prefs extends ChangeNotifier {
Future<int> _getHasFamiliarity() async { Future<int> _getHasFamiliarity() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "familiarity") as int? ?? boxName: DB.boxNamePrefs, key: "familiarity",) as int? ??
0; 0;
} }
@ -439,7 +439,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "showTestNetCoins", key: "showTestNetCoins",
value: showTestNetCoins); value: showTestNetCoins,);
_showTestNetCoins = showTestNetCoins; _showTestNetCoins = showTestNetCoins;
notifyListeners(); notifyListeners();
} }
@ -447,7 +447,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getShowTestNetCoins() async { Future<bool> _getShowTestNetCoins() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "showTestNetCoins") as bool? ?? boxName: DB.boxNamePrefs, key: "showTestNetCoins",) as bool? ??
false; false;
} }
@ -463,7 +463,7 @@ class Prefs extends ChangeNotifier {
.put<dynamic>( .put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "isAutoBackupEnabled", key: "isAutoBackupEnabled",
value: isAutoBackupEnabled) value: isAutoBackupEnabled,)
.then((_) { .then((_) {
_isAutoBackupEnabled = isAutoBackupEnabled; _isAutoBackupEnabled = isAutoBackupEnabled;
notifyListeners(); notifyListeners();
@ -473,7 +473,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getIsAutoBackupEnabled() async { Future<bool> _getIsAutoBackupEnabled() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "isAutoBackupEnabled") as bool? ?? boxName: DB.boxNamePrefs, key: "isAutoBackupEnabled",) as bool? ??
false; false;
} }
@ -488,7 +488,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "autoBackupLocation", key: "autoBackupLocation",
value: autoBackupLocation); value: autoBackupLocation,);
_autoBackupLocation = autoBackupLocation; _autoBackupLocation = autoBackupLocation;
notifyListeners(); notifyListeners();
} }
@ -496,7 +496,7 @@ class Prefs extends ChangeNotifier {
Future<String?> _getAutoBackupLocation() async { Future<String?> _getAutoBackupLocation() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "autoBackupLocation") as String?; boxName: DB.boxNamePrefs, key: "autoBackupLocation",) as String?;
} }
// auto backup frequency type // auto backup frequency type
@ -513,19 +513,19 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "backupFrequencyType", key: "backupFrequencyType",
value: "10Min"); value: "10Min",);
break; break;
case BackupFrequencyType.everyAppStart: case BackupFrequencyType.everyAppStart:
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "backupFrequencyType", key: "backupFrequencyType",
value: "onStart"); value: "onStart",);
break; break;
case BackupFrequencyType.afterClosingAWallet: case BackupFrequencyType.afterClosingAWallet:
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "backupFrequencyType", key: "backupFrequencyType",
value: "onWalletClose"); value: "onWalletClose",);
break; break;
} }
_backupFrequencyType = backupFrequencyType; _backupFrequencyType = backupFrequencyType;
@ -535,7 +535,7 @@ class Prefs extends ChangeNotifier {
Future<BackupFrequencyType> _getBackupFrequencyType() async { Future<BackupFrequencyType> _getBackupFrequencyType() async {
String? rate = await DB.instance.get<dynamic>( String? rate = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "backupFrequencyType") as String?; boxName: DB.boxNamePrefs, key: "backupFrequencyType",) as String?;
rate ??= "10Min"; rate ??= "10Min";
switch (rate) { switch (rate) {
case "10Min": case "10Min":
@ -560,7 +560,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "lastAutoBackup", key: "lastAutoBackup",
value: lastAutoBackup); value: lastAutoBackup,);
_lastAutoBackup = lastAutoBackup; _lastAutoBackup = lastAutoBackup;
notifyListeners(); notifyListeners();
} }
@ -568,7 +568,7 @@ class Prefs extends ChangeNotifier {
Future<DateTime?> _getLastAutoBackup() async { Future<DateTime?> _getLastAutoBackup() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "autoBackupFileUri") as DateTime?; boxName: DB.boxNamePrefs, key: "autoBackupFileUri",) as DateTime?;
} }
// auto backup // auto backup
@ -583,7 +583,7 @@ class Prefs extends ChangeNotifier {
.put<dynamic>( .put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "hideBlockExplorerWarning", key: "hideBlockExplorerWarning",
value: hideBlockExplorerWarning) value: hideBlockExplorerWarning,)
.then((_) { .then((_) {
_hideBlockExplorerWarning = hideBlockExplorerWarning; _hideBlockExplorerWarning = hideBlockExplorerWarning;
notifyListeners(); notifyListeners();
@ -594,7 +594,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getHideBlockExplorerWarning() async { Future<bool> _getHideBlockExplorerWarning() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "hideBlockExplorerWarning") as bool? ?? key: "hideBlockExplorerWarning",) as bool? ??
false; false;
} }
@ -610,7 +610,7 @@ class Prefs extends ChangeNotifier {
.put<dynamic>( .put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "gotoWalletOnStartup", key: "gotoWalletOnStartup",
value: gotoWalletOnStartup) value: gotoWalletOnStartup,)
.then((_) { .then((_) {
_gotoWalletOnStartup = gotoWalletOnStartup; _gotoWalletOnStartup = gotoWalletOnStartup;
notifyListeners(); notifyListeners();
@ -620,7 +620,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getGotoWalletOnStartup() async { Future<bool> _getGotoWalletOnStartup() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "gotoWalletOnStartup") as bool? ?? boxName: DB.boxNamePrefs, key: "gotoWalletOnStartup",) as bool? ??
false; false;
} }
@ -635,7 +635,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "startupWalletId", key: "startupWalletId",
value: startupWalletId); value: startupWalletId,);
_startupWalletId = startupWalletId; _startupWalletId = startupWalletId;
notifyListeners(); notifyListeners();
} }
@ -643,7 +643,7 @@ class Prefs extends ChangeNotifier {
Future<String?> _getStartupWalletId() async { Future<String?> _getStartupWalletId() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "startupWalletId") as String?; boxName: DB.boxNamePrefs, key: "startupWalletId",) as String?;
} }
// incognito mode off by default // incognito mode off by default
@ -658,7 +658,7 @@ class Prefs extends ChangeNotifier {
.put<dynamic>( .put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "externalCalls", key: "externalCalls",
value: externalCalls) value: externalCalls,)
.then((_) { .then((_) {
_externalCalls = externalCalls; _externalCalls = externalCalls;
notifyListeners(); notifyListeners();
@ -668,7 +668,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getHasExternalCalls() async { Future<bool> _getHasExternalCalls() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "externalCalls") as bool? ?? boxName: DB.boxNamePrefs, key: "externalCalls",) as bool? ??
true; true;
} }
@ -718,7 +718,7 @@ class Prefs extends ChangeNotifier {
Future<void> saveSignupEpoch(int signupEpoch) async { Future<void> saveSignupEpoch(int signupEpoch) async {
_signupEpoch = signupEpoch; _signupEpoch = signupEpoch;
await DB.instance.put<dynamic>( await DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch); boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch,);
// notifyListeners(); // notifyListeners();
} }
@ -733,7 +733,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "enableCoinControl", key: "enableCoinControl",
value: enableCoinControl); value: enableCoinControl,);
_enableCoinControl = enableCoinControl; _enableCoinControl = enableCoinControl;
notifyListeners(); notifyListeners();
} }
@ -741,7 +741,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getEnableCoinControl() async { Future<bool> _getEnableCoinControl() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "enableCoinControl") as bool? ?? boxName: DB.boxNamePrefs, key: "enableCoinControl",) as bool? ??
false; false;
} }
@ -756,7 +756,7 @@ class Prefs extends ChangeNotifier {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "enableSystemBrightness", key: "enableSystemBrightness",
value: enableSystemBrightness); value: enableSystemBrightness,);
_enableSystemBrightness = enableSystemBrightness; _enableSystemBrightness = enableSystemBrightness;
notifyListeners(); notifyListeners();
} }
@ -764,7 +764,7 @@ class Prefs extends ChangeNotifier {
Future<bool> _getEnableSystemBrightness() async { Future<bool> _getEnableSystemBrightness() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "enableSystemBrightness") as bool? ?? boxName: DB.boxNamePrefs, key: "enableSystemBrightness",) as bool? ??
false; false;
} }
@ -854,7 +854,7 @@ class Prefs extends ChangeNotifier {
_amountUnits[coin] ?? AmountUnit.normal; _amountUnits[coin] ?? AmountUnit.normal;
void updateAmountUnit( void updateAmountUnit(
{required CryptoCurrency coin, required AmountUnit amountUnit}) { {required CryptoCurrency coin, required AmountUnit amountUnit,}) {
if (this.amountUnit(coin) != amountUnit) { if (this.amountUnit(coin) != amountUnit) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
@ -867,7 +867,7 @@ class Prefs extends ChangeNotifier {
} }
Future<void> _setAmountUnits() async { Future<void> _setAmountUnits() async {
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
final unitIndex = await DB.instance.get<dynamic>( final unitIndex = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "amountUnitFor${coin.identifier}", key: "amountUnitFor${coin.identifier}",
@ -900,7 +900,7 @@ class Prefs extends ChangeNotifier {
} }
Future<void> _setMaxDecimals() async { Future<void> _setMaxDecimals() async {
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
final decimals = await DB.instance.get<dynamic>( final decimals = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "maxDecimalsFor${coin.identifier}", key: "maxDecimalsFor${coin.identifier}",

View file

@ -2,6 +2,27 @@ import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/node_model.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/banano.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/ecash.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/litecoin.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/monero.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/namecoin.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/nano.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/particl.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/peercoin.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/solana.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/stellar.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/tezos.dart';
export 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
export 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
enum CryptoCurrencyNetwork { enum CryptoCurrencyNetwork {
main, main,
test, test,

View file

@ -407,9 +407,7 @@ class WalletInfo implements IsarId {
this.cachedBalanceTertiaryString, this.cachedBalanceTertiaryString,
this.otherDataJsonString, this.otherDataJsonString,
}) : assert( }) : assert(
Coins.cryptocurrencies Coins.enabled.map((e) => e.identifier).contains(coinName),
.map((e) => e.identifier)
.contains(coinName),
); );
WalletInfo copyWith({ WalletInfo copyWith({

View file

@ -27,7 +27,7 @@ final pAllWalletsInfoByCoin = Provider((ref) {
} }
final List<({CryptoCurrency coin, List<WalletInfo> wallets})> results = []; final List<({CryptoCurrency coin, List<WalletInfo> wallets})> results = [];
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
if (map[coin] != null) { if (map[coin] != null) {
results.add(map[coin]!); results.add(map[coin]!);
} }
@ -42,7 +42,14 @@ final _pAllWalletsInfo = ChangeNotifierProvider((ref) {
if (_globalInstance == null) { if (_globalInstance == null) {
final isar = ref.watch(mainDBProvider).isar; final isar = ref.watch(mainDBProvider).isar;
_globalInstance = _WalletInfoWatcher( _globalInstance = _WalletInfoWatcher(
isar.walletInfo.where().findAllSync(), isar.walletInfo
.where()
.filter()
.anyOf<String, CryptoCurrency>(
Coins.enabled.map((e) => e.identifier),
(q, element) => q.coinNameMatches(element),
)
.findAllSync(),
isar, isar,
); );
} }
@ -60,7 +67,15 @@ class _WalletInfoWatcher extends ChangeNotifier {
_WalletInfoWatcher(this._value, Isar isar) { _WalletInfoWatcher(this._value, Isar isar) {
_streamSubscription = _streamSubscription =
isar.walletInfo.watchLazy(fireImmediately: true).listen((event) { isar.walletInfo.watchLazy(fireImmediately: true).listen((event) {
isar.walletInfo.where().findAll().then((value) { isar.walletInfo
.where()
.filter()
.anyOf<String, CryptoCurrency>(
Coins.enabled.map((e) => e.identifier),
(q, element) => q.coinNameMatches(element),
)
.findAll()
.then((value) {
_value = value; _value = value;
notifyListeners(); notifyListeners();
}); });

View file

@ -4,6 +4,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/providers/db/main_db_provider.dart'; import 'package:stackwallet/providers/db/main_db_provider.dart';
import 'package:stackwallet/supported_coins.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
class _Watcher extends ChangeNotifier { class _Watcher extends ChangeNotifier {
@ -17,6 +19,10 @@ class _Watcher extends ChangeNotifier {
_Watcher(this._value, this.isFavourite, Isar isar) { _Watcher(this._value, this.isFavourite, Isar isar) {
_streamSubscription = isar.walletInfo _streamSubscription = isar.walletInfo
.filter() .filter()
.anyOf<String, CryptoCurrency>(
Coins.enabled.map((e) => e.identifier),
(q, element) => q.coinNameMatches(element),
)
.isFavouriteEqualTo(isFavourite) .isFavouriteEqualTo(isFavourite)
.sortByFavouriteOrderIndex() .sortByFavouriteOrderIndex()
.watch(fireImmediately: true) .watch(fireImmediately: true)
@ -40,6 +46,10 @@ final _wiProvider = ChangeNotifierProvider.family<_Watcher, bool>(
final watcher = _Watcher( final watcher = _Watcher(
isar.walletInfo isar.walletInfo
.filter() .filter()
.anyOf<String, CryptoCurrency>(
Coins.enabled.map((e) => e.identifier),
(q, element) => q.coinNameMatches(element),
)
.isFavouriteEqualTo(isFavourite) .isFavouriteEqualTo(isFavourite)
.sortByFavouriteOrderIndex() .sortByFavouriteOrderIndex()
.findAllSync(), .findAllSync(),

View file

@ -72,7 +72,7 @@ class _AddressBookCardState extends ConsumerState<AddressBookCard> {
final List<CryptoCurrency> coins = []; final List<CryptoCurrency> coins = [];
for (final coin in Coins.cryptocurrencies) { for (final coin in Coins.enabled) {
if (contact.addresses.where((e) => e.coin == coin).isNotEmpty) { if (contact.addresses.where((e) => e.coin == coin).isNotEmpty) {
coins.add(coin); coins.add(coin);
} }

View file

@ -19,7 +19,6 @@ import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -52,7 +51,7 @@ class ChooseCoinView extends ConsumerStatefulWidget {
} }
class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> { class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
List<CryptoCurrency> _coins = [...Coins.cryptocurrencies]; List<CryptoCurrency> _coins = [...Coins.enabled];
@override @override
void initState() { void initState() {

View file

@ -11,7 +11,6 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_libmonero/wownero/wownero.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:solana/solana.dart'; import 'package:solana/solana.dart';
@ -33,35 +32,17 @@ import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart'; import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart'; import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/banano.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/ecash.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/litecoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/namecoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/nano.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/particl.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/peercoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/solana.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/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
class NodeOptionsSheet extends ConsumerWidget { class NodeOptionsSheet extends ConsumerWidget {
const NodeOptionsSheet({ const NodeOptionsSheet({
Key? key, super.key,
required this.nodeId, required this.nodeId,
required this.coin, required this.coin,
required this.popBackToRoute, required this.popBackToRoute,
}) : super(key: key); });
final String nodeId; final String nodeId;
final CryptoCurrency coin; final CryptoCurrency coin;
@ -101,7 +82,10 @@ class NodeOptionsSheet extends ConsumerWidget {
} }
Future<bool> _testConnection( Future<bool> _testConnection(
NodeModel node, BuildContext context, WidgetRef ref) async { NodeModel node,
BuildContext context,
WidgetRef ref,
) async {
bool testPassed = false; bool testPassed = false;
switch (coin.runtimeType) { switch (coin.runtimeType) {
@ -183,7 +167,7 @@ class NodeOptionsSheet extends ConsumerWidget {
break; break;
case (Ethereum): case const (Ethereum):
try { try {
testPassed = await testEthNodeConnection(node.host); testPassed = await testEthNodeConnection(node.host);
} catch (_) { } catch (_) {
@ -220,12 +204,14 @@ class NodeOptionsSheet extends ConsumerWidget {
// context: context, // context: context,
// ); // );
} else { } else {
unawaited(showFloatingFlushBar( unawaited(
showFloatingFlushBar(
type: FlushBarType.warning, type: FlushBarType.warning,
iconAsset: Assets.svg.circleAlert, iconAsset: Assets.svg.circleAlert,
message: "Could not connect to node", message: "Could not connect to node",
context: context, context: context,
)); ),
);
} }
return testPassed; return testPassed;
@ -234,12 +220,16 @@ class NodeOptionsSheet extends ConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final maxHeight = MediaQuery.of(context).size.height * 0.60; final maxHeight = MediaQuery.of(context).size.height * 0.60;
final node = ref.watch(nodeServiceChangeNotifierProvider final node = ref.watch(
.select((value) => value.getNodeById(id: nodeId)))!; nodeServiceChangeNotifierProvider
.select((value) => value.getNodeById(id: nodeId)),
)!;
final status = ref final status = ref
.watch(nodeServiceChangeNotifierProvider .watch(
.select((value) => value.getPrimaryNodeFor(currency: coin))) nodeServiceChangeNotifierProvider.select(
(value) => value.getPrimaryNodeFor(currency: coin)),
)
?.id != ?.id !=
nodeId nodeId
? "Disconnected" ? "Disconnected"
@ -313,7 +303,8 @@ class NodeOptionsSheet extends ConsumerWidget {
height: 15, height: 15,
width: 19, width: 19,
color: node.id.startsWith( color: node.id.startsWith(
DefaultNodes.defaultNodeIdPrefix) DefaultNodes.defaultNodeIdPrefix,
)
? Theme.of(context) ? Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.accentColorDark .accentColorDark
@ -381,7 +372,8 @@ class NodeOptionsSheet extends ConsumerWidget {
style: STextStyles.button(context).copyWith( style: STextStyles.button(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.accentColorDark), .accentColorDark,
),
), ),
), ),
), ),

View file

@ -6,8 +6,6 @@ import 'package:stackwallet/models/node_model.dart';
import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/supported_coins.dart'; import 'package:stackwallet/supported_coins.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
void main() { void main() {
@ -114,7 +112,7 @@ void main() {
await service.updateDefaults(); await service.updateDefaults();
expect( expect(
service.nodes.length, service.nodes.length,
Coins.cryptocurrencies.map((e) => e.defaultNode).length, Coins.enabled.map((e) => e.defaultNode).length,
); );
expect(fakeStore.interactions, 0); expect(fakeStore.interactions, 0);
}); });
@ -207,11 +205,10 @@ void main() {
final fakeStore = FakeSecureStorage(); final fakeStore = FakeSecureStorage();
final service = NodeService(secureStorageInterface: fakeStore); final service = NodeService(secureStorageInterface: fakeStore);
final nodes = service.nodes; final nodes = service.nodes;
final defaults = final defaults = Coins.enabled.map((e) => e.defaultNode).toList();
Coins.cryptocurrencies.map((e) => e.defaultNode).toList();
nodes.sort((a, b) => a.host.compareTo(b.host)); nodes.sort((a, b) => a.id.compareTo(b.id));
defaults.sort((a, b) => a.host.compareTo(b.host)); defaults.sort((a, b) => a.id.compareTo(b.id));
expect(nodes.length, defaults.length); expect(nodes.length, defaults.length);
expect(nodes.toString(), defaults.toString()); expect(nodes.toString(), defaults.toString());
@ -224,7 +221,7 @@ void main() {
await service.add(nodeA, null, true); await service.add(nodeA, null, true);
expect( expect(
service.nodes.length, service.nodes.length,
Coins.cryptocurrencies.map((e) => e.defaultNode).length + 1, Coins.enabled.map((e) => e.defaultNode).length + 1,
); );
expect(fakeStore.interactions, 0); expect(fakeStore.interactions, 0);
}); });
@ -235,7 +232,7 @@ void main() {
await service.add(nodeA, "some password", true); await service.add(nodeA, "some password", true);
expect( expect(
service.nodes.length, service.nodes.length,
Coins.cryptocurrencies.map((e) => e.defaultNode).length + 1, Coins.enabled.map((e) => e.defaultNode).length + 1,
); );
expect(fakeStore.interactions, 1); expect(fakeStore.interactions, 1);
expect(fakeStore.writes, 1); expect(fakeStore.writes, 1);
@ -293,7 +290,7 @@ void main() {
expect( expect(
service.nodes.length, service.nodes.length,
Coins.cryptocurrencies.map((e) => e.defaultNode).length + 2, Coins.enabled.map((e) => e.defaultNode).length + 2,
); );
expect( expect(
service.nodes.where((element) => element.id == nodeB.id).length, service.nodes.where((element) => element.id == nodeB.id).length,