diff --git a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex index 5fee550b6b..12bde16065 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex @@ -8,6 +8,7 @@ defmodule BlockScoutWeb.ABIEncodedValueView do use BlockScoutWeb, :view alias ABI.FunctionSelector + alias Explorer.Chain.{Address, Hash} alias Phoenix.HTML require Logger @@ -196,7 +197,10 @@ defmodule BlockScoutWeb.ABIEncodedValueView do end defp base_value_json(:address, value) do - hex_for_json(value) + case Hash.Address.cast(value) do + {:ok, address} -> Address.checksum(address) + :error -> "0x" + end end defp base_value_json(:bytes, value) do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs index 082f8db55d..58b7a38ca1 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs @@ -263,7 +263,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do "constructor_args" => target_contract.constructor_arguments, "decoded_constructor_args" => [ ["0x0000000000000000000000000000000000000000", %{"name" => "_proxyStorage", "type" => "address"}], - ["0x2cf6e7c9ec35d0b08a1062e13854f74b1aaae54e", %{"name" => "_implementationAddress", "type" => "address"}] + ["0x2Cf6E7c9eC35D0B08A1062e13854f74b1aaae54e", %{"name" => "_implementationAddress", "type" => "address"}] ], "is_self_destructed" => false, "deployed_bytecode" => @@ -849,7 +849,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do assert response["decoded_constructor_args"] == [ [ - "0xc35dadb65012ec5796536bd9864ed8773abc74c4", + "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", %{ "internalType" => "address", "name" => "_factory", @@ -857,7 +857,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do } ], [ - "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6", + "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", %{ "internalType" => "address", "name" => "_WETH",