From 343a9bd083729196c73a1d8faea8315be678b289 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 25 Feb 2019 10:08:56 -0500 Subject: [PATCH] feat: allow decoding input as utf-8 --- apps/block_scout_web/assets/js/app.js | 1 + .../js/lib/transaction_input_dropdown.js | 10 ++++ .../templates/transaction/overview.html.eex | 30 +++++++++-- .../block_scout_web/views/transaction_view.ex | 3 ++ apps/block_scout_web/priv/gettext/default.pot | 49 +++++++++++------- .../priv/gettext/en/LC_MESSAGES/default.po | 51 +++++++++++-------- 6 files changed, 101 insertions(+), 43 deletions(-) create mode 100644 apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js diff --git a/apps/block_scout_web/assets/js/app.js b/apps/block_scout_web/assets/js/app.js index f00b84c17c..e01a7fcd7f 100644 --- a/apps/block_scout_web/assets/js/app.js +++ b/apps/block_scout_web/assets/js/app.js @@ -46,6 +46,7 @@ import './lib/stop_propagation' import './lib/token_balance_dropdown' import './lib/token_balance_dropdown_search' import './lib/token_transfers_toggle' +import './lib/transaction_input_dropdown' import './lib/async_listing_load' import './lib/tooltip' import './lib/try_api' diff --git a/apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js b/apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js new file mode 100644 index 0000000000..2c8d21d7a4 --- /dev/null +++ b/apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js @@ -0,0 +1,10 @@ +import $ from 'jquery' + +$('.tx-input-dropdown').click(function (e) { + var el = $(e.currentTarget) + var target = $(el.attr('data-target')) + + target.show() + target.siblings('.transaction-input').hide() + $('#tx-input-decoding-button').text(el.text()) +}) 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 a22dabc755..9acb212994 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 @@ -93,15 +93,37 @@
<%= gettext "Raw Input" %>
-
+
+
+
<%= @transaction.input %>
+
+
+ + +
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 dd9a988b83..14a20481b8 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 @@ -91,6 +91,9 @@ defmodule BlockScoutWeb.TransactionView do def contract_creation?(_), do: false + # def utf8_encode() do + # end + def fee(%Transaction{} = transaction) do {_, value} = Chain.fee(transaction, :wei) value diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 114e00bf53..ae553639bc 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:118 +#: lib/block_scout_web/views/transaction_view.ex:121 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -278,12 +278,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:195 +#: lib/block_scout_web/views/transaction_view.ex:198 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:194 +#: lib/block_scout_web/views/transaction_view.ex:197 msgid "Contract Creation" msgstr "" @@ -377,12 +377,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:125 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:123 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -392,7 +392,7 @@ msgstr "" #: lib/block_scout_web/templates/layout/app.html.eex:51 #: 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:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 #: lib/block_scout_web/views/wei_helpers.ex:72 msgid "Ether" msgstr "" @@ -431,7 +431,7 @@ msgid "GET" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:131 +#: lib/block_scout_web/templates/transaction/overview.html.eex:153 msgid "Gas" msgstr "" @@ -495,7 +495,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:270 -#: lib/block_scout_web/views/transaction_view.ex:248 +#: lib/block_scout_web/views/transaction_view.ex:251 msgid "Internal Transactions" msgstr "" @@ -513,7 +513,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:143 +#: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "Limit" msgstr "" @@ -521,7 +521,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:249 +#: lib/block_scout_web/views/transaction_view.ex:252 msgid "Logs" msgstr "" @@ -533,7 +533,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:109 +#: lib/block_scout_web/views/transaction_view.ex:112 msgid "Max of" msgstr "" @@ -662,8 +662,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:117 -#: lib/block_scout_web/views/transaction_view.ex:151 +#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:154 msgid "Pending" msgstr "" @@ -768,7 +768,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 -#: lib/block_scout_web/views/transaction_view.ex:119 +#: lib/block_scout_web/views/transaction_view.ex:122 msgid "Success" msgstr "" @@ -879,7 +879,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:193 +#: lib/block_scout_web/views/transaction_view.ex:196 msgid "Token Transfer" msgstr "" @@ -891,7 +891,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:247 +#: lib/block_scout_web/views/transaction_view.ex:250 msgid "Token Transfers" msgstr "" @@ -932,7 +932,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:196 +#: lib/block_scout_web/views/transaction_view.ex:199 msgid "Transaction" msgstr "" @@ -999,7 +999,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:136 +#: lib/block_scout_web/templates/transaction/overview.html.eex:158 msgid "Used" msgstr "" @@ -1020,7 +1020,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 msgid "Value" msgstr "" @@ -1642,3 +1642,14 @@ msgstr "" #: lib/block_scout_web/templates/transaction/overview.html.eex:85 msgid "Transaction Speed" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:116 +#: lib/block_scout_web/templates/transaction/overview.html.eex:121 +msgid "Hex (Default)" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:125 +msgid "UTF-8" +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 d010200547..31ed957db2 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 @@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:118 +#: lib/block_scout_web/views/transaction_view.ex:121 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -278,12 +278,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:195 +#: lib/block_scout_web/views/transaction_view.ex:198 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:194 +#: lib/block_scout_web/views/transaction_view.ex:197 msgid "Contract Creation" msgstr "" @@ -377,12 +377,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:125 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:123 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -392,7 +392,7 @@ msgstr "" #: lib/block_scout_web/templates/layout/app.html.eex:51 #: 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:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 #: lib/block_scout_web/views/wei_helpers.ex:72 msgid "Ether" msgstr "POA" @@ -431,7 +431,7 @@ msgid "GET" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:131 +#: lib/block_scout_web/templates/transaction/overview.html.eex:153 msgid "Gas" msgstr "" @@ -495,7 +495,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:270 -#: lib/block_scout_web/views/transaction_view.ex:248 +#: lib/block_scout_web/views/transaction_view.ex:251 msgid "Internal Transactions" msgstr "" @@ -513,7 +513,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:143 +#: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "Limit" msgstr "" @@ -521,7 +521,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:249 +#: lib/block_scout_web/views/transaction_view.ex:252 msgid "Logs" msgstr "" @@ -533,7 +533,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:109 +#: lib/block_scout_web/views/transaction_view.ex:112 msgid "Max of" msgstr "" @@ -662,8 +662,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:117 -#: lib/block_scout_web/views/transaction_view.ex:151 +#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:154 msgid "Pending" msgstr "" @@ -768,7 +768,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 -#: lib/block_scout_web/views/transaction_view.ex:119 +#: lib/block_scout_web/views/transaction_view.ex:122 msgid "Success" msgstr "" @@ -879,7 +879,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:193 +#: lib/block_scout_web/views/transaction_view.ex:196 msgid "Token Transfer" msgstr "" @@ -891,7 +891,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:247 +#: lib/block_scout_web/views/transaction_view.ex:250 msgid "Token Transfers" msgstr "" @@ -932,7 +932,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:196 +#: lib/block_scout_web/views/transaction_view.ex:199 msgid "Transaction" msgstr "" @@ -999,7 +999,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:136 +#: lib/block_scout_web/templates/transaction/overview.html.eex:158 msgid "Used" msgstr "" @@ -1020,7 +1020,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 msgid "Value" msgstr "" @@ -1638,7 +1638,18 @@ msgstr "" msgid "Transactions Sent" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/templates/transaction/overview.html.eex:85 msgid "Transaction Speed" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:116 +#: lib/block_scout_web/templates/transaction/overview.html.eex:121 +msgid "Hex (Default)" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:125 +msgid "UTF-8" +msgstr ""