diff --git a/lib/eth/query.ex b/lib/eth/query.ex index 7984b66..9c93deb 100644 --- a/lib/eth/query.ex +++ b/lib/eth/query.ex @@ -155,17 +155,21 @@ defmodule ETH.Query do {:ok, hex_gas_estimate} -> {:ok, hex_gas_estimate |> convert_to_number |> convert(denomination) |> round} - error -> - error + {:error, error} -> + {:error, error} end end def estimate_gas!(transaction \\ %{data: ""}, denomaination \\ :wei) def estimate_gas!(transaction = %{to: _to, data: _data}, denomination) do - {:ok, hex_gas_estimate} = HttpClient.eth_estimate_gas(transaction) + case HttpClient.eth_estimate_gas(transaction) do + {:ok, hex_gas_estimate} -> + hex_gas_estimate |> convert_to_number |> convert(denomination) |> round - hex_gas_estimate |> convert_to_number |> convert(denomination) |> round + {:error, error} -> + {:error, error} + end end def convert_transaction_log(log) do diff --git a/lib/eth/transaction.ex b/lib/eth/transaction.ex index dd44035..f45fbc7 100644 --- a/lib/eth/transaction.ex +++ b/lib/eth/transaction.ex @@ -26,9 +26,12 @@ defmodule ETH.Transaction do def send_transaction(params, private_key) do set_default_from(params, private_key) |> build - |> sign_transaction(private_key) - |> Base.encode16() - |> send + |> case do + %{gas_limit: {:error, error}} -> {:error, error} + build -> sign_transaction(build, private_key) + |> Base.encode16() + |> send + end end def send_transaction(sender_wallet, receiver_wallet, value) when is_number(value) do