From b6fa059e5472bc989d1c33d37e67a2521152a877 Mon Sep 17 00:00:00 2001 From: Serhii Date: Wed, 10 Dec 2025 06:09:31 +0200 Subject: [PATCH] Cw 1307 debug swap creation error (#2713) * fix amount validator to include min and max values * add BitcoinVN workaround * fix Chainflip casting for decoded JSON --------- Co-authored-by: Serhii-Borodenko <17529954+Serhii-Borodenko@users.noreply.github.com> --- lib/core/amount_validator.dart | 4 ++-- lib/exchange/provider/chainflip_exchange_provider.dart | 4 +++- lib/exchange/provider/trocador_exchange_provider.dart | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/core/amount_validator.dart b/lib/core/amount_validator.dart index 0f27a1331..b6c8abda5 100644 --- a/lib/core/amount_validator.dart +++ b/lib/core/amount_validator.dart @@ -112,7 +112,7 @@ class AmountMinValidator extends Validator { return false; } - return valueInDouble > minInDouble; + return valueInDouble >= minInDouble; } double? parseToDouble(String value) { @@ -146,7 +146,7 @@ class AmountMaxValidator extends Validator { if (valueInDouble == null || maxInDouble == null) { return false; } - return valueInDouble < maxInDouble; + return valueInDouble <= maxInDouble; } double? parseToDouble(String value) { diff --git a/lib/exchange/provider/chainflip_exchange_provider.dart b/lib/exchange/provider/chainflip_exchange_provider.dart index cbd9fa85f..92c2f5245 100644 --- a/lib/exchange/provider/chainflip_exchange_provider.dart +++ b/lib/exchange/provider/chainflip_exchange_provider.dart @@ -388,7 +388,9 @@ class ChainflipExchangeProvider extends ExchangeProvider { throw Exception('Unexpected response: ${response.statusCode} / ${uri.toString()} / ${response.body}'); } - final quotes = json.decode(response.body) as List>; + final List jsonList = json.decode(response.body) as List; + final List> quotes = + jsonList.map((e) => e as Map).toList(); Map highestQuote = quotes.reduce((current, next) { double currentAmount = current['egressAmount'] as double; diff --git a/lib/exchange/provider/trocador_exchange_provider.dart b/lib/exchange/provider/trocador_exchange_provider.dart index f1e0d2ab0..77ad9486c 100644 --- a/lib/exchange/provider/trocador_exchange_provider.dart +++ b/lib/exchange/provider/trocador_exchange_provider.dart @@ -114,8 +114,7 @@ class TrocadorExchangeProvider extends ExchangeProvider { return Limits( min: coinJson['minimum'] as double?, - // TODO: remove hardcoded value and call `api/new_rate` when Trocador adds min and max to it - max: from == CryptoCurrency.zano ? 2600 : coinJson['maximum'] as double?, + max: coinJson['maximum'] as double?, ); } @@ -276,7 +275,9 @@ class TrocadorExchangeProvider extends ExchangeProvider { throw Exception('No available provider is enabled'); } - params['provider'] = _provider.first as String; + final provider = _provider.first as String; + // TODO : Remove this workaround when Trocador fixes BitcoinVN provider issue + params['provider'] = provider == 'BitcoinVN' ? '' : provider; final uri = await _getUri(createTradePath, params); final response = await ProxyWrapper().get(clearnetUri: uri, headers: {'API-Key': apiKey});