Skip to content

Commit

Permalink
feat: allow decoding input as utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Feb 25, 2019
1 parent 292bbe7 commit 343a9bd
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 43 deletions.
1 change: 1 addition & 0 deletions apps/block_scout_web/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
10 changes: 10 additions & 0 deletions apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js
Original file line number Diff line number Diff line change
@@ -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())
})
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,37 @@
<dl class="row">
<dt class="col-sm-3 text-muted"><%= gettext "Raw Input" %></dt>
<dd class="col-sm-9">
<div class="raw-transaction-input">
<div class="transaction-input" id="tx-raw-input">
<button type="button" class="copy icon-link mb-1" data-toggle="tooltip" data-placement="top" data-clipboard-text="<%= @transaction.input %>" aria-label="Copy Value">
<i class="fas fa-clone"></i>
</button>
<div class="tile tile-muted">
<pre class="pre-scrollable pre-scrollable-shorty pre-wrap mb-0"><code><%= @transaction.input %></code></pre>
</div>
</div>

<div class="transaction-input" id="tx-utf8-input" style="display: none;">
<button type="button" class="copy icon-link mb-1" data-toggle="tooltip" data-placement="top" data-clipboard-text="<%= @transaction.input %>" aria-label="Copy Value">
<i class="fas fa-clone"></i>
</button>
<div class="tile tile-muted">
<pre class="pre-scrollable pre-scrollable-shorty pre-wrap mb-0">
<code><%= @transaction.input %></code>
</pre>
<pre class="pre-scrollable pre-scrollable-shorty pre-wrap mb-0"><code><%= @transaction.input.bytes %></code></pre>
</div>
</div>

<div class="dropdown pt-1">
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="tx-input-decoding-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= gettext("Hex (Default)") %>
</button>

<div class="dropdown-menu" aria-labelledby="transaction-input-decoding-button">
<a class="dropdown-item tx-input-dropdown" data-target="#tx-raw-input" id="tx-dropdown-raw">
<%= gettext("Hex (Default)") %>
</a>

<a class="dropdown-item tx-input-dropdown" data-target="#tx-utf8-input" id="tx-dropdown-utf8">
<%= gettext("UTF-8") %>
</a>
</div>
</div>
</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 30 additions & 19 deletions apps/block_scout_web/priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand All @@ -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 ""
Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand All @@ -513,15 +513,15 @@ 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 ""

#, elixir-format
#: 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 ""

Expand All @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand All @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

Expand All @@ -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 ""

Expand Down Expand Up @@ -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 ""
Loading

0 comments on commit 343a9bd

Please sign in to comment.