Refactor Vyper.PublisherWorker

pull/6744/head
Nikita Pozdniakov 2 years ago
parent 14d7e96803
commit 7f21f87f97
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 34
      apps/explorer/lib/explorer/smart_contract/vyper/publisher_worker.ex
  2. 18
      apps/explorer/lib/explorer/smart_contract/vyper/verifier.ex

@ -9,34 +9,20 @@ defmodule Explorer.SmartContract.Vyper.PublisherWorker do
alias Explorer.SmartContract.Vyper.Publisher
def perform({address_hash, params, %Plug.Conn{} = conn}) do
result =
case Publisher.publish(address_hash, params) do
{:ok, _contract} = result ->
result
{:error, changeset} ->
{:error, changeset}
end
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand)
broadcast(address_hash, [address_hash, params], conn)
end
def perform({address_hash, params, files}) do
result =
case Publisher.publish(address_hash, params, files) do
{:ok, _contract} = result ->
result
{:error, changeset} ->
{:error, changeset}
end
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result}}], :on_demand)
broadcast(address_hash, [address_hash, params, files])
end
def perform({address_hash, params}) do
broadcast(address_hash, [address_hash, params])
end
defp broadcast(address_hash, args, conn \\ nil) do
result =
case Publisher.publish(address_hash, params) do
case apply(Publisher, :publish, args) do
{:ok, _contract} = result ->
result
@ -44,6 +30,10 @@ defmodule Explorer.SmartContract.Vyper.PublisherWorker do
{:error, changeset}
end
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result}}], :on_demand)
if conn do
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand)
else
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result}}], :on_demand)
end
end
end

@ -76,15 +76,6 @@ defmodule Explorer.SmartContract.Vyper.Verifier do
})
end
defp vyper_verify_multipart(params, creation_tx_input, deployed_bytecode, evm_version, files) do
params
|> Map.put("creation_bytecode", creation_tx_input)
|> Map.put("deployed_bytecode", deployed_bytecode)
|> Map.put("evm_version", evm_version || "istanbul")
|> Map.put("sources", files)
|> RustVerifierInterface.vyper_verify_multipart()
end
defp evaluate_authenticity_inner(false, address_hash, params) do
verify(address_hash, params)
end
@ -131,4 +122,13 @@ defmodule Explorer.SmartContract.Vyper.Verifier do
{:error, :generated_bytecode}
end
end
defp vyper_verify_multipart(params, creation_tx_input, deployed_bytecode, evm_version, files) do
params
|> Map.put("creation_bytecode", creation_tx_input)
|> Map.put("deployed_bytecode", deployed_bytecode)
|> Map.put("evm_version", evm_version || "istanbul")
|> Map.put("sources", files)
|> RustVerifierInterface.vyper_verify_multipart()
end
end

Loading…
Cancel
Save