minor fix [skip ci]

Omar committed Jul 13, 2026 at 05:49 UTC bff9b2fa9648b22c2fcc84062caba58861e9d24f
2 files changed +49 -54
lib/exchange/provider/near_Intents_exchange_provider.dart
+5 -3
@@ -271,15 +271,17 @@ class NearIntentsExchangeProvider extends ExchangeProvider {
271 throw Exception('Failed to parse to currency from assetId: $toAssetId');
272 }
273
274 - final from = CryptoCurrency.safeParseCurrencyFromString(fromCurrency.$1, tag: fromCurrency.$2);
275 - final to = CryptoCurrency.safeParseCurrencyFromString(toCurrency.$1, tag: toCurrency.$2);
274 + final from = CryptoCurrency.safeParseCurrencyFromString(fromCurrency.$1,
275 + tag: fromCurrency.$2);
276 + final to = CryptoCurrency.safeParseCurrencyFromString(toCurrency.$1,
277 + tag: toCurrency.$2);
278
279
280 final trade = Trade(
281 id: depositAddress,
282 // Using deposit address as trade ID
283 from: request.fromCurrency,
282 - to: request.fromCurrency,
284 + to: request.toCurrency,
285 provider: description,
286 providerName: title,
287 state: TradeState.created,
lib/view_model/exchange/exchange_trade_view_model.dart
+44 -51
@@ -214,11 +214,11 @@ abstract class ExchangeTradeViewModelBase with Store {
214 final canSendError = checkIfCanSend(trade, wallet);
215
216 if (canSendError != null) {
217 + _logCanSendError(trade, wallet, canSendError);
218 sendViewModel.state = FailureState(canSendError);
219 return;
220 }
221
221 -
222 final selected = trade.from;
223 if (selected == null) {
224 printV('No selectable currency for trade ${trade.id}');
@@ -354,62 +354,55 @@ abstract class ExchangeTradeViewModelBase with Store {
354 }
355
356 String? checkIfCanSend(Trade? trade, WalletBase wallet) {
357 - try {
357 + if (trade == null) return 'Trade is null';
358
359 - if (trade == null) throw Exception('Trade is null');
360 -
361 - final tradeFrom = trade.from;
362 - if (tradeFrom == null) throw Exception('Trade from currency is null');
359 + final tradeFrom = trade.from;
360 + if (tradeFrom == null) return 'Trade from currency is null';
361
364 - bool _sameCurrency(CryptoCurrency a, CryptoCurrency b) => a.titleAndTagEqual(b);
362 + bool _sameCurrency(CryptoCurrency a, CryptoCurrency b) => a.titleAndTagEqual(b);
363
366 - bool _isTokenBelongingToWallet(CryptoCurrency cur) {
367 - final chainTag = cur.tag ?? cur.title;
368 - return wallet.currency == cur &&
369 - tradeFrom.tag?.toUpperCase() == chainTag.toUpperCase();
370 - }
364 + bool _isTokenBelongingToWallet(CryptoCurrency cur) {
365 + final chainTag = cur.tag ?? cur.title;
366 + return wallet.currency == cur &&
367 + (tradeFrom.tag?.toUpperCase() == chainTag.toUpperCase() ||
368 + tradeFrom.title.toUpperCase() == chainTag.toUpperCase());
369 + }
370
372 - final canSend = _sameCurrency(tradeFrom, wallet.currency) ||
373 - (_sameCurrency(tradeFrom, CryptoCurrency.btcln) &&
374 - wallet.currency == CryptoCurrency.btc) ||
375 - trade.provider == ExchangeProviderDescription.xmrto ||
376 - _isTokenBelongingToWallet(CryptoCurrency.eth) ||
377 - _isTokenBelongingToWallet(CryptoCurrency.maticpoly) ||
378 - _isTokenBelongingToWallet(CryptoCurrency.baseEth) ||
379 - _isTokenBelongingToWallet(CryptoCurrency.arbEth) ||
380 - _isTokenBelongingToWallet(CryptoCurrency.trx) ||
381 - _isTokenBelongingToWallet(CryptoCurrency.sol) ||
382 - _isTokenBelongingToWallet(CryptoCurrency.bnb);
383 -
384 - if (!canSend) {
385 - throw Exception(
386 - 'Wallet currency ${wallet.currency.title} does not match trade from currency ${tradeFrom.title} or is not a supported token for this wallet.',
387 - );
388 - }
371 + final canSend = _sameCurrency(tradeFrom, wallet.currency) ||
372 + (_sameCurrency(tradeFrom, CryptoCurrency.btcln) &&
373 + wallet.currency == CryptoCurrency.btc) ||
374 + trade.provider == ExchangeProviderDescription.xmrto ||
375 + _isTokenBelongingToWallet(CryptoCurrency.eth) ||
376 + _isTokenBelongingToWallet(CryptoCurrency.maticpoly) ||
377 + _isTokenBelongingToWallet(CryptoCurrency.baseEth) ||
378 + _isTokenBelongingToWallet(CryptoCurrency.arbEth) ||
379 + _isTokenBelongingToWallet(CryptoCurrency.trx) ||
380 + _isTokenBelongingToWallet(CryptoCurrency.sol) ||
381 + _isTokenBelongingToWallet(CryptoCurrency.bnb);
382 +
383 + if (!canSend) {
384 + return 'Wallet currency ${wallet.currency.title} does not match trade from currency ${tradeFrom.title} or is not a supported token for this wallet.';
385 + }
386
390 - return null;
391 - } catch (e, s) {
392 - final trade = tradesStore.trade;
393 -
394 - ExchangeProviderLogger.logError(
395 - provider: trade?.provider,
396 - function: '_checkIfCanSend',
397 - error: e,
398 - stackTrace: s,
399 - requestData: {
400 - 'tradeId': trade?.id,
401 - 'tradeFrom': trade?.from?.title,
402 - 'tradeFromTag': trade?.from?.tag,
403 - 'tradeTo': trade?.to?.title,
404 - 'tradeToTag': trade?.to?.tag,
405 - 'walletName': wallet.name,
406 - 'walletCurrency': wallet.currency.title,
407 - 'walletCurrencyTag': wallet.currency.tag,
408 - },
409 - );
387 + return null;
388 + }
389
411 - return e.toString();
412 - }
390 + void _logCanSendError(Trade? trade, WalletBase wallet, String error) {
391 + ExchangeProviderLogger.logError(
392 + provider: trade?.provider,
393 + function: '_checkIfCanSend',
394 + error: error,
395 + requestData: {
396 + 'tradeId': trade?.id,
397 + 'tradeFrom': trade?.from?.title,
398 + 'tradeFromTag': trade?.from?.tag,
399 + 'tradeTo': trade?.to?.title,
400 + 'tradeToTag': trade?.to?.tag,
401 + 'walletName': wallet.name,
402 + 'walletCurrency': wallet.currency.title,
403 + 'walletCurrencyTag': wallet.currency.tag,
404 + },
405 + );
406 }
407
408 static bool _checkIfSwapsXYZCanSendFromExternal(Trade trade, WalletBase wallet) {