client-js icon indicating copy to clipboard operation
client-js copied to clipboard

Empty params are always replaced with empty list

Open hoffmannjan opened this issue 2 years ago • 1 comments

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.

hoffmannjan avatar Jun 30 '22 13:06 hoffmannjan

@hoffmannjan thx for the issue. And good catch! We should be able to throw out params and not have it specified, let me think about what the solution for this should be

zcstarr avatar Sep 12 '22 19:09 zcstarr