Select sub address or standard address instead of both. (#346)

* Use the sub address first then the std
wownero
Keith Simon 2 years ago committed by GitHub
parent 0caa7337af
commit 6762207bb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,35 +9,42 @@ class YatService {
static String get apiUrl =>
YatService.isDevMode ? YatService.apiDevUrl : YatService.apiReleaseUrl;
static const apiReleaseUrl = "https://a.y.at";
static const apiDevUrl = 'https://yat.fyi';
static const apiDevUrl = 'https://a.yat.fyi';
static String lookupEmojiUrl(String emojiId) =>
"$apiUrl/emoji_id/$emojiId/payment";
static const String MONERO_SUB_ADDRESS = '0x1002';
static const String MONERO_STD_ADDRESS = '0x1001';
static const tags = {
'XMR': '0x1001,0x1002',
'XMR': "$MONERO_STD_ADDRESS,$MONERO_SUB_ADDRESS",
'BTC': '0x1003',
'LTC': '0x3fff'
'LTC': '0x1019'
};
Future<List<YatRecord>> fetchYatAddress(String emojiId, String ticker) async {
final formattedTicker = ticker.toUpperCase();
final formattedEmojiId = emojiId.replaceAll(' ', '');
final tag = tags[formattedTicker];
final uri = Uri.parse(lookupEmojiUrl(formattedEmojiId)).replace(
queryParameters: <String, dynamic>{
"tags": tags[formattedTicker]
"tags": tag
});
final yatRecords = <YatRecord>[];
try {
final response = await get(uri);
final resBody = json.decode(response.body) as Map<String, dynamic>;
final results = resBody["result"] as Map<dynamic, dynamic>;
results.forEach((dynamic key, dynamic value) {
yatRecords.add(YatRecord.fromJson(value as Map<String, dynamic>));
});
// Favour a subaddress over a standard address.
final yatRecord = (
results[MONERO_SUB_ADDRESS] ??
results[MONERO_STD_ADDRESS] ??
results[tag]) as Map<String, dynamic>;
if (yatRecord != null) {
yatRecords.add(YatRecord.fromJson(yatRecord));
}
return yatRecords;
} catch (_) {

@ -29,7 +29,7 @@ class YatLink {
static const startFlowUrl = ''; // 'https://www.y03btrk.com/4RQSJ/6JHXF/';
static const isDevMode = true;
static const tags = <String, List<String>>{"XMR" : ['0x1001', '0x1002'],
"BTC" : ['0x1003'], "LTC" : ['0x3fff']};
"BTC" : ['0x1003'], "LTC" : ['0x1019']};
static String get apiUrl => YatLink.isDevMode
? YatLink.apiDevUrl
@ -281,4 +281,4 @@ abstract class YatStoreBase with Store {
//return base64.encode(addressJsonBytes);
return '';
}
}
}

Loading…
Cancel
Save