mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
disable eth token price fetching to prevent being throttled
This commit is contained in:
parent
af87ec76ef
commit
02997ffc70
1 changed files with 33 additions and 33 deletions
|
@ -187,39 +187,39 @@ class PriceAPI {
|
|||
}
|
||||
|
||||
try {
|
||||
for (final contractAddress in contractAddresses) {
|
||||
final uri = Uri.parse(
|
||||
"https://api.coingecko.com/api/v3/simple/token_price/ethereum"
|
||||
"?vs_currencies=${baseCurrency.toLowerCase()}&contract_addresses"
|
||||
"=$contractAddress&include_24hr_change=true");
|
||||
|
||||
final coinGeckoResponse = await client.get(
|
||||
url: uri,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
proxyInfo: Prefs.instance.useTor
|
||||
? TorService.sharedInstance.getProxyInfo()
|
||||
: null,
|
||||
);
|
||||
|
||||
try {
|
||||
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map;
|
||||
|
||||
final map = coinGeckoData[contractAddress] as Map;
|
||||
|
||||
final price =
|
||||
Decimal.parse(map[baseCurrency.toLowerCase()].toString());
|
||||
final change24h = double.parse(
|
||||
map["${baseCurrency.toLowerCase()}_24h_change"].toString());
|
||||
|
||||
tokenPrices[contractAddress] = Tuple2(price, change24h);
|
||||
} catch (e, s) {
|
||||
// only log the error as we don't want to interrupt the rest of the loop
|
||||
Logging.instance.log(
|
||||
"getPricesAnd24hChangeForEthTokens($baseCurrency,$contractAddress): $e\n$s\nRESPONSE: ${coinGeckoResponse.body}",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
}
|
||||
}
|
||||
// for (final contractAddress in contractAddresses) {
|
||||
// final uri = Uri.parse(
|
||||
// "https://api.coingecko.com/api/v3/simple/token_price/ethereum"
|
||||
// "?vs_currencies=${baseCurrency.toLowerCase()}&contract_addresses"
|
||||
// "=$contractAddress&include_24hr_change=true");
|
||||
//
|
||||
// final coinGeckoResponse = await client.get(
|
||||
// url: uri,
|
||||
// headers: {'Content-Type': 'application/json'},
|
||||
// proxyInfo: Prefs.instance.useTor
|
||||
// ? TorService.sharedInstance.getProxyInfo()
|
||||
// : null,
|
||||
// );
|
||||
//
|
||||
// try {
|
||||
// final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map;
|
||||
//
|
||||
// final map = coinGeckoData[contractAddress] as Map;
|
||||
//
|
||||
// final price =
|
||||
// Decimal.parse(map[baseCurrency.toLowerCase()].toString());
|
||||
// final change24h = double.parse(
|
||||
// map["${baseCurrency.toLowerCase()}_24h_change"].toString());
|
||||
//
|
||||
// tokenPrices[contractAddress] = Tuple2(price, change24h);
|
||||
// } catch (e, s) {
|
||||
// // only log the error as we don't want to interrupt the rest of the loop
|
||||
// Logging.instance.log(
|
||||
// "getPricesAnd24hChangeForEthTokens($baseCurrency,$contractAddress): $e\n$s\nRESPONSE: ${coinGeckoResponse.body}",
|
||||
// level: LogLevel.Warning,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
return tokenPrices;
|
||||
} catch (e, s) {
|
||||
|
|
Loading…
Reference in a new issue