|
|
|
@ -11,68 +11,29 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do |
|
|
|
|
alias Explorer.ThirdPartyIntegrations.Sourcify |
|
|
|
|
|
|
|
|
|
def perform({"flattened", %{"address_hash" => address_hash} = params, external_libraries, conn}) do |
|
|
|
|
result = |
|
|
|
|
case Publisher.publish(address_hash, params, external_libraries) do |
|
|
|
|
{:ok, _contract} = result -> |
|
|
|
|
result |
|
|
|
|
|
|
|
|
|
{:error, changeset} -> |
|
|
|
|
{:error, changeset} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand) |
|
|
|
|
broadcast(:publish, address_hash, [address_hash, params, external_libraries], conn) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"multipart", %{"address_hash" => address_hash} = params, files_map, external_libraries, conn}) |
|
|
|
|
when is_map(files_map) do |
|
|
|
|
result = |
|
|
|
|
case Publisher.publish_with_multi_part_files(params, external_libraries, files_map) do |
|
|
|
|
{:ok, _contract} = result -> |
|
|
|
|
result |
|
|
|
|
|
|
|
|
|
{:error, changeset} -> |
|
|
|
|
{:error, changeset} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"json_api", %{"address_hash" => address_hash} = params, json_input, uid}) when is_binary(uid) do |
|
|
|
|
VerificationStatus.insert_status(uid, :pending, address_hash) |
|
|
|
|
|
|
|
|
|
case Publisher.publish_with_standard_json_input(params, json_input) do |
|
|
|
|
{:ok, _contract} -> |
|
|
|
|
VerificationStatus.update_status(uid, :pass) |
|
|
|
|
|
|
|
|
|
{:error, _changeset} -> |
|
|
|
|
VerificationStatus.update_status(uid, :fail) |
|
|
|
|
end |
|
|
|
|
broadcast(:publish_with_multi_part_files, address_hash, [params, external_libraries, files_map], conn) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"json_web", %{"address_hash" => address_hash} = params, json_input, conn}) do |
|
|
|
|
result = |
|
|
|
|
case Publisher.publish_with_standard_json_input(params, json_input) do |
|
|
|
|
{:ok, _contract} = result -> |
|
|
|
|
result |
|
|
|
|
|
|
|
|
|
{:error, changeset} -> |
|
|
|
|
{:error, changeset} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand) |
|
|
|
|
broadcast(:publish_with_standard_json_input, address_hash, [params, json_input], conn) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"flattened_api_v2", %{"address_hash" => address_hash} = params}) do |
|
|
|
|
result = |
|
|
|
|
case Publisher.publish(address_hash, params) do |
|
|
|
|
{:ok, _contract} = result -> |
|
|
|
|
result |
|
|
|
|
broadcast(:publish, address_hash, [address_hash, params]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
{:error, changeset} -> |
|
|
|
|
{:error, changeset} |
|
|
|
|
end |
|
|
|
|
def perform({"json_api_v2", %{"address_hash" => address_hash} = params, json_input}) do |
|
|
|
|
broadcast(:publish_with_standard_json_input, address_hash, [params, json_input]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result}}], :on_demand) |
|
|
|
|
def perform({"multipart_api_v2", %{"address_hash" => address_hash} = params, files_map}) |
|
|
|
|
when is_map(files_map) do |
|
|
|
|
broadcast(:publish_with_multi_part_files, address_hash, [params, files_map]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"sourcify_api_v2", address_hash_string, files_array, conn, chosen_contract}) do |
|
|
|
@ -85,23 +46,21 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"json_api_v2", %{"address_hash" => address_hash} = params, json_input}) do |
|
|
|
|
result = |
|
|
|
|
case Publisher.publish_with_standard_json_input(params, json_input) do |
|
|
|
|
{:ok, _contract} = result -> |
|
|
|
|
result |
|
|
|
|
def perform({"json_api", %{"address_hash" => address_hash} = params, json_input, uid}) when is_binary(uid) do |
|
|
|
|
VerificationStatus.insert_status(uid, :pending, address_hash) |
|
|
|
|
|
|
|
|
|
{:error, changeset} -> |
|
|
|
|
{:error, changeset} |
|
|
|
|
end |
|
|
|
|
case Publisher.publish_with_standard_json_input(params, json_input) do |
|
|
|
|
{:ok, _contract} -> |
|
|
|
|
VerificationStatus.update_status(uid, :pass) |
|
|
|
|
|
|
|
|
|
EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result}}], :on_demand) |
|
|
|
|
{:error, _changeset} -> |
|
|
|
|
VerificationStatus.update_status(uid, :fail) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def perform({"multipart_api_v2", %{"address_hash" => address_hash} = params, files_map}) |
|
|
|
|
when is_map(files_map) do |
|
|
|
|
defp broadcast(method, address_hash, args, conn \\ nil) do |
|
|
|
|
result = |
|
|
|
|
case Publisher.publish_with_multi_part_files(params, files_map) do |
|
|
|
|
case apply(Publisher, method, args) do |
|
|
|
|
{:ok, _contract} = result -> |
|
|
|
|
result |
|
|
|
|
|
|
|
|
@ -109,6 +68,10 @@ defmodule Explorer.SmartContract.Solidity.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 |
|
|
|
|