Skip to content

Commit

Permalink
Fix raise on missing values
Browse files Browse the repository at this point in the history
  • Loading branch information
alisinabh committed Jan 29, 2024
1 parent 392f133 commit 83d526d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ethers/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 8 additions & 0 deletions test/ethers/transaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 83d526d

Please sign in to comment.