disable eth token price fetching to prevent being throttled

This commit is contained in:
julian 2024-04-24 15:12:49 -06:00
parent af87ec76ef
commit 02997ffc70

View file

@ -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) {