@ -18,37 +18,45 @@ 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 )
alias BlockScoutWeb.API . { RPC , V1 }
alias BlockScoutWeb.API.V1.HealthController
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 )
if Application . get_env ( :block_scout_web , __MODULE__ ) [ :read ing_enabled ] do
get ( " /supply " , V1.SupplyController , :supply )
post ( " /eth-rpc " , RPC.EthController , :eth_request )
end
end
if Application . get_env ( :block_scout_web , __MODULE__ ) [ :reading_enabled ] do
scope " / " do
alias BlockScoutWeb.API . { RPC , V1 }
pipe_through ( :api )
scope " /v1 " , as : :api_v1 do
get ( " /supply " , V1.SupplyController , :supply )
post ( " /eth-rpc " , RPC.Eth Controller, :eth_r equest )
end
if Application . get_env ( :block_scout_web , __MODULE__ ) [ :writing_enabled ] do
post ( " /decompiled_smart_contract " , V1.DecompiledSmartContractController , :create )
post ( " /verified_smart_contracts " , V1.VerifiedSmartContractController , :create )
end
# For backward compatibility. Should be removed
post ( " /eth-rpc " , RPC.EthController , :eth_request )
if Application . get_env ( :block_scout_web , __MODULE__ ) [ :reading_enabled ] 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
end
# For backward compatibility. Should be removed
scope " / " do
pipe_through ( :api )
alias BlockScoutWeb.API.RPC
scope " /v1 " , as : :api_v1 do
forward ( " / " , RPC.RPCTranslator , %{
if Application . get_env ( :block_scout_web , __MODULE__ ) [ :reading_enabled ] do
post ( " /eth-rpc " , RPC.EthController , :eth_request )
forward ( " / " , RPCTranslatorForwarder , %{
" block " = > { RPC.BlockController , [ ] } ,
" account " = > { RPC.AddressController , [ ] } ,
" logs " = > { RPC.LogsController , [ ] } ,
@ -58,16 +66,5 @@ defmodule BlockScoutWeb.ApiRouter do
" 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 , [ :verify ] } ,
" transaction " = > { RPC.TransactionController , [ ] }
} )
end
end