From 1b6937cd5179e959d4706a96249fb495810d7cd3 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Mon, 22 Apr 2024 23:05:38 +0700 Subject: [PATCH] fix(cli): null gasPriceStep --- docs/docs/change-log.md | 4 ++++ packages/graz/package.json | 2 +- packages/graz/src/cli.mjs | 39 ++++++++++++++++++++++++++------------ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/docs/docs/change-log.md b/docs/docs/change-log.md index f2b6ee3..2cd2574 100644 --- a/docs/docs/change-log.md +++ b/docs/docs/change-log.md @@ -4,6 +4,10 @@ sidebar_position: 8 # Changelog +## Version 0.1.9 + +- graz cli fix null `gasPriceStep` + ## Version 0.1.8 - Added [Metamask Snap Cosmos](https://github.com/cosmos/snap) integration diff --git a/packages/graz/package.json b/packages/graz/package.json index 1e97494..69a3007 100644 --- a/packages/graz/package.json +++ b/packages/graz/package.json @@ -1,7 +1,7 @@ { "name": "graz", "description": "React hooks for Cosmos", - "version": "0.1.8", + "version": "0.1.9", "author": "Griko Nibras ", "repository": "https://github.com/graz-sh/graz.git", "homepage": "https://github.com/graz-sh/graz", diff --git a/packages/graz/src/cli.mjs b/packages/graz/src/cli.mjs index d19d394..f5eefa1 100755 --- a/packages/graz/src/cli.mjs +++ b/packages/graz/src/cli.mjs @@ -188,18 +188,33 @@ const makeRecord = async (client, { filter = "" } = {}) => { coinGeckoId: mainAsset.coingecko_id, }; - const feeCurrencies = chain.fees?.fee_tokens.map((token) => ({ - coinDenom: chain.assets?.find((asset) => asset.denom === token.denom)?.denom_units.at(-1)?.denom || token.denom, - coinMinimalDenom: - chain.assets?.find((asset) => asset.denom === token.denom)?.denom_units[0]?.denom || token.denom, - coinDecimals: Number(chain.assets?.find((asset) => asset.denom === token.denom)?.decimals), - coinGeckoId: chain.assets?.find((asset) => asset.denom === token.denom)?.coingecko_id || "", - gasPriceStep: { - low: Number(token.low_gas_price), - average: Number(token.average_gas_price), - high: Number(token.high_gas_price), - }, - })); + const feeCurrencies = chain.fees?.fee_tokens.map((token) => { + const isGasPriceStepAvailable = token.low_gas_price && token.average_gas_price && token.high_gas_price; + + if (isGasPriceStepAvailable) { + return { + coinDenom: + chain.assets?.find((asset) => asset.denom === token.denom)?.denom_units.at(-1)?.denom || token.denom, + coinMinimalDenom: + chain.assets?.find((asset) => asset.denom === token.denom)?.denom_units[0]?.denom || token.denom, + coinDecimals: Number(chain.assets?.find((asset) => asset.denom === token.denom)?.decimals), + coinGeckoId: chain.assets?.find((asset) => asset.denom === token.denom)?.coingecko_id || "", + gasPriceStep: { + low: Number(token.low_gas_price), + average: Number(token.average_gas_price), + high: Number(token.high_gas_price), + }, + }; + } + return { + coinDenom: + chain.assets?.find((asset) => asset.denom === token.denom)?.denom_units.at(-1)?.denom || token.denom, + coinMinimalDenom: + chain.assets?.find((asset) => asset.denom === token.denom)?.denom_units[0]?.denom || token.denom, + coinDecimals: Number(chain.assets?.find((asset) => asset.denom === token.denom)?.decimals), + coinGeckoId: chain.assets?.find((asset) => asset.denom === token.denom)?.coingecko_id || "", + }; + }); if (!feeCurrencies) { throw new Error(`⚠️\t${chain.name} has no fee currencies, skipping codegen...`);