diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex index f55d52b6aa..b0afe771c1 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex @@ -1,4 +1,20 @@
+ <% decoded_result = decode(@log, @transaction) %> + <%= case decoded_result do %> + <%= {:error, :contract_not_verified, _cadidates} -> %> +
+ <%= gettext "To see accurate decoded input data, the contract must be verified." %> + <%= case @transaction do %> + <% %{to_address: %{hash: hash}} -> %> + <%= gettext "Verify the contract " %><%= gettext "here" %> + <% _ -> %> + <%= nil %> + <% end %> +
+ <% _ -> %> + <%= nil %> + <% end %> +
<%= gettext "Address" %>
@@ -84,7 +100,7 @@ <% end %>
- <% {:error, :contract_not_verified, results} when is_list(results) and not results == [] -> %> + <% {:error, :contract_not_verified, results} -> %> <%= for {:ok, method_id, text, mapping} <- results do %>
<%= gettext "Decoded" %>
diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex index 0cca6151f1..50d406433c 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_log_view.ex @@ -5,6 +5,6 @@ defmodule BlockScoutWeb.TransactionLogView do alias Explorer.Chain.Log def decode(log, transaction) do - Log.decode(log, transaction) |> IO.inspect() + Log.decode(log, transaction) end end diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 93e2111b51..d9998f00fe 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -98,7 +98,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:3 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19 #: lib/block_scout_web/views/address_view.ex:99 msgid "Address" msgstr "" @@ -562,8 +562,8 @@ msgstr "" #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:59 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:105 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:68 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121 msgid "Name" msgstr "" @@ -1132,10 +1132,10 @@ msgstr "" #: lib/block_scout_web/templates/address_logs/_logs.html.eex:16 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:28 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:34 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:28 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:36 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:89 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:32 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:44 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:105 msgid "Decoded" msgstr "" @@ -1146,7 +1146,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35 msgid "To see decoded input data, the contract must be verified." msgstr "" @@ -1159,14 +1159,16 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "Verify the contract " msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "here" msgstr "" @@ -1321,6 +1323,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:6 msgid "To see accurate decoded input data, the contract must be verified." msgstr "" @@ -1781,8 +1784,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:63 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:118 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:81 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:134 msgid "Copy Value" msgstr "" @@ -1795,29 +1798,29 @@ msgstr "" #: lib/block_scout_web/templates/address_logs/_logs.html.eex:53 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:118 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:55 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:108 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:175 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:71 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:124 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:191 msgid "Data" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 msgid "Failed to decode log data." msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:107 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:70 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:123 msgid "Indexed?" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:102 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:118 msgid "Log Data" msgstr "" @@ -1830,14 +1833,14 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:88 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:145 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:161 msgid "Topics" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:51 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:106 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122 msgid "Type" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 4ea99bcf8d..585b389bc0 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -98,7 +98,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:3 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19 #: lib/block_scout_web/views/address_view.ex:99 msgid "Address" msgstr "" @@ -562,8 +562,8 @@ msgstr "" #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:59 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:105 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:68 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121 msgid "Name" msgstr "" @@ -1132,10 +1132,10 @@ msgstr "" #: lib/block_scout_web/templates/address_logs/_logs.html.eex:16 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:28 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:34 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:28 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:36 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:89 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:32 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:44 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:105 msgid "Decoded" msgstr "" @@ -1146,7 +1146,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35 msgid "To see decoded input data, the contract must be verified." msgstr "" @@ -1159,14 +1159,16 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "Verify the contract " msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "here" msgstr "" @@ -1322,6 +1324,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:6 msgid "To see accurate decoded input data, the contract must be verified." msgstr "" @@ -1782,8 +1785,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:63 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:118 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:81 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:134 msgid "Copy Value" msgstr "" @@ -1796,29 +1799,29 @@ msgstr "" #: lib/block_scout_web/templates/address_logs/_logs.html.eex:53 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:118 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:55 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:108 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:175 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:71 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:124 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:191 msgid "Data" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 msgid "Failed to decode log data." msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:107 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:70 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:123 msgid "Indexed?" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:102 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:118 msgid "Log Data" msgstr "" @@ -1831,14 +1834,14 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:88 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:145 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:161 msgid "Topics" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:51 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:106 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122 msgid "Type" msgstr "" diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index 3e996e2d37..f84c59c38d 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -140,8 +140,14 @@ defmodule Explorer.Chain.Log do |> Repo.all() |> Enum.flat_map(fn contract_method -> case find_and_decode([contract_method.abi], log, transaction) do - {:ok, _, _} = result -> [result] - _ -> [] + {:ok, selector, mapping} -> + identifier = Base.encode16(selector.method_id, case: :lower) + text = function_call(selector.function, mapping) + + [{:ok, identifier, text, mapping}] + + _ -> + [] end end)