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
numbertypes for certain methods.Rationale
Some clients permit the use of JSON
numbertype 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_getTransactionByBlockHashAndIndexBlockNumberOrTageth_getTransactionByBlockNumberAndIndexeth_getBlockByNumbereth_getBlockTransactionCountByNumbereth_getUncleCountByBlockNumbereth_estimateGaseth_feeHistoryeth_createAccessListdebug_getRawHeaderdebug_getRawBlockdebug_getRawReceiptsBlockNumberOrTagOrHasheth_calleth_getBalanceeth_getStorageAteth_getTransactionCounteth_getCodeeth_getProofFiltereth_newFiltereth_uninstallFiltereth_getFilterChangeseth_getFilterLogsChanges
uintParamthat is defined as either hex string (current) or decimal number (new)uintwithuintParamfor method parameterseth_getBlockByNumberSecurity
JSON
numbertype 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.0and1e2.If clients parse these variants in different ways, end-users will observe different behaviour across clients.