Skip to content

Empty params are always replaced with empty list #314

Open
@hoffmannjan

Description

@hoffmannjan

Library replaces missing params argument with [] empty list.

To Reproduce

return await this.client
      .request({
        method: 'chain_get_state_root_hash',
      })

end in a JSON RPC request that looks like this:

{
  "jsonrpc": "2.0",
  "method": "chain_get_state_root_hash",
  "params": [],
  "id": 8466830112817644860
}

I also tried doing

return await this.client
      .request({
        method: 'chain_get_state_root_hash',
        params: null
      })

but the effect is the same.

Expected behavior
IMO if I don't add params to the request it shouldn't be auto-added to the request.
Our RPC server is very strict and it interpretes [] as wrong parameter.
I was looking for definition how it should be implemented correctly in JSON-RPC specification but it wasn't super clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions