refactor: delete dead Cake Pay/buy/exchange code; split di setup()

- Cake Pay: 36 files (~5.3k LOC) plus DI registrations, routes, and UI
  branches (feature was hard-disabled and unreachable)
- unreachable buy providers: robinhood, dfx, onramper, meld, kryptonim
  (~1.7k LOC); MoonPay untouched
- exchange providers that only existed as commented-out wiring:
  changenow, sideshift, chainflip, exolix, swaptrade, letsexchange,
  stealthex, xoswap, swapsxyz, thorchain, simpleswap (~5.2k LOC);
  Trocador untouched; ExchangeProviderDescription values and Hive
  adapters kept so stored trades and orders still deserialize
- di.dart setup() split from one 1,452-line function into 10 sequential
  chunk functions; registration execution order verified identical
  before and after (251 register calls)
This commit is contained in:
jwinterm
2026-08-15 16:29:03 -04:00
parent 71706314fb
commit adece963c3
75 changed files with 74 additions and 13200 deletions
@@ -2,7 +2,6 @@ import 'dart:async';
import 'package:hash_wallet/buy/buy_provider.dart';
import 'package:hash_wallet/buy/buy_quote.dart';
import 'package:hash_wallet/buy/onramper/onramper_buy_provider.dart';
import 'package:hash_wallet/buy/payment_method.dart';
import 'package:hash_wallet/buy/sell_buy_states.dart';
import 'package:hash_wallet/core/selectable_option.dart';
@@ -455,18 +454,6 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
return true;
}).toList();
final List<Quote> successRateQuotes = validQuotes
.where((element) =>
element.provider is OnRamperBuyProvider &&
element.recommendations.contains(ProviderRecommendation.successRate))
.toList();
for (final quote in successRateQuotes) {
if (!uniqueProviderQuotes.contains(quote)) {
uniqueProviderQuotes.add(quote);
}
}
sortedRecommendedQuotes.addAll(uniqueProviderQuotes);
sortedQuotes = ObservableList.of(
@@ -477,12 +464,6 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
..setIsBestRate = true;
bestRateQuote = sortedRecommendedQuotes.first;
sortedRecommendedQuotes.sort((a, b) {
if (a.provider is OnRamperBuyProvider) return -1;
if (b.provider is OnRamperBuyProvider) return 1;
return 0;
});
final Quote effectiveBestRateQuote =
sortedRecommendedQuotes.reduce((a, b) {
return isBuyAction ? a.rate < b.rate ? a : b : a.rate > b.rate ? a : b;
@@ -1,20 +0,0 @@
import 'package:hash_wallet/cake_pay/src/services/cake_pay_service.dart';
import 'package:mobx/mobx.dart';
part 'cake_pay_account_view_model.g.dart';
class CakePayAccountViewModel = CakePayAccountViewModelBase with _$CakePayAccountViewModel;
abstract class CakePayAccountViewModelBase with Store {
CakePayAccountViewModelBase({required this.cakePayService}) : email = '' {
cakePayService.getUserEmail().then((email) => this.email = email ?? '');
}
final CakePayService cakePayService;
@observable
String email;
@action
Future<void> logout() async => cakePayService.logout(email);
}
@@ -1,51 +0,0 @@
import 'package:hash_wallet/cake_pay/src/cake_pay_states.dart';
import 'package:hash_wallet/cake_pay/src/services/cake_pay_service.dart';
import 'package:mobx/mobx.dart';
part 'cake_pay_auth_view_model.g.dart';
class CakePayAuthViewModel = CakePayAuthViewModelBase with _$CakePayAuthViewModel;
abstract class CakePayAuthViewModelBase with Store {
CakePayAuthViewModelBase({required this.cakePayService})
: userVerificationState = CakePayUserVerificationStateInitial(),
otpState = CakePayOtpSendDisabled(),
email = '',
otp = '';
final CakePayService cakePayService;
@observable
CakePayUserVerificationState userVerificationState;
@observable
CakePayOtpState otpState;
@observable
String email;
@observable
String otp;
@action
Future<void> verifyEmail(String code) async {
try {
otpState = CakePayOtpValidating();
await cakePayService.verifyEmail(code);
otpState = CakePayOtpSuccess();
} catch (_) {
otpState = CakePayOtpFailure(error: 'Invalid OTP. Try again');
}
}
@action
Future<void> logIn(String email) async {
try {
userVerificationState = CakePayUserVerificationStateLoading();
await cakePayService.logIn(email);
userVerificationState = CakePayUserVerificationStateSuccess();
} catch (e) {
userVerificationState = CakePayUserVerificationStateFailure(error: e.toString());
}
}
}
@@ -1,267 +0,0 @@
import 'dart:async';
import 'package:hash_wallet/order/order_provider_description.dart';
import 'package:hash_wallet/order/order.dart';
import 'package:hash_wallet/order/order_source_description.dart';
import 'package:hash_wallet/cake_pay/src/models/cake_pay_card.dart';
import 'package:hash_wallet/cake_pay/src/models/cake_pay_order.dart';
import 'package:hash_wallet/cake_pay/src/models/cake_pay_vendor.dart';
import 'package:hash_wallet/cake_pay/src/services/cake_pay_service.dart';
import 'package:hash_wallet/core/execution_state.dart';
import 'package:hash_wallet/exchange/trade_state.dart';
import 'package:hash_wallet/utils/feature_flag.dart';
import 'package:hash_wallet/view_model/send/send_view_model.dart';
import 'package:hash_wallet/view_model/send/send_view_model_state.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
part 'cake_pay_buy_card_view_model.g.dart';
class CakePayBuyCardViewModel = CakePayBuyCardViewModelBase with _$CakePayBuyCardViewModel;
abstract class CakePayBuyCardViewModelBase with Store {
CakePayBuyCardViewModelBase(
{required this.vendor,
required CakePayService cakePayService,
required this.sendViewModel,
required this.orders})
: _cakePayService = cakePayService,
walletType = sendViewModel.walletType,
amount = vendor.card!.denominationItems.isNotEmpty
? vendor.card!.denominationItems.first.value
: 0,
quantity = 1,
card = vendor.card!,
min = _toDouble(vendor.card!.minValue) ?? 0,
max = _toDouble(vendor.card!.maxValue) ?? 0 {
selectedPaymentMethod = availableMethods.isNotEmpty ? availableMethods.first : null;
}
static double? _toDouble(String? value) {
if (value == null || value.isEmpty) return null;
return double.tryParse(value.replaceAll(',', '.'));
}
final CakePayVendor vendor;
final SendViewModel sendViewModel;
final CakePayService _cakePayService;
final double max;
final double min;
final CakePayCard card;
final WalletType walletType;
final Box<Order> orders;
CakePayOrder? order;
Timer? _timer;
DateTime? expirationTime;
Duration? remainingTime;
bool confirmsNoVpn = false;
bool confirmsVoidedRefund = false;
bool confirmsTermsAgreed = false;
(String, int?) selectedDenomination = ('', null);
String simulatedResponse = '';
bool get isDenominationSelected =>
card.denominationItems.isNotEmpty &&
card.denominationItems.any((item) => item.value == amount);
Future<bool> get isUserLogged async => await _cakePayService.isLogged();
@observable
double amount;
@observable
int quantity;
@observable
bool isPurchasing = false;
@observable
bool isSimulatingFlow = false;
@observable
bool isOrderExpired = false;
@observable
String formattedRemainingTime = '';
@computed
bool get isAmountSufficient =>
(amount >= min && amount <= max) || (isDenominationSelected && quantity > 0);
@observable
CakePayPaymentMethod? selectedPaymentMethod;
@computed
double get totalAmount => amount * quantity;
@computed
bool get isSimulating =>
isSimulatingFlow &&
FeatureFlag.hasDevOptions &&
FeatureFlag.isCakePayPurchaseSimulationEnabled;
@computed
List<CakePayPaymentMethod> get availableMethods {
switch (walletType) {
case WalletType.bitcoin:
return [
CakePayPaymentMethod.BTC,
if (sendViewModel.wallet.isSoftwareWallet) CakePayPaymentMethod.BTC_LN
];
case WalletType.litecoin:
return [
CakePayPaymentMethod.LTC,
if (sendViewModel.isMwebEnabled) CakePayPaymentMethod.LTC_MWEB
];
case WalletType.monero:
return [CakePayPaymentMethod.XMR];
default:
return const [];
}
}
@action
void chooseMethod(CakePayPaymentMethod method) {
selectedPaymentMethod = method;
if (walletType == WalletType.litecoin) {
sendViewModel.setAllowMwebCoins(method == CakePayPaymentMethod.LTC_MWEB);
}
}
@action
void onQuantityChanged(int? input) => quantity = input ?? 1;
@action
void onAmountChanged(String input) {
if (input.isEmpty) return;
amount = double.parse(input.replaceAll(',', '.'));
}
@action
Future<void> createOrder() async {
if (![
WalletType.bitcoin,
WalletType.monero,
WalletType.litecoin,
].contains(walletType)) {
sendViewModel.state =
FailureState('Unsupported wallet type, please use Bitcoin, Monero, or Litecoin.');
}
try {
order = await _cakePayService.createOrder(
cardId: isDenominationSelected ? selectedDenomination.$2 ?? card.id : card.id,
price: isDenominationSelected ? selectedDenomination.$1 : amount.toString(),
quantity: quantity,
confirmsNoVpn: confirmsNoVpn,
confirmsVoidedRefund: confirmsVoidedRefund,
confirmsTermsAgreed: confirmsTermsAgreed,
);
final paymentData =
CakePayOrder.getPaymentDataFor(method: selectedPaymentMethod, order: order); // TODO should hande other currencies if added
if (paymentData == null || order == null)
throw Exception('Payment data or order is not available.');
await confirmSending(paymentData);
expirationTime = order!.paymentData.expirationTime;
final orderRecord = Order(
id: order!.orderId,
state: TradeState.deserialize(raw: order!.status),
transferId: order!.externalId ?? '',
from: CakePayOrder.getCurrencyCodeFromPaymentMethod(selectedPaymentMethod!),
to: order!.fiatCurrencyCode,
createdAt: DateTime.now(),
amount: paymentData.amount,
receiveAmount: order!.totalReceiveAmount,
quantity: order!.quantity.toString(),
receiveAddress: paymentData.address,
source: OrderSourceDescription.order,
giftCardProvider: OrderProviderDescription.cakePay,
walletId: sendViewModel.wallet.id);
orders.add(orderRecord);
updateRemainingTime();
_startExpirationTimer();
} catch (e) {
sendViewModel.state = FailureState(
sendViewModel.translateErrorMessage(e, walletType, sendViewModel.wallet.currency));
}
}
@action
Future<void> confirmSending(CryptoPaymentData paymentData) async {
try {
sendViewModel.clearOutputs();
final output = sendViewModel.outputs.first;
output.address = paymentData.address;
output.setCryptoAmount(paymentData.price);
await sendViewModel.createTransaction();
} catch (e) {
throw e;
}
}
@action
Future<void> simulatePayment() async {
if (order == null) {
throw Exception('Order is not created yet.');
}
try {
simulatedResponse = await _cakePayService.simulatePayment(orderId: order!.orderId);
sendViewModel.state = TransactionCommitted();
} catch (e) {
sendViewModel.state = FailureState(
sendViewModel.translateErrorMessage(e, walletType, sendViewModel.wallet.currency));
}
}
@action
void updateRemainingTime() {
if (expirationTime == null) {
formattedRemainingTime = '';
return;
}
remainingTime = expirationTime!.difference(DateTime.now());
isOrderExpired = remainingTime!.isNegative;
if (isOrderExpired) {
disposeExpirationTimer();
sendViewModel.state = FailureState('Order has expired.');
} else {
formattedRemainingTime = formatDuration(remainingTime!);
}
}
Future<void> logout() async => await _cakePayService.logout();
void _startExpirationTimer() {
_timer?.cancel();
_timer = Timer.periodic(Duration(seconds: 1), (_) {
updateRemainingTime();
});
}
String formatDuration(Duration duration) {
final hours = duration.inHours;
final minutes = duration.inMinutes.remainder(60);
final seconds = duration.inSeconds.remainder(60);
return '${hours.toString().padLeft(2, '0')}:${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
}
void disposeExpirationTimer() {
_timer?.cancel();
remainingTime = null;
formattedRemainingTime = '';
expirationTime = null;
}
void dispose() {
disposeExpirationTimer();
}
}
@@ -1,299 +0,0 @@
import 'dart:async';
import 'package:hash_wallet/cake_pay/src/models/cake_pay_card.dart';
import 'package:hash_wallet/cake_pay/src/services/cake_pay_service.dart';
import 'package:hash_wallet/cake_pay/src/cake_pay_states.dart';
import 'package:hash_wallet/cake_pay/src/models/cake_pay_vendor.dart';
import 'package:hash_wallet/entities/country.dart';
import 'package:hash_wallet/entities/fiat_currency.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/store/settings_store.dart';
import 'package:hash_wallet/view_model/dashboard/filter_item.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:mobx/mobx.dart';
part 'cake_pay_cards_list_view_model.g.dart';
class CakePayCardsListViewModel = CakePayCardsListViewModelBase with _$CakePayCardsListViewModel;
abstract class CakePayCardsListViewModelBase with Store {
CakePayCardsListViewModelBase({
required this.cakePayService,
required this.settingsStore,
}) : cakePayVendors = [],
userCards = [],
availableCountries = ObservableList<Country>.of(Country.allForCakePay),
page = 1,
displayPrepaidCards = true,
displayGiftCards = true,
displayDenominationsCards = true,
displayCustomValueCards = true,
scrollOffsetFromTop = 0.0,
vendorsState = InitialCakePayVendorLoadingState(),
createCardState = CakePayCreateCardState(),
userCardState = UserCakePayCardsStateInitial(),
searchString = '',
searchMyCardsString = '' {
checkAuth();
initialization();
}
static Country _getInitialCountry(FiatCurrency fiatCurrency) {
if (fiatCurrency.countryCode == 'eur') {
return Country.deu;
}
return Country.fromCode(fiatCurrency.countryCode) ?? Country.usa;
}
void initialization() async {
getVendors();
getUserCards();
}
final CakePayService cakePayService;
final SettingsStore settingsStore;
Map<String, List<FilterItem>> get createFilterItems => {
'Card Type': [
FilterItem(
value: () => displayPrepaidCards,
caption: S.current.prepaid_cards,
onChanged: togglePrepaidCards),
FilterItem(
value: () => displayGiftCards,
caption: S.current.gift_cards,
onChanged: toggleGiftCards),
],
// Uncomment if will be added to backend
// S.current.value_type: [
// FilterItem(
// value: () => displayDenominationsCards,
// caption: S.current.denominations,
// onChanged: toggleDenominationsCards),
// FilterItem(
// value: () => displayCustomValueCards,
// caption: S.current.custom_value,
// onChanged: toggleCustomValueCards),
// ],
};
String searchString;
String? username;
int page;
late Country _initialSelectedCountry;
late bool _initialDisplayPrepaidCards;
late bool _initialDisplayGiftCards;
late bool _initialDisplayDenominationsCards;
late bool _initialDisplayCustomValueCards;
@observable
List<CakePayCard> userCards;
@observable
String searchMyCardsString;
@observable
double scrollOffsetFromTop;
@observable
CakePayCreateCardState createCardState;
@observable
UserCakePayCardsState userCardState;
@observable
CakePayVendorState vendorsState;
@observable
bool hasMoreDataToFetch = true;
@observable
bool isLoadingNextPage = false;
@observable
List<CakePayVendor> cakePayVendors;
@observable
List<Country> availableCountries;
@observable
bool displayPrepaidCards;
@observable
bool displayGiftCards;
@observable
bool displayDenominationsCards;
@observable
bool displayCustomValueCards;
@observable
ObservableFuture<bool>? authFuture;
@computed
bool? get isUserAuthenticated =>
authFuture?.status == FutureStatus.fulfilled ? authFuture?.value : null;
@computed
Country get selectedCountry =>
settingsStore.selectedCakePayCountry ?? _getInitialCountry(settingsStore.fiatCurrency);
@computed
bool get shouldShowCountryPicker =>
settingsStore.selectedCakePayCountry == null && availableCountries.isNotEmpty;
@computed
List<CakePayCard> get filteredUserCards {
final query = searchMyCardsString.trim().toLowerCase();
if (query.isEmpty) return userCards;
return userCards
.where((card) => card.name.toLowerCase().contains(query))
.toList(growable: false);
}
bool get hasFiltersChanged {
return selectedCountry != _initialSelectedCountry ||
displayPrepaidCards != _initialDisplayPrepaidCards ||
displayGiftCards != _initialDisplayGiftCards ||
displayDenominationsCards != _initialDisplayDenominationsCards ||
displayCustomValueCards != _initialDisplayCustomValueCards;
}
Future<void> getUserCards() async {
//Dummy user cards // TODO: fetch from API
userCardState = UserCakePayCardsStateFetching();
try {
await Future.delayed(const Duration(seconds: 2));
final vendorsCard = cakePayVendors
.where((vendor) => vendor.card != null)
.map((vendor) => vendor.card!)
.toList();
userCards = vendorsCard.sublist(0, 10);
vendorsCard.forEach((card) {
if (card.name.toLowerCase().contains('amazon.com')) {
userCards.add(card);
}
});
userCardState = UserCakePayCardsStateSuccess();
if (userCards.isEmpty) {
userCardState = UserCakePayCardsStateNoCards();
}
} catch (e) {
userCardState = UserCakePayCardsStateFailure(error: e.toString());
}
}
@action
Future<void> checkAuth() async {
authFuture = ObservableFuture(cakePayService.isLogged());
final logged = await authFuture!;
if (logged) {
username = await cakePayService.getUserEmail();
}
}
@action
Future<void> getVendors({
String? text,
int? currentPage,
}) async {
vendorsState = CakePayVendorLoadingState();
try {
searchString = text ?? '';
var newVendors = await cakePayService.getVendors(
countryCode: selectedCountry.countryCode,
page: currentPage ?? page,
search: searchString,
giftCards: displayGiftCards,
prepaidCards: displayPrepaidCards);
cakePayVendors = newVendors.where((vendor) {
if (vendor.card == null) return false;
if (vendor.available != true) return false;
return true;
}).toList();
} catch (e) {
printV(e);
}
vendorsState = CakePayVendorLoadedState();
}
@action
Future<void> fetchNextPage() async {
if (vendorsState is CakePayVendorLoadingState || !hasMoreDataToFetch || isLoadingNextPage) {
return;
}
isLoadingNextPage = true;
page++;
try {
var newVendors = await cakePayService.getVendors(
countryCode: selectedCountry.countryCode,
page: page,
search: searchString,
giftCards: displayGiftCards,
prepaidCards: displayPrepaidCards);
cakePayVendors.addAll(newVendors.where((vendor) {
if (vendor.card == null) return false;
if (vendor.available != true) return false;
return true;
}).toList());
} catch (error) {
if (error.toString().contains('detail":"Invalid page."')) {
hasMoreDataToFetch = false;
}
} finally {
isLoadingNextPage = false;
}
}
Future<bool> isCakePayUserAuthenticated() async {
return await cakePayService.isLogged();
}
void resetLoadingNextPageState() {
hasMoreDataToFetch = true;
page = 1;
}
void storeInitialFilterStates() {
_initialSelectedCountry = selectedCountry;
_initialDisplayPrepaidCards = displayPrepaidCards;
_initialDisplayGiftCards = displayGiftCards;
_initialDisplayDenominationsCards = displayDenominationsCards;
_initialDisplayCustomValueCards = displayCustomValueCards;
}
@action
void setSelectedCountry(Country country) {
// just so it triggers the reaction even when selecting the default country
settingsStore.selectedCakePayCountry = null;
settingsStore.selectedCakePayCountry = country;
}
@action
void setMyCardsQuery(String text) => searchMyCardsString = text;
@action
void togglePrepaidCards() => displayPrepaidCards = !displayPrepaidCards;
@action
void toggleGiftCards() => displayGiftCards = !displayGiftCards;
@action
void toggleDenominationsCards() => displayDenominationsCards = !displayDenominationsCards;
@action
void toggleCustomValueCards() => displayCustomValueCards = !displayCustomValueCards;
void setScrollOffsetFromTop(double scrollOffset) {
scrollOffsetFromTop = scrollOffset;
}
}
@@ -1,16 +0,0 @@
import 'package:hash_wallet/cake_pay/src/services/cake_pay_service.dart';
import 'package:mobx/mobx.dart';
part 'cake_features_view_model.g.dart';
class CakeFeaturesViewModel = CakeFeaturesViewModelBase with _$CakeFeaturesViewModel;
abstract class CakeFeaturesViewModelBase with Store {
final CakePayService _cakePayService;
CakeFeaturesViewModelBase(this._cakePayService);
Future<bool> isIoniaUserAuthenticated() async {
return await _cakePayService.isLogged();
}
}
@@ -4,19 +4,9 @@ import 'package:hash_wallet/core/amount_parsing_proxy.dart';
import 'package:hash_wallet/entities/calculate_fiat_amount.dart';
import 'package:hash_wallet/entities/fiat_currency.dart';
import 'package:hash_wallet/exchange/exchange_provider_description.dart';
import 'package:hash_wallet/exchange/provider/chainflip_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/changenow_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/exolix_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/near_Intents_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swapsxyz_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swaptrade_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/sideshift_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/simpleswap_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/stealth_ex_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/thorchain_exchange.provider.dart';
import 'package:hash_wallet/exchange/provider/trocador_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/xoswap_exchange_provider.dart';
import 'package:hash_wallet/exchange/trade.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/reactions/wallet_connect.dart';
@@ -51,41 +41,12 @@ abstract class ExchangeTradeViewModelBase with Store {
isSwapsXYZCanSendFromExternal = _checkIfSwapsXYZCanSendFromExternal(tradesStore.trade!, wallet),
items = ObservableList<ExchangeTradeItem>() {
setUpOutput();
// Trades from providers whose implementations were removed keep a null
// _provider; status polling is simply skipped for them.
switch (trade.provider) {
case ExchangeProviderDescription.changeNow:
_provider =
ChangeNowExchangeProvider(settingsStore: sendViewModel.balanceViewModel.settingsStore);
break;
case ExchangeProviderDescription.sideShift:
_provider = SideShiftExchangeProvider();
break;
case ExchangeProviderDescription.simpleSwap:
_provider = SimpleSwapExchangeProvider();
break;
case ExchangeProviderDescription.trocador:
_provider = TrocadorExchangeProvider();
break;
case ExchangeProviderDescription.exolix:
_provider = ExolixExchangeProvider();
break;
case ExchangeProviderDescription.swapTrade:
_provider = SwapTradeExchangeProvider();
break;
case ExchangeProviderDescription.stealthEx:
_provider = StealthExExchangeProvider();
break;
case ExchangeProviderDescription.thorChain:
_provider = ThorChainExchangeProvider();
break;
case ExchangeProviderDescription.chainflip:
_provider = ChainflipExchangeProvider();
break;
case ExchangeProviderDescription.xoSwap:
_provider = XOSwapExchangeProvider();
break;
case ExchangeProviderDescription.swapsXyz:
_provider = SwapsXyzExchangeProvider();
break;
case ExchangeProviderDescription.nearIntents:
_provider = NearIntentsExchangeProvider();
break;
@@ -195,7 +156,6 @@ abstract class ExchangeTradeViewModelBase with Store {
output = sendViewModel.outputs.first;
output.address = trade.inputAddress ?? '';
output.setCryptoAmount(trade.amount);
if (_provider is ThorChainExchangeProvider) output.memo = trade.memo ?? "";
if (trade.isSendAll == true) output.sendAll = true;
}
@@ -211,19 +171,7 @@ abstract class ExchangeTradeViewModelBase with Store {
sendViewModel.selectedCryptoCurrency = selected;
final pendingTransaction =
await sendViewModel.createTransaction(provider: _provider, trade: trade);
if (_provider is SwapsXyzExchangeProvider) {
final hash = pendingTransaction?.evmTxHashFromRawHex ?? pendingTransaction?.id ?? '';
trade.txId = hash;
await trade.save();
}
if (_provider is ThorChainExchangeProvider) {
trade.id = pendingTransaction?.id ?? '';
await trade.save();
}
await sendViewModel.createTransaction(provider: _provider, trade: trade);
}
@action
@@ -23,17 +23,8 @@ import 'package:hash_wallet/exchange/exchange_template.dart';
import 'package:hash_wallet/exchange/exchange_trade_state.dart';
import 'package:hash_wallet/exchange/limits.dart';
import 'package:hash_wallet/exchange/limits_state.dart';
import 'package:hash_wallet/exchange/provider/chainflip_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/letsexchange_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/changenow_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/exolix_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/near_Intents_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/stealth_ex_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swapsxyz_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swaptrade_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/trocador_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/xoswap_exchange_provider.dart';
import 'package:hash_wallet/exchange/trade.dart';
import 'package:hash_wallet/exchange/trade_request.dart';
import 'package:hash_wallet/generated/i18n.dart';
@@ -49,7 +40,6 @@ import 'package:hash_wallet/store/settings_store.dart';
import 'package:hash_wallet/store/templates/exchange_template_store.dart';
import 'package:hash_wallet/evm/evm.dart';
import 'package:hash_wallet/reactions/wallet_connect.dart';
import 'package:hash_wallet/utils/feature_flag.dart';
import 'package:hash_wallet/utils/token_utilities.dart';
import 'package:hash_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:hash_wallet/view_model/send/fees_view_model.dart';
@@ -197,8 +187,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
final initialProvider = provider;
provider!.checkIsAvailable().then((bool isAvailable) {
if (!isAvailable && provider == initialProvider) {
provider = providerList.firstWhere((provider) => provider is ChangeNowExchangeProvider,
orElse: () => providerList.last);
provider = providerList.last;
_onPairChange();
}
});
@@ -323,20 +312,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
// Hash Bags: trimmed to Trocador only. Trocador's aggregator already fronts
// ChangeNow, LetsExchange, Exolix, StealthEx, FixedFloat, Quantex, etc.,
// letting us collect markup as the affiliate. Re-enable individual providers
// here only after registering Such Software affiliate keys per provider.
// letting us collect markup as the affiliate. The individual provider
// implementations were deleted; restore them from Cake Wallet upstream and
// register Such Software affiliate keys per provider before re-adding any.
List<ExchangeProvider> get _allProviders => [
// ChangeNowExchangeProvider(settingsStore: _settingsStore),
// SideShiftExchangeProvider(),
// ChainflipExchangeProvider(),
// if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(),
// SwapTradeExchangeProvider(),
// LetsExchangeExchangeProvider(),
// StealthExExchangeProvider(),
// XOSwapExchangeProvider(),
// SwapsXyzExchangeProvider(),
// JupiterExchangeProvider(),
// NearIntentsExchangeProvider(),
TrocadorExchangeProvider(
useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates),
];
@@ -1501,16 +1480,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
}
void _defineIsReceiveAmountEditable() {
/*if ((provider is ChangeNowExchangeProvider)
&&(depositCurrency == CryptoCurrency.xmr)
&&(receiveCurrency == CryptoCurrency.btc)) {
isReceiveAmountEditable = true;
} else {
isReceiveAmountEditable = false;
}*/
//isReceiveAmountEditable = false;
// isReceiveAmountEditable = selectedProviders.any((provider) => provider is ChangeNowExchangeProvider);
// isReceiveAmountEditable = provider is ChangeNowExchangeProvider || provider is SimpleSwapExchangeProvider;
isReceiveAmountEditable = true;
}
+2 -38
View File
@@ -1,25 +1,16 @@
import 'dart:async';
import 'package:hash_wallet/buy/buy_provider_description.dart';
import 'package:hash_wallet/cake_pay/src/models/cake_pay_order.dart';
import 'package:hash_wallet/cake_pay/src/services/cake_pay_service.dart';
import 'package:hash_wallet/core/utilities.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/order/order.dart';
import 'package:hash_wallet/order/order_provider.dart';
import 'package:hash_wallet/order/order_provider_adapter/cake_pay_order_provider_adapter.dart';
import 'package:hash_wallet/order/order_provider_description.dart';
import 'package:hash_wallet/order/order_source_description.dart';
import 'package:hash_wallet/src/screens/order_details/cake_pay_detail_list_card_item.dart';
import 'package:hash_wallet/src/screens/trade_details/track_trade_list_item.dart';
import 'package:hash_wallet/src/screens/trade_details/trade_details_status_item.dart';
import 'package:hash_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:hash_wallet/utils/date_formatter.dart';
import 'package:hash_wallet/utils/show_bar.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -32,7 +23,6 @@ abstract class OrderDetailsViewModelBase with Store {
OrderDetailsViewModelBase({
required WalletBase wallet,
required Order orderForDetails,
required this.cakePayService,
required this.orders,
}) : items = ObservableList<StandartListItem>(),
order = orderForDetails {
@@ -44,9 +34,8 @@ abstract class OrderDetailsViewModelBase with Store {
break;
case OrderSourceDescription.order:
if (order.orderProvider == OrderProviderDescription.cakePay) {
_provider = CakePayOrderProviderAdapter(wallet: wallet, cakePayService: cakePayService);
}
// Cake Pay orders: the Cake Pay integration was removed, so stored
// orders are shown from persisted data only (_provider stays null).
break;
}
@@ -61,10 +50,8 @@ abstract class OrderDetailsViewModelBase with Store {
@observable
ObservableList<StandartListItem> items;
final CakePayService cakePayService;
final Box<Order> orders;
OrderProvider? _provider;
List<OrderCard> cards = [];
Timer? timer;
@@ -76,10 +63,6 @@ abstract class OrderDetailsViewModelBase with Store {
final updatedOrderObj = await _provider!.findOrderById(order.id);
final updatedOrder = updatedOrderObj.$1;
if (_provider is CakePayOrderProviderAdapter) {
cards = updatedOrderObj.$2 as List<OrderCard>? ?? [];
}
final existing = orders.values.firstWhereOrNull((e) => e.id == updatedOrder.id);
if (existing != null) {
existing.stateRaw = updatedOrder.stateRaw;
@@ -98,30 +81,11 @@ abstract class OrderDetailsViewModelBase with Store {
}
void _updateItems() {
final dateFormat = DateFormatter.withCurrentLocal();
items.clear();
items.add(
DetailsListStatusItem(title: S.current.trade_details_state, value: order.state.toString()));
if (_provider is CakePayOrderProviderAdapter) {
items.add(CakePayDetailsListCardItem(
title: '',
value: '',
id: order.id,
createdAt: dateFormat.format(order.createdAt),
price: order.receiveAmount,
quantity: order.quantity,
from: order.from ?? '',
to: order.to ?? '',
cards: cards,
onTap: (BuildContext context) {
Clipboard.setData(ClipboardData(text: '${order.id}'));
showBar<void>(context, S.of(context).copied_to_clipboard);
},
));
}
items.add(StandartListItem(title: 'Order provider', value: _provider?.title ?? ''));
final trackUrl = _provider?.trackUrl ?? '';
-347
View File
@@ -21,11 +21,8 @@ import 'package:hash_wallet/entities/template.dart';
import 'package:hash_wallet/entities/transaction_description.dart';
import 'package:hash_wallet/entities/wallet_contact.dart';
import 'package:hash_wallet/evm/evm.dart';
import 'package:hash_wallet/exchange/exchange_provider_description.dart';
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/near_Intents_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swapsxyz_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/thorchain_exchange.provider.dart';
import 'package:hash_wallet/exchange/trade.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/monero/monero.dart';
@@ -47,13 +44,11 @@ import 'package:hash_wallet/view_model/unspent_coins/unspent_coins_list_view_mod
import 'package:hash_wallet/wownero/wownero.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/currency_for_wallet_type.dart';
import 'package:cw_core/erc20_token.dart';
import 'package:cw_core/exceptions.dart';
import 'package:cw_core/lnurl.dart';
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/sync_status.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/unspent_coin_type.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/wallet_type.dart';
@@ -131,10 +126,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
});
}
// Store trade and provider references for post-commit updates (e.g., Jupiter trade ID update)
Trade? _currentTrade;
ExchangeProvider? _currentProvider;
@observable
ExecutionState state;
@@ -596,8 +587,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
@action
Future<PendingTransaction?> createTransaction({ExchangeProvider? provider, Trade? trade}) async {
_currentTrade = trade;
_currentProvider = provider;
pendingTransaction = null;
try {
@@ -615,184 +604,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
}
}
// Swaps.xyz (EVM) path
if (isEVMWallet && trade != null && provider is SwapsXyzExchangeProvider) {
final routerTo = trade.inputAddress;
final routerData = trade.routerData;
if (routerData != null && routerData != '0x') {
final tokenContract = (trade.sourceTokenAddress ?? '').toLowerCase();
final priority = _settingsStore.getPriority(
walletType, chainId: selectedChainId);
final routerValueWei = BigInt.tryParse(trade.routerValue ?? '0') ??
BigInt.zero;
if (routerTo == null || routerTo.isEmpty) {
state = FailureState('Invalid router address');
return null;
}
try {
final selector = _decodeMethodSelector(routerData);
const transferSig = '0xa9059cbb';
const swapAndExecuteSig = '0x9be111d1';
// Direct Transfer (Simple routing, no approval needed)
if (selector == transferSig) {
pendingTransaction = await evm!.createRawCallDataTransaction(
wallet,
routerTo,
routerData,
BigInt.zero,
priority,
useBlinkProtection: canSupportBlinkProtection(selectedChainId)
? _settingsStore.useBlinkProtection
: false,
);
state = ExecutedSuccessfullyState();
return pendingTransaction;
}
// Smart Swap (Requires Approval)
if (selector == swapAndExecuteSig) {
final requiredAmount = BigInt.tryParse(
(trade.sourceTokenAmountRaw ?? '0').replaceAll('n', '')) ??
BigInt.zero;
final needsApproval = tokenContract.isNotEmpty &&
requiredAmount > BigInt.zero
? await evm!.isApprovalRequired(
wallet, tokenContract, routerTo, requiredAmount)
: false;
printV(
'[Swaps.xyz sending flow] Approval required: $needsApproval for token ${trade
.from?.title} ${trade.from?.tag ??
''} with amount $requiredAmount');
if (needsApproval) {
// USDT Approval Flow (Special Case). We must reset allowance to 0 first.
final isUSDTMainnet = selectedChainId == 1 &&
tokenContract.toLowerCase() ==
'0xdac17f958d2ee523a2206206994597c13d831ec7';
if (isUSDTMainnet) {
final currentAllowance = await evm!.getAllowance(
wallet, tokenContract, routerTo);
if (currentAllowance != null &&
currentAllowance > BigInt.zero) {
printV(
'[Swaps.xyz sending flow] currentAllowance USDT: $currentAllowance. Resetting to 0 before setting new allowance.');
final resetTx = await buildApprovalNeeded(
spender: routerTo,
tokenContract: tokenContract,
requiredAmount: BigInt.zero,
// Approve 0
sourceTokenDecimals: trade.sourceTokenDecimals,
priority: priority
);
if (resetTx != null) {
await resetTx.commit();
final resetConfirmed = await _waitForApprovalUpdate(
tokenContract: tokenContract,
spender: routerTo,
requiredAmount: BigInt.zero, // Wait until it equals 0
waitForExactMatch: true,
);
if (!resetConfirmed) {
state = FailureState(
'Failed to reset USDT allowance. Please try again.');
return null;
}
printV(
'[Swaps.xyz sending flow] USDT allowance reset to 0 confirmed on-chain.');
}
}
}
// Standard Approval Flow
final approvalTx = await buildApprovalNeeded(
spender: routerTo,
tokenContract: tokenContract,
requiredAmount: requiredAmount,
sourceTokenDecimals: trade.sourceTokenDecimals,
priority: priority
);
if (approvalTx == null) {
state = FailureState('Failed to build approval transaction');
return null;
}
pendingTransaction = null;
try {
printV(
'[Swaps.xyz sending flow] Submitting approval transaction for token ${trade
.from?.title} ${trade.from?.tag ?? ''} ');
await approvalTx.commit();
// Wait for the approval to be mined on-chain
final isApproved = await _waitForApprovalUpdate(
tokenContract: tokenContract,
spender: routerTo,
requiredAmount: requiredAmount,
);
if (!isApproved) {
state = FailureState(
'Approval transaction failed or timed out on-chain. Try again.');
return null;
}
printV(
'[Swaps.xyz sending flow] Approval transaction confirmed on-chain. Proceeding with swap execution.');
} catch (e, s) {
printV(
'[Swaps.xyz sending flow] Approval transaction error: $e\n$s');
state = FailureState(
translateErrorMessage(e, wallet.type, wallet.currency));
return null;
}
}
// Construct Final Swap Transaction
printV('[Swaps.xyz sending flow] Building swap transaction');
pendingTransaction = await evm!.createRawCallDataTransaction(
wallet,
routerTo,
routerData,
routerValueWei,
priority,
sourceTokenAddress: tokenContract,
sourceTokenAmount: requiredAmount,
useBlinkProtection: canSupportBlinkProtection(selectedChainId)
? _settingsStore.useBlinkProtection
: false,
);
state = ExecutedSuccessfullyState();
return pendingTransaction;
}
state = FailureState('Unsupported Swaps.xyz transaction type');
return null;
} catch (e, s) {
printV('Swaps.xyz transaction error: $e\n$s');
state = FailureState(
'Failed to create Swaps.xyz transaction - ${translateErrorMessage(
e, wallet.type, wallet.currency)}');
return null;
}
}
}
// END Swaps.xyz path
// Regular flow
@@ -823,16 +634,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
}
}
if (provider is ThorChainExchangeProvider) {
final outputCount = pendingTransaction?.outputCount ?? 0;
if (outputCount > 10) {
throw Exception("THORChain does not support more than 10 outputs");
}
if (_hasTaprootInput(pendingTransaction)) {
throw Exception("THORChain does not support Taproot addresses");
}
}
}
@@ -936,13 +737,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
state = TransactionCommitted();
if (_currentTrade != null) {
final provider = _currentTrade!.provider;
if (provider == ExchangeProviderDescription.swapsXyz) {
registerSwapsXyzTransaction(_currentTrade!);
}
}
// Immediate transaction update for EVM chains and Nano
if (isEVMWallet || [WalletType.bitcoin, WalletType.nano].contains(walletType)) {
Future.delayed(Duration(seconds: 4), () async {
@@ -1121,88 +915,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return null;
}
// Helper functions for EVM transaction monitoring and approval flow
// Polls the token contract directly to see if allowance is updated.
Future<bool> _waitForApprovalUpdate({
required String tokenContract,
required String spender,
required BigInt requiredAmount,
bool waitForExactMatch = false,
}) async {
if (!isEVMWallet || evm == null) return false;
int attempts = 0;
const int maxAttempts = 30; // ~60 seconds
printV('[Swaps.xyz sending flow] Starting allowance check. Target: $requiredAmount (Exact match: $waitForExactMatch)');
while (attempts < maxAttempts) {
try {
final currentAllowance = await evm!.getAllowance(wallet, tokenContract, spender);
if (currentAllowance != null) {
printV('[Swaps.xyz sending flow] Current Allowance: $currentAllowance / Target: $requiredAmount');
if (waitForExactMatch) {
// For Reset (Target 0): We need it to be exactly 0 (or less, though it can't be negative)
if (currentAllowance <= requiredAmount) {
printV('[Swaps.xyz sending flow] Allowance reset verified!');
return true;
}
} else {
// For Approval: We need it to be at least the required amount
if (currentAllowance >= requiredAmount) {
printV('[Swaps.xyz sending flow] Allowance verified!');
return true;
}
}
}
} catch (e) {
printV('[Swaps.xyz sending flow] Allowance check error: $e');
}
await Future.delayed(const Duration(seconds: 1));
attempts++;
}
printV('[Swaps.xyz sending flow] Allowance check timed out.');
return false;
}
// Builds a token approval transaction
Future<PendingTransaction?> buildApprovalNeeded({
required String spender,
required String tokenContract,
required BigInt requiredAmount,
required TransactionPriority? priority,
int? sourceTokenDecimals,
}) async {
final erc20Token = wallet.balance.keys.whereType<Erc20Token>().firstWhere(
(t) => t.contractAddress.toLowerCase() == tokenContract.toLowerCase(),
orElse: () => Erc20Token(
name: '',
symbol: '',
contractAddress: tokenContract,
decimal: sourceTokenDecimals ?? 18,
enabled: true,
),
);
return await evm!.createTokenApproval(
wallet,
requiredAmount,
spender,
erc20Token,
priority,
useBlinkProtection:
canSupportBlinkProtection(selectedChainId) ? _settingsStore.useBlinkProtection : false,
);
}
// End EVM helper functions
String translateErrorMessage(
Object error,
WalletType walletType,
@@ -1322,63 +1034,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return null;
}
bool _hasTaprootInput(PendingTransaction? pendingTransaction) {
if (walletType == WalletType.bitcoin && pendingTransaction != null) {
return bitcoin!.hasTaprootInput(pendingTransaction);
}
return false;
}
Future<void> registerSwapsXyzTransaction(Trade trade) async {
try {
// register only for vmId is alt-vm or bridgeId is alt-vm (trade.needToRegisterInSwapXyz)
final needToRegister = trade.needToRegisterInSwapXyz ?? false;
if (!needToRegister) return;
final vmId = (trade.providerId ?? '').toLowerCase();
if (vmId.isEmpty) {
printV('SwapsXyz: transaction register: skipped (vmId empty)');
return;
}
final txHash = pendingTransaction?.evmTxHashFromRawHex
?? pendingTransaction?.id
?? '';
if (txHash.isEmpty) {
printV('SwapsXyz: transaction register: skipped (txHash empty)');
return;
}
final chainId = int.tryParse(trade.router ?? '') ?? 0;
if (chainId <= 0) {
printV('SwapsXyz: transaction register: skipped (invalid chainId)');
return;
}
printV(
'SwapsXyz: attempting to register transaction: tradeId = ${trade.id}, txHash = $txHash, chainId = $chainId, vmId = $vmId');
final registered = await SwapsXyzExchangeProvider.registerAltVmTx(
txId: trade.id,
txHash: txHash,
chainId: chainId,
vmId: vmId,
);
if (!registered) {
printV('SwapsXyz: transaction register: failed');
} else {
printV('SwapsXyz: transaction register: success');
}
} catch (e) {
printV('registerSwapsXyzTransaction error: $e');
}
}
@computed
bool get usePayjoin => _settingsStore.usePayjoin;
@@ -1397,6 +1052,4 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
}
}
String _decodeMethodSelector(String s) =>
(s.startsWith('0x') && s.length >= 10) ? s.substring(0, 10) : '';
}
+2 -43
View File
@@ -1,20 +1,9 @@
import 'dart:async';
import 'package:hash_wallet/exchange/exchange_provider_description.dart';
import 'package:hash_wallet/exchange/provider/chainflip_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/changenow_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/exolix_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/letsexchange_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/near_Intents_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swapsxyz_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/swaptrade_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/sideshift_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/simpleswap_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/stealth_ex_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/thorchain_exchange.provider.dart';
import 'package:hash_wallet/exchange/provider/trocador_exchange_provider.dart';
import 'package:hash_wallet/exchange/provider/xoswap_exchange_provider.dart';
import 'package:hash_wallet/exchange/trade.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/src/screens/trade_details/track_trade_list_item.dart';
@@ -40,42 +29,12 @@ abstract class TradeDetailsViewModelBase with Store {
required this.appStore,
}) : items = ObservableList<StandartListItem>(),
trade = tradeForDetails {
// Trades from providers whose implementations were removed keep a null
// _provider and show the "provider unsupported" item with stored data.
switch (trade.provider) {
case ExchangeProviderDescription.changeNow:
_provider = ChangeNowExchangeProvider(settingsStore: appStore.settingsStore);
break;
case ExchangeProviderDescription.sideShift:
_provider = SideShiftExchangeProvider();
break;
case ExchangeProviderDescription.simpleSwap:
_provider = SimpleSwapExchangeProvider();
break;
case ExchangeProviderDescription.trocador:
_provider = TrocadorExchangeProvider();
break;
case ExchangeProviderDescription.exolix:
_provider = ExolixExchangeProvider();
break;
case ExchangeProviderDescription.thorChain:
_provider = ThorChainExchangeProvider();
break;
case ExchangeProviderDescription.swapTrade:
_provider = SwapTradeExchangeProvider();
case ExchangeProviderDescription.letsExchange:
_provider = LetsExchangeExchangeProvider();
break;
case ExchangeProviderDescription.stealthEx:
_provider = StealthExExchangeProvider();
break;
case ExchangeProviderDescription.chainflip:
_provider = ChainflipExchangeProvider();
break;
case ExchangeProviderDescription.xoSwap:
_provider = XOSwapExchangeProvider();
break;
case ExchangeProviderDescription.swapsXyz:
_provider = SwapsXyzExchangeProvider();
break;
case ExchangeProviderDescription.nearIntents:
_provider = NearIntentsExchangeProvider();
break;