mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 06:38:52 +00:00
eth token price fetch "fix" and clearer eth token price fetch error logging
This commit is contained in:
parent
622740a8c0
commit
bfba6d9f5d
2 changed files with 27 additions and 28 deletions
|
@ -187,12 +187,11 @@ class PriceAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final contractAddressesString =
|
for (final contractAddress in contractAddresses) {
|
||||||
contractAddresses.reduce((value, element) => "$value,$element");
|
|
||||||
final uri = Uri.parse(
|
final uri = Uri.parse(
|
||||||
"https://api.coingecko.com/api/v3/simple/token_price/ethereum"
|
"https://api.coingecko.com/api/v3/simple/token_price/ethereum"
|
||||||
"?vs_currencies=${baseCurrency.toLowerCase()}&contract_addresses"
|
"?vs_currencies=${baseCurrency.toLowerCase()}&contract_addresses"
|
||||||
"=$contractAddressesString&include_24hr_change=true");
|
"=$contractAddress&include_24hr_change=true");
|
||||||
|
|
||||||
final coinGeckoResponse = await client.get(
|
final coinGeckoResponse = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
|
@ -202,18 +201,24 @@ class PriceAPI {
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map;
|
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map;
|
||||||
|
|
||||||
for (final key in coinGeckoData.keys) {
|
|
||||||
final contractAddress = key as String;
|
|
||||||
|
|
||||||
final map = coinGeckoData[contractAddress] as Map;
|
final map = coinGeckoData[contractAddress] as Map;
|
||||||
|
|
||||||
final price = Decimal.parse(map[baseCurrency.toLowerCase()].toString());
|
final price =
|
||||||
|
Decimal.parse(map[baseCurrency.toLowerCase()].toString());
|
||||||
final change24h = double.parse(
|
final change24h = double.parse(
|
||||||
map["${baseCurrency.toLowerCase()}_24h_change"].toString());
|
map["${baseCurrency.toLowerCase()}_24h_change"].toString());
|
||||||
|
|
||||||
tokenPrices[contractAddress] = Tuple2(price, change24h);
|
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;
|
return tokenPrices;
|
||||||
|
|
|
@ -697,12 +697,6 @@ mixin ElectrumXInterface<T extends Bip39HDCurrency> on Bip39HDWallet<T> {
|
||||||
cryptoCurrency.networkParams,
|
cryptoCurrency.networkParams,
|
||||||
);
|
);
|
||||||
|
|
||||||
print("=============================================================");
|
|
||||||
print("$i ${txData.recipients![i].amount.decimal}");
|
|
||||||
print("$i ${txData.recipients![i].amount.raw}");
|
|
||||||
print("$address");
|
|
||||||
print("=============================================================");
|
|
||||||
|
|
||||||
final output = coinlib.Output.fromAddress(
|
final output = coinlib.Output.fromAddress(
|
||||||
txData.recipients![i].amount.raw,
|
txData.recipients![i].amount.raw,
|
||||||
address,
|
address,
|
||||||
|
|
Loading…
Reference in a new issue