mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-03 12:24:19 +01:00
Cw 171 exchange auto selector bug (#523)
* Fix de-selecting exchange providers not getting saved * only change field value when the amount is better than the already existing one * Show calculated amount after getting the best value from all providers * Catch exceptions to avoid stopping the providers calculate amount APIs * Fix Splay map only saving the last value obtained * Show limits for the provider with the highest rate * Load limits on currency pair change * Show limits for lowest min provider * Show limits for lowest min and highest max * Sync best rate every 10 seconds instead of calculating it on every amount change * Fix conflicts with flutter upgrade Add null safety to changes in exchange_view_model.dart * Remove un-necessary checks
This commit is contained in:
@@ -56,7 +56,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||
final uri = Uri.https(apiAuthority, getEstimatePath, params);
|
||||
final response = await get(uri);
|
||||
|
||||
if (response.body == null) return 0.00;
|
||||
if (response.body == null || response.body == "null") return 0.00;
|
||||
final data = json.decode(response.body) as String;
|
||||
|
||||
return double.parse(data);
|
||||
@@ -151,8 +151,8 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final min = responseJSON['min'] != null ? double.tryParse(responseJSON['min'] as String) : null;
|
||||
final max = responseJSON['max'] != null ? double.parse(responseJSON['max'] as String) : null;
|
||||
final min = double.tryParse(responseJSON['min'] as String? ?? '');
|
||||
final max = double.tryParse(responseJSON['max'] as String? ?? '');
|
||||
|
||||
return Limits(min: min, max: max);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user