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. 19
      apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex
  2. 27
      apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex

@ -46,14 +46,17 @@
<dd class="col-sm-8 col-md-10"><%= @address.smart_contract.optimization_runs %></dd>
</dl>
<% end %>
<%= if @address.smart_contract.constructor_arguments do %>
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "Constructor arguments" %></dt>
<dd class="col-sm-8 col-md-10"><%= format_constructor_arguments(@address.smart_contract) %></dd>
</dl>
<% end %>
</div>
<hr/>
<%= if @address.smart_contract.constructor_arguments do %>
<section>
<div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Constructor Arguments" %></h3>
</div>
<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>
<div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Contract source code" %></h3>

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

Loading…
Cancel
Save