fix: decode addresses as checksummed (#10777)

* fix: decode addresses as checksummed

* chore: fix failing tests
pull/10805/head
Kirill Fedoseev 2 months ago committed by GitHub
parent 26a8899548
commit 45c8368fad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex
  2. 6
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs

@ -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

@ -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",

Loading…
Cancel
Save