From 5cdd291803e4fad7b794f5869d11a284c547928c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 17 Jul 2019 14:07:34 +0300 Subject: [PATCH] change view --- .../templates/address_contract/index.html.eex | 19 +++++++------ .../views/address_contract_view.ex | 27 ++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex index 3916d227de..79ca3f4d93 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex @@ -46,14 +46,17 @@
<%= @address.smart_contract.optimization_runs %>
<% end %> - <%= if @address.smart_contract.constructor_arguments do %> -
-
<%= gettext "Constructor arguments" %>
-
<%= format_constructor_arguments(@address.smart_contract) %>
-
- <% end %> - -
+ <%= if @address.smart_contract.constructor_arguments do %> +
+
+

<%= gettext "Constructor Arguments" %>

+
+
+
<%= format_constructor_arguments(@address.smart_contract) %>
+              
+
+
+ <% end %>

<%= gettext "Contract source code" %>

diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex index ae9b15b0d8..69ca3406e1 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex @@ -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