change view

pull/2374/head
Ayrat Badykov 5 years ago
parent 9bc027daff
commit 5cdd291803
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 15
      apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex
  2. 7
      apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex

@ -47,13 +47,16 @@
</dl> </dl>
<% end %> <% end %>
<%= if @address.smart_contract.constructor_arguments do %> <%= if @address.smart_contract.constructor_arguments do %>
<dl class="row"> <section>
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Constructor arguments" %></dt> <div class="d-flex justify-content-between align-items-baseline">
<dd class="col-sm-8 col-md-10"><%= format_constructor_arguments(@address.smart_contract) %></dd> <h3><%= gettext "Constructor Arguments" %></h3>
</dl>
<% end %>
</div> </div>
<hr/> <div class="tile tile-muted mb-4">
<pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= format_constructor_arguments(@address.smart_contract) %></code>
</pre>
</div>
</section>
<% end %>
<section> <section>
<div class="d-flex justify-content-between align-items-baseline"> <div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Contract source code" %></h3> <h3><%= gettext "Contract source code" %></h3>

@ -27,9 +27,10 @@ defmodule BlockScoutWeb.AddressContractView do
input_types = Enum.map(constructor_abi["inputs"], &FunctionSelector.parse_specification_type/1) input_types = Enum.map(constructor_abi["inputs"], &FunctionSelector.parse_specification_type/1)
{_, result} =
contract.constructor_arguments contract.constructor_arguments
|> decode_data(input_types) |> decode_data(input_types)
|> Enum.reduce("", fn val, acc -> |> Enum.reduce({0, "#{contract.constructor_arguments}\n\n"}, fn val, {count, acc} ->
formatted_val = formatted_val =
if is_binary(val) do if is_binary(val) do
Base.encode16(val) Base.encode16(val)
@ -37,8 +38,10 @@ defmodule BlockScoutWeb.AddressContractView do
val val
end end
"#{acc}#{formatted_val}\n" {count + 1, "#{acc}Arg [#{count}] : #{formatted_val}\n"}
end) end)
result
rescue rescue
_ -> contract.constructor_arguments _ -> contract.constructor_arguments
end end

Loading…
Cancel
Save