From e787c96734100c63ef766c92dbdcdf2ae6a0e371 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 31 Aug 2021 18:47:00 +0300 Subject: [PATCH] CAKE-356 | fixed yat_record.dart (request with tag) --- lib/yat/yat_record.dart | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/yat/yat_record.dart b/lib/yat/yat_record.dart index 8b14ba1b3..382baff4a 100644 --- a/lib/yat/yat_record.dart +++ b/lib/yat/yat_record.dart @@ -4,15 +4,8 @@ import 'package:http/http.dart'; Future 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 fetchYatAddress(String emojiId, String ticker) async { final responseJSON = json.decode(response.body) as Map; final result = responseJSON['result'] as List; - 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; - 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; } \ No newline at end of file