From 98722a92528618de82dde9d401d6177fb84693ad Mon Sep 17 00:00:00 2001 From: nikitosing Date: Sat, 12 Mar 2022 20:16:04 +0300 Subject: [PATCH 1/4] Add name for the proxy implementation on address page --- .../controllers/smart_contract_controller.ex | 6 ++++-- .../templates/address/overview.html.eex | 4 ++-- apps/explorer/lib/explorer/chain.ex | 12 ++++++------ apps/explorer/lib/explorer/etherscan/contracts.ex | 5 ++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex index 621dd661cd..c90d431436 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex @@ -18,8 +18,10 @@ defmodule BlockScoutWeb.SmartContractController do {:ok, address} <- Chain.find_contract_address(address_hash, address_options, true) do implementation_address_hash_string = if contract_type == "proxy" do - Chain.get_implementation_address_hash(address.hash, address.smart_contract.abi) || - @burn_address + (address.hash + |> Chain.get_implementation_address_hash(address.smart_contract.abi) + |> Tuple.to_list() + |> List.first()) || @burn_address else @burn_address end 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 1b32353575..d0a8b3a751 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 @@ -141,7 +141,7 @@ <% end %> <%= if @is_proxy do %> - <% implementation_address = Chain.get_implementation_address_hash(@address.hash, @address.smart_contract.abi) || "0x0000000000000000000000000000000000000000" %> + <% {implementation_address, name} = Chain.get_implementation_address_hash(@address.hash, @address.smart_contract.abi) || "0x0000000000000000000000000000000000000000" %>
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", @@ -150,7 +150,7 @@
<%= link( - implementation_address, + (if name, do: name <> " | " <> implementation_address, else: implementation_address), to: address_path(@conn, :show, implementation_address), class: "contract-address" ) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 3f25f63e99..4d33844f9f 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -6667,7 +6667,7 @@ defmodule Explorer.Chain do def gnosis_safe_contract?(abi) when is_nil(abi), do: false - @spec get_implementation_address_hash(Hash.Address.t(), list()) :: String.t() | nil + @spec get_implementation_address_hash(Hash.Address.t(), list()) :: {String.t() | nil, String.t() | nil} def get_implementation_address_hash(proxy_address_hash, abi) when not is_nil(proxy_address_hash) and not is_nil(abi) do implementation_method_abi = @@ -6698,7 +6698,7 @@ defmodule Explorer.Chain do end def get_implementation_address_hash(proxy_address_hash, abi) when is_nil(proxy_address_hash) or is_nil(abi) do - nil + {nil, nil} end defp get_implementation_address_hash_eip_1967(proxy_address_hash) do @@ -6855,7 +6855,7 @@ defmodule Explorer.Chain do "0x0000000000000000000000000000000000000000000000000000000000000000", @burn_address_hash_str ], - do: empty_address_hash_string + do: {empty_address_hash_string, nil} defp save_implementation_name(implementation_address_hash_string, proxy_address_hash) when is_binary(implementation_address_hash_string) do @@ -6866,10 +6866,10 @@ defmodule Explorer.Chain do |> update(set: [implementation_name: ^name]) |> Repo.update_all([]) - implementation_address_hash_string + {implementation_address_hash_string, name} else _ -> - implementation_address_hash_string + {implementation_address_hash_string, nil} end end @@ -6924,7 +6924,7 @@ defmodule Explorer.Chain do def get_implementation_abi_from_proxy(proxy_address_hash, abi) when not is_nil(proxy_address_hash) and not is_nil(abi) do - implementation_address_hash_string = get_implementation_address_hash(proxy_address_hash, abi) + {implementation_address_hash_string, _name} = get_implementation_address_hash(proxy_address_hash, abi) get_implementation_abi(implementation_address_hash_string) end diff --git a/apps/explorer/lib/explorer/etherscan/contracts.ex b/apps/explorer/lib/explorer/etherscan/contracts.ex index d224294e03..37e8ef7a34 100644 --- a/apps/explorer/lib/explorer/etherscan/contracts.ex +++ b/apps/explorer/lib/explorer/etherscan/contracts.ex @@ -64,7 +64,10 @@ defmodule Explorer.Etherscan.Contracts do |> Map.put(:is_proxy, true) |> Map.put( :implementation_address_hash_string, - Chain.get_implementation_address_hash(address.hash, smart_contract.abi) + address.hash + |> Chain.get_implementation_address_hash(smart_contract.abi) + |> Tuple.to_list() + |> List.first() ) else smart_contract From 16788aad5326c74039b298ec4c8c55a3e4db744f Mon Sep 17 00:00:00 2001 From: nikitosing Date: Sat, 12 Mar 2022 21:15:50 +0300 Subject: [PATCH 2/4] Add contract's name to logs (transaction page) --- CHANGELOG.md | 2 +- .../controllers/smart_contract_controller.ex | 4 ++-- .../controllers/transaction_log_controller.ex | 2 ++ .../templates/transaction_log/_logs.html.eex | 3 ++- .../block_scout_web/views/transaction_log_view.ex | 1 + apps/block_scout_web/priv/gettext/default.pot | 12 ++++++------ .../priv/gettext/en/LC_MESSAGES/default.po | 12 ++++++------ apps/explorer/lib/explorer/chain.ex | 2 +- 8 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47e5dd340e..0b336fd449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Features - [#5312](https://github.com/blockscout/blockscout/pull/5312) - Add OpenZeppelin proxy storage slot - [#5302](https://github.com/blockscout/blockscout/pull/5302) - Add specific tx receipt fields for the GoQuorum client -- [#5268](https://github.com/blockscout/blockscout/pull/5268) - Contract names display improvement +- [#5268](https://github.com/blockscout/blockscout/pull/5268), [#5313](https://github.com/blockscout/blockscout/pull/5313) - Contract names display improvement ### Fixes - [#5455](https://github.com/blockscout/blockscout/pull/5455) - Fix unverified_smart_contract function: add md5 of bytecode to the changeset diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex index c90d431436..59121293f1 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex @@ -18,10 +18,10 @@ defmodule BlockScoutWeb.SmartContractController do {:ok, address} <- Chain.find_contract_address(address_hash, address_options, true) do implementation_address_hash_string = if contract_type == "proxy" do - (address.hash + address.hash |> Chain.get_implementation_address_hash(address.smart_contract.abi) |> Tuple.to_list() - |> List.first()) || @burn_address + |> List.first() || @burn_address else @burn_address end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex index a5ba2959d1..f9abbf207b 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex @@ -20,6 +20,8 @@ defmodule BlockScoutWeb.TransactionLogController do Keyword.merge( [ necessity_by_association: %{ + [address: :names] => :optional, + [address: :smart_contract] => :optional, address: :optional } ], diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex index 1813358d34..2b1b4e0d35 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex @@ -20,8 +20,9 @@
<%= gettext "Address" %>

+ <% name = implementation_name(@log.address) || primary_name(@log.address)%> <%= link( - @log.address, + (if name, do: name <> " | "<> to_string(@log.address), else: @log.address), to: address_path(@conn, :show, @log.address), "data-test": "log_address_link", "data-address-hash": @log.address diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex index 50d406433c..e494bbd889 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex @@ -3,6 +3,7 @@ defmodule BlockScoutWeb.TransactionLogView do @dialyzer :no_match alias Explorer.Chain.Log + import BlockScoutWeb.AddressView, only: [implementation_name: 1, primary_name: 1] def decode(log, transaction) do Log.decode(log, transaction) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 900b502a09..321a607d85 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -881,7 +881,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:101 #: lib/block_scout_web/templates/log/_data_decoded_view.html.eex:7 lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:120 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121 msgid "Data" msgstr "" @@ -904,8 +904,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:32 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:38 lib/block_scout_web/templates/address_logs/_logs.html.eex:53 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:33 lib/block_scout_web/templates/transaction_log/_logs.html.eex:41 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:56 lib/block_scout_web/templates/transaction_log/_logs.html.eex:72 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:34 lib/block_scout_web/templates/transaction_log/_logs.html.eex:42 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:57 lib/block_scout_web/templates/transaction_log/_logs.html.eex:73 msgid "Decoded" msgstr "" @@ -1154,7 +1154,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:35 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:36 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:37 msgid "Failed to decode log data." msgstr "" @@ -1485,7 +1485,7 @@ msgid "Log Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:130 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:131 msgid "Log Index" msgstr "" @@ -2685,7 +2685,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:71 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:90 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:91 msgid "Topics" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 900b502a09..321a607d85 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -881,7 +881,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:101 #: lib/block_scout_web/templates/log/_data_decoded_view.html.eex:7 lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:120 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121 msgid "Data" msgstr "" @@ -904,8 +904,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:32 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:38 lib/block_scout_web/templates/address_logs/_logs.html.eex:53 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:33 lib/block_scout_web/templates/transaction_log/_logs.html.eex:41 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:56 lib/block_scout_web/templates/transaction_log/_logs.html.eex:72 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:34 lib/block_scout_web/templates/transaction_log/_logs.html.eex:42 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:57 lib/block_scout_web/templates/transaction_log/_logs.html.eex:73 msgid "Decoded" msgstr "" @@ -1154,7 +1154,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:35 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:36 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:37 msgid "Failed to decode log data." msgstr "" @@ -1485,7 +1485,7 @@ msgid "Log Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:130 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:131 msgid "Log Index" msgstr "" @@ -2685,7 +2685,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:71 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:90 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:91 msgid "Topics" msgstr "" diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 4d33844f9f..559ae11099 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -6873,7 +6873,7 @@ defmodule Explorer.Chain do end end - defp save_implementation_name(other, _), do: other + defp save_implementation_name(other, _), do: {other, nil} defp abi_decode_address_output(nil), do: nil From a3fce6766532c2ef2d361f847bb160bc856ceed2 Mon Sep 17 00:00:00 2001 From: nikitosing Date: Thu, 17 Mar 2022 21:23:08 +0300 Subject: [PATCH 3/4] Ignore implementation name on an internal transaction tile --- .../lib/block_scout_web/templates/address/_link.html.eex | 2 +- .../templates/address/_responsive_hash.html.eex | 2 +- .../templates/internal_transaction/_tile.html.eex | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex index 8a7c412365..e1272aee76 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex @@ -1,6 +1,6 @@ <%= if @address do %> <%= if assigns[:show_full_hash] do %> - <%= if name = implementation_name(@address) || primary_name(@address) do %> + <%= if name = if assigns[:ignore_implementation_name], do: implementation_name(@address) || primary_name(@address), else: primary_name(@address) do %> <%= name %> | <% end %> <%= link to: address_path(BlockScoutWeb.Endpoint, :show, @address), "data-test": "address_hash_link", class: assigns[:class] do %> 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 85aa6dfc85..168e68da36 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,5 +1,5 @@ - <%= if name = implementation_name(@address) || primary_name(@address) do %> + <%= if name = if assigns[:ignore_implementation_name], do: implementation_name(@address) || primary_name(@address), else: primary_name(@address) do %> <%= if assigns[:no_tooltip] do %> <%= if @use_custom_tooltip == true do %> <%= name %> (<%= short_hash(@address) %>...) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex index 63fbe96bcb..73b08b37a3 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex @@ -15,9 +15,9 @@
<%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @internal_transaction.transaction_hash %> - <%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> + <%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> Keyword.put(:ignore_implementation_name, true) |> BlockScoutWeb.RenderHelpers.render_partial() %> → - <%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> + <%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> Keyword.put(:ignore_implementation_name, true) |> BlockScoutWeb.RenderHelpers.render_partial() %> From 7b0cd50e04847c4dad6263efa0640be442cbd39f Mon Sep 17 00:00:00 2001 From: nikitosing Date: Fri, 22 Apr 2022 21:22:17 +0300 Subject: [PATCH 4/4] Fix displaying own names on internal tx tiles --- .../templates/address/_link.html.eex | 4 +-- .../address/_responsive_hash.html.eex | 2 +- .../lib/block_scout_web/views/address_view.ex | 14 +++++++--- apps/block_scout_web/priv/gettext/default.pot | 26 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 26 +++++++++---------- 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex index e1272aee76..275a8f058d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_link.html.eex @@ -1,6 +1,6 @@ <%= if @address do %> <%= if assigns[:show_full_hash] do %> - <%= if name = if assigns[:ignore_implementation_name], do: implementation_name(@address) || primary_name(@address), else: primary_name(@address) do %> + <%= if name = if assigns[:ignore_implementation_name], do: primary_name(@address), else: implementation_name(@address) || primary_name(@address) do %> <%= name %> | <% end %> <%= link to: address_path(BlockScoutWeb.Endpoint, :show, @address), "data-test": "address_hash_link", class: assigns[:class] do %> @@ -9,7 +9,7 @@ <% else %> <%= link to: address_path(BlockScoutWeb.Endpoint, :show, @address), "data-test": "address_hash_link", class: assigns[:class] do %> - <%= render BlockScoutWeb.AddressView, "_responsive_hash.html", address: @address, contract: @contract, truncate: assigns[:truncate], use_custom_tooltip: @use_custom_tooltip, no_tooltip: assigns[:no_tooltip], custom_classes_tooltip: assigns[:custom_classes_tooltip] %> + <%= render BlockScoutWeb.AddressView, "_responsive_hash.html", address: @address, contract: @contract, truncate: assigns[:truncate], use_custom_tooltip: @use_custom_tooltip, no_tooltip: assigns[:no_tooltip], custom_classes_tooltip: assigns[:custom_classes_tooltip], ignore_implementation_name: assigns[:ignore_implementation_name] %> <% end %> <% end %> <% end %> 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 168e68da36..06b0954cb0 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,5 +1,5 @@ - <%= if name = if assigns[:ignore_implementation_name], do: implementation_name(@address) || primary_name(@address), else: primary_name(@address) do %> + <%= if name = if assigns[:ignore_implementation_name], do: primary_name(@address), else: implementation_name(@address) || primary_name(@address) do %> <%= if assigns[:no_tooltip] do %> <%= if @use_custom_tooltip == true do %> <%= name %> (<%= short_hash(@address) %>...) diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex index d915238c48..6c49191dae 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex @@ -4,7 +4,7 @@ defmodule BlockScoutWeb.AddressView do require Logger alias BlockScoutWeb.{AccessHelpers, LayoutView} - alias Explorer.{Chain, CustomContractsHelpers} + alias Explorer.{Chain, CustomContractsHelpers, Repo} alias Explorer.Chain.{Address, Hash, InternalTransaction, SmartContract, Token, TokenTransfer, Transaction, Wei} alias Explorer.Chain.Block.Reward alias Explorer.ExchangeRates.Token, as: TokenExchangeRate @@ -176,9 +176,11 @@ defmodule BlockScoutWeb.AddressView do end @doc """ - Returns the primary name of an address if available. + Returns the primary name of an address if available. If there is no names on address function performs preload of names association. """ - def primary_name(%Address{names: [_ | _] = address_names}) do + def primary_name(_, second_time? \\ false) + + def primary_name(%Address{names: [_ | _] = address_names}, _second_time?) do case Enum.find(address_names, &(&1.primary == true)) do nil -> %Address.Name{name: name} = Enum.at(address_names, 0) @@ -189,7 +191,11 @@ defmodule BlockScoutWeb.AddressView do end end - def primary_name(%Address{names: _}), do: nil + def primary_name(%Address{names: _} = address, false) do + primary_name(Repo.preload(address, [:names]), true) + end + + def primary_name(%Address{names: _}, true), do: nil def implementation_name(%Address{smart_contract: %{implementation_name: implementation_name}}), do: implementation_name diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 321a607d85..fe7b187da3 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -430,7 +430,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:48 #: lib/block_scout_web/templates/address/overview.html.eex:290 lib/block_scout_web/templates/address_validation/index.html.eex:11 -#: lib/block_scout_web/views/address_view.ex:365 +#: lib/block_scout_web/views/address_view.ex:371 msgid "Blocks Validated" msgstr "" @@ -569,13 +569,13 @@ msgstr "" #: lib/block_scout_web/templates/address/_tabs.html.eex:58 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165 lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:126 lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:149 -#: lib/block_scout_web/views/address_view.ex:358 +#: lib/block_scout_web/views/address_view.ex:364 msgid "Code" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:34 -#: lib/block_scout_web/views/address_view.ex:364 +#: lib/block_scout_web/views/address_view.ex:370 msgid "Coin Balance History" msgstr "" @@ -910,7 +910,7 @@ msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/views/address_view.ex:359 +#: lib/block_scout_web/views/address_view.ex:365 msgid "Decompiled Code" msgstr "" @@ -1377,7 +1377,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:28 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:17 lib/block_scout_web/templates/transaction/_tabs.html.eex:11 -#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 lib/block_scout_web/views/address_view.ex:355 +#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 lib/block_scout_web/views/address_view.ex:361 #: lib/block_scout_web/views/transaction_view.ex:512 msgid "Internal Transactions" msgstr "" @@ -1492,7 +1492,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:41 #: lib/block_scout_web/templates/address_logs/index.html.eex:10 lib/block_scout_web/templates/transaction/_tabs.html.eex:17 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 lib/block_scout_web/views/address_view.ex:366 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 lib/block_scout_web/views/address_view.ex:372 #: lib/block_scout_web/views/transaction_view.ex:513 msgid "Logs" msgstr "" @@ -1933,14 +1933,14 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:81 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:27 lib/block_scout_web/views/address_view.ex:360 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:27 lib/block_scout_web/views/address_view.ex:366 #: lib/block_scout_web/views/tokens/overview_view.ex:43 msgid "Read Contract" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:88 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:41 lib/block_scout_web/views/address_view.ex:361 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:41 lib/block_scout_web/views/address_view.ex:367 msgid "Read Proxy" msgstr "" @@ -2628,7 +2628,7 @@ msgstr "" #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16 lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:5 #: lib/block_scout_web/templates/tokens/transfer/index.html.eex:14 lib/block_scout_web/templates/transaction/_tabs.html.eex:4 -#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 lib/block_scout_web/views/address_view.ex:357 +#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 lib/block_scout_web/views/address_view.ex:363 #: lib/block_scout_web/views/tokens/instance/overview_view.ex:195 lib/block_scout_web/views/tokens/overview_view.ex:41 #: lib/block_scout_web/views/transaction_view.ex:511 msgid "Token Transfers" @@ -2649,7 +2649,7 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:191 lib/block_scout_web/templates/address_token/overview.html.eex:58 #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:13 lib/block_scout_web/templates/layout/_topnav.html.eex:69 #: lib/block_scout_web/templates/layout/_topnav.html.eex:101 lib/block_scout_web/templates/tokens/index.html.eex:10 -#: lib/block_scout_web/views/address_view.ex:354 +#: lib/block_scout_web/views/address_view.ex:360 msgid "Tokens" msgstr "" @@ -2797,7 +2797,7 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:216 lib/block_scout_web/templates/address_transaction/index.html.eex:13 #: lib/block_scout_web/templates/block/overview.html.eex:80 lib/block_scout_web/templates/block_transaction/index.html.eex:10 #: lib/block_scout_web/templates/chain/show.html.eex:236 lib/block_scout_web/templates/layout/_topnav.html.eex:43 -#: lib/block_scout_web/views/address_view.ex:356 +#: lib/block_scout_web/views/address_view.ex:362 msgid "Transactions" msgstr "" @@ -3139,13 +3139,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:95 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:34 lib/block_scout_web/views/address_view.ex:362 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:34 lib/block_scout_web/views/address_view.ex:368 msgid "Write Contract" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:102 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:48 lib/block_scout_web/views/address_view.ex:363 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:48 lib/block_scout_web/views/address_view.ex:369 msgid "Write Proxy" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 321a607d85..fe7b187da3 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -430,7 +430,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:48 #: lib/block_scout_web/templates/address/overview.html.eex:290 lib/block_scout_web/templates/address_validation/index.html.eex:11 -#: lib/block_scout_web/views/address_view.ex:365 +#: lib/block_scout_web/views/address_view.ex:371 msgid "Blocks Validated" msgstr "" @@ -569,13 +569,13 @@ msgstr "" #: lib/block_scout_web/templates/address/_tabs.html.eex:58 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165 lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:126 lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:149 -#: lib/block_scout_web/views/address_view.ex:358 +#: lib/block_scout_web/views/address_view.ex:364 msgid "Code" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:34 -#: lib/block_scout_web/views/address_view.ex:364 +#: lib/block_scout_web/views/address_view.ex:370 msgid "Coin Balance History" msgstr "" @@ -910,7 +910,7 @@ msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/views/address_view.ex:359 +#: lib/block_scout_web/views/address_view.ex:365 msgid "Decompiled Code" msgstr "" @@ -1377,7 +1377,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:28 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:17 lib/block_scout_web/templates/transaction/_tabs.html.eex:11 -#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 lib/block_scout_web/views/address_view.ex:355 +#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 lib/block_scout_web/views/address_view.ex:361 #: lib/block_scout_web/views/transaction_view.ex:512 msgid "Internal Transactions" msgstr "" @@ -1492,7 +1492,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:41 #: lib/block_scout_web/templates/address_logs/index.html.eex:10 lib/block_scout_web/templates/transaction/_tabs.html.eex:17 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 lib/block_scout_web/views/address_view.ex:366 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 lib/block_scout_web/views/address_view.ex:372 #: lib/block_scout_web/views/transaction_view.ex:513 msgid "Logs" msgstr "" @@ -1933,14 +1933,14 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:81 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:27 lib/block_scout_web/views/address_view.ex:360 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:27 lib/block_scout_web/views/address_view.ex:366 #: lib/block_scout_web/views/tokens/overview_view.ex:43 msgid "Read Contract" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:88 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:41 lib/block_scout_web/views/address_view.ex:361 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:41 lib/block_scout_web/views/address_view.ex:367 msgid "Read Proxy" msgstr "" @@ -2628,7 +2628,7 @@ msgstr "" #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16 lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:5 #: lib/block_scout_web/templates/tokens/transfer/index.html.eex:14 lib/block_scout_web/templates/transaction/_tabs.html.eex:4 -#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 lib/block_scout_web/views/address_view.ex:357 +#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 lib/block_scout_web/views/address_view.ex:363 #: lib/block_scout_web/views/tokens/instance/overview_view.ex:195 lib/block_scout_web/views/tokens/overview_view.ex:41 #: lib/block_scout_web/views/transaction_view.ex:511 msgid "Token Transfers" @@ -2649,7 +2649,7 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:191 lib/block_scout_web/templates/address_token/overview.html.eex:58 #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:13 lib/block_scout_web/templates/layout/_topnav.html.eex:69 #: lib/block_scout_web/templates/layout/_topnav.html.eex:101 lib/block_scout_web/templates/tokens/index.html.eex:10 -#: lib/block_scout_web/views/address_view.ex:354 +#: lib/block_scout_web/views/address_view.ex:360 msgid "Tokens" msgstr "" @@ -2797,7 +2797,7 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:216 lib/block_scout_web/templates/address_transaction/index.html.eex:13 #: lib/block_scout_web/templates/block/overview.html.eex:80 lib/block_scout_web/templates/block_transaction/index.html.eex:10 #: lib/block_scout_web/templates/chain/show.html.eex:236 lib/block_scout_web/templates/layout/_topnav.html.eex:43 -#: lib/block_scout_web/views/address_view.ex:356 +#: lib/block_scout_web/views/address_view.ex:362 msgid "Transactions" msgstr "" @@ -3139,13 +3139,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:95 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:34 lib/block_scout_web/views/address_view.ex:362 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:34 lib/block_scout_web/views/address_view.ex:368 msgid "Write Contract" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:102 -#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:48 lib/block_scout_web/views/address_view.ex:363 +#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:48 lib/block_scout_web/views/address_view.ex:369 msgid "Write Proxy" msgstr ""