diff --git a/apps/explorer/lib/explorer/chain/smart_contract.ex b/apps/explorer/lib/explorer/chain/smart_contract.ex index 3773ed9464..edf9dda544 100644 --- a/apps/explorer/lib/explorer/chain/smart_contract.ex +++ b/apps/explorer/lib/explorer/chain/smart_contract.ex @@ -1082,6 +1082,17 @@ defmodule Explorer.Chain.SmartContract do [] end + @doc """ + Gets smart-contract by address hash + """ + @spec get_smart_contract_query(Hash.Address.t() | binary) :: Ecto.Query.t() + def get_smart_contract_query(address_hash) do + from( + smart_contract in __MODULE__, + where: smart_contract.address_hash == ^address_hash + ) + end + defp upsert_contract_methods(%Changeset{changes: %{abi: abi}} = changeset) do ContractMethod.upsert_from_abi(abi, get_field(changeset, :address_hash)) @@ -1226,13 +1237,6 @@ defmodule Explorer.Chain.SmartContract do end end - defp get_smart_contract_query(address_hash) do - from( - smart_contract in __MODULE__, - where: smart_contract.address_hash == ^address_hash - ) - end - defp check_verified_with_full_match(address_hash, options) do smart_contract = address_hash_to_smart_contract_without_twin(address_hash, options) diff --git a/apps/explorer/lib/explorer/chain/smart_contract/proxy/eip_1167.ex b/apps/explorer/lib/explorer/chain/smart_contract/proxy/eip_1167.ex index 9bf1bd70e4..5095c6b17c 100644 --- a/apps/explorer/lib/explorer/chain/smart_contract/proxy/eip_1167.ex +++ b/apps/explorer/lib/explorer/chain/smart_contract/proxy/eip_1167.ex @@ -7,8 +7,6 @@ defmodule Explorer.Chain.SmartContract.Proxy.EIP1167 do alias Explorer.Chain.{Address, Hash, SmartContract} alias Explorer.Chain.SmartContract.Proxy - import Ecto.Query, only: [from: 2] - @doc """ Get implementation address following EIP-1167 """ @@ -56,13 +54,8 @@ defmodule Explorer.Chain.SmartContract.Proxy.EIP1167 do defp implementation_to_smart_contract(nil, _options), do: nil defp implementation_to_smart_contract(address_hash, options) do - query = - from( - smart_contract in SmartContract, - where: smart_contract.address_hash == ^address_hash - ) - - query + address_hash + |> SmartContract.get_smart_contract_query() |> Chain.select_repo(options).one(timeout: 10_000) end end