|
|
|
@ -3,6 +3,7 @@ defmodule BlockScoutWeb.API.RPC.ContractView do |
|
|
|
|
|
|
|
|
|
alias BlockScoutWeb.AddressView |
|
|
|
|
alias BlockScoutWeb.API.RPC.RPCView |
|
|
|
|
alias Ecto.Association.NotLoaded |
|
|
|
|
alias Explorer.Chain |
|
|
|
|
alias Explorer.Chain.{Address, DecompiledSmartContract, SmartContract} |
|
|
|
|
|
|
|
|
@ -34,25 +35,6 @@ defmodule BlockScoutWeb.API.RPC.ContractView do |
|
|
|
|
RPCView.render("show.json", data: result) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp prepare_source_code_contract(nil) do |
|
|
|
|
%{ |
|
|
|
|
"Address" => "", |
|
|
|
|
"SourceCode" => "", |
|
|
|
|
"ABI" => "Contract source code not verified", |
|
|
|
|
"ContractName" => "", |
|
|
|
|
"CompilerVersion" => "", |
|
|
|
|
"DecompiledSourceCode" => "", |
|
|
|
|
"DecompilerVersion" => decompiler_version(nil), |
|
|
|
|
"OptimizationUsed" => "", |
|
|
|
|
"OptimizationRuns" => "", |
|
|
|
|
"EVMVersion" => "", |
|
|
|
|
"ConstructorArguments" => "", |
|
|
|
|
"ExternalLibraries" => "", |
|
|
|
|
"FileName" => "", |
|
|
|
|
"IsProxy" => "false" |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp prepare_source_code_contract(address) do |
|
|
|
|
decompiled_smart_contract = latest_decompiled_smart_contract(address.decompiled_smart_contracts) |
|
|
|
|
contract = address.smart_contract || %{} |
|
|
|
@ -220,6 +202,8 @@ defmodule BlockScoutWeb.API.RPC.ContractView do |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp latest_decompiled_smart_contract(%NotLoaded{}), do: nil |
|
|
|
|
|
|
|
|
|
defp latest_decompiled_smart_contract([]), do: nil |
|
|
|
|
|
|
|
|
|
defp latest_decompiled_smart_contract(contracts) do |
|
|
|
|