diff --git a/lib/ethers/transaction.ex b/lib/ethers/transaction.ex index c82d798..04ae4e4 100644 --- a/lib/ethers/transaction.ex +++ b/lib/ethers/transaction.ex @@ -200,6 +200,8 @@ defmodule Ethers.Transaction do tx |> Map.from_struct() |> Map.new(fn + {k, nil} -> {k, nil} + {k, ""} -> {k, nil} {k, v} when k in @integer_type_values -> {k, Utils.hex_to_integer!(v)} {k, v} when k in @binary_type_values -> {k, Utils.hex_decode!(v)} {k, v} -> {k, v} diff --git a/test/ethers/transaction_test.exs b/test/ethers/transaction_test.exs index e2cbfde..1384cb9 100644 --- a/test/ethers/transaction_test.exs +++ b/test/ethers/transaction_test.exs @@ -55,5 +55,13 @@ defmodule Ethers.TransactionTest do assert is_binary(decoded.signature_r) assert is_binary(decoded.signature_s) end + + test "does not fail with missing values" do + assert %{signature_recovery_id: nil} = + Transaction.decode_values(%{@transaction_fixture | signature_recovery_id: nil}) + + assert %{signature_recovery_id: nil} = + Transaction.decode_values(%{@transaction_fixture | signature_recovery_id: ""}) + end end end