|
|
|
@ -61,21 +61,16 @@ defmodule BlockScoutWeb.TransactionController do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def show(conn, %{"id" => id}) do |
|
|
|
|
case Chain.string_to_transaction_hash(id) do |
|
|
|
|
{:ok, transaction_hash} -> show_transaction(conn, id, Chain.hash_to_transaction(transaction_hash)) |
|
|
|
|
:error -> conn |> put_status(422) |> render("invalid.html", transaction_hash: id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp show_transaction(conn, id, {:error, :not_found}) do |
|
|
|
|
conn |> put_status(404) |> render("not_found.html", transaction_hash: id) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp show_transaction(conn, id, {:ok, %Chain.Transaction{} = transaction}) do |
|
|
|
|
if Chain.transaction_has_token_transfers?(transaction.hash) do |
|
|
|
|
redirect(conn, to: transaction_token_transfer_path(conn, :index, id)) |
|
|
|
|
with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(id), |
|
|
|
|
{:ok, %Chain.Transaction{} = transaction} <- Chain.hash_to_transaction(transaction_hash) do |
|
|
|
|
if Chain.transaction_has_token_transfers?(transaction.hash) do |
|
|
|
|
redirect(conn, to: transaction_token_transfer_path(conn, :index, id)) |
|
|
|
|
else |
|
|
|
|
redirect(conn, to: transaction_internal_transaction_path(conn, :index, id)) |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
redirect(conn, to: transaction_internal_transaction_path(conn, :index, id)) |
|
|
|
|
:error -> conn |> put_status(422) |> render("invalid.html", transaction_hash: id) |
|
|
|
|
{:error, :not_found} -> conn |> put_status(404) |> render("not_found.html", transaction_hash: id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|