Merge pull request #661 from poanetwork/638

Treat "status" => nil the same as no "status"
pull/671/head
Andrew Cravenho 6 years ago committed by GitHub
commit e528ce16f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex
  2. 5
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs

@ -266,6 +266,7 @@ defmodule EthereumJSONRPC.Receipt do
defp elixir_reducer({:ok, {_, _}}, {:error, _reasons} = acc_error), do: acc_error
defp elixir_reducer({:error, reason}, {:ok, _}), do: {:error, [reason]}
defp elixir_reducer({:error, reason}, {:error, reasons}), do: {:error, [reason | reasons]}
defp elixir_reducer(:ignore, acc), do: acc
defp ok!({:ok, elixir}, _receipt), do: elixir
@ -327,6 +328,8 @@ defmodule EthereumJSONRPC.Receipt do
case status do
"0x0" -> {:ok, {key, :error}}
"0x1" -> {:ok, {key, :ok}}
# pre-Byzantium / Ethereum Classic on Parity
nil -> :ignore
other -> {:error, {:unknown_value, %{key: key, value: other}}}
end
end

@ -43,5 +43,10 @@ defmodule EthereumJSONRPC.ReceiptTest do
})
end
end
# Regression test for https://github.com/poanetwork/blockscout/issues/638
test ~s|"status" => nil is treated the same as no status| do
assert Receipt.to_elixir(%{"status" => nil, "transactionHash" => "0x0"}) == %{"transactionHash" => "0x0"}
end
end
end

Loading…
Cancel
Save