From b717c37c0ba110960a9343b50754333b720c58b6 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 17 Jul 2019 16:10:17 +0300 Subject: [PATCH] Fix failed contract verifications test --- apps/block_scout_web/lib/block_scout_web.ex | 1 + .../lib/block_scout_web/api_router.ex | 35 ++++++++++--------- .../lib/block_scout_web/router.ex | 5 ++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web.ex b/apps/block_scout_web/lib/block_scout_web.ex index 7cbe856f5f..20ca4351df 100644 --- a/apps/block_scout_web/lib/block_scout_web.ex +++ b/apps/block_scout_web/lib/block_scout_web.ex @@ -55,6 +55,7 @@ defmodule BlockScoutWeb do Views.ScriptHelpers, WeiHelpers } + import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2] import PhoenixFormAwesomplete diff --git a/apps/block_scout_web/lib/block_scout_web/api_router.ex b/apps/block_scout_web/lib/block_scout_web/api_router.ex index c40bd69e73..650188b6a2 100644 --- a/apps/block_scout_web/lib/block_scout_web/api_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/api_router.ex @@ -11,28 +11,31 @@ defmodule BlockScoutWeb.ApiRouter do plug(:accepts, ["json"]) end - scope "/v1", BlockScoutWeb.API.V1, as: :api_v1 do + scope "/v1", as: :api_v1 do pipe_through(:api) - get("/supply", SupplyController, :supply) + post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) - get("/health", HealthController, :health) + scope "/", BlockScoutWeb.API.V1 do + get("/supply", SupplyController, :supply) - post("/decompiled_smart_contract", DecompiledSmartContractController, :create) - post("/verified_smart_contracts", VerifiedSmartContractController, :create) - post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) + get("/health", HealthController, :health) - post("/eth_rpc", EthController, :eth_request) + post("/decompiled_smart_contract", DecompiledSmartContractController, :create) + post("/verified_smart_contracts", VerifiedSmartContractController, :create) - forward("/", RPCTranslator, %{ - "block" => RPC.BlockController, - "account" => RPC.AddressController, - "logs" => RPC.LogsController, - "token" => RPC.TokenController, - "stats" => RPC.StatsController, - "contract" => RPC.ContractController, - "transaction" => RPC.TransactionController - }) + post("/eth_rpc", EthController, :eth_request) + + forward("/", RPCTranslator, %{ + "block" => RPC.BlockController, + "account" => RPC.AddressController, + "logs" => RPC.LogsController, + "token" => RPC.TokenController, + "stats" => RPC.StatsController, + "contract" => RPC.ContractController, + "transaction" => RPC.TransactionController + }) + end end # Needs to be 200 to support the schema introspection for graphiql 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 e522ce842e..1354c57d56 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -14,7 +14,7 @@ defmodule BlockScoutWeb.Router do forward("/wobserver", Wobserver.Web.Router) forward("/admin", BlockScoutWeb.AdminRouter) - if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter, :enabled) do + if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:enabled] do forward("/api", BlockScoutWeb.ApiRouter) # For backward compatibility. Should be removed @@ -37,8 +37,7 @@ defmodule BlockScoutWeb.Router do ) end - if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter, :enabled) do + if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter)[:enabled] do forward("/", BlockScoutWeb.WebRouter) end - end