Merge pull request #1522 from pryzm-finance/fix-gas-price-validation-regex
Update validation of GasPrice.fromString to allow using ibc denoms as gas denom
This commit is contained in:
commit
62a4ad1b6f
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user