From 13731aafd4c1ea365db549ac35e386316cee9a07 Mon Sep 17 00:00:00 2001 From: James Duncombe Date: Fri, 26 May 2023 15:58:51 +0100 Subject: [PATCH] Fixes get_block_by_number parameter type. --- lib/tt_eth.ex | 9 ++++++--- lib/tt_eth/chain_client.ex | 4 ++-- lib/tt_eth/chain_client_mock_impl.ex | 2 +- test/tt_eth_test.exs | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/tt_eth.ex b/lib/tt_eth.ex index eab59f7..f3eece7 100644 --- a/lib/tt_eth.ex +++ b/lib/tt_eth.ex @@ -95,10 +95,13 @@ defmodule TTEth do do: tx_obj |> chain_client().eth_estimate_gas(opts) @doc """ - Delegate to `TTEth.ChainClient.eth_get_block/1+2`. + Delegate to `TTEth.ChainClient.eth_get_block/1+2` + + `tx_detail` flag set to false to mirror RPC call: + SEE: https://www.quicknode.com/docs/ethereum/eth_getBlockByNumber. """ - def get_block_by_number("" <> block, opts \\ []), - do: block |> chain_client().eth_get_block_by_number(opts) + def get_block_by_number("" <> block, tx_detail \\ false), + do: block |> chain_client().eth_get_block_by_number(tx_detail) ## Dependencies / Injection. diff --git a/lib/tt_eth/chain_client.ex b/lib/tt_eth/chain_client.ex index 52ab07d..728f4cf 100644 --- a/lib/tt_eth/chain_client.ex +++ b/lib/tt_eth/chain_client.ex @@ -58,8 +58,8 @@ defmodule TTEth.ChainClient do do: tx_obj |> HttpClient.eth_estimate_gas(opts) @impl ChainClient - def eth_get_block_by_number("" <> block, transaction_detail \\ false), - do: block |> HttpClient.eth_get_block_by_number(transaction_detail) + def eth_get_block_by_number("" <> block, tx_detail \\ false), + do: block |> HttpClient.eth_get_block_by_number(tx_detail) ## Helpers outside of the ChainClient behaviour. diff --git a/lib/tt_eth/chain_client_mock_impl.ex b/lib/tt_eth/chain_client_mock_impl.ex index 420b8c2..188a320 100644 --- a/lib/tt_eth/chain_client_mock_impl.ex +++ b/lib/tt_eth/chain_client_mock_impl.ex @@ -43,6 +43,6 @@ defmodule TTEth.ChainClientMockImpl do do: {:ok, "0x5208"} @impl ChainClient - def eth_get_block_by_number(_block, _opts \\ []), + def eth_get_block_by_number(_block, _tx_detail \\ false), do: {:ok, %{"number" => "0x1", "baseFeePerGas" => "0x10"}} end diff --git a/test/tt_eth_test.exs b/test/tt_eth_test.exs index f40fd5a..d6b9d46 100644 --- a/test/tt_eth_test.exs +++ b/test/tt_eth_test.exs @@ -174,9 +174,9 @@ defmodule TTEthTest do test "delegates to `ChainClient.eth_get_block_by_number/1+2`" do ChainClientMock # We want to make sure that the chain client is called to get the max priority fee. - |> expect(:eth_get_block_by_number, fn block_, opts_ -> + |> expect(:eth_get_block_by_number, fn block_, tx_detail_ -> assert block_ == "pending" - assert opts_ == [] + assert tx_detail_ == false {:ok, %{"baseFeePerGas" => "0x10"}} end)