use get_smart_contract_query

mf-8807-example
Viktor Baranov 1 year ago
parent f8782d04ce
commit cb181284e3
  1. 18
      apps/explorer/lib/explorer/chain/smart_contract.ex
  2. 11
      apps/explorer/lib/explorer/chain/smart_contract/proxy/eip_1167.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)

@ -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

Loading…
Cancel
Save