mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
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>
This commit is contained in:
co-authored by
Serhii-Borodenko
parent
4cb6bb3686
commit
b6fa059e54
@@ -112,7 +112,7 @@ class AmountMinValidator extends Validator<String> {
|
||||
return false;
|
||||
}
|
||||
|
||||
return valueInDouble > minInDouble;
|
||||
return valueInDouble >= minInDouble;
|
||||
}
|
||||
|
||||
double? parseToDouble(String value) {
|
||||
@@ -146,7 +146,7 @@ class AmountMaxValidator extends Validator<String> {
|
||||
if (valueInDouble == null || maxInDouble == null) {
|
||||
return false;
|
||||
}
|
||||
return valueInDouble < maxInDouble;
|
||||
return valueInDouble <= maxInDouble;
|
||||
}
|
||||
|
||||
double? parseToDouble(String value) {
|
||||
|
||||
@@ -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<Map<String, dynamic>>;
|
||||
final List<dynamic> jsonList = json.decode(response.body) as List<dynamic>;
|
||||
final List<Map<String, dynamic>> quotes =
|
||||
jsonList.map((e) => e as Map<String, dynamic>).toList();
|
||||
|
||||
Map<String, dynamic> highestQuote = quotes.reduce((current, next) {
|
||||
double currentAmount = current['egressAmount'] as double;
|
||||
|
||||
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user