feat(schemas): Permit hex/dec input via uintParam #454
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.
Description
At present, clients implementing methods that have integer inputs MUST accept hex string formats. This PR adds the
requirement that they MUST also accept JSON
number
types for certain methods.Rationale
Some clients permit the use of JSON
number
type in JSON-RPC requests. Primarily this is a conveniencefeature, as block numbers and transaction indices are usually represented as decimal.
This change standardises this convenience behaviour and is mainly an ergonomics change affecting RPC endpoint users.
Scope
The changes are limited to the parameter in requests. Responses are not modified and still use the hex representation.
Affected methods are those that accept transaction indices, block numbers or filter numbers:
eth_getTransactionByBlockHashAndIndex
BlockNumberOrTag
eth_getTransactionByBlockNumberAndIndex
eth_getBlockByNumber
eth_getBlockTransactionCountByNumber
eth_getUncleCountByBlockNumber
eth_estimateGas
eth_feeHistory
eth_createAccessList
debug_getRawHeader
debug_getRawBlock
debug_getRawReceipts
BlockNumberOrTagOrHash
eth_call
eth_getBalance
eth_getStorageAt
eth_getTransactionCount
eth_getCode
eth_getProof
Filter
eth_newFilter
eth_uninstallFilter
eth_getFilterChanges
eth_getFilterLogs
Changes
uintParam
that is defined as either hex string (current) or decimal number (new)uint
withuintParam
for method parameterseth_getBlockByNumber
Security
JSON
number
type does not differentiate between integer, floating point and SI notation.Floating point numbers and SI notation should be rejected as invalid parameters. This is clear with block number
100.5
, but should also apply to block numbers100.0
and1e2
.If clients parse these variants in different ways, end-users will observe different behaviour across clients.