mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
c78662fbfe
* replace all print statements with printV * restore backup error message * missing print statements, error fixes * Update cw_core/lib/utils/print_verbose.dart [skip ci] * Update cw_core/lib/utils/print_verbose.dart [skip ci] * CW-846: Correctly display balance (#1848) * Correctly display balance even with frozen coins * remove package= from AndroidMainfest.xml * update namespace * print -> printV --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
29 lines
No EOL
979 B
Dart
29 lines
No EOL
979 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
Future<String> fetchUnstoppableDomainAddress(String domain, String ticker) async {
|
|
var address = '';
|
|
|
|
try {
|
|
final uri = Uri.parse("https://api.unstoppabledomains.com/profile/public/${Uri.encodeQueryComponent(domain)}?fields=records");
|
|
final jsonString = await http.read(uri);
|
|
final jsonParsed = json.decode(jsonString) as Map<String, dynamic>;
|
|
if (jsonParsed["records"] == null) {
|
|
throw Exception(".records response from $uri is empty");
|
|
};
|
|
final records = jsonParsed["records"] as Map<String, dynamic>;
|
|
final key = "crypto.${ticker.toUpperCase()}.address";
|
|
if (records[key] == null) {
|
|
throw Exception(".records.${key} response from $uri is empty");
|
|
}
|
|
|
|
return records[key] as String? ?? '';
|
|
} catch (e) {
|
|
printV('Unstoppable domain error: ${e.toString()}');
|
|
address = '';
|
|
}
|
|
|
|
return address;
|
|
} |