cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
635 stars 328 forks source link

Getting Denom must be between 3 and 128 characters Error #1521

Open shukr-acharya opened 7 months ago

shukr-acharya commented 7 months ago

While using GasPrice.fromString function I am getting the Denom must be between 3 and 128 characters Error

But for chain fxcore the Fee denom is 'FX'

fee_tokens: [ { denom: 'FX', fixed_min_gas_price: 4000000000000, low_gas_price: 4000000000000, average_gas_price: 4200000000000, high_gas_price: 5000000000000 } ]

webmaster128 commented 7 months ago

As a workaround you can use the GasPrice constructor directly. Something like this should work:

const price = new GasPrice(Decimal.fromUserInput("0.123", 18), "FX");
shukr-acharya commented 7 months ago

As a workaround you can use the GasPrice constructor directly. Something like this should work:

const price = new GasPrice(Decimal.fromUserInput("0.123", 18), "FX");

Thanks @webmaster128, it works

webmaster128 commented 7 months ago

How do you implement this on chain? The pattern in Cosmos SDK requires denoms to be at least 3 characters: https://github.com/cosmos/cosmos-sdk/blob/v0.50.2/types/coin.go#L831-L833. So I am wondering if GasPrice.fromString should support this case.