Fix error when indexing Wanchain

Why:

* When attempting to index Wanchain we were seeing this error:
  ```
  ** (FunctionClauseError) no function clause matching in
  EthereumJSONRPC.Transaction.entry_to_elixir/1
  (ethereum_jsonrpc) lib/ethereum_jsonrpc/transaction.ex:260:
  EthereumJSONRPC.Transaction.entry_to_elixir({"txType", "0x1"})
  ```

  After looking into this it looks like Wanchain returns a "txType" of 1
  for normal transactions and 6 for privacy transactions. It's not clear
  at this time if this is something we want BlockScout to keep track of so
  we'll be ignoring it for now.
* Issue link: https://github.com/poanetwork/blockscout/issues/994

This change addresses the need by:

* Editing `EthereumJSONRPC.Transaction.entry_to_elixir/1` to accept a
key of "txType" without generating a `FunctionClauseError`.
pull/997/head
Sebastian Abondano 6 years ago
parent ef35c9b320
commit 8ac6d8d0a4
  1. 4
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex

@ -257,8 +257,10 @@ defmodule EthereumJSONRPC.Transaction do
# double check that no new keys are being missed by requiring explicit match for passthrough
# `t:EthereumJSONRPC.address/0` and `t:EthereumJSONRPC.hash/0` pass through as `Explorer.Chain` can verify correct
# hash format
#
# "txType": to avoid FunctionClauseError when indexing Wanchain
defp entry_to_elixir({key, value})
when key in ~w(blockHash condition creates from hash input jsonrpc publicKey raw to),
when key in ~w(blockHash condition creates from hash input jsonrpc publicKey raw to txType),
do: {key, value}
defp entry_to_elixir({key, quantity}) when key in ~w(gas gasPrice nonce r s standardV v value) and quantity != nil do

Loading…
Cancel
Save