getIdentity method

  1. @override
Future<BlockchainIdentity> getIdentity(
  1. String address
)
override

Gets the name and avatar of a provided address on the given chain

Implementation

@override
Future<BlockchainIdentity> getIdentity(String address) async {
  try {
    final uri = Uri.parse('$_baseUrl/identity/$address');
    final queryParams = {..._requiredParams};
    if (queryParams['clientId'] == null) {
      queryParams['clientId'] = await _core.crypto.getClientId();
    }
    final response = await http.get(
      uri.replace(queryParameters: queryParams),
      headers: _requiredHeaders,
    );
    if (response.statusCode == 200) {
      return BlockchainIdentity.fromJson(jsonDecode(response.body));
    } else {
      throw Exception('Failed to load avatar');
    }
  } catch (e) {
    loggerService.instance.e('[$runtimeType] getIdentity: $e');
    rethrow;
  }
}