getHistory method
Implementation
@override
Future<ActivityData> getHistory({
required String address,
String? caip2Chain,
String? cursor,
}) async {
final uri = Uri.parse('$_baseUrl/account/$address/history');
final queryParams = {
..._requiredParams,
if (caip2Chain != null) 'chainId': caip2Chain,
if (cursor != null) 'cursor': cursor,
};
final url = uri.replace(queryParameters: queryParams);
final response = await http.get(url, headers: _requiredHeaders);
_core.logger.i('[$runtimeType] getHistory $url => ${response.body}');
if (response.statusCode == 200 && response.body.isNotEmpty) {
try {
return ActivityData.fromRawJson(response.body);
} catch (e) {
_core.logger.e('[$runtimeType] getHistory, parse result error => $e');
throw Exception('Failed to load wallet activity. $e');
}
}
try {
final reason = _parseResponseError(response.body);
throw Exception(reason);
} catch (e) {
_core.logger.e('[$runtimeType] getHistory, decode result error => $e');
rethrow;
}
}