centralize isStackCoin check functionality

This commit is contained in:
julian 2024-05-23 11:26:58 -06:00
parent 3ee22cbbac
commit cf7433655c
13 changed files with 92 additions and 129 deletions

View file

@ -37,6 +37,23 @@ abstract class AppConfig {
} }
} }
static bool isStackCoin(String? ticker) {
if (ticker == null) {
return false;
}
if (getCryptoCurrencyForTicker(ticker, caseInsensitive: false) != null) {
return true;
}
try {
getCryptoCurrencyByPrettyName(ticker);
return true;
} catch (_) {
return false;
}
}
/// Fuzzy logic. Use with caution!! /// Fuzzy logic. Use with caution!!
@Deprecated("dangerous") @Deprecated("dangerous")
static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) { static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) {

View file

@ -9,6 +9,7 @@
*/ */
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import '../../../app_config.dart'; import '../../../app_config.dart';
import 'pair.dart'; import 'pair.dart';
@ -98,7 +99,7 @@ class Currency {
rateType: rateType, rateType: rateType,
isAvailable: json["isAvailable"] as bool?, isAvailable: json["isAvailable"] as bool?,
isStackCoin: isStackCoin:
json["isStackCoin"] as bool? ?? Currency.checkIsStackCoin(ticker), json["isStackCoin"] as bool? ?? AppConfig.isStackCoin(ticker),
tokenContract: json["tokenContract"] as String?, tokenContract: json["tokenContract"] as String?,
)..id = json["id"] as int?; )..id = json["id"] as int?;
} catch (e) { } catch (e) {
@ -158,13 +159,4 @@ class Currency {
String toString() { String toString() {
return "Currency: ${toJson()}"; return "Currency: ${toJson()}";
} }
static bool checkIsStackCoin(String ticker) {
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
return true;
} catch (_) {
return false;
}
}
} }

View file

@ -16,17 +16,13 @@ import 'package:flutter/services.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:intl/intl.dart'; import 'package:intl/intl.dart';
import '../../app_config.dart'; import '../../app_config.dart';
import '../../models/buy/response_objects/crypto.dart'; import '../../models/buy/response_objects/crypto.dart';
import '../../models/buy/response_objects/fiat.dart'; import '../../models/buy/response_objects/fiat.dart';
import '../../models/buy/response_objects/quote.dart'; import '../../models/buy/response_objects/quote.dart';
import '../../models/contact_address_entry.dart'; import '../../models/contact_address_entry.dart';
import '../../models/isar/models/ethereum/eth_contract.dart'; import '../../models/isar/models/ethereum/eth_contract.dart';
import '../address_book_views/address_book_view.dart';
import 'buy_quote_preview.dart';
import 'sub_widgets/crypto_selection_view.dart';
import 'sub_widgets/fiat_selection_view.dart';
import '../exchange_view/choose_from_stack_view.dart';
import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart';
import '../../providers/providers.dart'; import '../../providers/providers.dart';
import '../../services/buy/buy_response.dart'; import '../../services/buy/buy_response.dart';
@ -56,6 +52,11 @@ import '../../widgets/rounded_white_container.dart';
import '../../widgets/stack_dialog.dart'; import '../../widgets/stack_dialog.dart';
import '../../widgets/stack_text_field.dart'; import '../../widgets/stack_text_field.dart';
import '../../widgets/textfield_icon_button.dart'; import '../../widgets/textfield_icon_button.dart';
import '../address_book_views/address_book_view.dart';
import '../exchange_view/choose_from_stack_view.dart';
import 'buy_quote_preview.dart';
import 'sub_widgets/crypto_selection_view.dart';
import 'sub_widgets/fiat_selection_view.dart';
class BuyForm extends ConsumerStatefulWidget { class BuyForm extends ConsumerStatefulWidget {
const BuyForm({ const BuyForm({
@ -409,17 +410,6 @@ class _BuyFormState extends ConsumerState<BuyForm> {
// return null; // return null;
// } // }
bool isStackCoin(String? ticker) {
if (ticker == null) return false;
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}
Future<void> previewQuote(SimplexQuote quote) async { Future<void> previewQuote(SimplexQuote quote) async {
bool shouldPop = false; bool shouldPop = false;
unawaited( unawaited(
@ -1163,7 +1153,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
Theme.of(context).extension<StackColors>()!.textDark3, Theme.of(context).extension<StackColors>()!.textDark3,
), ),
), ),
if (isStackCoin(selectedCrypto?.ticker)) if (AppConfig.isStackCoin(selectedCrypto?.ticker))
CustomTextButton( CustomTextButton(
text: "Choose from Stack", text: "Choose from Stack",
onTap: () { onTap: () {
@ -1297,7 +1287,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
: const XIcon(), : const XIcon(),
), ),
if (_receiveAddressController.text.isEmpty && if (_receiveAddressController.text.isEmpty &&
isStackCoin(selectedCrypto?.ticker) && AppConfig.isStackCoin(selectedCrypto?.ticker) &&
isDesktop) isDesktop)
TextFieldIconButton( TextFieldIconButton(
key: const Key("buyViewAddressBookButtonKey"), key: const Key("buyViewAddressBookButtonKey"),
@ -1358,7 +1348,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
child: const AddressBookIcon(), child: const AddressBookIcon(),
), ),
if (_receiveAddressController.text.isEmpty && if (_receiveAddressController.text.isEmpty &&
isStackCoin(selectedCrypto?.ticker) && AppConfig.isStackCoin(selectedCrypto?.ticker) &&
!isDesktop) !isDesktop)
TextFieldIconButton( TextFieldIconButton(
key: const Key("buyViewAddressBookButtonKey"), key: const Key("buyViewAddressBookButtonKey"),

View file

@ -267,17 +267,6 @@ class _CryptoSelectionViewState extends ConsumerState<CryptoSelectionView> {
} }
} }
bool isStackCoin(String? ticker) {
if (ticker == null) return false;
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}
// make a stateless widget that takes in string and double (won't ever be null) // make a stateless widget that takes in string and double (won't ever be null)
// class getIconForTicker extends ConsumerWidget{ // class getIconForTicker extends ConsumerWidget{
// const getIconForTicker({ // const getIconForTicker({

View file

@ -13,16 +13,16 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import '../../../app_config.dart';
import '../../../exceptions/exchange/unsupported_currency_exception.dart'; import '../../../exceptions/exchange/unsupported_currency_exception.dart';
import '../../../models/isar/exchange_cache/currency.dart'; import '../../../models/isar/exchange_cache/currency.dart';
import '../../../models/isar/exchange_cache/pair.dart'; import '../../../models/isar/exchange_cache/pair.dart';
import '../../buy_view/sub_widgets/crypto_selection_view.dart';
import '../../../services/exchange/change_now/change_now_exchange.dart'; import '../../../services/exchange/change_now/change_now_exchange.dart';
import '../../../services/exchange/exchange.dart'; import '../../../services/exchange/exchange.dart';
import '../../../services/exchange/exchange_data_loading_service.dart'; import '../../../services/exchange/exchange_data_loading_service.dart';
import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart';
import '../../../services/exchange/trocador/trocador_exchange.dart'; import '../../../services/exchange/trocador/trocador_exchange.dart';
import '../../../app_config.dart';
import '../../../themes/stack_colors.dart'; import '../../../themes/stack_colors.dart';
import '../../../utilities/assets.dart'; import '../../../utilities/assets.dart';
import '../../../utilities/constants.dart'; import '../../../utilities/constants.dart';
@ -41,6 +41,7 @@ import '../../../widgets/rounded_white_container.dart';
import '../../../widgets/stack_dialog.dart'; import '../../../widgets/stack_dialog.dart';
import '../../../widgets/stack_text_field.dart'; import '../../../widgets/stack_text_field.dart';
import '../../../widgets/textfield_icon_button.dart'; import '../../../widgets/textfield_icon_button.dart';
import '../../buy_view/sub_widgets/crypto_selection_view.dart';
class ExchangeCurrencySelectionView extends StatefulWidget { class ExchangeCurrencySelectionView extends StatefulWidget {
const ExchangeCurrencySelectionView({ const ExchangeCurrencySelectionView({
@ -418,27 +419,28 @@ class _ExchangeCurrencySelectionViewState
SizedBox( SizedBox(
width: 24, width: 24,
height: 24, height: 24,
child: isStackCoin(items[index].ticker) child:
? CoinIconForTicker( AppConfig.isStackCoin(items[index].ticker)
ticker: items[index].ticker, ? CoinIconForTicker(
size: 24, ticker: items[index].ticker,
) size: 24,
// ? getIconForTicker(
// items[index].ticker,
// size: 24,
// )
: hasImageUrl
? SvgPicture.network(
items[index].image,
width: 24,
height: 24,
placeholderBuilder: (_) =>
const LoadingIndicator(),
) )
: const SizedBox( // ? getIconForTicker(
width: 24, // items[index].ticker,
height: 24, // size: 24,
), // )
: hasImageUrl
? SvgPicture.network(
items[index].image,
width: 24,
height: 24,
placeholderBuilder: (_) =>
const LoadingIndicator(),
)
: const SizedBox(
width: 24,
height: 24,
),
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,

View file

@ -11,13 +11,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../app_config.dart'; import '../../../app_config.dart';
import '../../../models/exchange/incomplete_exchange.dart'; import '../../../models/exchange/incomplete_exchange.dart';
import '../../address_book_views/address_book_view.dart';
import '../../address_book_views/subviews/contact_popup.dart';
import '../choose_from_stack_view.dart';
import 'step_3_view.dart';
import '../sub_widgets/step_row.dart';
import '../../../providers/providers.dart'; import '../../../providers/providers.dart';
import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart';
import '../../../themes/stack_colors.dart'; import '../../../themes/stack_colors.dart';
@ -38,6 +34,11 @@ import '../../../widgets/icon_widgets/x_icon.dart';
import '../../../widgets/rounded_white_container.dart'; import '../../../widgets/rounded_white_container.dart';
import '../../../widgets/stack_text_field.dart'; import '../../../widgets/stack_text_field.dart';
import '../../../widgets/textfield_icon_button.dart'; import '../../../widgets/textfield_icon_button.dart';
import '../../address_book_views/address_book_view.dart';
import '../../address_book_views/subviews/contact_popup.dart';
import '../choose_from_stack_view.dart';
import '../sub_widgets/step_row.dart';
import 'step_3_view.dart';
class Step2View extends ConsumerStatefulWidget { class Step2View extends ConsumerStatefulWidget {
const Step2View({ const Step2View({
@ -70,15 +71,6 @@ class _Step2ViewState extends ConsumerState<Step2View> {
bool enableNext = false; bool enableNext = false;
bool isStackCoin(String ticker) {
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}
@override @override
void initState() { void initState() {
model = widget.model; model = widget.model;
@ -202,7 +194,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
"Recipient Wallet", "Recipient Wallet",
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
if (isStackCoin(model.receiveTicker)) if (AppConfig.isStackCoin(model.receiveTicker))
CustomTextButton( CustomTextButton(
text: "Choose from Stack", text: "Choose from Stack",
onTap: () { onTap: () {
@ -488,7 +480,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
"Refund Wallet (required)", "Refund Wallet (required)",
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
if (isStackCoin(model.sendTicker)) if (AppConfig.isStackCoin(model.sendTicker))
CustomTextButton( CustomTextButton(
text: "Choose from Stack", text: "Choose from Stack",
onTap: () { onTap: () {

View file

@ -86,18 +86,6 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
late final Transaction? transactionIfSentFromStack; late final Transaction? transactionIfSentFromStack;
late final String? walletId; late final String? walletId;
bool isStackCoin(String ticker) {
try {
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
} catch (_) {}
AppConfig.getCryptoCurrencyByPrettyName(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}
@override @override
initState() { initState() {
tradeId = widget.tradeId; tradeId = widget.tradeId;
@ -260,7 +248,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
), ),
), ),
if (!hasTx && if (!hasTx &&
isStackCoin(trade.payInCurrency) && AppConfig.isStackCoin(trade.payInCurrency) &&
(trade.status == "New" || (trade.status == "New" ||
trade.status == "new" || trade.status == "new" ||
trade.status == "waiting" || trade.status == "waiting" ||
@ -269,7 +257,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
height: 32, height: 32,
), ),
if (!hasTx && if (!hasTx &&
isStackCoin(trade.payInCurrency) && AppConfig.isStackCoin(trade.payInCurrency) &&
(trade.status == "New" || (trade.status == "New" ||
trade.status == "new" || trade.status == "new" ||
trade.status == "waiting" || trade.status == "waiting" ||
@ -1372,7 +1360,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
), ),
if (!isDesktop && if (!isDesktop &&
!hasTx && !hasTx &&
isStackCoin(trade.payInCurrency) && AppConfig.isStackCoin(trade.payInCurrency) &&
(trade.status == "New" || (trade.status == "New" ||
trade.status == "new" || trade.status == "new" ||
trade.status == "waiting" || trade.status == "waiting" ||

View file

@ -58,15 +58,6 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
late final FocusNode _toFocusNode; late final FocusNode _toFocusNode;
late final FocusNode _refundFocusNode; late final FocusNode _refundFocusNode;
bool isStackCoin(String ticker) {
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}
void selectRecipientAddressFromStack() async { void selectRecipientAddressFromStack() async {
try { try {
final coin = AppConfig.getCryptoCurrencyForTicker( final coin = AppConfig.getCryptoCurrencyForTicker(
@ -311,7 +302,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
.textFieldActiveSearchIconRight, .textFieldActiveSearchIconRight,
), ),
), ),
if (isStackCoin( if (AppConfig.isStackCoin(
ref.watch( ref.watch(
desktopExchangeModelProvider desktopExchangeModelProvider
.select((value) => value!.receiveTicker), .select((value) => value!.receiveTicker),
@ -416,7 +407,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
: const XIcon(), : const XIcon(),
), ),
if (_toController.text.isEmpty && if (_toController.text.isEmpty &&
isStackCoin( AppConfig.isStackCoin(
ref.watch( ref.watch(
desktopExchangeModelProvider desktopExchangeModelProvider
.select((value) => value!.receiveTicker), .select((value) => value!.receiveTicker),
@ -458,7 +449,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
.textFieldActiveSearchIconRight, .textFieldActiveSearchIconRight,
), ),
), ),
if (isStackCoin( if (AppConfig.isStackCoin(
ref.watch( ref.watch(
desktopExchangeModelProvider desktopExchangeModelProvider
.select((value) => value!.sendTicker), .select((value) => value!.sendTicker),
@ -565,7 +556,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
: const XIcon(), : const XIcon(),
), ),
if (_refundController.text.isEmpty && if (_refundController.text.isEmpty &&
isStackCoin( AppConfig.isStackCoin(
ref.watch( ref.watch(
desktopExchangeModelProvider desktopExchangeModelProvider
.select((value) => value!.sendTicker), .select((value) => value!.sendTicker),

View file

@ -12,18 +12,19 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../app_config.dart'; import '../../../app_config.dart';
import '../../../models/buy/response_objects/crypto.dart'; import '../../../models/buy/response_objects/crypto.dart';
import '../../../models/buy/response_objects/fiat.dart'; import '../../../models/buy/response_objects/fiat.dart';
import '../../../models/buy/response_objects/order.dart'; import '../../../models/buy/response_objects/order.dart';
import '../../../models/buy/response_objects/quote.dart'; import '../../../models/buy/response_objects/quote.dart';
import '../../../networking/http.dart'; import '../../../networking/http.dart';
import '../buy_response.dart';
import '../../tor_service.dart';
import '../../../utilities/enums/fiat_enum.dart'; import '../../../utilities/enums/fiat_enum.dart';
import '../../../utilities/logger.dart'; import '../../../utilities/logger.dart';
import '../../../utilities/prefs.dart'; import '../../../utilities/prefs.dart';
import 'package:url_launcher/url_launcher.dart'; import '../../tor_service.dart';
import '../buy_response.dart';
class SimplexAPI { class SimplexAPI {
static const String authority = "buycrypto.stackwallet.com"; static const String authority = "buycrypto.stackwallet.com";
@ -90,7 +91,7 @@ class SimplexAPI {
for (final crypto in jsonArray as List) { for (final crypto in jsonArray as List) {
// TODO validate jsonArray // TODO validate jsonArray
if (isStackCoin("${crypto['ticker_symbol']}")) { if (AppConfig.isStackCoin("${crypto['ticker_symbol']}")) {
cryptos.add( cryptos.add(
Crypto.fromJson({ Crypto.fromJson({
'ticker': "${crypto['ticker_symbol']}", 'ticker': "${crypto['ticker_symbol']}",
@ -400,14 +401,3 @@ class SimplexAPI {
String timeZoneFormatter(Duration offset) => String timeZoneFormatter(Duration offset) =>
"${offset.isNegative ? "-" : "+"}${offset.inHours.abs().toString().padLeft(2, "0")}:${(offset.inMinutes - offset.inHours * 60).abs().toString().padLeft(2, "0")}"; "${offset.isNegative ? "-" : "+"}${offset.inHours.abs().toString().padLeft(2, "0")}:${(offset.inMinutes - offset.inHours * 60).abs().toString().padLeft(2, "0")}";
} }
bool isStackCoin(String? ticker) {
if (ticker == null) return false;
try {
AppConfig.getCryptoCurrencyForTicker(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}

View file

@ -9,6 +9,9 @@
*/ */
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
import 'package:uuid/uuid.dart';
import '../../../app_config.dart';
import '../../../exceptions/exchange/exchange_exception.dart'; import '../../../exceptions/exchange/exchange_exception.dart';
import '../../../exceptions/exchange/majestic_bank/mb_exception.dart'; import '../../../exceptions/exchange/majestic_bank/mb_exception.dart';
import '../../../models/exchange/majestic_bank/mb_order.dart'; import '../../../models/exchange/majestic_bank/mb_order.dart';
@ -20,7 +23,6 @@ import '../../../models/isar/exchange_cache/pair.dart';
import '../exchange.dart'; import '../exchange.dart';
import '../exchange_response.dart'; import '../exchange_response.dart';
import 'majestic_bank_api.dart'; import 'majestic_bank_api.dart';
import 'package:uuid/uuid.dart';
class MajesticBankExchange extends Exchange { class MajesticBankExchange extends Exchange {
MajesticBankExchange._(); MajesticBankExchange._();
@ -140,7 +142,7 @@ class MajesticBankExchange extends Exchange {
isFiat: false, isFiat: false,
rateType: SupportedRateType.both, rateType: SupportedRateType.both,
isAvailable: true, isAvailable: true,
isStackCoin: Currency.checkIsStackCoin(limit.currency), isStackCoin: AppConfig.isStackCoin(limit.currency),
tokenContract: null, tokenContract: null,
); );
currencies.add(currency); currencies.add(currency);

View file

@ -9,6 +9,8 @@
*/ */
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
import '../../../app_config.dart';
import '../../../models/exchange/response_objects/estimate.dart'; import '../../../models/exchange/response_objects/estimate.dart';
import '../../../models/exchange/response_objects/range.dart'; import '../../../models/exchange/response_objects/range.dart';
import '../../../models/exchange/response_objects/trade.dart'; import '../../../models/exchange/response_objects/trade.dart';
@ -76,7 +78,7 @@ class SimpleSwapExchange extends Exchange {
? SupportedRateType.both ? SupportedRateType.both
: SupportedRateType.estimated, : SupportedRateType.estimated,
isAvailable: true, isAvailable: true,
isStackCoin: Currency.checkIsStackCoin(e.symbol), isStackCoin: AppConfig.isStackCoin(e.symbol),
tokenContract: null, tokenContract: null,
), ),
) )

View file

@ -11,6 +11,9 @@
import 'dart:math'; import 'dart:math';
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
import 'package:uuid/uuid.dart';
import '../../../app_config.dart';
import '../../../exceptions/exchange/exchange_exception.dart'; import '../../../exceptions/exchange/exchange_exception.dart';
import '../../../models/exchange/response_objects/estimate.dart'; import '../../../models/exchange/response_objects/estimate.dart';
import '../../../models/exchange/response_objects/range.dart'; import '../../../models/exchange/response_objects/range.dart';
@ -22,7 +25,6 @@ import '../exchange_response.dart';
import 'response_objects/trocador_coin.dart'; import 'response_objects/trocador_coin.dart';
import 'response_objects/trocador_quote.dart'; import 'response_objects/trocador_quote.dart';
import 'trocador_api.dart'; import 'trocador_api.dart';
import 'package:uuid/uuid.dart';
class TrocadorExchange extends Exchange { class TrocadorExchange extends Exchange {
TrocadorExchange._(); TrocadorExchange._();
@ -117,7 +119,8 @@ class TrocadorExchange extends Exchange {
@override @override
Future<ExchangeResponse<List<Currency>>> getAllCurrencies( Future<ExchangeResponse<List<Currency>>> getAllCurrencies(
bool fixedRate) async { bool fixedRate,
) async {
_cachedCurrencies ??= (await TrocadorAPI.getCoins(isOnion: false)).value; _cachedCurrencies ??= (await TrocadorAPI.getCoins(isOnion: false)).value;
_cachedCurrencies?.removeWhere((e) => e.network != onlySupportedNetwork); _cachedCurrencies?.removeWhere((e) => e.network != onlySupportedNetwork);
@ -132,7 +135,7 @@ class TrocadorExchange extends Exchange {
image: e.image, image: e.image,
isFiat: false, isFiat: false,
rateType: SupportedRateType.both, rateType: SupportedRateType.both,
isStackCoin: Currency.checkIsStackCoin(e.ticker), isStackCoin: AppConfig.isStackCoin(e.ticker),
tokenContract: null, tokenContract: null,
isAvailable: true, isAvailable: true,
), ),
@ -267,7 +270,9 @@ class TrocadorExchange extends Exchange {
@override @override
Future<ExchangeResponse<List<Currency>>> getPairedCurrencies( Future<ExchangeResponse<List<Currency>>> getPairedCurrencies(
String forCurrency, bool fixedRate) async { String forCurrency,
bool fixedRate,
) async {
// TODO: implement getPairedCurrencies // TODO: implement getPairedCurrencies
throw UnimplementedError(); throw UnimplementedError();
} }

View file

@ -11,6 +11,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.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 '../../app_config.dart';
import '../../models/exchange/aggregate_currency.dart'; import '../../models/exchange/aggregate_currency.dart';
import '../../pages/buy_view/sub_widgets/crypto_selection_view.dart'; import '../../pages/buy_view/sub_widgets/crypto_selection_view.dart';
import '../../providers/global/locale_provider.dart'; import '../../providers/global/locale_provider.dart';
@ -173,7 +175,8 @@ class _ExchangeTextFieldState extends ConsumerState<ExchangeTextField> {
), ),
child: Builder( child: Builder(
builder: (context) { builder: (context) {
if (isStackCoin(widget.currency?.ticker)) { if (AppConfig.isStackCoin(
widget.currency?.ticker)) {
return Center( return Center(
child: CoinIconForTicker( child: CoinIconForTicker(
size: 18, size: 18,