From 21a1c1403c81c7459d1cd2f2950758c486e67af1 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 15:14:14 -0500 Subject: [PATCH 01/20] feat: fix ABI decodding, and decode tx logs --- .../css/components/_transaction-input.scss | 25 ++- .../templates/transaction/overview.html.eex | 155 ++++++++---------- .../templates/transaction_log/index.html.eex | 116 ++++++++++--- .../views/abi_encoded_value_view.ex | 108 ++++++++++++ .../views/transaction_log_view.ex | 6 + .../views/abi_encoded_value_view_test.exs | 91 ++++++++++ apps/ethereum_jsonrpc/mix.exs | 2 +- apps/explorer/lib/explorer/chain/log.ex | 59 +++++++ mix.lock | 2 +- 9 files changed, 442 insertions(+), 122 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex create mode 100644 apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs diff --git a/apps/block_scout_web/assets/css/components/_transaction-input.scss b/apps/block_scout_web/assets/css/components/_transaction-input.scss index 63c3a847b8..12ca615be8 100644 --- a/apps/block_scout_web/assets/css/components/_transaction-input.scss +++ b/apps/block_scout_web/assets/css/components/_transaction-input.scss @@ -1,9 +1,26 @@ .raw-transaction-input{ - display: none; + display: none; +} + +.raw-transaction-log-topics{ + display: none; +} + +.raw-transaction-log-data{ + display: none; } .transaction-input-text{ - resize: vertical; - overflow: auto; - word-break: break-all; + white-space: pre; + color: black; + + pre{ + code{ + color: black; + } + } +} + +.transaction-input-table{ + overflow-x: scroll; } diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index 21440d0c8b..23008b60c8 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -75,102 +75,75 @@ -
- <%= case decoded_input_data(@transaction) do %> - <% {:error, :contract_not_verified} -> %> -
<%= gettext "Input" %>
-
-
- To see decoded input data, the contract must be verified. -
-
- <% {:error, :could_not_decode} -> %> -
<%= gettext "Input" %>
-
-
- Failed to decode input data. Some dynamic types are not currently supported. -
-
- <% {:ok, method_id, text, mapping} -> %> -
<%= gettext "Input" %>
-
- - - - - +

<%= gettext "Input" %>

+ <%= case decoded_input_data(@transaction) do %> + <% {:error, :contract_not_verified} -> %> +
+ To see decoded input data, the contract must be verified. +
+ <% {:error, :could_not_decode} -> %> +
+ Failed to decode input data. Some dynamic types are not currently supported. +
+ <% {:ok, method_id, text, mapping} -> %> +
Method Id0x<%= method_id %>
+ + + + + + + + +
Method Id0x<%= method_id %>
Call<%= text %>
+ + + + + + + + + <%= for {name, type, value} <- mapping do %> - - + + + + -
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Data" %>
Call<%= text %> + <% copy_text = BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) %> + + <%= name %><%= type %> +
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+
- - - - - - - - - <%= for {{name, type, value}, index} <- Enum.with_index(mapping) do %> - - - - - <%= case type do %> - <% "address" -> %> - <% address = "0x" <> Base.encode16(value, case: :lower) %> - - + <% end %> +
#NameTypeData
<%= index %><%= name %><%= type %> - - - -
+ <% _ -> %> + <%= nil %> + <% end %> - <% _ -> %> - -
<%= value %> - - - - - <% end %> - - <% end %> - -
- <% _ -> %> - <%= nil %> - <% end %> + <%= unless @transaction.input.bytes in [<<>>, nil] do %> +

<%= gettext "Raw Input" %>

+
+ +
+
+ + - <%= unless @transaction.input.bytes in [<<>>, nil] do %> -
<%= gettext "Raw Input" %>
-
-
- +
+
+                  <%= @transaction.input %>
+                
-
- -
- -
-                    <%= @transaction.input %>
-                  
-
-
-
- <% end %> -
+ + <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex index 4eb501a5fd..7f8d7066c4 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex @@ -23,39 +23,105 @@ ) %> -
<%= gettext "Topics" %>
+
<%= gettext "Decoded" %>
- <%= unless is_nil(log.first_topic) do %> -
- [0] - <%= log.first_topic %> -
- <% end %> - <%= unless is_nil(log.second_topic) do %> -
- [1] - <%= log.second_topic %> -
- <% end %> - <%= unless is_nil(log.third_topic) do %> -
- [2] - <%= log.third_topic %> -
- <% end %> - <%= unless is_nil(log.fourth_topic) do %> -
- [3] - <%= log.fourth_topic %> -
+ <%= case decode(log, @transaction) do %> + <% {:error, :contract_not_verified} -> %> +
+ To see decoded input data, the contract must be verified. +
+ <% {:error, :could_not_decode} -> %> +
+ Failed to decode log data. +
+ <% {:ok, method_id, text, mapping} -> %> + + + + + + + + + +
Method Id0x<%= method_id %>
Call<%= text %>
+ + + + + + + + + <%= for {name, type, indexed?, value} <- mapping do %> + + + + + + + + <% end %> +
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Indexed?" %><%= gettext "Data" %>
+ <% copy_text = BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) %> + + + <%= name %><%= type %><%= indexed? %> +
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+
<% end %> + +
+
<%= gettext "Topics" %>
+
+
+ +
+
+ + <%= unless is_nil(log.first_topic) do %> +
+ [0] + <%= log.first_topic %> +
+ <% end %> + <%= unless is_nil(log.second_topic) do %> +
+ [1] + <%= log.second_topic %> +
+ <% end %> + <%= unless is_nil(log.third_topic) do %> +
+ [2] + <%= log.third_topic %> +
+ <% end %> + <%= unless is_nil(log.fourth_topic) do %> +
+ [3] + <%= log.fourth_topic %> +
+ <% end %> +
<%= gettext "Data" %>
<%= unless is_nil(log.data) do %> -
+
+ +
+ +
+ <%= log.data %>
<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex new file mode 100644 index 0000000000..a0b5e2bd61 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex @@ -0,0 +1,108 @@ +defmodule BlockScoutWeb.ABIEncodedValueView do + @moduledoc """ + Renders a decoded value that is encoded according to an ABI. + + Does not leverage an eex template because it renders formatted + values via `
` tags, and that is hard to do in an eex template.
+  """
+  use BlockScoutWeb, :view
+
+  require Logger
+
+  def value_html(type, value) do
+    decoded_type = ABI.FunctionSelector.decode_type(type)
+
+    do_value_html(decoded_type, value)
+  rescue
+    exception ->
+      Logger.warn(fn ->
+        ["Error determining value html for #{inspect(type)}: ", Exception.format(:error, exception)]
+      end)
+  end
+
+  def copy_text(type, value) do
+    decoded_type = ABI.FunctionSelector.decode_type(type)
+
+    do_copy_text(decoded_type, value)
+  rescue
+    exception ->
+      Logger.warn(fn ->
+        ["Error determining copy text for #{inspect(type)}: ", Exception.format(:error, exception)]
+      end)
+  end
+
+  def do_copy_text({:bytes, _type}, value) do
+    hex(value)
+  end
+
+  def do_copy_text({:array, type, _}, value) do
+    do_copy_text({:array, type}, value)
+  end
+
+  def do_copy_text({:array, type}, value) do
+    values =
+      value
+      |> Enum.map(&do_copy_text(type, &1))
+      |> Enum.intersperse(", ")
+
+    ~E|[<%= values %>]|
+  end
+
+  def do_copy_text(_, {:dynamic, value}) do
+    hex(value)
+  end
+
+  def do_copy_text(type, value) when type in [:bytes, :address] do
+    hex(value)
+  end
+
+  def do_copy_text(_type, value) do
+    to_string(value)
+  end
+
+  defp do_value_html(type, value, depth \\ 0)
+
+  defp do_value_html({:bytes, _}, value, depth) do
+    do_value_html(:bytes, value, depth)
+  end
+
+  defp do_value_html({:array, type, _}, value, depth) do
+    do_value_html({:array, type}, value, depth)
+  end
+
+  defp do_value_html({:array, type}, value, depth) do
+    values =
+      Enum.map(value, fn inner_value ->
+        do_value_html(type, inner_value, depth + 1)
+      end)
+
+    spacing = String.duplicate(" ", depth * 2)
+    delimited = Enum.intersperse(values, ",\n")
+
+    ~E|<%= spacing %>[<%= "\n" %><%= delimited %><%= "\n" %><%= spacing %>]|
+  end
+
+  defp do_value_html(type, value, depth) do
+    spacing = String.duplicate(" ", depth * 2)
+    ~E|<%= spacing %><%=base_value_html(type, value)%>|
+    [spacing, base_value_html(type, value)]
+  end
+
+  def base_value_html(_, {:dynamic, value}) do
+    hex(value)
+  end
+
+  def base_value_html(:address, value) do
+    address = hex(value)
+
+    ~E|<%= address %>|
+  end
+
+  def base_value_html(:bytes, value) do
+    hex(value)
+  end
+
+  def base_value_html(_, value), do: Phoenix.HTML.html_escape(value)
+
+  defp hex(value), do: "0x" <> Base.encode16(value, case: :lower)
+end
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 96cf62fe9a..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
@@ -1,4 +1,10 @@
 defmodule BlockScoutWeb.TransactionLogView do
   use BlockScoutWeb, :view
   @dialyzer :no_match
+
+  alias Explorer.Chain.Log
+
+  def decode(log, transaction) do
+    Log.decode(log, transaction)
+  end
 end
diff --git a/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs
new file mode 100644
index 0000000000..a63f15cf64
--- /dev/null
+++ b/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs
@@ -0,0 +1,91 @@
+defmodule BlockScoutWeb.ABIEncodedValueViewTest do
+  use BlockScoutWeb.ConnCase, async: true
+
+  alias BlockScoutWeb.ABIEncodedValueView
+
+  defp value_html(type, value) do
+    type
+    |> ABIEncodedValueView.value_html(value)
+    |> Phoenix.HTML.Safe.to_iodata()
+    |> IO.iodata_to_binary()
+  end
+
+  defp copy_text(type, value) do
+    type
+    |> ABIEncodedValueView.copy_text(value)
+    |> Phoenix.HTML.Safe.to_iodata()
+    |> IO.iodata_to_binary()
+  end
+
+  describe "value_html/2" do
+    test "it formats addresses as links" do
+      address = "0x0000000000000000000000000000000000000000"
+      address_bytes = address |> String.trim_leading("0x") |> Base.decode16!()
+
+      expected = ~s(#{address})
+
+      assert value_html("address", address_bytes) == expected
+    end
+
+    test "it formats lists with newlines and spaces" do
+      expected = String.trim("""
+      [
+        1,
+        2,
+        3,
+        4
+      ]
+      """)
+
+      assert value_html("uint[]", [1, 2, 3, 4]) == expected
+    end
+
+    test "it formats nested lists with nested depth" do
+      expected = String.trim("""
+      [
+        [
+          1,
+          2
+        ],
+        [
+          3,
+          4
+        ]
+      ]
+      """)
+
+      assert value_html("uint[][]", [[1, 2], [3, 4]]) == expected
+    end
+
+    test "it formats lists of addresses as a list of links" do
+      address = "0x0000000000000000000000000000000000000000"
+      address_link = ~s(#{address})
+
+      expected = String.trim("""
+      [
+        #{address_link},
+        #{address_link},
+        #{address_link},
+        #{address_link}
+      ]
+      """)
+
+      address_bytes = "0x0000000000000000000000000000000000000000" |> String.trim_leading("0x") |> Base.decode16!()
+
+      assert value_html("address[]", [address_bytes, address_bytes, address_bytes, address_bytes]) == expected
+    end
+  end
+
+  describe "copy_text/2" do
+    test "it skips link formatting of addresses" do
+      address = "0x0000000000000000000000000000000000000000"
+      address_bytes = address |> String.trim_leading("0x") |> Base.decode16!()
+
+      assert copy_text("address", address_bytes) == address
+    end
+
+    test "it skips the formatting when copying lists" do
+      assert copy_text("uint[]", [1, 2, 3, 4]) == "[1, 2, 3, 4]"
+    end
+  end
+end
diff --git a/apps/ethereum_jsonrpc/mix.exs b/apps/ethereum_jsonrpc/mix.exs
index 16608e0942..02c8ccfe53 100644
--- a/apps/ethereum_jsonrpc/mix.exs
+++ b/apps/ethereum_jsonrpc/mix.exs
@@ -79,7 +79,7 @@ defmodule EthereumJsonrpc.MixProject do
       # Convert unix timestamps in JSONRPC to DateTimes
       {:timex, "~> 3.4"},
       # Encode/decode function names and arguments
-      {:ex_abi, "~> 0.1.17"},
+      {:ex_abi, "~> 0.1.18"},
       # `:verify_fun` for `Socket.Web.connect`
       {:ssl_verify_fun, "~> 1.1"},
       # `EthereumJSONRPC.WebSocket`
diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex
index 9dcb31405a..f97a24b378 100644
--- a/apps/explorer/lib/explorer/chain/log.ex
+++ b/apps/explorer/lib/explorer/chain/log.ex
@@ -3,6 +3,8 @@ defmodule Explorer.Chain.Log do
 
   use Explorer.Schema
 
+  require Logger
+
   alias Explorer.Chain.{Address, Data, Hash, Transaction}
 
   @required_attrs ~w(address_hash data index transaction_hash)a
@@ -98,4 +100,61 @@ defmodule Explorer.Chain.Log do
     |> cast(attrs, @optional_attrs)
     |> validate_required(@required_attrs)
   end
+
+  @doc """
+  Decode transaction log data.
+  """
+  def decode(log, transaction) do
+    abi = transaction.to_address.smart_contract.abi
+
+    with {:ok, selector, mapping} <- find_and_decode(abi, log),
+         identifier <- Base.encode16(selector.method_id, case: :lower),
+         text <- function_call(selector.function, mapping),
+         do: {:ok, identifier, text, mapping}
+  end
+
+  defp find_and_decode(abi, log) do
+    with {selector, mapping} <-
+           abi
+           |> ABI.parse_specification(include_events?: true)
+           |> ABI.Event.find_and_decode(
+             decode16!(log.first_topic),
+             decode16!(log.second_topic),
+             decode16!(log.third_topic),
+             decode16!(log.fourth_topic),
+             log.data.bytes
+           ) do
+      {:ok, selector, mapping}
+    end
+  rescue
+    _ ->
+      Logger.warn(fn -> ["Could not decode input data for log: ", Hash.to_iodata(log.hash)] end)
+      {:error, :could_not_decode}
+  end
+
+  defp function_call(name, mapping) do
+    text =
+      mapping
+      |> Stream.map(fn {name, type, indexed?, _value} ->
+        indexed_keyword =
+          if indexed? do
+            ["indexed "]
+          else
+            []
+          end
+
+        [type, " ", indexed_keyword, name]
+      end)
+      |> Enum.intersperse(", ")
+
+    IO.iodata_to_binary([name, "(", text, ")"])
+  end
+
+  def decode16!(nil), do: nil
+
+  def decode16!(value) do
+    value
+    |> String.trim_leading("0x")
+    |> Base.decode16!(case: :lower)
+  end
 end
diff --git a/mix.lock b/mix.lock
index a1d0a1c603..3a6bf7bd26 100644
--- a/mix.lock
+++ b/mix.lock
@@ -28,7 +28,7 @@
   "earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
   "ecto": {:hex, :ecto, "2.2.11", "4bb8f11718b72ba97a2696f65d247a379e739a0ecabf6a13ad1face79844791c", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
   "elixir_make": {:hex, :elixir_make, "0.4.2", "332c649d08c18bc1ecc73b1befc68c647136de4f340b548844efc796405743bf", [:mix], [], "hexpm"},
-  "ex_abi": {:hex, :ex_abi, "0.1.17", "11822f88b3ed70773c64858a49321b3c51ed913128a3f9fc7a05fa7ceb19d8fa", [:mix], [{:exth_crypto, "~> 0.1.4", [hex: :exth_crypto, repo: "hexpm", optional: false]}], "hexpm"},
+  "ex_abi": {:hex, :ex_abi, "0.1.18", "19db9bffdd201edbdff97d7dd5849291218b17beda045c1b76bff5248964f37d", [:mix], [{:exth_crypto, "~> 0.1.4", [hex: :exth_crypto, repo: "hexpm", optional: false]}], "hexpm"},
   "ex_cldr": {:hex, :ex_cldr, "1.3.2", "8f4a00c99d1c537b8e8db7e7903f4bd78d82a7289502d080f70365392b13921b", [:mix], [{:abnf2, "~> 0.1", [hex: :abnf2, optional: false]}, {:decimal, "~> 1.4", [hex: :decimal, optional: false]}, {:gettext, "~> 0.13", [hex: :gettext, optional: true]}, {:poison, "~> 2.1 or ~> 3.0", [hex: :poison, optional: true]}]},
   "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "1.2.0", "ef27299922da913ffad1ed296cacf28b6452fc1243b77301dc17c03276c6ee34", [:mix], [{:decimal, "~> 1.4", [hex: :decimal, optional: false]}, {:ex_cldr, "~> 1.3", [hex: :ex_cldr, optional: false]}, {:poison, "~> 2.1 or ~> 3.1", [hex: :poison, optional: false]}]},
   "ex_cldr_units": {:hex, :ex_cldr_units, "1.1.1", "b3c7256709bdeb3740a5f64ce2bce659eb9cf4cc1afb4cf94aba033b4a18bc5f", [:mix], [{:ex_cldr, "~> 1.0", [hex: :ex_cldr, optional: false]}, {:ex_cldr_numbers, "~> 1.0", [hex: :ex_cldr_numbers, optional: false]}]},

From e97873ddae1f33ffd3ceb9ddf34f8bf083704c54 Mon Sep 17 00:00:00 2001
From: zachdaniel 
Date: Mon, 19 Nov 2018 15:29:51 -0500
Subject: [PATCH 02/20] chore: format

---
 .../views/abi_encoded_value_view_test.exs     | 55 ++++++++++---------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs
index a63f15cf64..d6b5060347 100644
--- a/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs
@@ -28,31 +28,33 @@ defmodule BlockScoutWeb.ABIEncodedValueViewTest do
     end
 
     test "it formats lists with newlines and spaces" do
-      expected = String.trim("""
-      [
-        1,
-        2,
-        3,
-        4
-      ]
-      """)
+      expected =
+        String.trim("""
+        [
+          1,
+          2,
+          3,
+          4
+        ]
+        """)
 
       assert value_html("uint[]", [1, 2, 3, 4]) == expected
     end
 
     test "it formats nested lists with nested depth" do
-      expected = String.trim("""
-      [
+      expected =
+        String.trim("""
         [
-          1,
-          2
-        ],
-        [
-          3,
-          4
+          [
+            1,
+            2
+          ],
+          [
+            3,
+            4
+          ]
         ]
-      ]
-      """)
+        """)
 
       assert value_html("uint[][]", [[1, 2], [3, 4]]) == expected
     end
@@ -61,14 +63,15 @@ defmodule BlockScoutWeb.ABIEncodedValueViewTest do
       address = "0x0000000000000000000000000000000000000000"
       address_link = ~s(#{address})
 
-      expected = String.trim("""
-      [
-        #{address_link},
-        #{address_link},
-        #{address_link},
-        #{address_link}
-      ]
-      """)
+      expected =
+        String.trim("""
+        [
+          #{address_link},
+          #{address_link},
+          #{address_link},
+          #{address_link}
+        ]
+        """)
 
       address_bytes = "0x0000000000000000000000000000000000000000" |> String.trim_leading("0x") |> Base.decode16!()
 

From c85e9e9e91cedab874d1956861c93e8b15af7ea6 Mon Sep 17 00:00:00 2001
From: zachdaniel 
Date: Mon, 19 Nov 2018 15:32:15 -0500
Subject: [PATCH 03/20] chore: gettext

---
 apps/block_scout_web/priv/gettext/default.pot | 61 ++++++++++++------
 .../priv/gettext/en/LC_MESSAGES/default.po    | 63 ++++++++++++-------
 2 files changed, 83 insertions(+), 41 deletions(-)

diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot
index c2da36a554..001eb26652 100644
--- a/apps/block_scout_web/priv/gettext/default.pot
+++ b/apps/block_scout_web/priv/gettext/default.pot
@@ -355,7 +355,9 @@ msgid "Curl"
 msgstr ""
 
 #, elixir-format
+#: lib/block_scout_web/templates/transaction/overview.html.eex:105
 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:113
 msgid "Data"
 msgstr ""
 
@@ -405,7 +407,7 @@ msgstr ""
 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16
 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:19
 #: lib/block_scout_web/templates/transaction/_tile.html.eex:26
-#: lib/block_scout_web/templates/transaction/overview.html.eex:182
+#: lib/block_scout_web/templates/transaction/overview.html.eex:155
 #: lib/block_scout_web/views/wei_helpers.ex:72
 msgid "Ether"
 msgstr ""
@@ -444,7 +446,7 @@ msgid "GET"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:195
+#: lib/block_scout_web/templates/transaction/overview.html.eex:168
 msgid "Gas"
 msgstr ""
 
@@ -488,9 +490,7 @@ msgid "Indexing Tokens"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:81
-#: lib/block_scout_web/templates/transaction/overview.html.eex:88
-#: lib/block_scout_web/templates/transaction/overview.html.eex:95
+#: lib/block_scout_web/templates/transaction/overview.html.eex:78
 msgid "Input"
 msgstr ""
 
@@ -527,7 +527,7 @@ msgid "Less than"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:207
+#: lib/block_scout_web/templates/transaction/overview.html.eex:180
 msgid "Limit"
 msgstr ""
 
@@ -588,6 +588,8 @@ msgstr ""
 
 #, elixir-format
 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:29
+#: lib/block_scout_web/templates/transaction/overview.html.eex:103
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:51
 msgid "Name"
 msgstr ""
 
@@ -599,7 +601,7 @@ msgstr ""
 #, elixir-format
 #:
 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23
-#: lib/block_scout_web/templates/transaction_log/index.html.eex:74
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:140
 msgid "Newer"
 msgstr ""
 
@@ -821,7 +823,7 @@ msgid "There are no internal transactions for this transaction."
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction_log/index.html.eex:68
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:134
 msgid "There are no logs for this transaction."
 msgstr ""
 
@@ -933,7 +935,7 @@ msgid "Top Accounts - %{subnetwork} Explorer"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction_log/index.html.eex:26
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:77
 msgid "Topics"
 msgstr ""
 
@@ -1022,7 +1024,7 @@ msgid "Unique Token"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:200
+#: lib/block_scout_web/templates/transaction/overview.html.eex:173
 msgid "Used"
 msgstr ""
 
@@ -1043,7 +1045,7 @@ msgid "Validations"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:182
+#: lib/block_scout_web/templates/transaction/overview.html.eex:155
 msgid "Value"
 msgstr ""
 
@@ -1227,20 +1229,13 @@ msgid "This API is provided for developers transitioning their applications from
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:153
+#: lib/block_scout_web/templates/transaction/overview.html.eex:128
 msgid "Raw Input"
 msgstr ""
 
-#, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:156
-msgid "Show Raw Input"
-msgstr ""
-
 #, elixir-format
 #: lib/block_scout_web/templates/transaction/overview.html.eex:130
-#: lib/block_scout_web/templates/transaction/overview.html.eex:140
-#: lib/block_scout_web/templates/transaction/overview.html.eex:164
-msgid "copy"
+msgid "Show Raw Input"
 msgstr ""
 
 #, elixir-format
@@ -1322,3 +1317,29 @@ msgstr ""
 #: lib/block_scout_web/views/internal_transaction_view.ex:24
 msgid "Static Call"
 msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:26
+msgid "Decoded"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:53
+msgid "Indexed?"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:118
+msgid "Show Raw Data"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:80
+msgid "Show Raw Topics"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction/overview.html.eex:104
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:52
+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 c932738907..0b267e4c22 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
@@ -355,7 +355,9 @@ msgid "Curl"
 msgstr ""
 
 #, elixir-format
+#: lib/block_scout_web/templates/transaction/overview.html.eex:105
 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:113
 msgid "Data"
 msgstr ""
 
@@ -405,7 +407,7 @@ msgstr ""
 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16
 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:19
 #: lib/block_scout_web/templates/transaction/_tile.html.eex:26
-#: lib/block_scout_web/templates/transaction/overview.html.eex:182
+#: lib/block_scout_web/templates/transaction/overview.html.eex:155
 #: lib/block_scout_web/views/wei_helpers.ex:72
 msgid "Ether"
 msgstr "POA"
@@ -444,7 +446,7 @@ msgid "GET"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:195
+#: lib/block_scout_web/templates/transaction/overview.html.eex:168
 msgid "Gas"
 msgstr ""
 
@@ -488,9 +490,7 @@ msgid "Indexing Tokens"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:81
-#: lib/block_scout_web/templates/transaction/overview.html.eex:88
-#: lib/block_scout_web/templates/transaction/overview.html.eex:95
+#: lib/block_scout_web/templates/transaction/overview.html.eex:78
 msgid "Input"
 msgstr ""
 
@@ -527,7 +527,7 @@ msgid "Less than"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:207
+#: lib/block_scout_web/templates/transaction/overview.html.eex:180
 msgid "Limit"
 msgstr ""
 
@@ -588,6 +588,8 @@ msgstr ""
 
 #, elixir-format
 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:29
+#: lib/block_scout_web/templates/transaction/overview.html.eex:103
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:51
 msgid "Name"
 msgstr ""
 
@@ -599,7 +601,7 @@ msgstr ""
 #, elixir-format
 #:
 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23
-#: lib/block_scout_web/templates/transaction_log/index.html.eex:74
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:140
 msgid "Newer"
 msgstr ""
 
@@ -821,7 +823,7 @@ msgid "There are no internal transactions for this transaction."
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction_log/index.html.eex:68
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:134
 msgid "There are no logs for this transaction."
 msgstr ""
 
@@ -933,7 +935,7 @@ msgid "Top Accounts - %{subnetwork} Explorer"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction_log/index.html.eex:26
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:77
 msgid "Topics"
 msgstr ""
 
@@ -1022,7 +1024,7 @@ msgid "Unique Token"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:200
+#: lib/block_scout_web/templates/transaction/overview.html.eex:173
 msgid "Used"
 msgstr ""
 
@@ -1043,7 +1045,7 @@ msgid "Validations"
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:182
+#: lib/block_scout_web/templates/transaction/overview.html.eex:155
 msgid "Value"
 msgstr ""
 
@@ -1170,7 +1172,7 @@ msgstr ""
 msgid "Reward"
 msgstr ""
 
-#, elixir-format, fuzzy
+#, elixir-format
 #: lib/block_scout_web/views/internal_transaction_view.ex:26
 msgid "Self-Destruct"
 msgstr ""
@@ -1227,20 +1229,13 @@ msgid "This API is provided for developers transitioning their applications from
 msgstr ""
 
 #, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:153
+#: lib/block_scout_web/templates/transaction/overview.html.eex:128
 msgid "Raw Input"
 msgstr ""
 
-#, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:156
-msgid "Show Raw Input"
-msgstr ""
-
 #, elixir-format
 #: lib/block_scout_web/templates/transaction/overview.html.eex:130
-#: lib/block_scout_web/templates/transaction/overview.html.eex:140
-#: lib/block_scout_web/templates/transaction/overview.html.eex:164
-msgid "copy"
+msgid "Show Raw Input"
 msgstr ""
 
 #, elixir-format
@@ -1322,3 +1317,29 @@ msgstr ""
 #: lib/block_scout_web/views/internal_transaction_view.ex:24
 msgid "Static Call"
 msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:26
+msgid "Decoded"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:53
+msgid "Indexed?"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:118
+msgid "Show Raw Data"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:80
+msgid "Show Raw Topics"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/transaction/overview.html.eex:104
+#: lib/block_scout_web/templates/transaction_log/index.html.eex:52
+msgid "Type"
+msgstr ""

From ee3c1b3d346881042d1b4231ee82bc738f88924b Mon Sep 17 00:00:00 2001
From: zachdaniel 
Date: Mon, 19 Nov 2018 15:50:30 -0500
Subject: [PATCH 04/20] fix: handle case where contract is not verified

---
 .../templates/transaction_log/index.html.eex                | 2 ++
 apps/explorer/lib/explorer/chain/log.ex                     | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
index 7f8d7066c4..a89eb44f0c 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
@@ -71,6 +71,8 @@
                         
                     <% end %>
                     
+                  <% _ -> %>
+                    <%= nil %>
                 <% end %>
 
               
diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index f97a24b378..4a98535125 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -104,14 +104,14 @@ defmodule Explorer.Chain.Log do @doc """ Decode transaction log data. """ - def decode(log, transaction) do - abi = transaction.to_address.smart_contract.abi - + def decode(log, %Transaction{to_address: nil}), do: {:error, :no_to_address} + def decode(log, %Transaction{to_address: %{smart_contract: %{abi: abi}}}) when not is_nil(abi) do with {:ok, selector, mapping} <- find_and_decode(abi, log), identifier <- Base.encode16(selector.method_id, case: :lower), text <- function_call(selector.function, mapping), do: {:ok, identifier, text, mapping} end + def decode(_log, _transaction), do: {:error, :contract_not_verified} defp find_and_decode(abi, log) do with {selector, mapping} <- From 8a1b408f8e803ccae4f968730ed7b16344ae9e01 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 15:51:55 -0500 Subject: [PATCH 05/20] chore: fix unused var warning --- apps/explorer/lib/explorer/chain/log.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index 4a98535125..63fd231da9 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -104,7 +104,7 @@ defmodule Explorer.Chain.Log do @doc """ Decode transaction log data. """ - def decode(log, %Transaction{to_address: nil}), do: {:error, :no_to_address} + def decode(_log, %Transaction{to_address: nil}), do: {:error, :no_to_address} def decode(log, %Transaction{to_address: %{smart_contract: %{abi: abi}}}) when not is_nil(abi) do with {:ok, selector, mapping} <- find_and_decode(abi, log), identifier <- Base.encode16(selector.method_id, case: :lower), From d76bb10f71ebbdaaabdf2b7cadc2ab1e6391f161 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 15:56:30 -0500 Subject: [PATCH 06/20] chore: gettext --- apps/block_scout_web/priv/gettext/default.pot | 12 ++++++------ .../priv/gettext/en/LC_MESSAGES/default.po | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 001eb26652..d9d3bde01b 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -357,7 +357,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/overview.html.eex:105 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:113 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:115 msgid "Data" msgstr "" @@ -601,7 +601,7 @@ msgstr "" #, elixir-format #: #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:140 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:142 msgid "Newer" msgstr "" @@ -823,7 +823,7 @@ msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:134 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:136 msgid "There are no logs for this transaction." msgstr "" @@ -935,7 +935,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:77 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:79 msgid "Topics" msgstr "" @@ -1329,12 +1329,12 @@ msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:118 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:120 msgid "Show Raw Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:80 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 msgid "Show Raw Topics" 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 0b267e4c22..e9648a1053 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 @@ -357,7 +357,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/overview.html.eex:105 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:113 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:115 msgid "Data" msgstr "" @@ -601,7 +601,7 @@ msgstr "" #, elixir-format #: #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:140 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:142 msgid "Newer" msgstr "" @@ -823,7 +823,7 @@ msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:134 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:136 msgid "There are no logs for this transaction." msgstr "" @@ -935,7 +935,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:77 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:79 msgid "Topics" msgstr "" @@ -1329,12 +1329,12 @@ msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:118 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:120 msgid "Show Raw Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:80 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 msgid "Show Raw Topics" msgstr "" From 7610adb155e86a8f072be4d884544f2333a59cb3 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 16:05:18 -0500 Subject: [PATCH 07/20] chore: resolve credo warnings --- .../lib/block_scout_web/views/abi_encoded_value_view.ex | 9 ++++++--- apps/explorer/lib/explorer/chain/log.ex | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex index a0b5e2bd61..28d649e1d0 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex @@ -7,10 +7,13 @@ defmodule BlockScoutWeb.ABIEncodedValueView do """ use BlockScoutWeb, :view + alias ABI.FunctionSelector + alias Phoenix.HTML + require Logger def value_html(type, value) do - decoded_type = ABI.FunctionSelector.decode_type(type) + decoded_type = FunctionSelector.decode_type(type) do_value_html(decoded_type, value) rescue @@ -21,7 +24,7 @@ defmodule BlockScoutWeb.ABIEncodedValueView do end def copy_text(type, value) do - decoded_type = ABI.FunctionSelector.decode_type(type) + decoded_type = FunctionSelector.decode_type(type) do_copy_text(decoded_type, value) rescue @@ -102,7 +105,7 @@ defmodule BlockScoutWeb.ABIEncodedValueView do hex(value) end - def base_value_html(_, value), do: Phoenix.HTML.html_escape(value) + def base_value_html(_, value), do: HTML.html_escape(value) defp hex(value), do: "0x" <> Base.encode16(value, case: :lower) end diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index 63fd231da9..46abe9f461 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -5,6 +5,7 @@ defmodule Explorer.Chain.Log do require Logger + alias ABI.Event alias Explorer.Chain.{Address, Data, Hash, Transaction} @required_attrs ~w(address_hash data index transaction_hash)a @@ -117,7 +118,7 @@ defmodule Explorer.Chain.Log do with {selector, mapping} <- abi |> ABI.parse_specification(include_events?: true) - |> ABI.Event.find_and_decode( + |> Event.find_and_decode( decode16!(log.first_topic), decode16!(log.second_topic), decode16!(log.third_topic), From 8dc75f29dbb8c27d39ddf0818287619761c384f5 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 16:06:03 -0500 Subject: [PATCH 08/20] chore: format --- apps/explorer/lib/explorer/chain/log.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index 46abe9f461..88f3829173 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -106,12 +106,14 @@ defmodule Explorer.Chain.Log do Decode transaction log data. """ def decode(_log, %Transaction{to_address: nil}), do: {:error, :no_to_address} + def decode(log, %Transaction{to_address: %{smart_contract: %{abi: abi}}}) when not is_nil(abi) do with {:ok, selector, mapping} <- find_and_decode(abi, log), identifier <- Base.encode16(selector.method_id, case: :lower), text <- function_call(selector.function, mapping), do: {:ok, identifier, text, mapping} end + def decode(_log, _transaction), do: {:error, :contract_not_verified} defp find_and_decode(abi, log) do From 63f7ca7f1dd1f7042901bbe84a5d8096a9f6712c Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 16:57:10 -0500 Subject: [PATCH 09/20] chore: improve test coverage --- apps/explorer/lib/explorer/chain/log.ex | 14 ++-- .../explorer/test/explorer/chain/log_test.exs | 64 +++++++++++++++++++ 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index 88f3829173..1d247bfe6b 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -107,8 +107,8 @@ defmodule Explorer.Chain.Log do """ def decode(_log, %Transaction{to_address: nil}), do: {:error, :no_to_address} - def decode(log, %Transaction{to_address: %{smart_contract: %{abi: abi}}}) when not is_nil(abi) do - with {:ok, selector, mapping} <- find_and_decode(abi, log), + def decode(log, transaction = %Transaction{to_address: %{smart_contract: %{abi: abi}}}) when not is_nil(abi) do + with {:ok, selector, mapping} <- find_and_decode(abi, log, transaction), identifier <- Base.encode16(selector.method_id, case: :lower), text <- function_call(selector.function, mapping), do: {:ok, identifier, text, mapping} @@ -116,8 +116,8 @@ defmodule Explorer.Chain.Log do def decode(_log, _transaction), do: {:error, :contract_not_verified} - defp find_and_decode(abi, log) do - with {selector, mapping} <- + defp find_and_decode(abi, log, transaction) do + with {selector, mapping} when selector != :error <- abi |> ABI.parse_specification(include_events?: true) |> Event.find_and_decode( @@ -128,10 +128,14 @@ defmodule Explorer.Chain.Log do log.data.bytes ) do {:ok, selector, mapping} + else + :error -> + {:error, :could_not_decode} end rescue _ -> - Logger.warn(fn -> ["Could not decode input data for log: ", Hash.to_iodata(log.hash)] end) + Logger.warn(fn -> ["Could not decode input data for log from transaction: ", Hash.to_iodata(transaction.hash)] end) + {:error, :could_not_decode} end diff --git a/apps/explorer/test/explorer/chain/log_test.exs b/apps/explorer/test/explorer/chain/log_test.exs index 38f264705a..28be44a1af 100644 --- a/apps/explorer/test/explorer/chain/log_test.exs +++ b/apps/explorer/test/explorer/chain/log_test.exs @@ -37,4 +37,68 @@ defmodule Explorer.Chain.LogTest do assert changeset.changes.first_topic === "ham" end end + + describe "decode/2" do + test "that a contract call transaction that has no verified contract returns a commensurate error" do + transaction = + :transaction + |> insert(to_address: insert(:contract_address)) + |> Repo.preload(to_address: :smart_contract) + + log = insert(:log, transaction: transaction) + + assert Log.decode(log, transaction) == {:error, :contract_not_verified} + end + + test "that a contract call transaction that has a verified contract returns the decoded input data" do + smart_contract = + insert(:smart_contract, + abi: [ + %{ + "anonymous" => false, + "inputs" => [ + %{"indexed" => true, "name" => "_from_human", "type" => "string"}, + %{"indexed" => false, "name" => "_number", "type" => "uint256"}, + %{"indexed" => true, "name" => "_belly", "type" => "bool"} + ], + "name" => "WantsPets", + "type" => "event" + } + ] + ) + + topic1 = "0x" <> Base.encode16(:keccakf1600.hash(:sha3_256, "WantsPets(string,uint256,bool)"), case: :lower) + topic2 = "0x" <> Base.encode16(:keccakf1600.hash(:sha3_256, "bob"), case: :lower) + topic3 = "0x0000000000000000000000000000000000000000000000000000000000000001" + data = "0x0000000000000000000000000000000000000000000000000000000000000000" + + to_address = insert(:address, smart_contract: smart_contract) + + transaction = + :transaction_to_verified_contract + |> insert(to_address: to_address) + |> Repo.preload(to_address: :smart_contract) + + log = + insert(:log, + transaction: transaction, + first_topic: topic1, + second_topic: topic2, + third_topic: topic3, + fourth_topic: nil, + data: data + ) + + assert Log.decode(log, transaction) == + {:ok, "eb9b3c4c", "WantsPets(string indexed _from_human, uint256 _number, bool indexed _belly)", + [ + {"_from_human", "string", true, + {:dynamic, + <<56, 228, 122, 123, 113, 157, 206, 99, 102, 42, 234, 244, 52, 64, 50, 111, 85, 27, 138, 126, 225, + 152, 206, 227, 92, 181, 213, 23, 242, 210, 150, 162>>}}, + {"_number", "uint256", false, 0}, + {"_belly", "bool", true, true} + ]} + end + end end From 3efb1b11b2ce27b501f776507e10bee4fb345797 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 19 Nov 2018 17:03:13 -0500 Subject: [PATCH 10/20] chore: dialyzer --- apps/explorer/lib/explorer/chain/log.ex | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index 1d247bfe6b..b2dc8ca639 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -117,7 +117,7 @@ defmodule Explorer.Chain.Log do def decode(_log, _transaction), do: {:error, :contract_not_verified} defp find_and_decode(abi, log, transaction) do - with {selector, mapping} when selector != :error <- + with {selector, mapping} <- abi |> ABI.parse_specification(include_events?: true) |> Event.find_and_decode( @@ -128,9 +128,6 @@ defmodule Explorer.Chain.Log do log.data.bytes ) do {:ok, selector, mapping} - else - :error -> - {:error, :could_not_decode} end rescue _ -> From a2f01eccae366db052f862a52f017ba274650a53 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 11:10:35 -0500 Subject: [PATCH 11/20] chore: refactor/clean up and improve visuals --- .../transaction/_decoded_input.html.eex | 57 ++++++++++++ .../templates/transaction/overview.html.eex | 93 ++++++------------- .../block_scout_web/views/transaction_view.ex | 2 + apps/block_scout_web/priv/gettext/default.pot | 91 ++++++++++++------ .../priv/gettext/en/LC_MESSAGES/default.po | 91 ++++++++++++------ 5 files changed, 212 insertions(+), 122 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex new file mode 100644 index 0000000000..2391747dd4 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex @@ -0,0 +1,57 @@ +
+
+

<%= gettext "Input" %>

+ + <%= case @decoded_input_data do %> + <% {:error, :contract_not_verified} -> %> +
+ <%= gettext "To see decoded input data, the contract must be verified." %> + <%= case @transaction do %> + <% %{to_address: %{hash: hash}} -> %> + <%= gettext "Verify the contract " %><%= gettext "here" %> + <% _ -> %> + <%= nil %> + <% end %> +
+ <% {:ok, method_id, text, mapping} -> %> + " class="table thead-light table-bordered table-responsive transaction-info-table"> + + + + + + + + +
<%= gettext "Method Id" %>0x<%= method_id %>
Call<%= text %>
+ + " class="table thead-light table-bordered table-responsive"> + + + + + + + <%= for {name, type, value} <- mapping do %> + + + + + + + <% end %> +
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Data" %>
+ <% copy_text = BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) %> + + <%= name %><%= type %> +
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+
+ <% _ -> %> +
+ <%= gettext "Failed to decode input data." %> +
+ <% end %> +
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index 23008b60c8..8fef7e3088 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -1,4 +1,5 @@ <% block = @transaction.block %> +<% decoded_input_data = decoded_input_data(@transaction) %>
@@ -74,75 +75,29 @@ - -

<%= gettext "Input" %>

- <%= case decoded_input_data(@transaction) do %> - <% {:error, :contract_not_verified} -> %> -
- To see decoded input data, the contract must be verified. -
- <% {:error, :could_not_decode} -> %> -
- Failed to decode input data. Some dynamic types are not currently supported. -
- <% {:ok, method_id, text, mapping} -> %> - - - - - - - - - -
Method Id0x<%= method_id %>
Call<%= text %>
- - - - - - - - - <%= for {name, type, value} <- mapping do %> - - - - - - - <% end %> -
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Data" %>
- <% copy_text = BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) %> - - <%= name %><%= type %> -
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
-
- <% _ -> %> - <%= nil %> - <% end %> - <%= unless @transaction.input.bytes in [<<>>, nil] do %> -

<%= gettext "Raw Input" %>

-
- -
-
- - +
+
<%= gettext "Raw Input" %>
+
+
+ +
+
+ + -
-
-                  <%= @transaction.input %>
-                
+
+
+                    <%= @transaction.input %>
+                  
+
-
+
+
<% end %>
@@ -185,4 +140,10 @@
+ +
+
+ <%= render BlockScoutWeb.TransactionView, "_decoded_input.html", Map.put(assigns, :decoded_input_data, decoded_input_data) %> +
+
diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index 6f630668b4..d307395f57 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -75,6 +75,8 @@ defmodule BlockScoutWeb.TransactionView do def decoded_input_data(transaction) do Transaction.decoded_input_data(transaction) + # {:error, :contract_not_verified} + # {:error, :could_not_decode} end @doc """ diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index d9d3bde01b..14c452a124 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -151,7 +151,7 @@ msgid "Block %{block_number} - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:59 +#: lib/block_scout_web/templates/transaction/overview.html.eex:60 msgid "Block Confirmations" msgstr "" @@ -166,7 +166,7 @@ msgid "Block Mined, awaiting import..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:45 +#: lib/block_scout_web/templates/transaction/overview.html.eex:46 msgid "Block Number" msgstr "" @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:131 +#: lib/block_scout_web/views/transaction_view.ex:133 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:130 +#: lib/block_scout_web/views/transaction_view.ex:132 msgid "Contract Creation" msgstr "" @@ -329,13 +329,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:9 -#: lib/block_scout_web/templates/transaction/overview.html.eex:10 +#: lib/block_scout_web/templates/transaction/overview.html.eex:11 msgid "Copy Transaction Hash" msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:9 -#: lib/block_scout_web/templates/transaction/overview.html.eex:10 +#: lib/block_scout_web/templates/transaction/overview.html.eex:11 msgid "Copy Txn Hash" msgstr "" @@ -355,7 +355,7 @@ msgid "Curl" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:105 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:33 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54 #: lib/block_scout_web/templates/transaction_log/index.html.eex:115 msgid "Data" @@ -407,7 +407,7 @@ msgstr "" #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:19 #: lib/block_scout_web/templates/transaction/_tile.html.eex:26 -#: lib/block_scout_web/templates/transaction/overview.html.eex:155 +#: lib/block_scout_web/templates/transaction/overview.html.eex:110 #: lib/block_scout_web/views/wei_helpers.ex:72 msgid "Ether" msgstr "" @@ -446,7 +446,7 @@ msgid "GET" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:168 +#: lib/block_scout_web/templates/transaction/overview.html.eex:123 msgid "Gas" msgstr "" @@ -490,7 +490,7 @@ msgid "Indexing Tokens" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:78 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:3 msgid "Input" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:180 +#: lib/block_scout_web/views/transaction_view.ex:182 msgid "Internal Transactions" msgstr "" @@ -527,7 +527,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:180 +#: lib/block_scout_web/templates/transaction/overview.html.eex:135 msgid "Limit" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:181 +#: lib/block_scout_web/views/transaction_view.ex:183 msgid "Logs" msgstr "" @@ -588,7 +588,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:29 -#: lib/block_scout_web/templates/transaction/overview.html.eex:103 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:31 #: lib/block_scout_web/templates/transaction_log/index.html.eex:51 msgid "Name" msgstr "" @@ -624,7 +624,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:69 -#: lib/block_scout_web/templates/transaction/overview.html.eex:66 +#: lib/block_scout_web/templates/transaction/overview.html.eex:67 msgid "Nonce" msgstr "" @@ -683,9 +683,9 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 -#: lib/block_scout_web/templates/transaction/overview.html.eex:54 +#: lib/block_scout_web/templates/transaction/overview.html.eex:55 #: lib/block_scout_web/views/transaction_view.ex:57 -#: lib/block_scout_web/views/transaction_view.ex:87 +#: lib/block_scout_web/views/transaction_view.ex:89 msgid "Pending" msgstr "" @@ -797,7 +797,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 #: lib/block_scout_web/templates/transaction/_tile.html.eex:29 -#: lib/block_scout_web/templates/transaction/overview.html.eex:71 +#: lib/block_scout_web/templates/transaction/overview.html.eex:72 msgid "TX Fee" msgstr "" @@ -863,7 +863,7 @@ msgid "There are no transfers for this Token." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:23 +#: lib/block_scout_web/templates/transaction/overview.html.eex:24 msgid "This transaction is pending confirmation." msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:129 +#: lib/block_scout_web/views/transaction_view.ex:131 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:179 +#: lib/block_scout_web/views/transaction_view.ex:181 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:132 +#: lib/block_scout_web/views/transaction_view.ex:134 msgid "Transaction" msgstr "" @@ -971,7 +971,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:14 -#: lib/block_scout_web/templates/transaction/overview.html.eex:15 +#: lib/block_scout_web/templates/transaction/overview.html.eex:16 msgid "Transaction Details" msgstr "" @@ -1024,7 +1024,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:173 +#: lib/block_scout_web/templates/transaction/overview.html.eex:128 msgid "Used" msgstr "" @@ -1045,7 +1045,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:155 +#: lib/block_scout_web/templates/transaction/overview.html.eex:110 msgid "Value" msgstr "" @@ -1229,12 +1229,12 @@ msgid "This API is provided for developers transitioning their applications from msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:128 +#: lib/block_scout_web/templates/transaction/overview.html.eex:80 msgid "Raw Input" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:130 +#: lib/block_scout_web/templates/transaction/overview.html.eex:83 msgid "Show Raw Input" msgstr "" @@ -1339,7 +1339,42 @@ msgid "Show Raw Topics" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:104 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:32 #: lib/block_scout_web/templates/transaction_log/index.html.eex:52 msgid "Type" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:19 +msgid "Method Id" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 +msgid "To see decoded input data, the contract must be verified." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:17 +msgid "Transaction Info" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:28 +msgid "Transaction Inputs" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +msgid "Verify the contract " +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +msgid "here" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 +msgid "Failed to decode input data." +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 e9648a1053..4889aea215 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 @@ -151,7 +151,7 @@ msgid "Block %{block_number} - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:59 +#: lib/block_scout_web/templates/transaction/overview.html.eex:60 msgid "Block Confirmations" msgstr "" @@ -166,7 +166,7 @@ msgid "Block Mined, awaiting import..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:45 +#: lib/block_scout_web/templates/transaction/overview.html.eex:46 msgid "Block Number" msgstr "" @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:131 +#: lib/block_scout_web/views/transaction_view.ex:133 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:130 +#: lib/block_scout_web/views/transaction_view.ex:132 msgid "Contract Creation" msgstr "" @@ -329,13 +329,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:9 -#: lib/block_scout_web/templates/transaction/overview.html.eex:10 +#: lib/block_scout_web/templates/transaction/overview.html.eex:11 msgid "Copy Transaction Hash" msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:9 -#: lib/block_scout_web/templates/transaction/overview.html.eex:10 +#: lib/block_scout_web/templates/transaction/overview.html.eex:11 msgid "Copy Txn Hash" msgstr "" @@ -355,7 +355,7 @@ msgid "Curl" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:105 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:33 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54 #: lib/block_scout_web/templates/transaction_log/index.html.eex:115 msgid "Data" @@ -407,7 +407,7 @@ msgstr "" #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:19 #: lib/block_scout_web/templates/transaction/_tile.html.eex:26 -#: lib/block_scout_web/templates/transaction/overview.html.eex:155 +#: lib/block_scout_web/templates/transaction/overview.html.eex:110 #: lib/block_scout_web/views/wei_helpers.ex:72 msgid "Ether" msgstr "POA" @@ -446,7 +446,7 @@ msgid "GET" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:168 +#: lib/block_scout_web/templates/transaction/overview.html.eex:123 msgid "Gas" msgstr "" @@ -490,7 +490,7 @@ msgid "Indexing Tokens" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:78 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:3 msgid "Input" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:180 +#: lib/block_scout_web/views/transaction_view.ex:182 msgid "Internal Transactions" msgstr "" @@ -527,7 +527,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:180 +#: lib/block_scout_web/templates/transaction/overview.html.eex:135 msgid "Limit" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:181 +#: lib/block_scout_web/views/transaction_view.ex:183 msgid "Logs" msgstr "" @@ -588,7 +588,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:29 -#: lib/block_scout_web/templates/transaction/overview.html.eex:103 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:31 #: lib/block_scout_web/templates/transaction_log/index.html.eex:51 msgid "Name" msgstr "" @@ -624,7 +624,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:69 -#: lib/block_scout_web/templates/transaction/overview.html.eex:66 +#: lib/block_scout_web/templates/transaction/overview.html.eex:67 msgid "Nonce" msgstr "" @@ -683,9 +683,9 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 -#: lib/block_scout_web/templates/transaction/overview.html.eex:54 +#: lib/block_scout_web/templates/transaction/overview.html.eex:55 #: lib/block_scout_web/views/transaction_view.ex:57 -#: lib/block_scout_web/views/transaction_view.ex:87 +#: lib/block_scout_web/views/transaction_view.ex:89 msgid "Pending" msgstr "" @@ -797,7 +797,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 #: lib/block_scout_web/templates/transaction/_tile.html.eex:29 -#: lib/block_scout_web/templates/transaction/overview.html.eex:71 +#: lib/block_scout_web/templates/transaction/overview.html.eex:72 msgid "TX Fee" msgstr "" @@ -863,7 +863,7 @@ msgid "There are no transfers for this Token." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:23 +#: lib/block_scout_web/templates/transaction/overview.html.eex:24 msgid "This transaction is pending confirmation." msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:129 +#: lib/block_scout_web/views/transaction_view.ex:131 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:179 +#: lib/block_scout_web/views/transaction_view.ex:181 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:132 +#: lib/block_scout_web/views/transaction_view.ex:134 msgid "Transaction" msgstr "" @@ -971,7 +971,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:14 -#: lib/block_scout_web/templates/transaction/overview.html.eex:15 +#: lib/block_scout_web/templates/transaction/overview.html.eex:16 msgid "Transaction Details" msgstr "" @@ -1024,7 +1024,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:173 +#: lib/block_scout_web/templates/transaction/overview.html.eex:128 msgid "Used" msgstr "" @@ -1045,7 +1045,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:155 +#: lib/block_scout_web/templates/transaction/overview.html.eex:110 msgid "Value" msgstr "" @@ -1229,12 +1229,12 @@ msgid "This API is provided for developers transitioning their applications from msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:128 +#: lib/block_scout_web/templates/transaction/overview.html.eex:80 msgid "Raw Input" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:130 +#: lib/block_scout_web/templates/transaction/overview.html.eex:83 msgid "Show Raw Input" msgstr "" @@ -1339,7 +1339,42 @@ msgid "Show Raw Topics" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:104 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:32 #: lib/block_scout_web/templates/transaction_log/index.html.eex:52 msgid "Type" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:19 +msgid "Method Id" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 +msgid "To see decoded input data, the contract must be verified." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:17 +msgid "Transaction Info" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:28 +msgid "Transaction Inputs" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +msgid "Verify the contract " +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +msgid "here" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 +msgid "Failed to decode input data." +msgstr "" From 8f05ada7f4a6770699031442a270d12d5209c38f Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 11:50:10 -0500 Subject: [PATCH 12/20] chore: cleanup, error handling, tests --- .../transaction/_decoded_input.html.eex | 22 ++++++++++--- .../templates/transaction_log/index.html.eex | 13 +++++--- .../views/abi_encoded_value_view.ex | 4 +++ apps/block_scout_web/priv/gettext/default.pot | 19 +++++++---- .../priv/gettext/en/LC_MESSAGES/default.po | 19 +++++++---- .../views/abi_encoded_value_view_test.exs | 33 +++++++++++++++++-- 6 files changed, 84 insertions(+), 26 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex index 2391747dd4..91a5ce1a2b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex @@ -35,15 +35,27 @@ <%= for {name, type, value} <- mapping do %> - <% copy_text = BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) %> - + <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> + <% :error -> %> + <%= nil %> + <% copy_text -> %> + + <% end %> <%= name %> <%= type %> -
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+ <%= case BlockScoutWeb.ABIEncodedValueView.value_html(type, value) do %> + <% :error -> %> +
+ <%= gettext "Error rendering value" %> +
+ <% value -> %> +
<%= value %>
+ <% end %> + <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex index a89eb44f0c..c4bb03a252 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex @@ -56,11 +56,14 @@ <%= for {name, type, indexed?, value} <- mapping do %> - <% copy_text = BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) %> - - + <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> + <% :error -> %> + <%= nil %> + <% copy_text -> %> + + <% end %> <%= name %> <%= type %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex index 28d649e1d0..a2ff2a4db2 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex @@ -21,6 +21,8 @@ defmodule BlockScoutWeb.ABIEncodedValueView do Logger.warn(fn -> ["Error determining value html for #{inspect(type)}: ", Exception.format(:error, exception)] end) + + :error end def copy_text(type, value) do @@ -32,6 +34,8 @@ defmodule BlockScoutWeb.ABIEncodedValueView do Logger.warn(fn -> ["Error determining copy text for #{inspect(type)}: ", Exception.format(:error, exception)] end) + + :error end def do_copy_text({:bytes, _type}, value) do diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 14c452a124..4ba1db9e70 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -357,7 +357,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:33 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:115 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:118 msgid "Data" msgstr "" @@ -601,7 +601,7 @@ msgstr "" #, elixir-format #: #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:142 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:145 msgid "Newer" msgstr "" @@ -823,7 +823,7 @@ msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:136 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:139 msgid "There are no logs for this transaction." msgstr "" @@ -935,7 +935,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:79 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 msgid "Topics" msgstr "" @@ -1329,12 +1329,12 @@ msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:120 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:123 msgid "Show Raw Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:85 msgid "Show Raw Topics" msgstr "" @@ -1375,6 +1375,11 @@ msgid "here" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:65 msgid "Failed to decode input data." msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 +msgid "Error rendering value" +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 4889aea215..6510ad675e 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 @@ -357,7 +357,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:33 #: lib/block_scout_web/templates/transaction_log/index.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:115 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:118 msgid "Data" msgstr "" @@ -601,7 +601,7 @@ msgstr "" #, elixir-format #: #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:142 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:145 msgid "Newer" msgstr "" @@ -823,7 +823,7 @@ msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:136 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:139 msgid "There are no logs for this transaction." msgstr "" @@ -935,7 +935,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:79 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 msgid "Topics" msgstr "" @@ -1329,12 +1329,12 @@ msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:120 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:123 msgid "Show Raw Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:85 msgid "Show Raw Topics" msgstr "" @@ -1375,6 +1375,11 @@ msgid "here" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:65 msgid "Failed to decode input data." msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 +msgid "Error rendering value" +msgstr "" diff --git a/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs index d6b5060347..c095bb4de4 100644 --- a/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/abi_encoded_value_view_test.exs @@ -6,6 +6,13 @@ defmodule BlockScoutWeb.ABIEncodedValueViewTest do defp value_html(type, value) do type |> ABIEncodedValueView.value_html(value) + |> case do + :error -> + raise "failed to generate html" + + other -> + other + end |> Phoenix.HTML.Safe.to_iodata() |> IO.iodata_to_binary() end @@ -13,6 +20,13 @@ defmodule BlockScoutWeb.ABIEncodedValueViewTest do defp copy_text(type, value) do type |> ABIEncodedValueView.copy_text(value) + |> case do + :error -> + raise "failed to generate copy text" + + other -> + other + end |> Phoenix.HTML.Safe.to_iodata() |> IO.iodata_to_binary() end @@ -75,7 +89,11 @@ defmodule BlockScoutWeb.ABIEncodedValueViewTest do address_bytes = "0x0000000000000000000000000000000000000000" |> String.trim_leading("0x") |> Base.decode16!() - assert value_html("address[]", [address_bytes, address_bytes, address_bytes, address_bytes]) == expected + assert value_html("address[4]", [address_bytes, address_bytes, address_bytes, address_bytes]) == expected + end + + test "it renders :dynamic values as bytes" do + assert value_html("uint", {:dynamic, <<1>>}) == "0x01" end end @@ -88,7 +106,18 @@ defmodule BlockScoutWeb.ABIEncodedValueViewTest do end test "it skips the formatting when copying lists" do - assert copy_text("uint[]", [1, 2, 3, 4]) == "[1, 2, 3, 4]" + assert copy_text("uint[4]", [1, 2, 3, 4]) == "[1, 2, 3, 4]" + end + + test "it copies bytes as their hex representation" do + hex = "0xffffff" + bytes = hex |> String.trim_leading("0x") |> Base.decode16!(case: :lower) + + assert copy_text("bytes", bytes) == hex + end + + test "it copies :dynamic values as bytes" do + assert copy_text("uint", {:dynamic, <<1>>}) == "0x01" end end end From 705d7fb2a86080230eac3abea43b95c1a257e245 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 15:00:06 -0500 Subject: [PATCH 13/20] chore: hide decoded input for transfers/contract creations --- .../templates/transaction/overview.html.eex | 13 +++++---- .../block_scout_web/views/transaction_view.ex | 10 +++++++ apps/block_scout_web/priv/gettext/default.pot | 28 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 28 +++++++++---------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index 8fef7e3088..77663a0cec 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -75,7 +75,7 @@ - <%= unless @transaction.input.bytes in [<<>>, nil] do %> + <%= unless value_transfer?(@transaction) do %>
<%= gettext "Raw Input" %>
@@ -141,9 +141,12 @@ -
-
- <%= render BlockScoutWeb.TransactionView, "_decoded_input.html", Map.put(assigns, :decoded_input_data, decoded_input_data) %> + <%= unless should_decode?(@transaction) do %> +
+
+ <%= render BlockScoutWeb.TransactionView, "_decoded_input.html", Map.put(assigns, :decoded_input_data, decoded_input_data) %> +
-
+ <% end %> + diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index d307395f57..c007cdc517 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -20,6 +20,12 @@ defmodule BlockScoutWeb.TransactionView do def block_timestamp(%Transaction{block_number: nil, inserted_at: time}), do: time def block_timestamp(%Transaction{block: %Block{timestamp: time}}), do: time + def value_transfer?(%Transaction{input: %{bytes: bytes}}) when bytes in [<<>>, nil] do + true + end + + def value_transfer?(_), do: false + def confirmations(%Transaction{block: block}, named_arguments) when is_list(named_arguments) do case block do nil -> 0 @@ -73,6 +79,10 @@ defmodule BlockScoutWeb.TransactionView do Cldr.Number.to_string!(gas) end + def should_decode?(transaction) do + contract_creation?(transaction) || value_transfer?(transaction) + end + def decoded_input_data(transaction) do Transaction.decoded_input_data(transaction) # {:error, :contract_not_verified} diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 4ba1db9e70..d07837a1fd 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -56,7 +56,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:58 +#: lib/block_scout_web/views/transaction_view.ex:63 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:133 +#: lib/block_scout_web/views/transaction_view.ex:142 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:132 +#: lib/block_scout_web/views/transaction_view.ex:141 msgid "Contract Creation" msgstr "" @@ -394,12 +394,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:62 +#: lib/block_scout_web/views/transaction_view.ex:67 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:60 +#: lib/block_scout_web/views/transaction_view.ex:65 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:182 +#: lib/block_scout_web/views/transaction_view.ex:191 msgid "Internal Transactions" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:183 +#: lib/block_scout_web/views/transaction_view.ex:192 msgid "Logs" msgstr "" @@ -547,7 +547,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:49 +#: lib/block_scout_web/views/transaction_view.ex:54 msgid "Max of" msgstr "" @@ -684,8 +684,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 -#: lib/block_scout_web/views/transaction_view.ex:57 -#: lib/block_scout_web/views/transaction_view.ex:89 +#: lib/block_scout_web/views/transaction_view.ex:62 +#: lib/block_scout_web/views/transaction_view.ex:98 msgid "Pending" msgstr "" @@ -790,7 +790,7 @@ msgid "Showing 250 addresses of" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:59 +#: lib/block_scout_web/views/transaction_view.ex:64 msgid "Success" msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:131 +#: lib/block_scout_web/views/transaction_view.ex:140 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:181 +#: lib/block_scout_web/views/transaction_view.ex:190 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:134 +#: lib/block_scout_web/views/transaction_view.ex:143 msgid "Transaction" 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 6510ad675e..0f0e2896bd 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 @@ -56,7 +56,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:58 +#: lib/block_scout_web/views/transaction_view.ex:63 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:133 +#: lib/block_scout_web/views/transaction_view.ex:142 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:132 +#: lib/block_scout_web/views/transaction_view.ex:141 msgid "Contract Creation" msgstr "" @@ -394,12 +394,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:62 +#: lib/block_scout_web/views/transaction_view.ex:67 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:60 +#: lib/block_scout_web/views/transaction_view.ex:65 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:182 +#: lib/block_scout_web/views/transaction_view.ex:191 msgid "Internal Transactions" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:183 +#: lib/block_scout_web/views/transaction_view.ex:192 msgid "Logs" msgstr "" @@ -547,7 +547,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:49 +#: lib/block_scout_web/views/transaction_view.ex:54 msgid "Max of" msgstr "" @@ -684,8 +684,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 -#: lib/block_scout_web/views/transaction_view.ex:57 -#: lib/block_scout_web/views/transaction_view.ex:89 +#: lib/block_scout_web/views/transaction_view.ex:62 +#: lib/block_scout_web/views/transaction_view.ex:98 msgid "Pending" msgstr "" @@ -790,7 +790,7 @@ msgid "Showing 250 addresses of" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:59 +#: lib/block_scout_web/views/transaction_view.ex:64 msgid "Success" msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:131 +#: lib/block_scout_web/views/transaction_view.ex:140 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:181 +#: lib/block_scout_web/views/transaction_view.ex:190 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:134 +#: lib/block_scout_web/views/transaction_view.ex:143 msgid "Transaction" msgstr "" From 67a635df3e3fe76220095e384693496c5968e8ad Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 15:08:16 -0500 Subject: [PATCH 14/20] chore: gettext --- apps/block_scout_web/priv/gettext/default.pot | 28 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index d07837a1fd..26dd449b51 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -56,7 +56,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:63 +#: lib/block_scout_web/views/transaction_view.ex:64 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:142 +#: lib/block_scout_web/views/transaction_view.ex:143 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:141 +#: lib/block_scout_web/views/transaction_view.ex:142 msgid "Contract Creation" msgstr "" @@ -394,12 +394,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:67 +#: lib/block_scout_web/views/transaction_view.ex:68 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:65 +#: lib/block_scout_web/views/transaction_view.ex:66 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:191 +#: lib/block_scout_web/views/transaction_view.ex:192 msgid "Internal Transactions" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:192 +#: lib/block_scout_web/views/transaction_view.ex:193 msgid "Logs" msgstr "" @@ -547,7 +547,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:54 +#: lib/block_scout_web/views/transaction_view.ex:55 msgid "Max of" msgstr "" @@ -684,8 +684,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 -#: lib/block_scout_web/views/transaction_view.ex:62 -#: lib/block_scout_web/views/transaction_view.ex:98 +#: lib/block_scout_web/views/transaction_view.ex:63 +#: lib/block_scout_web/views/transaction_view.ex:99 msgid "Pending" msgstr "" @@ -790,7 +790,7 @@ msgid "Showing 250 addresses of" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:64 +#: lib/block_scout_web/views/transaction_view.ex:65 msgid "Success" msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:140 +#: lib/block_scout_web/views/transaction_view.ex:141 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:190 +#: lib/block_scout_web/views/transaction_view.ex:191 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:143 +#: lib/block_scout_web/views/transaction_view.ex:144 msgid "Transaction" 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 0f0e2896bd..dbc5e1ded2 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 @@ -56,7 +56,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:63 +#: lib/block_scout_web/views/transaction_view.ex:64 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:142 +#: lib/block_scout_web/views/transaction_view.ex:143 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:141 +#: lib/block_scout_web/views/transaction_view.ex:142 msgid "Contract Creation" msgstr "" @@ -394,12 +394,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:67 +#: lib/block_scout_web/views/transaction_view.ex:68 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:65 +#: lib/block_scout_web/views/transaction_view.ex:66 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:191 +#: lib/block_scout_web/views/transaction_view.ex:192 msgid "Internal Transactions" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:192 +#: lib/block_scout_web/views/transaction_view.ex:193 msgid "Logs" msgstr "" @@ -547,7 +547,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:54 +#: lib/block_scout_web/views/transaction_view.ex:55 msgid "Max of" msgstr "" @@ -684,8 +684,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 -#: lib/block_scout_web/views/transaction_view.ex:62 -#: lib/block_scout_web/views/transaction_view.ex:98 +#: lib/block_scout_web/views/transaction_view.ex:63 +#: lib/block_scout_web/views/transaction_view.ex:99 msgid "Pending" msgstr "" @@ -790,7 +790,7 @@ msgid "Showing 250 addresses of" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:64 +#: lib/block_scout_web/views/transaction_view.ex:65 msgid "Success" msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:140 +#: lib/block_scout_web/views/transaction_view.ex:141 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:190 +#: lib/block_scout_web/views/transaction_view.ex:191 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:143 +#: lib/block_scout_web/views/transaction_view.ex:144 msgid "Transaction" msgstr "" From 7d5fe1eaade1ad21b6c4433b783417d95463f629 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 15:41:16 -0500 Subject: [PATCH 16/20] chore: remove comments --- .../lib/block_scout_web/views/transaction_view.ex | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index c007cdc517..3fc4ee279e 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -85,8 +85,6 @@ defmodule BlockScoutWeb.TransactionView do def decoded_input_data(transaction) do Transaction.decoded_input_data(transaction) - # {:error, :contract_not_verified} - # {:error, :could_not_decode} end @doc """ From fcc7d70b2b32826d6f481e7e14649d46a916624d Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 15:47:47 -0500 Subject: [PATCH 17/20] chore: gettext --- apps/block_scout_web/priv/gettext/default.pot | 16 ++++++++-------- .../priv/gettext/en/LC_MESSAGES/default.po | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 26dd449b51..8dad01d4e5 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:143 +#: lib/block_scout_web/views/transaction_view.ex:141 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:142 +#: lib/block_scout_web/views/transaction_view.ex:140 msgid "Contract Creation" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:192 +#: lib/block_scout_web/views/transaction_view.ex:190 msgid "Internal Transactions" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:193 +#: lib/block_scout_web/views/transaction_view.ex:191 msgid "Logs" msgstr "" @@ -685,7 +685,7 @@ msgstr "" #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 #: lib/block_scout_web/views/transaction_view.ex:63 -#: lib/block_scout_web/views/transaction_view.ex:99 +#: lib/block_scout_web/views/transaction_view.ex:97 msgid "Pending" msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:141 +#: lib/block_scout_web/views/transaction_view.ex:139 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:191 +#: lib/block_scout_web/views/transaction_view.ex:189 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:144 +#: lib/block_scout_web/views/transaction_view.ex:142 msgid "Transaction" 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 dbc5e1ded2..9c8554adb9 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 @@ -283,12 +283,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:143 +#: lib/block_scout_web/views/transaction_view.ex:141 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:142 +#: lib/block_scout_web/views/transaction_view.ex:140 msgid "Contract Creation" msgstr "" @@ -509,7 +509,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:213 -#: lib/block_scout_web/views/transaction_view.ex:192 +#: lib/block_scout_web/views/transaction_view.ex:190 msgid "Internal Transactions" msgstr "" @@ -535,7 +535,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:193 +#: lib/block_scout_web/views/transaction_view.ex:191 msgid "Logs" msgstr "" @@ -685,7 +685,7 @@ msgstr "" #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 #: lib/block_scout_web/views/transaction_view.ex:63 -#: lib/block_scout_web/views/transaction_view.ex:99 +#: lib/block_scout_web/views/transaction_view.ex:97 msgid "Pending" msgstr "" @@ -901,7 +901,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:141 +#: lib/block_scout_web/views/transaction_view.ex:139 msgid "Token Transfer" msgstr "" @@ -913,7 +913,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:191 +#: lib/block_scout_web/views/transaction_view.ex:189 msgid "Token Transfers" msgstr "" @@ -955,7 +955,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:144 +#: lib/block_scout_web/views/transaction_view.ex:142 msgid "Transaction" msgstr "" From 743f446e48efee17cf7b594c0297e1466122e0f2 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 16:01:53 -0500 Subject: [PATCH 18/20] chore: do_copy_text -> defp --- .../block_scout_web/views/abi_encoded_value_view.ex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex index a2ff2a4db2..f049a0cfd9 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex @@ -38,15 +38,15 @@ defmodule BlockScoutWeb.ABIEncodedValueView do :error end - def do_copy_text({:bytes, _type}, value) do + defp do_copy_text({:bytes, _type}, value) do hex(value) end - def do_copy_text({:array, type, _}, value) do + defp do_copy_text({:array, type, _}, value) do do_copy_text({:array, type}, value) end - def do_copy_text({:array, type}, value) do + defp do_copy_text({:array, type}, value) do values = value |> Enum.map(&do_copy_text(type, &1)) @@ -55,15 +55,15 @@ defmodule BlockScoutWeb.ABIEncodedValueView do ~E|[<%= values %>]| end - def do_copy_text(_, {:dynamic, value}) do + defp do_copy_text(_, {:dynamic, value}) do hex(value) end - def do_copy_text(type, value) when type in [:bytes, :address] do + defp do_copy_text(type, value) when type in [:bytes, :address] do hex(value) end - def do_copy_text(_type, value) do + defp do_copy_text(_type, value) do to_string(value) end From f82d40c86687cbf5017f94f4eeae777153c8f923 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 20 Nov 2018 16:37:11 -0500 Subject: [PATCH 19/20] chore: privatize function and fix indentation --- .../templates/transaction/_decoded_input.html.eex | 8 ++++---- .../lib/block_scout_web/views/abi_encoded_value_view.ex | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex index 91a5ce1a2b..cc0c35273d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex @@ -7,10 +7,10 @@
<%= gettext "To see decoded input data, the contract must be verified." %> <%= case @transaction do %> - <% %{to_address: %{hash: hash}} -> %> - <%= gettext "Verify the contract " %><%= gettext "here" %> - <% _ -> %> - <%= nil %> + <% %{to_address: %{hash: hash}} -> %> + <%= gettext "Verify the contract " %><%= gettext "here" %> + <% _ -> %> + <%= nil %> <% end %>
<% {:ok, method_id, text, mapping} -> %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex index f049a0cfd9..31c4aa1140 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/abi_encoded_value_view.ex @@ -95,21 +95,21 @@ defmodule BlockScoutWeb.ABIEncodedValueView do [spacing, base_value_html(type, value)] end - def base_value_html(_, {:dynamic, value}) do + defp base_value_html(_, {:dynamic, value}) do hex(value) end - def base_value_html(:address, value) do + defp base_value_html(:address, value) do address = hex(value) ~E|<%= address %>| end - def base_value_html(:bytes, value) do + defp base_value_html(:bytes, value) do hex(value) end - def base_value_html(_, value), do: HTML.html_escape(value) + defp base_value_html(_, value), do: HTML.html_escape(value) defp hex(value), do: "0x" <> Base.encode16(value, case: :lower) end From 168bb12fc3f497d492067c3e709f73164811fd70 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Wed, 21 Nov 2018 09:53:49 -0500 Subject: [PATCH 20/20] chore: gettext --- .../transaction/_decoded_input.html.eex | 2 +- .../templates/transaction_log/index.html.eex | 18 +++++--- apps/block_scout_web/priv/gettext/default.pot | 41 ++++++++++++++----- .../priv/gettext/en/LC_MESSAGES/default.po | 41 ++++++++++++++----- 4 files changed, 75 insertions(+), 27 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex index cc0c35273d..87cf28afd6 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input.html.eex @@ -39,7 +39,7 @@ <% :error -> %> <%= nil %> <% copy_text -> %> - <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex index c4bb03a252..e1862c1447 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex @@ -28,11 +28,17 @@ <%= case decode(log, @transaction) do %> <% {:error, :contract_not_verified} -> %>
- To see decoded input data, the contract must be verified. + <%= gettext "To see decoded input data, the contract must be verified." %> + <%= case @transaction do %> + <% %{to_address: %{hash: hash}} -> %> + <%= gettext "Verify the contract " %><%= gettext "here" %> + <% _ -> %> + <%= nil %> + <% end %>
<% {:error, :could_not_decode} -> %>
- Failed to decode log data. + <%= gettext "Failed to decode log data." %>
<% {:ok, method_id, text, mapping} -> %> @@ -45,7 +51,7 @@
<%= text %>
- +
" class="table thead-light table-bordered table-responsive"> @@ -60,7 +66,7 @@ <% :error -> %> <%= nil %> <% copy_text -> %> - <% end %> @@ -85,7 +91,7 @@
- <%= unless is_nil(log.first_topic) do %> @@ -124,7 +130,7 @@
- <%= log.data %> diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 8dad01d4e5..fb0c863b6c 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -218,6 +218,8 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:82 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:84 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:92 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:94 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:133 msgid "Close" msgstr "" @@ -356,8 +358,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:33 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:118 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:60 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:124 msgid "Data" msgstr "" @@ -589,7 +591,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:29 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:51 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:57 msgid "Name" msgstr "" @@ -601,7 +603,7 @@ msgstr "" #, elixir-format #: #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:145 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:151 msgid "Newer" msgstr "" @@ -823,7 +825,7 @@ msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:139 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:145 msgid "There are no logs for this transaction." msgstr "" @@ -935,7 +937,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:88 msgid "Topics" msgstr "" @@ -1324,23 +1326,23 @@ msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:53 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:59 msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:123 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:129 msgid "Show Raw Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:85 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:91 msgid "Show Raw Topics" msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:32 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:52 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:58 msgid "Type" msgstr "" @@ -1351,6 +1353,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:31 msgid "To see decoded input data, the contract must be verified." msgstr "" @@ -1366,11 +1369,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:34 msgid "Verify the contract " msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:34 msgid "here" msgstr "" @@ -1383,3 +1388,19 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 msgid "Error rendering value" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:42 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:69 +msgid "Copy Value" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction_log/index.html.eex:41 +msgid "Failed to decode log data." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction_log/index.html.eex:54 +msgid "Log Data" +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 9c8554adb9..83fed0d3b1 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 @@ -218,6 +218,8 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:82 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:84 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:92 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:94 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:133 msgid "Close" msgstr "" @@ -356,8 +358,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:33 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:54 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:118 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:60 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:124 msgid "Data" msgstr "" @@ -589,7 +591,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:29 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:51 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:57 msgid "Name" msgstr "" @@ -601,7 +603,7 @@ msgstr "" #, elixir-format #: #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:23 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:145 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:151 msgid "Newer" msgstr "" @@ -823,7 +825,7 @@ msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:139 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:145 msgid "There are no logs for this transaction." msgstr "" @@ -935,7 +937,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:82 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:88 msgid "Topics" msgstr "" @@ -1324,23 +1326,23 @@ msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:53 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:59 msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:123 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:129 msgid "Show Raw Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:85 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:91 msgid "Show Raw Topics" msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:32 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:52 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:58 msgid "Type" msgstr "" @@ -1351,6 +1353,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:31 msgid "To see decoded input data, the contract must be verified." msgstr "" @@ -1366,11 +1369,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:34 msgid "Verify the contract " msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:34 msgid "here" msgstr "" @@ -1383,3 +1388,19 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:53 msgid "Error rendering value" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:42 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:69 +msgid "Copy Value" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction_log/index.html.eex:41 +msgid "Failed to decode log data." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction_log/index.html.eex:54 +msgid "Log Data" +msgstr ""
<%= gettext "Name" %>