From 2f48f5f27c1e4830fe1f069579cf79738ce6945a Mon Sep 17 00:00:00 2001 From: Konstantin Zolotarev Date: Tue, 8 Jan 2019 15:33:43 +0200 Subject: [PATCH] Fixes for ganache JSON RPC mistakes --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex | 5 +++++ apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex index b66cc2ebf6..e10a7678e6 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex @@ -282,6 +282,11 @@ defmodule EthereumJSONRPC.Receipt do end end + # fixes for latest ganache JSON RPC + defp entry_to_elixir({key, quantity}) when key in ~w(r s v) do + :ignore + end + defp entry_to_elixir({key, value}) do {:error, {:unknown_key, %{key: key, value: value}}} end diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex index ea56d889fc..4f3ced8ff0 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex @@ -311,6 +311,11 @@ defmodule EthereumJSONRPC.Transaction do {key, quantity_to_integer(quantity)} end + # as always ganache has it's own vision on JSON RPC standard + defp entry_to_elixir({key, quantity}) when key in ~w(r s v) and quantity == nil do + {key, 0} + end + # quantity or nil for pending defp entry_to_elixir({key, quantity_or_nil}) when key in ~w(blockNumber transactionIndex) do elixir =