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>
Serhii committed
Dec 10, 2025 at 06:09 UTC
b6fa059e5472bc989d1c33d37e67a2521152a877
3 files changed
+9
-6
lib/core/amount_validator.dart
+2
-2
@@ -112,7 +112,7 @@ class AmountMinValidator extends Validator<String> {
112
return false;
113
}
114
115
- return valueInDouble > minInDouble;
115
+ return valueInDouble >= minInDouble;
116
}
117
118
double? parseToDouble(String value) {
@@ -146,7 +146,7 @@ class AmountMaxValidator extends Validator<String> {
146
if (valueInDouble == null || maxInDouble == null) {
147
return false;
148
}
149
- return valueInDouble < maxInDouble;
149
+ return valueInDouble <= maxInDouble;
150
}
151
152
double? parseToDouble(String value) {
lib/exchange/provider/chainflip_exchange_provider.dart
+3
-1
@@ -388,7 +388,9 @@ class ChainflipExchangeProvider extends ExchangeProvider {
388
throw Exception('Unexpected response: ${response.statusCode} / ${uri.toString()} / ${response.body}');
389
}
390
391
- final quotes = json.decode(response.body) as List<Map<String, dynamic>>;
391
+ final List<dynamic> jsonList = json.decode(response.body) as List<dynamic>;
392
+ final List<Map<String, dynamic>> quotes =
393
+ jsonList.map((e) => e as Map<String, dynamic>).toList();
394
395
Map<String, dynamic> highestQuote = quotes.reduce((current, next) {
396
double currentAmount = current['egressAmount'] as double;
lib/exchange/provider/trocador_exchange_provider.dart
+4
-3
@@ -114,8 +114,7 @@ class TrocadorExchangeProvider extends ExchangeProvider {
114
115
return Limits(
116
min: coinJson['minimum'] as double?,
117
- // TODO: remove hardcoded value and call `api/new_rate` when Trocador adds min and max to it
118
- max: from == CryptoCurrency.zano ? 2600 : coinJson['maximum'] as double?,
117
+ max: coinJson['maximum'] as double?,
118
);
119
}
120
@@ -276,7 +275,9 @@ class TrocadorExchangeProvider extends ExchangeProvider {
275
throw Exception('No available provider is enabled');
276
}
277
279
- params['provider'] = _provider.first as String;
278
+ final provider = _provider.first as String;
279
+ // TODO : Remove this workaround when Trocador fixes BitcoinVN provider issue
280
+ params['provider'] = provider == 'BitcoinVN' ? '' : provider;
281
282
final uri = await _getUri(createTradePath, params);
283
final response = await ProxyWrapper().get(clearnetUri: uri, headers: {'API-Key': apiKey});