|
|
|
@ -18,42 +18,56 @@ defmodule BlockScoutWeb.ApiRouter do |
|
|
|
|
plug(:accepts, ["json"]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
|
scope "/v1", BlockScoutWeb.API.V1, as: :api_v1 do |
|
|
|
|
pipe_through(:api) |
|
|
|
|
get("/health", HealthController, :health) |
|
|
|
|
|
|
|
|
|
if Application.get_env(:block_scout_web, __MODULE__)[:writing_enabled] do |
|
|
|
|
post("/decompiled_smart_contract", DecompiledSmartContractController, :create) |
|
|
|
|
post("/verified_smart_contracts", VerifiedSmartContractController, :create) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if Application.get_env(:block_scout_web, __MODULE__)[:reading_enabled] do |
|
|
|
|
scope "/" do |
|
|
|
|
alias BlockScoutWeb.API.{RPC, V1} |
|
|
|
|
get("/supply", V1.SupplyController, :supply) |
|
|
|
|
pipe_through(:api) |
|
|
|
|
|
|
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
|
get("/supply", V1.SupplyController, :supply) |
|
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
forward("/", RPC.RPCTranslator, %{ |
|
|
|
|
"block" => RPC.BlockController, |
|
|
|
|
"account" => RPC.AddressController, |
|
|
|
|
"logs" => RPC.LogsController, |
|
|
|
|
"token" => RPC.TokenController, |
|
|
|
|
"stats" => RPC.StatsController, |
|
|
|
|
"contract" => RPC.ContractController, |
|
|
|
|
"transaction" => RPC.TransactionController |
|
|
|
|
}) |
|
|
|
|
# For backward compatibility. Should be removed |
|
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# For backward compatibility. Should be removed |
|
|
|
|
scope "/" do |
|
|
|
|
alias BlockScoutWeb.API.RPC |
|
|
|
|
pipe_through(:api) |
|
|
|
|
alias BlockScoutWeb.API.RPC |
|
|
|
|
|
|
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
|
forward("/", RPC.RPCTranslator, %{ |
|
|
|
|
"block" => {RPC.BlockController, []}, |
|
|
|
|
"account" => {RPC.AddressController, []}, |
|
|
|
|
"logs" => {RPC.LogsController, []}, |
|
|
|
|
"token" => {RPC.TokenController, []}, |
|
|
|
|
"stats" => {RPC.StatsController, []}, |
|
|
|
|
"contract" => {RPC.ContractController, [:verify]}, |
|
|
|
|
"transaction" => {RPC.TransactionController, []} |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# For backward compatibility. Should be removed |
|
|
|
|
forward("/", RPCTranslatorForwarder, %{ |
|
|
|
|
"block" => RPC.BlockController, |
|
|
|
|
"account" => RPC.AddressController, |
|
|
|
|
"logs" => RPC.LogsController, |
|
|
|
|
"token" => RPC.TokenController, |
|
|
|
|
"stats" => RPC.StatsController, |
|
|
|
|
"contract" => RPC.ContractController, |
|
|
|
|
"transaction" => RPC.TransactionController |
|
|
|
|
"block" => {RPC.BlockController, []}, |
|
|
|
|
"account" => {RPC.AddressController, []}, |
|
|
|
|
"logs" => {RPC.LogsController, []}, |
|
|
|
|
"token" => {RPC.TokenController, []}, |
|
|
|
|
"stats" => {RPC.StatsController, []}, |
|
|
|
|
"contract" => {RPC.ContractController, [:verify]}, |
|
|
|
|
"transaction" => {RPC.TransactionController, []} |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|