diff --git a/lib/ethereumex/client/base_client.ex b/lib/ethereumex/client/base_client.ex index d69331b..6d275c0 100644 --- a/lib/ethereumex/client/base_client.ex +++ b/lib/ethereumex/client/base_client.ex @@ -71,6 +71,17 @@ defmodule Ethereumex.Client.BaseClient do request("eth_gasPrice", [], opts) end + @impl true + def eth_max_priority_fee_per_gas(opts \\ []) do + request("eth_maxPriorityFeePerGas", [], opts) + end + + @impl true + def eth_fee_history(block_count, newestblock, reward_percentiles, opts \\ []) do + params = [block_count, newestblock, reward_percentiles] + request("eth_feeHistory", params, opts) + end + @impl true def eth_accounts(opts \\ []) do request("eth_accounts", [], opts) diff --git a/lib/ethereumex/client/behaviour.ex b/lib/ethereumex/client/behaviour.ex index b08d72f..5919ab9 100644 --- a/lib/ethereumex/client/behaviour.ex +++ b/lib/ethereumex/client/behaviour.ex @@ -15,6 +15,8 @@ defmodule Ethereumex.Client.Behaviour do @callback eth_mining(keyword()) :: {:ok, boolean()} | error @callback eth_hashrate(keyword()) :: {:ok, binary()} | error @callback eth_gas_price(keyword()) :: {:ok, binary()} | error + @callback eth_max_priority_fee_per_gas(keyword()) :: {:ok, binary()} | error + @callback eth_fee_history(binary(), binary(), list(binary()), keyword()) :: {:ok, map()} | error @callback eth_accounts(keyword()) :: {:ok, [binary()]} | error @callback eth_block_number(keyword()) :: {:ok, binary} | error @callback eth_get_balance(binary(), binary(), keyword()) :: {:ok, binary()} | error diff --git a/test/ethereumex/client/base_client_test.exs b/test/ethereumex/client/base_client_test.exs index 71eeca1..41738a5 100644 --- a/test/ethereumex/client/base_client_test.exs +++ b/test/ethereumex/client/base_client_test.exs @@ -95,6 +95,8 @@ defmodule Ethereumex.Client.BaseClientTest do test ".eth_mining/0", do: Helpers.check("eth_mining") test ".eth_hashrate/0", do: Helpers.check("eth_hashrate") test ".eth_gas_price/0", do: Helpers.check("eth_gas_price") + test ".eth_max_priority_fee_per_gas/0", do: Helpers.check("eth_max_priority_fee_per_gas") + test ".eth_fee_history/3", do: Helpers.check("eth_fee_history", [1, "latest", [25, 75]]) test ".eth_accounts/0", do: Helpers.check("eth_accounts") test ".eth_block_number/0", do: Helpers.check("eth_block_number") test ".eth_get_compilers/0", do: Helpers.check("eth_get_compilers") diff --git a/test/ethereumex/http_client_test.exs b/test/ethereumex/http_client_test.exs index cbda54f..b7baa82 100644 --- a/test/ethereumex/http_client_test.exs +++ b/test/ethereumex/http_client_test.exs @@ -104,6 +104,24 @@ defmodule Ethereumex.HttpClientTest do end end + @tag :eth + describe "HttpClient.eth_max_priority_fee_per_gas/1" do + test "returns current max priority fee per gas" do + result = HttpClient.eth_max_priority_fee_per_gas() + + {:ok, <<_::binary>>} = result + end + end + + @tag :eth + describe "HttpClient.eth_fee_history/3" do + test "returns a collection of historical gas information" do + result = HttpClient.eth_fee_history(1, "latest", [25, 75]) + + assert is_map(result) + end + end + @tag :eth describe "HttpClient.eth_accounts/1" do test "returns addresses owned by client" do diff --git a/test/ethereumex/ipc_client_test.exs b/test/ethereumex/ipc_client_test.exs index 265bc28..2fa23f2 100644 --- a/test/ethereumex/ipc_client_test.exs +++ b/test/ethereumex/ipc_client_test.exs @@ -115,6 +115,24 @@ defmodule Ethereumex.IpcClientTest do end end + @tag :eth + describe "IpcClient.eth_max_priority_fee_per_gas/1" do + test "returns current max priority fee per gas" do + result = IpcClient.eth_max_priority_fee_per_gas() + + {:ok, <<_::binary>>} = result + end + end + + @tag :eth + describe "IpcClient.eth_fee_history/3" do + test "returns a collection of historical gas information" do + result = IpcClient.eth_fee_history(1, "latest", [25, 75]) + + assert is_map(result) + end + end + @tag :eth describe "IpcClient.eth_accounts/1" do test "returns addresses owned by client" do