diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex index a8ccafb0a2..604c7b2235 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex @@ -149,23 +149,25 @@ defmodule EthereumJSONRPC.Transaction do elixir_to_params(%{transaction | "input" => "0x"}) end - def elixir_to_params(%{ - "blockHash" => block_hash, - "blockNumber" => block_number, - "from" => from_address_hash, - "gas" => gas, - "gasPrice" => gas_price, - "hash" => hash, - "input" => input, - "nonce" => nonce, - "r" => r, - "s" => s, - "to" => to_address_hash, - "transactionIndex" => index, - "v" => v, - "value" => value - }) do - %{ + def elixir_to_params( + %{ + "blockHash" => block_hash, + "blockNumber" => block_number, + "from" => from_address_hash, + "gas" => gas, + "gasPrice" => gas_price, + "hash" => hash, + "input" => input, + "nonce" => nonce, + "r" => r, + "s" => s, + "to" => to_address_hash, + "transactionIndex" => index, + "v" => v, + "value" => value + } = transaction + ) do + result = %{ block_hash: block_hash, block_number: block_number, from_address_hash: from_address_hash, @@ -182,6 +184,12 @@ defmodule EthereumJSONRPC.Transaction do value: value, transaction_index: index } + + if transaction["creates"] do + Map.put(result, :created_contract_address_hash, transaction["creates"]) + else + result + end end # Ganache bug. it return `to: "0x0"` except of `to: null` diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transactions.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transactions.ex index cae14b1cd8..e056fb12c2 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transactions.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transactions.ex @@ -56,7 +56,8 @@ defmodule EthereumJSONRPC.Transactions do to_address_hash: nil, v: "0xbd", value: 0, - transaction_index: 0 + transaction_index: 0, + created_contract_address_hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb4" } ] diff --git a/apps/indexer/lib/indexer/block/fetcher/receipts.ex b/apps/indexer/lib/indexer/block/fetcher/receipts.ex index 1257d8db2a..f38676cf12 100644 --- a/apps/indexer/lib/indexer/block/fetcher/receipts.ex +++ b/apps/indexer/lib/indexer/block/fetcher/receipts.ex @@ -42,7 +42,14 @@ defmodule Indexer.Block.Fetcher.Receipts do end) 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