From b816543851c47b6b3c93eb535c2643c5b6af1338 Mon Sep 17 00:00:00 2001 From: Lucas Narciso Date: Wed, 1 Aug 2018 15:39:57 -0300 Subject: [PATCH] Change Transaction Details redirection behaviour Redirects to Token Transfers if the transaction contains token transfers, otherwise keeps the old way of redirecting to Internal Transactions. --- .../controllers/transaction_controller.ex | 8 ++++++- .../index.html.eex | 4 ++-- .../templates/transaction_log/index.html.eex | 2 +- .../transaction_controller_test.exs | 23 +++++++++++++++---- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex index af08d2c01c..1bfc278e1c 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex @@ -34,6 +34,12 @@ defmodule BlockScoutWeb.TransactionController do end def show(conn, %{"id" => id, "locale" => locale}) do - redirect(conn, to: transaction_internal_transaction_path(conn, :index, locale, id)) + {:ok, transaction_hash} = Chain.string_to_transaction_hash(id) + + if Chain.transaction_has_token_transfers?(transaction_hash) do + redirect(conn, to: transaction_token_transfer_path(conn, :index, locale, id)) + else + redirect(conn, to: transaction_internal_transaction_path(conn, :index, locale, id)) + end end end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex index 1c6322c3fb..0254272148 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex @@ -19,7 +19,7 @@ <%= link( gettext("Internal Transactions"), class: "nav-link active", - to: transaction_path(@conn, :show, @conn.assigns.locale, @transaction) + to: transaction_internal_transaction_path(@conn, :index, @conn.assigns.locale, @transaction) ) %>