mana-ethereum / ethereumex

Elixir JSON-RPC client for the Ethereum blockchain 0x063D3d782598744AF1252eBEaf3aA97D990Edf72
MIT License
378 stars 73 forks source link

Default block parameter for eth_estimate_gas (and some others) #54

Closed kminevskiy closed 5 years ago

kminevskiy commented 5 years ago

Hi,

I was trying to use the eth_estimate_gas function, but it looks like it has not been tested and all calls to it were failing.

Here's the error:

{:error, %{"code" => -32602, "message" => "too many arguments, want at most 1"}}

So after looking at the Ethereum JSON RPC specs, I figured that default block parameters can be specified only for certain calls. However, when scrolling through the actual examples, some of them still specify the quantity/tag param.

But back to the issue at hand.

I removed the default block parameter from the spec, from the function signature and body params and it works as expected. Am I doing something wrong (with your initial implementation) or is it an actual bug and I should submit a PR?

Thanks!

hswick commented 5 years ago

It looks like in the link you posted (https://github.com/mana-ethereum/ethereumex/blob/master/lib/ethereumex/client/base_client.ex#L168) the typespec is incorrect. Please submit a PR.

You can get around this by using the generic request function:

Ethereumex.HttpClient.request("eth_estimateGas", params, opts)
ayrat555 commented 5 years ago

https://github.com/mana-ethereum/ethereumex/pull/55 merged