gasPrice method

  1. @override
Future<GasPrice> gasPrice({
  1. required String caip2Chain,
})
override

Implementation

@override
Future<GasPrice> gasPrice({required String caip2Chain}) async {
  final uri = Uri.parse('$_baseUrl/convert/gas-price');
  final queryParams = {..._requiredParams, 'chainId': caip2Chain};
  final url = uri.replace(queryParameters: queryParams);
  final response = await http.get(url, headers: _requiredHeaders);
  _core.logger.i('[$runtimeType] gasPrice $url => ${response.body}');
  if (response.statusCode == 200 && response.body.isNotEmpty) {
    final result = jsonDecode(response.body) as Map<String, dynamic>;
    return GasPrice.fromJson(result);
  }
  try {
    final reason = _parseResponseError(response.body);
    throw Exception(reason);
  } catch (e) {
    _core.logger.e('[$runtimeType] gasPrice, decode result error => $e');
    rethrow;
  }
}