From 4ed9fdd2c98205cfefe522ba26cfb6231f20d7bb Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 10 Dec 2019 17:04:03 +0300 Subject: [PATCH] Add guard is_empty_string --- .../block_scout_web/views/api/rpc/contract_view.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex index cd0c0a7af5..7d92c8d5a2 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex +++ b/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, [])