|
|
|
@ -24,59 +24,55 @@ defmodule BlockScoutWeb.TransactionRawTraceController do |
|
|
|
|
), |
|
|
|
|
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), |
|
|
|
|
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do |
|
|
|
|
internal_transactions = Chain.all_transaction_to_internal_transactions(hash) |
|
|
|
|
if is_nil(transaction.block_number) do |
|
|
|
|
render_raw_trace(conn, [], transaction, hash) |
|
|
|
|
else |
|
|
|
|
internal_transactions = Chain.all_transaction_to_internal_transactions(hash) |
|
|
|
|
|
|
|
|
|
first_trace_exists = |
|
|
|
|
Enum.find_index(internal_transactions, fn trace -> |
|
|
|
|
trace.index == 0 |
|
|
|
|
end) |
|
|
|
|
first_trace_exists = |
|
|
|
|
Enum.find_index(internal_transactions, fn trace -> |
|
|
|
|
trace.index == 0 |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
internal_transactions = |
|
|
|
|
if first_trace_exists do |
|
|
|
|
internal_transactions |
|
|
|
|
else |
|
|
|
|
response = |
|
|
|
|
Chain.fetch_first_trace( |
|
|
|
|
[ |
|
|
|
|
%{ |
|
|
|
|
block_hash: transaction.block_hash, |
|
|
|
|
block_number: transaction.block_number, |
|
|
|
|
hash_data: hash_string, |
|
|
|
|
transaction_index: transaction.index |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
json_rpc_named_arguments |
|
|
|
|
) |
|
|
|
|
internal_transactions = |
|
|
|
|
if first_trace_exists do |
|
|
|
|
internal_transactions |
|
|
|
|
else |
|
|
|
|
response = |
|
|
|
|
Chain.fetch_first_trace( |
|
|
|
|
[ |
|
|
|
|
%{ |
|
|
|
|
block_hash: transaction.block_hash, |
|
|
|
|
block_number: transaction.block_number, |
|
|
|
|
hash_data: hash_string, |
|
|
|
|
transaction_index: transaction.index |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
json_rpc_named_arguments |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
case response do |
|
|
|
|
{:ok, first_trace_params} -> |
|
|
|
|
InternalTransactions.run_insert_only(first_trace_params, %{ |
|
|
|
|
timeout: :infinity, |
|
|
|
|
timestamps: Import.timestamps(), |
|
|
|
|
internal_transactions: %{params: first_trace_params} |
|
|
|
|
}) |
|
|
|
|
case response do |
|
|
|
|
{:ok, first_trace_params} -> |
|
|
|
|
InternalTransactions.run_insert_only(first_trace_params, %{ |
|
|
|
|
timeout: :infinity, |
|
|
|
|
timestamps: Import.timestamps(), |
|
|
|
|
internal_transactions: %{params: first_trace_params} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
Chain.all_transaction_to_internal_transactions(hash) |
|
|
|
|
Chain.all_transaction_to_internal_transactions(hash) |
|
|
|
|
|
|
|
|
|
{:error, _} -> |
|
|
|
|
internal_transactions |
|
|
|
|
{:error, _} -> |
|
|
|
|
internal_transactions |
|
|
|
|
|
|
|
|
|
:ignore -> |
|
|
|
|
internal_transactions |
|
|
|
|
:ignore -> |
|
|
|
|
internal_transactions |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
render( |
|
|
|
|
conn, |
|
|
|
|
"index.html", |
|
|
|
|
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), |
|
|
|
|
internal_transactions: internal_transactions, |
|
|
|
|
block_height: Chain.block_height(), |
|
|
|
|
show_token_transfers: Chain.transaction_has_token_transfers?(hash), |
|
|
|
|
transaction: transaction |
|
|
|
|
) |
|
|
|
|
render_raw_trace(conn, internal_transactions, transaction, hash) |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
{:restricted_access, _} -> |
|
|
|
|
TransactionController.set_not_found_view(conn, hash_string) |
|
|
|
@ -88,4 +84,16 @@ defmodule BlockScoutWeb.TransactionRawTraceController do |
|
|
|
|
TransactionController.set_not_found_view(conn, hash_string) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp render_raw_trace(conn, internal_transactions, transaction, hash) do |
|
|
|
|
render( |
|
|
|
|
conn, |
|
|
|
|
"index.html", |
|
|
|
|
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), |
|
|
|
|
internal_transactions: internal_transactions, |
|
|
|
|
block_height: Chain.block_height(), |
|
|
|
|
show_token_transfers: Chain.transaction_has_token_transfers?(hash), |
|
|
|
|
transaction: transaction |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|