diff --git a/lib/app_config/app_config.dart b/lib/app_config/app_config.dart index 7e2aa67527..1fd622126c 100644 --- a/lib/app_config/app_config.dart +++ b/lib/app_config/app_config.dart @@ -73,6 +73,8 @@ const List excludedAssetList = [ 'FENIX', 'AWR', 'BOT', + // Pirate activation params are not yet implemented, so we need to + // exclude it from the list of coins for now. 'ARRR', 'ZOMBIE', 'SMTF-v2', @@ -128,13 +130,6 @@ List get enabledByDefaultCoins => [ 'FTM', if (kDebugMode) 'DOC', if (kDebugMode) 'MARTY', - - // NFT v2 methods require the new NFT coins to be enabled by default. - 'NFT_ETH', - 'NFT_AVAX', - 'NFT_BNB', - 'NFT_FTM', - 'NFT_MATIC', ]; List get enabledByDefaultTrezorCoins => [ diff --git a/lib/bloc/bridge_form/bridge_bloc.dart b/lib/bloc/bridge_form/bridge_bloc.dart index 941cb1c43c..729e6a068b 100644 --- a/lib/bloc/bridge_form/bridge_bloc.dart +++ b/lib/bloc/bridge_form/bridge_bloc.dart @@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:komodo_defi_sdk/komodo_defi_sdk.dart'; import 'package:komodo_defi_types/komodo_defi_types.dart'; import 'package:rational/rational.dart'; +import 'package:web_dex/app_config/app_config.dart'; import 'package:web_dex/bloc/bridge_form/bridge_event.dart'; import 'package:web_dex/bloc/bridge_form/bridge_repository.dart'; import 'package:web_dex/bloc/bridge_form/bridge_state.dart'; @@ -257,6 +258,12 @@ class BridgeBloc extends Bloc { number: 1, )); + + /// Unsupported coins like ARRR cause downstream errors, so we need to + /// remove them from the list here + bestOrders.result + ?.removeWhere((coinId, _) => excludedAssetList.contains(coinId)); + emit(state.copyWith( bestOrders: () => bestOrders, )); diff --git a/lib/bloc/coins_manager/coins_manager_bloc.dart b/lib/bloc/coins_manager/coins_manager_bloc.dart index e1d38d412b..468b6183ea 100644 --- a/lib/bloc/coins_manager/coins_manager_bloc.dart +++ b/lib/bloc/coins_manager/coins_manager_bloc.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:equatable/equatable.dart'; import 'package:flutter_bloc/flutter_bloc.dart' show Bloc, Emitter; import 'package:komodo_defi_sdk/komodo_defi_sdk.dart'; +import 'package:web_dex/app_config/app_config.dart'; import 'package:web_dex/bloc/coins_bloc/coins_repo.dart'; import 'package:web_dex/model/coin.dart'; import 'package:web_dex/model/coin_type.dart'; @@ -35,18 +36,18 @@ class CoinsManagerBloc extends Bloc { final KomodoDefiSdk _sdk; List mergeCoinLists(List originalList, List newList) { - Map coinMap = {}; + final Map coinMap = {}; - for (Coin coin in originalList) { + for (final Coin coin in originalList) { coinMap[coin.abbr] = coin; } - for (Coin coin in newList) { + for (final Coin coin in newList) { coinMap[coin.abbr] = coin; } - final list = coinMap.values.toList(); - list.sort((a, b) => a.abbr.compareTo(b.abbr)); + final list = coinMap.values.toList() + ..sort((a, b) => a.abbr.compareTo(b.abbr)); return list; } @@ -213,9 +214,9 @@ Future> _getOriginalCoinList( switch (action) { case CoinsManagerAction.add: - return await _getDeactivatedCoins(coinsRepo, sdk, walletType); + return _getDeactivatedCoins(coinsRepo, sdk, walletType); case CoinsManagerAction.remove: - return await coinsRepo.getWalletCoins(); + return coinsRepo.getWalletCoins(); case CoinsManagerAction.none: return []; } @@ -228,7 +229,8 @@ Future> _getDeactivatedCoins( ) async { final Iterable enabledCoins = await sdk.assets.getEnabledCoins(); final Map disabledCoins = coinsRepo.getKnownCoinsMap() - ..removeWhere((key, coin) => enabledCoins.contains(key)); + ..removeWhere((coinId, coin) => enabledCoins.contains(coinId)) + ..removeWhere((coinId, coin) => excludedAssetList.contains(coinId)); switch (walletType) { case WalletType.iguana: diff --git a/lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart b/lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart index b0d8ba3bf8..55cff96817 100644 --- a/lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart +++ b/lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart @@ -9,6 +9,7 @@ import 'package:formz/formz.dart'; import 'package:komodo_defi_sdk/komodo_defi_sdk.dart'; import 'package:komodo_defi_types/komodo_defi_types.dart'; import 'package:logging/logging.dart'; +import 'package:web_dex/app_config/app_config.dart'; import 'package:web_dex/bloc/coins_bloc/asset_coin_extension.dart'; import 'package:web_dex/bloc/fiat/base_fiat_provider.dart'; import 'package:web_dex/bloc/fiat/fiat_order_status.dart'; @@ -319,6 +320,8 @@ class FiatFormBloc extends Bloc { try { final fiatList = await _fiatRepository.getFiatList(); final coinList = await _fiatRepository.getCoinList(); + coinList + .removeWhere((coin) => excludedAssetList.contains(coin.getAbbr())); emit(state.copyWith(fiatList: fiatList, coinList: coinList)); } catch (e, s) { _log.shout('Error loading currency list', e, s); diff --git a/lib/bloc/taker_form/taker_bloc.dart b/lib/bloc/taker_form/taker_bloc.dart index 51382e0acb..9b89d0ff91 100644 --- a/lib/bloc/taker_form/taker_bloc.dart +++ b/lib/bloc/taker_form/taker_bloc.dart @@ -293,6 +293,11 @@ class TakerBloc extends Bloc { ), ); + /// Unsupported coins like ARRR cause downstream errors, so we need to + /// remove them from the list here + bestOrders.result + ?.removeWhere((coinId, _) => excludedAssetList.contains(coinId)); + emit(state.copyWith(bestOrders: () => bestOrders)); final buyCoin = event.autoSelectOrderAbbr; diff --git a/lib/blocs/wallets_repository.dart b/lib/blocs/wallets_repository.dart index 2b621f69ef..a6d44e3a2e 100644 --- a/lib/blocs/wallets_repository.dart +++ b/lib/blocs/wallets_repository.dart @@ -43,7 +43,7 @@ class WalletsRepository { } Future> _getLegacyWallets() async { - var newVariable = + final newVariable = await _legacyWalletStorage.read(allWalletsStorageKey) as List?; final List> json = newVariable?.cast>() ?? >[]; @@ -115,7 +115,7 @@ class WalletsRepository { type: LoadFileType.text, ); } catch (e) { - throw Exception('Failed to download encrypted wallet: ${e.toString()}'); + throw Exception('Failed to download encrypted wallet: $e'); } } diff --git a/lib/views/dex/simple/form/tables/orders_table/grouped_list_view.dart b/lib/views/dex/simple/form/tables/orders_table/grouped_list_view.dart index 2b7a8e0ba2..0474a6c297 100644 --- a/lib/views/dex/simple/form/tables/orders_table/grouped_list_view.dart +++ b/lib/views/dex/simple/form/tables/orders_table/grouped_list_view.dart @@ -12,14 +12,14 @@ import 'package:web_dex/views/dex/simple/form/tables/coins_table/coins_table_ite class GroupedListView extends StatelessWidget { const GroupedListView({ - super.key, required this.items, required this.onSelect, required this.maxHeight, + super.key, }); final List items; - final Function(T) onSelect; + final void Function(T) onSelect; final double maxHeight; @override @@ -35,7 +35,7 @@ class GroupedListView extends StatelessWidget { .isNotEmpty; final rightPadding = areGroupedItemsPresent ? const EdgeInsets.only(right: 52) - : const EdgeInsets.all(0); + : EdgeInsets.zero; return Flexible( child: ConstrainedBox( @@ -83,8 +83,8 @@ class GroupedListView extends StatelessWidget { Widget buildItem( BuildContext context, T item, - dynamic onSelect, { - EdgeInsets padding = const EdgeInsets.all(0), + void Function(T) onSelect, { + EdgeInsets padding = EdgeInsets.zero, }) { return Padding( padding: padding, @@ -106,7 +106,7 @@ class GroupedListView extends StatelessWidget { } Map> _groupList(BuildContext context, List list) { - Map> grouped = {}; + final Map> grouped = {}; for (final item in list) { final coin = getCoin(context, item); grouped.putIfAbsent(coin.name, () => []).add(item);