mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
4b4d8a4840
* Add passphrase support for Eth, Polygon, and Tron * move passphrase to advanced settings even for restore
28 lines
No EOL
927 B
Dart
28 lines
No EOL
927 B
Dart
import 'dart:convert';
|
|
|
|
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) {
|
|
print('Unstoppable domain error: ${e.toString()}');
|
|
address = '';
|
|
}
|
|
|
|
return address;
|
|
} |