diff --git a/apps/block_scout_web/test/block_scout_web/chain_test.exs b/apps/block_scout_web/test/block_scout_web/chain_test.exs index 9ca92c59ab..3d1a7312f4 100644 --- a/apps/block_scout_web/test/block_scout_web/chain_test.exs +++ b/apps/block_scout_web/test/block_scout_web/chain_test.exs @@ -51,6 +51,13 @@ defmodule BlockScoutWeb.ChainTest do assert {:ok, %Address{}} = name |> Chain.from_param() end + test "finds a token by its name even if lowercase name was passed" do + name = "ayr" + insert(:token, symbol: String.upcase(name)) + + assert {:ok, %Address{}} = name |> Chain.from_param() + end + test "returns {:error, :not_found} when garbage is passed in" do assert {:error, :not_found} = Chain.from_param("any ol' thing") end diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 74aa6ce22b..eb3b99bcbb 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -640,7 +640,7 @@ defmodule Explorer.Chain do def token_contract_address_from_token_name(name) when is_binary(name) do query = from(token in Token, - where: token.symbol == ^name, + where: ilike(token.symbol, ^name), select: token.contract_address_hash )