Skip to content

Commit

Permalink
fix(cli): null gasPriceStep
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki committed Apr 22, 2024
1 parent 4ad662a commit 1b6937c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
4 changes: 4 additions & 0 deletions docs/docs/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/graz/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graz",
"description": "React hooks for Cosmos",
"version": "0.1.8",
"version": "0.1.9",
"author": "Griko Nibras <[email protected]>",
"repository": "https://github.com/graz-sh/graz.git",
"homepage": "https://github.com/graz-sh/graz",
Expand Down
39 changes: 27 additions & 12 deletions packages/graz/src/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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...`);
Expand Down

0 comments on commit 1b6937c

Please sign in to comment.