mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
Select sub address or standard address instead of both. (#346)
* Use the sub address first then the std
This commit is contained in:
@@ -9,35 +9,42 @@ class YatService {
|
|||||||
static String get apiUrl =>
|
static String get apiUrl =>
|
||||||
YatService.isDevMode ? YatService.apiDevUrl : YatService.apiReleaseUrl;
|
YatService.isDevMode ? YatService.apiDevUrl : YatService.apiReleaseUrl;
|
||||||
static const apiReleaseUrl = "https://a.y.at";
|
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) =>
|
static String lookupEmojiUrl(String emojiId) =>
|
||||||
"$apiUrl/emoji_id/$emojiId/payment";
|
"$apiUrl/emoji_id/$emojiId/payment";
|
||||||
|
|
||||||
|
static const String MONERO_SUB_ADDRESS = '0x1002';
|
||||||
|
static const String MONERO_STD_ADDRESS = '0x1001';
|
||||||
static const tags = {
|
static const tags = {
|
||||||
'XMR': '0x1001,0x1002',
|
'XMR': "$MONERO_STD_ADDRESS,$MONERO_SUB_ADDRESS",
|
||||||
'BTC': '0x1003',
|
'BTC': '0x1003',
|
||||||
'LTC': '0x3fff'
|
'LTC': '0x1019'
|
||||||
};
|
};
|
||||||
|
|
||||||
Future<List<YatRecord>> fetchYatAddress(String emojiId, String ticker) async {
|
Future<List<YatRecord>> fetchYatAddress(String emojiId, String ticker) async {
|
||||||
final formattedTicker = ticker.toUpperCase();
|
final formattedTicker = ticker.toUpperCase();
|
||||||
final formattedEmojiId = emojiId.replaceAll(' ', '');
|
final formattedEmojiId = emojiId.replaceAll(' ', '');
|
||||||
|
final tag = tags[formattedTicker];
|
||||||
final uri = Uri.parse(lookupEmojiUrl(formattedEmojiId)).replace(
|
final uri = Uri.parse(lookupEmojiUrl(formattedEmojiId)).replace(
|
||||||
queryParameters: <String, dynamic>{
|
queryParameters: <String, dynamic>{
|
||||||
"tags": tags[formattedTicker]
|
"tags": tag
|
||||||
});
|
});
|
||||||
|
|
||||||
final yatRecords = <YatRecord>[];
|
final yatRecords = <YatRecord>[];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await get(uri);
|
final response = await get(uri);
|
||||||
final resBody = json.decode(response.body) as Map<String, dynamic>;
|
final resBody = json.decode(response.body) as Map<String, dynamic>;
|
||||||
|
|
||||||
final results = resBody["result"] as Map<dynamic, dynamic>;
|
final results = resBody["result"] as Map<dynamic, dynamic>;
|
||||||
results.forEach((dynamic key, dynamic value) {
|
// Favour a subaddress over a standard address.
|
||||||
yatRecords.add(YatRecord.fromJson(value as Map<String, dynamic>));
|
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;
|
return yatRecords;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class YatLink {
|
|||||||
static const startFlowUrl = ''; // 'https://www.y03btrk.com/4RQSJ/6JHXF/';
|
static const startFlowUrl = ''; // 'https://www.y03btrk.com/4RQSJ/6JHXF/';
|
||||||
static const isDevMode = true;
|
static const isDevMode = true;
|
||||||
static const tags = <String, List<String>>{"XMR" : ['0x1001', '0x1002'],
|
static const tags = <String, List<String>>{"XMR" : ['0x1001', '0x1002'],
|
||||||
"BTC" : ['0x1003'], "LTC" : ['0x3fff']};
|
"BTC" : ['0x1003'], "LTC" : ['0x1019']};
|
||||||
|
|
||||||
static String get apiUrl => YatLink.isDevMode
|
static String get apiUrl => YatLink.isDevMode
|
||||||
? YatLink.apiDevUrl
|
? YatLink.apiDevUrl
|
||||||
@@ -281,4 +281,4 @@ abstract class YatStoreBase with Store {
|
|||||||
//return base64.encode(addressJsonBytes);
|
//return base64.encode(addressJsonBytes);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user