@ -3,7 +3,11 @@
<%= if @use_custom_tooltip == true do %>
<span><%= name %> (<%= short_hash(@address) %>...)</span>
<% else %>
<span data-toggle="tooltip" data-placement="top" title="<%= @address %>"><%= name %> (<%= short_hash(@address) %>...)</span>
<span data-toggle="tooltip" data-placement="top" title="<%= @address %>">
<span class="d-none d-md-none d-lg-inline-block d-xl-inline"><%= short_contract_name(name, 30) %></span>
<span class="d-inline-block d-md-inline-block d-lg-none d-xl-none"><%= short_contract_name(name, 10) %></span>
<span> (<%= BlockScoutWeb.AddressView.trimmed_hash(@address.hash) %>)</span>
</span>
<% end %>
<%= if assigns[:truncate] do %>
@ -62,7 +62,9 @@
<h3 class="address-detail-hash-title <%= if BlockScoutWeb.AddressView.contract?(@address) do %>contract-address<% end %>" data-test="address_detail_hash"><%= @address %></h3>
<div class="d-flex flex-column flex-lg-row justify-content-start text-muted">
<%= if address_name = primary_name(@address) do %>
<strong class="mr-4 mb-2 text-dark"><%= address_name %></strong>
<strong class="mr-4 mb-2 text-dark" title="<%= address_name %>">
<%= short_contract_name(address_name, 30) %>
</strong>
<%= if @address.token do %>
<span class="mr-4 mb-2">
@ -323,6 +323,13 @@ defmodule BlockScoutWeb.AddressView do
"0x" <> short_address
end
def short_contract_name(name, max_length) do
part_length = Kernel.trunc(max_length / 4)
if (String.length(name) <= max_length),
do: name,
else: "#{String.slice(name, 0, max_length - part_length)}..#{String.slice(name, -part_length, part_length)}"
def address_page_title(address) do
cond do
smart_contract_verified?(address) -> "#{address.smart_contract.name} (#{to_string(address)})"