fix: formatChainIdToHex returns unprefixed hex#7909
Merged
Conversation
| } | ||
| if (typeof chainId === 'number' || parseInt(chainId, 10)) { | ||
| return toHex(chainId); | ||
| return numberToHex(Number(chainId)); |
There was a problem hiding this comment.
Malformed chain IDs now parse silently
Low Severity
Replacing toHex with numberToHex(Number(...)) removes strict decimal-string validation. Inputs like scientific-notation strings can now be accepted and reinterpreted as different chain IDs instead of being rejected, so invalid chainId values may silently route to the wrong network.
Additional Locations (1)
Member
Author
There was a problem hiding this comment.
There is a type check for number so this is ok. Also this is restoring the previous implementation of the formatter
infiniteflower
approved these changes
Feb 11, 2026
ghgoodreau
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Explanation
References
Checklist
Note
Low Risk
Small utility-level formatting change; main risk is subtle behavior differences for inputs that previously produced non-prefixed hex (or for callers passing
undefinedtoformatAddressToAssetId).Overview
Fixes chain ID formatting in
bridge-controllerso EVM chain IDs derived from numbers/strings/CAIP references are converted usingnumberToHex, ensuring a0x-prefixed hex output (including when building CAIP chain IDs viaformatChainIdToCaip).Updates
formatAddressToAssetId’s signature to requireaddressOrAssetId(no longer optional), and records the fix in the Unreleased changelog (marking66.1.0as deprecated).Written by Cursor Bugbot for commit 8e4e316. This will update automatically on new commits. Configure here.