Merge pull request #5487 from blockscout/np-fix-contract-constructor-args-ui

Fix array displaying in decoded constructor args
pull/5491/head
Victor Baranov 3 years ago committed by GitHub
commit 6d47ee5511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 29
      apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex

@ -7,6 +7,7 @@
### Fixes
- [#5488](https://github.com/blockscout/blockscout/pull/5488) - Split long contract output to multiple lines
- [#5487](https://github.com/blockscout/blockscout/pull/5487) - Fix array displaying in decoded constructor args
- [#5455](https://github.com/blockscout/blockscout/pull/5455) - Fix unverified_smart_contract function: add md5 of bytecode to the changeset
- [#5454](https://github.com/blockscout/blockscout/pull/5454) - Docker: Fix the qemu-x86_64 signal 11 error on Apple Silicon
- [#5443](https://github.com/blockscout/blockscout/pull/5443) - Geth: display tx revert reason

@ -33,8 +33,26 @@ defmodule BlockScoutWeb.AddressContractView do
|> decode_data(input_types)
|> Enum.zip(constructor_abi["inputs"])
|> Enum.reduce({0, "#{contract.constructor_arguments}\n\n"}, fn {val, %{"type" => type}}, {count, acc} ->
formatted_val =
formatted_val = val_to_string(val, type, conn)
{count + 1, "#{acc}Arg [#{count}] (<b>#{type}</b>) : #{formatted_val}\n"}
end)
result
rescue
_ -> contract.constructor_arguments
end
defp val_to_string(val, type, conn) do
cond do
type =~ "[]" ->
if is_list(val) or is_tuple(val) do
"[" <>
Enum.map_join(val, ", ", fn el -> val_to_string(el, String.replace_suffix(type, "[]", ""), conn) end) <> "]"
else
to_string(val)
end
type =~ "address" ->
address_hash = "0x" <> Base.encode16(val, case: :lower)
@ -46,15 +64,8 @@ defmodule BlockScoutWeb.AddressContractView do
Base.encode16(val, case: :lower)
true ->
val
to_string(val)
end
{count + 1, "#{acc}Arg [#{count}] (<b>#{type}</b>) : #{formatted_val}\n"}
end)
result
rescue
_ -> contract.constructor_arguments
end
defp get_address(address_hash) do

Loading…
Cancel
Save