diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index ed47963856..56f573f85f 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -11,7 +11,8 @@ defmodule BlockScoutWeb.Chain do number_to_block: 1, string_to_address_hash: 1, string_to_block_hash: 1, - string_to_transaction_hash: 1 + string_to_transaction_hash: 1, + token_contract_address_from_token_name: 1 ] alias Explorer.Chain.Block.Reward @@ -67,10 +68,10 @@ defmodule BlockScoutWeb.Chain do end end - def from_param(formatted_number) when is_binary(formatted_number) do - case param_to_block_number(formatted_number) do + def from_param(string) when is_binary(string) do + case param_to_block_number(string) do {:ok, number} -> number_to_block(number) - {:error, :invalid} -> {:error, :not_found} + _ -> token_address_from_name(string) end end @@ -159,6 +160,13 @@ defmodule BlockScoutWeb.Chain do end end + defp token_address_from_name(name) do + case token_contract_address_from_token_name(name) do + {:ok, hash} -> find_or_insert_address_from_hash(hash) + _ -> {:error, :not_found} + end + end + defp paging_params({%Reward{block: %{number: number}}, _}) do %{"block_number" => number, "index" => 0} end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 9b298f214b..1eaffa3834 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -80,7 +80,7 @@
<%= form_for @conn, chain_path(@conn, :search), [class: "form-inline my-2 my-lg-0", method: :get, enforce_utf8: false], fn f -> %>
- <%= search_input f, :q, class: 'form-control mr-auto', placeholder: gettext("Search by address, transaction hash, or block number"), "aria-describedby": "search-icon", "aria-label": gettext("Search"), "data-test": "search_input" %> + <%= search_input f, :q, class: 'form-control mr-auto', placeholder: gettext("Search by address, token symbol name, transaction hash, or block number"), "aria-describedby": "search-icon", "aria-label": gettext("Search"), "data-test": "search_input" %>