|
|
@ -18,42 +18,56 @@ defmodule BlockScoutWeb.ApiRouter do |
|
|
|
plug(:accepts, ["json"]) |
|
|
|
plug(:accepts, ["json"]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
scope "/v1", BlockScoutWeb.API.V1, as: :api_v1 do |
|
|
|
pipe_through(:api) |
|
|
|
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 |
|
|
|
scope "/" do |
|
|
|
alias BlockScoutWeb.API.{RPC, V1} |
|
|
|
alias BlockScoutWeb.API.{RPC, V1} |
|
|
|
get("/supply", V1.SupplyController, :supply) |
|
|
|
pipe_through(:api) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scope "/v1", as: :api_v1 do |
|
|
|
|
|
|
|
get("/supply", V1.SupplyController, :supply) |
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
forward("/", RPC.RPCTranslator, %{ |
|
|
|
# For backward compatibility. Should be removed |
|
|
|
"block" => RPC.BlockController, |
|
|
|
post("/eth_rpc", RPC.EthController, :eth_request) |
|
|
|
"account" => RPC.AddressController, |
|
|
|
|
|
|
|
"logs" => RPC.LogsController, |
|
|
|
|
|
|
|
"token" => RPC.TokenController, |
|
|
|
|
|
|
|
"stats" => RPC.StatsController, |
|
|
|
|
|
|
|
"contract" => RPC.ContractController, |
|
|
|
|
|
|
|
"transaction" => RPC.TransactionController |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# For backward compatibility. Should be removed |
|
|
|
|
|
|
|
scope "/" do |
|
|
|
scope "/" do |
|
|
|
alias BlockScoutWeb.API.RPC |
|
|
|
|
|
|
|
pipe_through(:api) |
|
|
|
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, %{ |
|
|
|
forward("/", RPCTranslatorForwarder, %{ |
|
|
|
"block" => RPC.BlockController, |
|
|
|
"block" => {RPC.BlockController, []}, |
|
|
|
"account" => RPC.AddressController, |
|
|
|
"account" => {RPC.AddressController, []}, |
|
|
|
"logs" => RPC.LogsController, |
|
|
|
"logs" => {RPC.LogsController, []}, |
|
|
|
"token" => RPC.TokenController, |
|
|
|
"token" => {RPC.TokenController, []}, |
|
|
|
"stats" => RPC.StatsController, |
|
|
|
"stats" => {RPC.StatsController, []}, |
|
|
|
"contract" => RPC.ContractController, |
|
|
|
"contract" => {RPC.ContractController, [:verify]}, |
|
|
|
"transaction" => RPC.TransactionController |
|
|
|
"transaction" => {RPC.TransactionController, []} |
|
|
|
}) |
|
|
|
}) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|