From 2f91e8c3804c43d0d4daf0152ac55bca28e52e81 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 8 Jul 2019 12:36:59 +0300 Subject: [PATCH] add new endpoing for contract verification --- .../address_contract_verification_controller.ex | 3 +-- .../block_scout_web/lib/block_scout_web/router.ex | 15 +++++++++++++-- .../address_contract_verification/new.html.eex | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex index ee8ef7b635..e4aa87eae4 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex @@ -24,12 +24,11 @@ defmodule BlockScoutWeb.AddressContractVerificationController do def create( conn, %{ - "address_id" => address_hash_string, "smart_contract" => smart_contract, "external_libraries" => external_libraries } ) 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, "") end diff --git a/apps/block_scout_web/lib/block_scout_web/router.ex b/apps/block_scout_web/lib/block_scout_web/router.ex index e01d121eb8..4b5471cb52 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -18,6 +18,13 @@ defmodule BlockScoutWeb.Router do plug(:accepts, ["json"]) 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 pipe_through(:api) @@ -29,6 +36,12 @@ defmodule BlockScoutWeb.Router do resources("/verified_smart_contracts", VerifiedSmartContractController, only: [:create]) end + scope "/verify_smart_contract" do + pipe_through(:contract_verification) + + post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) + end + scope "/api", BlockScoutWeb.API.RPC do pipe_through(:api) @@ -165,8 +178,6 @@ defmodule BlockScoutWeb.Router do as: :verify_contract ) - get("/contract_verifications", AddressContractVerificationController, :create) - resources( "/read_contract", AddressReadContractController, diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex index 80356dc0ea..6d56ecb51f 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex @@ -9,8 +9,8 @@

<%= gettext "New Smart Contract Verification" %>

<%= form_for @changeset, - "/address/#{@address_hash}/contract_verifications", - [method: :get], + "/verify_smart_contract/contract_verifications", + [], fn f -> %>