{"record":{"id":"f54c8347dffcfc4e","repo":"unionlabs/union","slug":"denom-must-be-between-2-and-128-characters","errorCode":null,"errorMessage":"Denom must be between 2 and 128 characters","messagePattern":"Denom must be between 2 and 128 characters","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"patches/@cosmjs__stargate.patch","lineNumber":27,"sourceCode":"-const math_1 = require(\"@cosmjs/math\");\n-const proto_signing_1 = require(\"@cosmjs/proto-signing\");\n+\"use strict\"\n+Object.defineProperty(exports, \"__esModule\", { value: true })\n+exports.calculateFee = exports.GasPrice = void 0\n+const math_1 = require(\"@cosmjs/math\")\n+const proto_signing_1 = require(\"@cosmjs/proto-signing\")\n /**\n  * Denom checker for the Cosmos SDK 0.42 denom pattern\n  * (https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/types/coin.go#L599-L601).\n@@ -10,58 +10,58 @@ const proto_signing_1 = require(\"@cosmjs/proto-signing\");\n  * This is like a regexp but with helpful error messages.\n  */\n function checkDenom(denom) {\n-    if (denom.length < 3 || denom.length > 128) {\n-        throw new Error(\"Denom must be between 3 and 128 characters\");\n-    }\n+  if (denom.length < 2 || denom.length > 128) {\n+    throw new Error(\"Denom must be between 2 and 128 characters\")\n+  }\n }\n /**\n  * A gas price, i.e. the price of a single unit of gas. This is typically a fraction of\n  * the smallest fee token unit, such as 0.012utoken.\n  */\n class GasPrice {\n-    constructor(amount, denom) {\n-        this.amount = amount;\n-        this.denom = denom;\n-    }\n-    /**\n-     * Parses a gas price formatted as `<amount><denom>`, e.g. `GasPrice.fromString(\"0.012utoken\")`.\n-     *\n-     * The denom must match the Cosmos SDK 0.42 pattern (https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/types/coin.go#L599-L601).\n-     * See `GasPrice` in @cosmjs/stargate for a more generic matcher.\n-     *\n-     * Separators are not yet supported.","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/unionlabs/union/blob/031785bb6dc6b957c624e62bc64c184409c97d7b/patches/@cosmjs__stargate.patch#L9-L45","documentation":"This message comes from a patch the repo applies to @cosmjs/stargate's GasPrice.checkDenom. The patch relaxes the minimum denom length from 3 to 2 characters (aligned with the Cosmos SDK 0.42 denom regex note); it still throws when the denom in a gas price string is shorter than 2 or longer than 128 characters.","triggerScenarios":"Calling GasPrice.fromString (directly or via Stargate/Union client setup with gasPrice) where the denom portion is 1 character (e.g. \"0.025u\") or over 128 characters. With the patch, 2-character denoms like \"ux\" are accepted; without the patch applied, even valid 2-character denoms throw the 3-and-128 variant.","commonSituations":"A chain with a 2-character base denom (why the patch exists) failing after node_modules was reinstalled without applying patchedDependencies; hand-built gas price strings with truncated denoms; upgrading @cosmjs/stargate so the patch no longer applies cleanly.","solutions":["Ensure the patch is applied: reinstall dependencies through the package manager config (e.g. bun's patchedDependencies in package.json) so patches/@cosmjs__stargate.patch takes effect","Use a denom of at least 2 characters (prefer the chain's canonical 3+ character base denom like \"uatom\")","After upgrading @cosmjs/stargate, re-generate/refresh the patch file so it matches the new version"],"exampleFix":"// before (denom too short — throws even with the patch)\nconst gasPrice = GasPrice.fromString(\"0.025u\")\n\n// after\nconst gasPrice = GasPrice.fromString(\"0.025uatom\") // 2+ character denom","handlingStrategy":"validation","validationCode":"const GAS_PRICE_PATTERN = /^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/\nexport const validateGasPrice = (s: string) => {\n  const m = s.match(GAS_PRICE_PATTERN)\n  if (!m) throw new Error(`Invalid gas price string: ${s}`)\n  const denom = m[2]\n  if (denom.length < 2 || denom.length > 128) {\n    throw new Error(`Denom ${denom} must be 2-128 characters`)\n  }\n  return s\n}","typeGuard":"const isPatchedGasPriceString = (s: string): boolean => {\n  const m = s.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/)\n  return Boolean(m) && m![2].length >= 2 && m![2].length <= 128\n}","tryCatchPattern":"try {\n  const gasPrice = GasPrice.fromString(raw)\n} catch (error) {\n  if ((error as Error).message.includes(\"Denom must be between\")) {\n    // either fix the denom length, or verify the repo patch to @cosmjs/stargate is applied\n  }\n  throw error\n}","preventionTips":["After any dependency reinstall/upgrade, confirm patches/@cosmjs__stargate.patch is applied (check the patched file in node_modules shows 2..128)","Use the chain's canonical base denom (usually 3+ chars) in gas prices","Wrap GasPrice.fromString in a single validated helper used everywhere"],"tags":["cosmos","patch","gas-price","configuration"],"backgroundTag":null,"analyzedSha":"031785bb6dc6b957c624e62bc64c184409c97d7b","analyzedAt":"2026-08-16T06:24:09.996Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}