|
|
@ -33,21 +33,7 @@ defmodule BlockScoutWeb.AddressContractView do |
|
|
|
|> decode_data(input_types) |
|
|
|
|> decode_data(input_types) |
|
|
|
|> Enum.zip(constructor_abi["inputs"]) |
|
|
|
|> Enum.zip(constructor_abi["inputs"]) |
|
|
|
|> Enum.reduce({0, "#{contract.constructor_arguments}\n\n"}, fn {val, %{"type" => type}}, {count, acc} -> |
|
|
|
|> Enum.reduce({0, "#{contract.constructor_arguments}\n\n"}, fn {val, %{"type" => type}}, {count, acc} -> |
|
|
|
formatted_val = |
|
|
|
formatted_val = val_to_string(val, type, conn) |
|
|
|
cond do |
|
|
|
|
|
|
|
type =~ "address" -> |
|
|
|
|
|
|
|
address_hash = "0x" <> Base.encode16(val, case: :lower) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
address = get_address(address_hash) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_formatted_address_data(address, address_hash, conn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type =~ "bytes" -> |
|
|
|
|
|
|
|
Base.encode16(val, case: :lower) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
true -> |
|
|
|
|
|
|
|
val |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{count + 1, "#{acc}Arg [#{count}] (<b>#{type}</b>) : #{formatted_val}\n"} |
|
|
|
{count + 1, "#{acc}Arg [#{count}] (<b>#{type}</b>) : #{formatted_val}\n"} |
|
|
|
end) |
|
|
|
end) |
|
|
@ -57,6 +43,31 @@ defmodule BlockScoutWeb.AddressContractView do |
|
|
|
_ -> contract.constructor_arguments |
|
|
|
_ -> contract.constructor_arguments |
|
|
|
end |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
address = get_address(address_hash) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_formatted_address_data(address, address_hash, conn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type =~ "bytes" -> |
|
|
|
|
|
|
|
Base.encode16(val, case: :lower) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
true -> |
|
|
|
|
|
|
|
to_string(val) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp get_address(address_hash) do |
|
|
|
defp get_address(address_hash) do |
|
|
|
case Chain.string_to_address_hash(address_hash) do |
|
|
|
case Chain.string_to_address_hash(address_hash) do |
|
|
|
{:ok, address} -> address |
|
|
|
{:ok, address} -> address |
|
|
|