mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
CAKE-356 | fixed yat_record.dart (request with tag)
This commit is contained in:
parent
6defc6384e
commit
e787c96734
1 changed files with 4 additions and 24 deletions
|
@ -4,15 +4,8 @@ import 'package:http/http.dart';
|
|||
|
||||
Future<String> fetchYatAddress(String emojiId, String ticker) async {
|
||||
const _requestURL = 'https://a.y.at/emoji_id/';
|
||||
const classValue = '0x10';
|
||||
const tagValues = {'xmr' : ['01', '02'], 'btc' : ['03'], 'eth' : ['04']};
|
||||
final tagValue = tagValues[ticker];
|
||||
|
||||
if (tagValue == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
final url = _requestURL + emojiId;
|
||||
final url = _requestURL + emojiId + '/' + ticker.toUpperCase();
|
||||
final response = await get(url);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
|
@ -22,23 +15,10 @@ Future<String> fetchYatAddress(String emojiId, String ticker) async {
|
|||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final result = responseJSON['result'] as List<dynamic>;
|
||||
|
||||
if (result == null) {
|
||||
if (result == null || result.isEmpty) {
|
||||
return '';
|
||||
}
|
||||
|
||||
for (var value in tagValue) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
final record = result[i] as Map<String, dynamic>;
|
||||
final tag = record['tag'] as String;
|
||||
if (tag?.contains(classValue + value) ?? false) {
|
||||
final yatAddress = record['data'] as String;
|
||||
return yatAddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
//final yatAddress = responseJSON['result'][2]['data'] as String;
|
||||
//return yatAddress;
|
||||
final yatAddress = result.first['data'] as String;
|
||||
return yatAddress;
|
||||
}
|
Loading…
Reference in a new issue