From 284e510761a5f0e46638adbdf521b61a1d109a5c Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Fri, 14 Apr 2023 17:26:20 +0200 Subject: [PATCH 1/2] Query gasprice --- components/chainSelect/ChainSelect.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/chainSelect/ChainSelect.tsx b/components/chainSelect/ChainSelect.tsx index 127a9b3..31d9a2e 100644 --- a/components/chainSelect/ChainSelect.tsx +++ b/components/chainSelect/ChainSelect.tsx @@ -135,7 +135,16 @@ const ChainSelect = () => { const firstAsset: ChainRegistryAsset | undefined = assetData.assets?.[0]; const denom = firstAsset?.base || ""; const displayDenom = firstAsset?.symbol || ""; - const gasPrice = firstAsset ? `0.03${firstAsset.base}` : ""; + const feeToken = chainData["fees"]?.fee_tokens.find( + (token: { denom: string }) => token.denom == denom, + ); + const gasPrice = + feeToken["average_gas_price"] ?? + feeToken["low_gas_price"] ?? + feeToken["high_gas_price"] ?? + feeToken["fixed_min_gas_price"] ?? + 0.03; + const formattedGasPrice = firstAsset ? `${gasPrice}${denom}` : ""; const displayUnit = firstAsset?.denom_units.find((u) => u.denom == firstAsset.display); const displayDenomExponent = displayUnit?.exponent ?? 6; @@ -151,7 +160,7 @@ const ChainSelect = () => { denom, displayDenom, displayDenomExponent, - gasPrice, + gasPrice: formattedGasPrice, chainId, chainDisplayName, registryName, From ddc374d4e74adaf2820a09b094311c550a00ce74 Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:43:18 +0200 Subject: [PATCH 2/2] Add empty object fallback for feeToken --- components/chainSelect/ChainSelect.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/chainSelect/ChainSelect.tsx b/components/chainSelect/ChainSelect.tsx index 31d9a2e..1945db7 100644 --- a/components/chainSelect/ChainSelect.tsx +++ b/components/chainSelect/ChainSelect.tsx @@ -135,9 +135,9 @@ const ChainSelect = () => { const firstAsset: ChainRegistryAsset | undefined = assetData.assets?.[0]; const denom = firstAsset?.base || ""; const displayDenom = firstAsset?.symbol || ""; - const feeToken = chainData["fees"]?.fee_tokens.find( - (token: { denom: string }) => token.denom == denom, - ); + const feeToken = + chainData["fees"]?.fee_tokens.find((token: { denom: string }) => token.denom == denom) ?? + {}; const gasPrice = feeToken["average_gas_price"] ?? feeToken["low_gas_price"] ??