refactor(juno): restrict felt.Felt to accept only 0x prefixed hex values#3488
refactor(juno): restrict felt.Felt to accept only 0x prefixed hex values#3488
felt.Felt to accept only 0x prefixed hex values#3488Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3488 +/- ##
==========================================
- Coverage 75.52% 75.41% -0.11%
==========================================
Files 384 384
Lines 34937 34968 +31
==========================================
- Hits 26386 26372 -14
- Misses 6693 6696 +3
- Partials 1858 1900 +42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
starknet_call data parameters to allow hex decimal numbes onlystarknet_call data parameters to allow hex decimal numbes only
starknet_call data parameters to allow hex decimal numbes onlyfelt.Felt to accept only 0x prefixed hex values
467626f to
e462337
Compare
There was a problem hiding this comment.
I have one question: if our concern is only about not allowing users to set decimals on felt fields values that should only allow hex values in RPC requests, why then not make this change specific to the RPC?
I mean, we are applying a general change in our entire code base (since felt is used everywhere (consensus, p2p, cryptography...)), where a felt from a decimal is not a problem at all (in some cases, it's even a required behavior (like the EntryPointOffset situation). IMO, this is not good. We should have a patch specifically for RPC-related code.
One idea is to create a new felt type, specifically to be used in all RPC requests, and implement the filter logic on it. Then, we update all RPC methods to use this type instead of felt.Felt.
E.g:
type FeltInput struct {
*felt.Felt // with it as an embedded field, we can access all felt methods out of the box from the FeltInput type
}
func (z *FeltInput) UnmarshalJSON(data []byte) error {
// filter logic here....
}It's just one idea. How it should be done is something that we need to discuss, but I really believe this is the right choice.
Edit: after internal discussion with the team, we decided to move forward with the proposed approach in the PR.
8848187 to
aac696e
Compare
aac696e to
1c63412
Compare
… values (#3488) * refactor: `starknet_call` data parameters to allow hex decimal numbers only * chore: renames, increase codecov * refactor: allow only 0x-prefixed hex strings for felt * chore: linter issues * chore: self review * chore: remove deprecated felt constructors * chore: minor cleanups * chore: fix linter issues
Previously,
Feltaccepted decimal numbers, binary strings, and bare hex. Now it only accepts0x-prefixed hexadecimal strings. This tightens input validation for all JSON-deserialized felt values.