Skip to content

Commit

Permalink
Fixes get_block_by_number parameter type.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesduncombe committed Oct 9, 2023
1 parent 49280aa commit 13731aa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lib/tt_eth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions lib/tt_eth/chain_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion lib/tt_eth/chain_client_mock_impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/tt_eth_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 13731aa

Please sign in to comment.