diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ef77990d1..e38886d06f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to ## [Unreleased] +### Changed + +- @cosmjs/stargate: Update validation of GasPrice.fromString to allow using ibc denoms as gas denom ([#1522]) + +[#1522]: https://github.com/cosmos/cosmjs/pull/1522 + ## [0.32.1] - 2023-12-04 ### Fixed diff --git a/packages/stargate/src/fee.spec.ts b/packages/stargate/src/fee.spec.ts index 38736f1770..a8ca0fc026 100644 --- a/packages/stargate/src/fee.spec.ts +++ b/packages/stargate/src/fee.spec.ts @@ -30,6 +30,10 @@ describe("GasPrice", () => { "0.14ucoin2": { amount: "0.14", denom: "ucoin2" }, // eslint-disable-next-line @typescript-eslint/naming-convention "0.14FOOBAR": { amount: "0.14", denom: "FOOBAR" }, + "0.01ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2": { + amount: "0.01", + denom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", + }, }; for (const [input, expected] of Object.entries(inputs)) { const gasPrice = GasPrice.fromString(input); diff --git a/packages/stargate/src/fee.ts b/packages/stargate/src/fee.ts index 3f210e9f56..21c3c5c28b 100644 --- a/packages/stargate/src/fee.ts +++ b/packages/stargate/src/fee.ts @@ -37,7 +37,7 @@ export class GasPrice { */ public static fromString(gasPrice: string): GasPrice { // Use Decimal.fromUserInput and checkDenom for detailed checks and helpful error messages - const matchResult = gasPrice.match(/^([0-9.]+)([a-z][a-z0-9]*)$/i); + const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/); if (!matchResult) { throw new Error("Invalid gas price string"); }