diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_responsive_hash.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_responsive_hash.html.eex index bea2a2159f..23e05644f8 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/_responsive_hash.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_responsive_hash.html.eex @@ -1,6 +1,11 @@ <%= if name = primary_name(@address) do %> - <%= name %> (<%= short_hash(@address) %>...) + <%= if assigns[:truncate] do %> + <%= name %> (<%= short_hash(@address) %>...) + <% else %> + <%= name %> (<%= @address.hash %>) + <%= name %> (<%= BlockScoutWeb.AddressView.trimmed_hash(@address.hash) %>) + <% end %> <% else %> <%= if assigns[:truncate] do %> <%= BlockScoutWeb.AddressView.trimmed_hash(@address.hash) %> diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs index 071667cf77..7734ef05aa 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs @@ -14,6 +14,15 @@ defmodule BlockScoutWeb.AddressControllerTest do |> Enum.map(fn {address, _transaction_count} -> address end) |> Enum.map(& &1.hash) == address_hashes end + + test "returns an address's primary name when present", %{conn: conn} do + address = insert(:address, fetched_coin_balance: 1) + address_name = insert(:address_name, address: address, primary: true, name: "POA Wallet") + + conn = get(conn, address_path(conn, :index)) + + assert html_response(conn, 200) =~ address_name.name + end end describe "GET show/3" do diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 24ac174873..63509f9315 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -913,6 +913,7 @@ defmodule Explorer.Chain do from(a in Address, where: a.fetched_coin_balance > ^0, order_by: [desc: a.fetched_coin_balance, asc: a.hash], + preload: [:names], select: {a, fragment("coalesce(1 + ?, 0)", a.nonce)}, limit: 250 )