diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex index 8aeac76906..04a00fa068 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex @@ -21,6 +21,9 @@ <%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %> <%= gettext "Transactions" %> <%= if contract?(@address) do %> + + <%= link(gettext("Token"), to: token_path(BlockScoutWeb.Endpoint, :show, @address.hash), "data-test": "token_hash_link" ) %> + <%= gettext "Contract created by" %> <%= link( diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex index 1d6c4aef9e..b43817886c 100644 --- a/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex +++ b/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex @@ -15,6 +15,10 @@ defmodule BlockScoutWeb.AddressPage do css("[data-test='address_balance']") end + def token_hash_link do + css("[data-test='token_hash_link']") + end + def contract_creator do css("[data-test='address_contract_creator']") end diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs index ad998dbaaf..0d67b6ac30 100644 --- a/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs +++ b/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs @@ -94,6 +94,29 @@ defmodule BlockScoutWeb.ViewingAddressesTest do end end + describe "viewing contract token" do + test "see a link to the token of the contract", %{session: session} do + address = insert(:address) + contract = insert(:address, contract_code: Factory.data("contract_code")) + transaction = insert(:transaction, from_address: address, created_contract_address: contract) + + internal_transaction = + insert( + :internal_transaction_create, + index: 0, + transaction: transaction, + from_address: address, + created_contract_address: contract + ) + + insert(:token, contract_address: address) + + session + |> AddressPage.visit_page(internal_transaction.created_contract_address) + |> assert_has(AddressPage.token_hash_link()) + end + end + describe "viewing transactions" do test "sees all addresses transactions by default", %{ addresses: addresses,