CWA-169 | added try-catch to calculateAmount() in MorphTokenExchangeProvider

This commit is contained in:
Oleksandr Sobol 2020-02-07 15:34:00 +02:00
parent d80123d960
commit eb875b1321

View file

@ -214,8 +214,12 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
final response = await get(url);
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final rate = responseJSON['data'][from.toString()][to.toString()] as String;
final estimatedAmount = double.parse(rate) * amount;
return estimatedAmount;
try {
final estimatedAmount = double.parse(rate) * amount;
return estimatedAmount;
} catch(e) {
return 0.0;
}
}
}