Skip to content

Commit

Permalink
Adds eth_get_balance to client.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesduncombe committed Feb 21, 2024
1 parent 81e266b commit 0232409
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tt_eth/chain_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ defmodule TTEth.ChainClient do
|> Base.encode16(case: :lower)
|> hex_prefix!()

@impl ChainClient
def eth_get_balance(address, block \\ "latest", opts \\ []),
do: address |> HttpClient.eth_get_balance(block, opts)

@impl ChainClient
def eth_get_transaction_count(address, block \\ "latest", opts \\ []),
do: address |> HttpClient.eth_get_transaction_count(block, opts)
Expand Down
4 changes: 4 additions & 0 deletions lib/tt_eth/chain_client_mock_impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ defmodule TTEth.ChainClientMockImpl do
def build_tx_data(to, abi_data, %Wallet{} = wallet, nonce, opts \\ []),
do: to |> TTEth.ChainClient.build_tx_data(abi_data, wallet, nonce, opts)

@impl ChainClient
def eth_get_balance(_address, _block \\ "latest", _opts \\ []),
do: {:ok, "0x7"}

@impl ChainClient
def eth_get_transaction_count(_address, _block \\ "latest", _opts \\ []),
do: {:ok, "0x42"}
Expand Down

0 comments on commit 0232409

Please sign in to comment.