Merge pull request #1178 from poanetwork/add-primary-names-to-accounts-page

Add primary names to accounts page
pull/1180/head
Andrew Cravenho 6 years ago committed by GitHub
commit dd23bcbe3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      apps/block_scout_web/lib/block_scout_web/templates/address/_responsive_hash.html.eex
  2. 9
      apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs
  3. 1
      apps/explorer/lib/explorer/chain.ex

@ -1,6 +1,11 @@
<span class="<%= if @contract do %>contract-address<% end %>" data-address-hash="<%= @address.hash %>"> <span class="<%= if @contract do %>contract-address<% end %>" data-address-hash="<%= @address.hash %>">
<%= if name = primary_name(@address) do %> <%= if name = primary_name(@address) do %>
<%= if assigns[:truncate] do %>
<span data-toggle="tooltip" data-placement="top" title="<%= @address.hash %>"><%= name %> (<%= short_hash(@address) %>...)</span> <span data-toggle="tooltip" data-placement="top" title="<%= @address.hash %>"><%= name %> (<%= short_hash(@address) %>...)</span>
<% else %>
<span class="d-none d-md-none d-lg-inline" data-toggle="tooltip" data-placement="top" title="<%= @address.hash %>"><%= name %> (<%= @address.hash %>)</span>
<span class="d-md-inline-block d-lg-none" data-toggle="tooltip" data-placement="top" title="<%= @address.hash %>"><%= name %> (<%= BlockScoutWeb.AddressView.trimmed_hash(@address.hash) %>)</span>
<% end %>
<% else %> <% else %>
<%= if assigns[:truncate] do %> <%= if assigns[:truncate] do %>
<%= BlockScoutWeb.AddressView.trimmed_hash(@address.hash) %> <%= BlockScoutWeb.AddressView.trimmed_hash(@address.hash) %>

@ -14,6 +14,15 @@ defmodule BlockScoutWeb.AddressControllerTest do
|> Enum.map(fn {address, _transaction_count} -> address end) |> Enum.map(fn {address, _transaction_count} -> address end)
|> Enum.map(& &1.hash) == address_hashes |> Enum.map(& &1.hash) == address_hashes
end 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 end
describe "GET show/3" do describe "GET show/3" do

@ -913,6 +913,7 @@ defmodule Explorer.Chain do
from(a in Address, from(a in Address,
where: a.fetched_coin_balance > ^0, where: a.fetched_coin_balance > ^0,
order_by: [desc: a.fetched_coin_balance, asc: a.hash], order_by: [desc: a.fetched_coin_balance, asc: a.hash],
preload: [:names],
select: {a, fragment("coalesce(1 + ?, 0)", a.nonce)}, select: {a, fragment("coalesce(1 + ?, 0)", a.nonce)},
limit: 250 limit: 250
) )

Loading…
Cancel
Save