Skip to content

fix(encoding): Stop passing Infinity as bech32 decode limit - #1983

Open
jonathan-nansen wants to merge 1 commit into
cosmos:mainfrom
jonathan-nansen:fix/bech32-infinity-limit
Open

jonathan-nansen wants to merge 1 commit into
cosmos:mainfrom
jonathan-nansen:fix/bech32-infinity-limit

Conversation

@jonathan-nansen

Copy link
Copy Markdown

fromBech32 defaults limit to Infinity and passes it to @scure/base's bech32.decode. Since @scure/base 2.3.0, decode validates limit as a safe integer unless it is false, so every default-argument call (and normalizeBech32) throws:

RangeError: limit: expected safe integer, got Infinity

@cosmjs/encoding depends on @scure/base@^2.0.0, so fresh installs pick up 2.3.0+ and hit this.

bech32.decode has accepted limit: false to disable the length check since 2.0.0 (the limit !== false && length > limit guard is unchanged across 2.0.0–2.4.0). This change maps an omitted limit, and an explicit Infinity for callers who copied the old default, to false. Numeric limits pass through unchanged, and the public signature stays limit?: number.

Tests: the existing long-address test (>90 chars, default limit) covers the regression; added a case passing Infinity explicitly. Note that yarn.lock currently resolves @scure/base@2.0.0, so CI won't reproduce the RangeError without a lockfile bump. I haven't run the suite locally.

Fixes #1982

@greptile-apps

greptile-apps Bot commented Sep 25, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fromBech32 throws RangeError with @scure/base >= 2.3.0, which a clean install now resolves

1 participant