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