Description
Problem
Problem:
The eth_getBalance
method in packages/relay/src/lib/eth.ts
currently allows the second parameter blockNumberOrTagOrHash
to be null
, as indicated by its TypeScript type:
blockNumberOrTagOrHash: string | null
However, the method is decorated with @rpcParamValidationRules
enforcing this parameter as required:
@rpcParamValidationRules({
0: { type: ParamType.ADDRESS, required: true },
1: { type: ParamType.BLOCK_NUMBER_OR_HASH, required: true },
})
This mismatch is inconsistent with Ethereum's openrpc.json
, where the Block
parameter is required and must conform to the BlockNumberOrTagOrHash
schema.
In contrast, the Hedera-specific OpenRPC spec allows the parameter to be optional, but for Ethereum compatibility, we must follow the Ethereum spec.
Solution
-
Update the implementation of
getBalance
to no longer allownull
for theblockNumberOrTagOrHash
parameter:blockNumberOrTagOrHash: string
-
Ensure the entire code path respects the required status of this parameter and gracefully handles cases where it's missing or invalid.
-
Add or update unit tests to confirm that a missing or
null
blockNumberOrTagOrHash
leads to validation errors, aligning behavior with Ethereum JSON-RPC expectations.
Alternatives
No response