add new endpoing for contract verification

pull/2264/head
Ayrat Badykov 5 years ago
parent 55a5c651d5
commit 2f91e8c380
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 3
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex
  2. 15
      apps/block_scout_web/lib/block_scout_web/router.ex
  3. 4
      apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex

@ -24,12 +24,11 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
def create( def create(
conn, conn,
%{ %{
"address_id" => address_hash_string,
"smart_contract" => smart_contract, "smart_contract" => smart_contract,
"external_libraries" => external_libraries "external_libraries" => external_libraries
} }
) do ) do
Que.add(PublisherWorker, {address_hash_string, smart_contract, external_libraries}) Que.add(PublisherWorker, {smart_contract["address_hash"], smart_contract, external_libraries})
send_resp(conn, 204, "") send_resp(conn, 204, "")
end end

@ -18,6 +18,13 @@ defmodule BlockScoutWeb.Router do
plug(:accepts, ["json"]) plug(:accepts, ["json"])
end end
pipeline :contract_verification do
plug(:accepts, ["html"])
plug(:fetch_session)
plug(:fetch_flash)
plug(BlockScoutWeb.CSPHeader)
end
scope "/api/v1", BlockScoutWeb.API.V1, as: :api_v1 do scope "/api/v1", BlockScoutWeb.API.V1, as: :api_v1 do
pipe_through(:api) pipe_through(:api)
@ -29,6 +36,12 @@ defmodule BlockScoutWeb.Router do
resources("/verified_smart_contracts", VerifiedSmartContractController, only: [:create]) resources("/verified_smart_contracts", VerifiedSmartContractController, only: [:create])
end end
scope "/verify_smart_contract" do
pipe_through(:contract_verification)
post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create)
end
scope "/api", BlockScoutWeb.API.RPC do scope "/api", BlockScoutWeb.API.RPC do
pipe_through(:api) pipe_through(:api)
@ -165,8 +178,6 @@ defmodule BlockScoutWeb.Router do
as: :verify_contract as: :verify_contract
) )
get("/contract_verifications", AddressContractVerificationController, :create)
resources( resources(
"/read_contract", "/read_contract",
AddressReadContractController, AddressReadContractController,

@ -9,8 +9,8 @@
<h1 class="smart-contract-title"><%= gettext "New Smart Contract Verification" %></h1> <h1 class="smart-contract-title"><%= gettext "New Smart Contract Verification" %></h1>
<%= form_for @changeset, <%= form_for @changeset,
"/address/#{@address_hash}/contract_verifications", "/verify_smart_contract/contract_verifications",
[method: :get], [],
fn f -> %> fn f -> %>
<div class="smart-contract-form-group"> <div class="smart-contract-form-group">

Loading…
Cancel
Save