Add guard is_empty_string

pull/2857/head
Victor Baranov 5 years ago
parent 30132a71a9
commit 4ed9fdd2c9
  1. 11
      apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex

@ -4,6 +4,8 @@ defmodule BlockScoutWeb.API.RPC.ContractView do
alias BlockScoutWeb.API.RPC.RPCView
alias Explorer.Chain.{Address, DecompiledSmartContract, SmartContract}
defguardp is_empty_string(input) when input == "" or input == nil
def render("listcontracts.json", %{contracts: contracts}) do
contracts = Enum.map(contracts, &prepare_contract/1)
@ -82,13 +84,14 @@ defmodule BlockScoutWeb.API.RPC.ContractView do
end
end
defp set_constructor_arguments(contract_output, %{constructor_arguments: constructor_arguments}) do
defp set_constructor_arguments(contract_output, %{constructor_arguments: arguments}) when is_empty_string(arguments),
do: contract_output
defp set_constructor_arguments(contract_output, %{constructor_arguments: arguments}) do
contract_output
|> Map.put_new(:ConstructorArguments, constructor_arguments)
|> Map.put_new(:ConstructorArguments, arguments)
end
defp set_constructor_arguments(contract_output, _), do: contract_output
defp set_external_libraries(contract_output, contract) do
external_libraries = Map.get(contract, :external_libraries, [])

Loading…
Cancel
Save