Merge pull request #1581 from poanetwork/ab-creates-param

consider `creates` param when fetching transactions
pull/1597/head
Victor Baranov 6 years ago committed by GitHub
commit 504c0995bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex
  2. 3
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transactions.ex
  3. 9
      apps/indexer/lib/indexer/block/fetcher/receipts.ex

@ -149,7 +149,8 @@ defmodule EthereumJSONRPC.Transaction do
elixir_to_params(%{transaction | "input" => "0x"}) elixir_to_params(%{transaction | "input" => "0x"})
end end
def elixir_to_params(%{ def elixir_to_params(
%{
"blockHash" => block_hash, "blockHash" => block_hash,
"blockNumber" => block_number, "blockNumber" => block_number,
"from" => from_address_hash, "from" => from_address_hash,
@ -164,8 +165,9 @@ defmodule EthereumJSONRPC.Transaction do
"transactionIndex" => index, "transactionIndex" => index,
"v" => v, "v" => v,
"value" => value "value" => value
}) do } = transaction
%{ ) do
result = %{
block_hash: block_hash, block_hash: block_hash,
block_number: block_number, block_number: block_number,
from_address_hash: from_address_hash, from_address_hash: from_address_hash,
@ -182,6 +184,12 @@ defmodule EthereumJSONRPC.Transaction do
value: value, value: value,
transaction_index: index transaction_index: index
} }
if transaction["creates"] do
Map.put(result, :created_contract_address_hash, transaction["creates"])
else
result
end
end end
# Ganache bug. it return `to: "0x0"` except of `to: null` # Ganache bug. it return `to: "0x0"` except of `to: null`

@ -56,7 +56,8 @@ defmodule EthereumJSONRPC.Transactions do
to_address_hash: nil, to_address_hash: nil,
v: "0xbd", v: "0xbd",
value: 0, value: 0,
transaction_index: 0 transaction_index: 0,
created_contract_address_hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb4"
} }
] ]

@ -42,7 +42,14 @@ defmodule Indexer.Block.Fetcher.Receipts do
end) end)
Enum.map(transactions_params, fn %{hash: transaction_hash} = transaction_params -> Enum.map(transactions_params, fn %{hash: transaction_hash} = transaction_params ->
Map.merge(transaction_params, Map.fetch!(transaction_hash_to_receipt_params, transaction_hash)) receipts_params = Map.fetch!(transaction_hash_to_receipt_params, transaction_hash)
merged_params = Map.merge(transaction_params, receipts_params)
if transaction_params[:created_contract_address_hash] && is_nil(receipts_params[:created_contract_address_hash]) do
Map.put(merged_params, :created_contract_address_hash, transaction_params[:created_contract_address_hash])
else
merged_params
end
end) end)
end end

Loading…
Cancel
Save