4
0
Fork 0

Returns error when tx has not been mined

pull/32/head
Miguel Diaz 6 years ago
parent 66fa460fe7
commit fade49b11f
  1. 20
      lib/exw3.ex

@ -175,23 +175,20 @@ defmodule ExW3 do
@spec keys_to_decimal(%{}, []) :: %{} @spec keys_to_decimal(%{}, []) :: %{}
def keys_to_decimal(map, keys) do def keys_to_decimal(map, keys) do
Map.new( for k <- keys, into: %{}, do: {k, map |> Map.get(k) |> to_decimal()}
Enum.map(keys, fn k ->
{k, Map.get(map, k) |> to_decimal}
end)
)
end end
@spec tx_receipt(binary()) :: %{} @spec tx_receipt(binary()) :: %{}
@doc "Returns transaction receipt for specified transaction hash(id)" @doc "Returns transaction receipt for specified transaction hash(id)"
def tx_receipt(tx_hash) do def tx_receipt(tx_hash) do
case call_client(:eth_get_transaction_receipt, [tx_hash]) do case call_client(:eth_get_transaction_receipt, [tx_hash]) do
{:ok, nil} ->
{:error, :not_mined}
{:ok, receipt} -> {:ok, receipt} ->
{:ok, decimal_res = keys_to_decimal(receipt, ~w(blockNumber cumulativeGasUsed gasUsed))
Map.merge(
receipt, {:ok, Map.merge(receipt, decimal_res)}
keys_to_decimal(receipt, ["blockNumber", "cumulativeGasUsed", "gasUsed"])
)}
err -> err ->
{:error, err} {:error, err}
@ -701,7 +698,8 @@ defmodule ExW3 do
end end
def eth_send_helper(address, abi, method_name, args, options) do def eth_send_helper(address, abi, method_name, args, options) do
encoded_options = ExW3.encode_options( encoded_options =
ExW3.encode_options(
options, options,
[:gas, :gasPrice, :value, :nonce] [:gas, :gasPrice, :value, :nonce]
) )

Loading…
Cancel
Save