diff --git a/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex index 602fd4326f..80db35c435 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex @@ -103,7 +103,18 @@ <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %> - <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> + <%= if ExplorerWeb.InternalTransactionView.contract?(internal_transaction) do %> + + <%= link( + gettext("Contract Creation"), + class: "transaction__link", + "data-address-hash": internal_transaction.created_contract_address_hash, + to: address_path(ExplorerWeb.Endpoint, :show, @locale, internal_transaction.created_contract_address_hash), + title: internal_transaction.created_contract_address_hash + ) %> + <% else %> + <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> + <% end %> <%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %> diff --git a/apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex index 34c4a9b2ec..c5b44b4d68 100644 --- a/apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex @@ -41,7 +41,18 @@ <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %> - <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> + <%= if ExplorerWeb.InternalTransactionView.contract?(internal_transaction) do %> + + <%= link( + gettext("Contract Creation"), + class: "transaction__link", + "data-address-hash": internal_transaction.created_contract_address_hash, + to: address_path(ExplorerWeb.Endpoint, :show, @locale, internal_transaction.created_contract_address_hash), + title: internal_transaction.created_contract_address_hash + ) %> + <% else %> + <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> + <% end %> <%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %> <%= ExplorerWeb.TransactionView.gas(internal_transaction) %> diff --git a/apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex b/apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex index 5b82153dc0..68084933a4 100644 --- a/apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex +++ b/apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex @@ -1,4 +1,9 @@ defmodule ExplorerWeb.InternalTransactionView do use ExplorerWeb, :view @dialyzer :no_match + + alias Explorer.Chain.InternalTransaction + + def contract?(%InternalTransaction{type: :create}), do: true + def contract?(_), do: false end diff --git a/apps/explorer_web/test/explorer_web/views/internal_transaction_view_test.exs b/apps/explorer_web/test/explorer_web/views/internal_transaction_view_test.exs new file mode 100644 index 0000000000..ba118f5bd1 --- /dev/null +++ b/apps/explorer_web/test/explorer_web/views/internal_transaction_view_test.exs @@ -0,0 +1,19 @@ +defmodule ExplorerWeb.InternalTransactionViewTest do + use ExplorerWeb.ConnCase, async: true + + alias ExplorerWeb.InternalTransactionView + + describe "contract?/1" do + test "with internal transaction of type create returns true" do + internal_transaction = build(:internal_transaction_create) + + assert InternalTransactionView.contract?(internal_transaction) + end + + test "with non-create type internal transaction returns false" do + internal_transaction = build(:internal_transaction) + + refute InternalTransactionView.contract?(internal_transaction) + end + end +end