fix!(rpc): disallow non-prefixed hex strings in RPC input#3328
Open
fix!(rpc): disallow non-prefixed hex strings in RPC input#3328
Conversation
Changes the JSON-RPC deserialization logic to reject hex strings without the `0x` prefix. This brings us closer in line with the Starknet API spec.
zvolin
approved these changes
Apr 13, 2026
Contributor
There was a problem hiding this comment.
this shouldn't say optional now
CHr15F0x
approved these changes
Apr 13, 2026
Contributor
There was a problem hiding this comment.
LGTM
Not sure if it was tested against:
https://github.com/starknet-io/starknet.js
https://github.com/software-mansion/starknet.py
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.
Changes the JSON-RPC deserialization logic to reject hex strings without the
0xprefix. This brings us closer in line with the Starknet API spec.Closes: #3309
It goes without saying that this change could break many existing clients, so it might be worth considering a more gradual deprecation strategy.
Also, while we're on the topic, I noticed another inconsistency between our deserialization logic and the spec. Patterns like
^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$do not allow empty strings after the0xprefix, but our deserialization logic currently allows them and treats them as zero.