Merge pull request #3834 from blockscout/vb-method-name-in-tx-tile

Method name in tx tile
pull/3870/head
Victor Baranov 4 years ago committed by GitHub
commit b40758e36f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 3
      apps/block_scout_web/assets/css/components/_label.scss
  3. 4
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex
  4. 12
      apps/block_scout_web/priv/gettext/default.pot
  5. 12
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  6. 32
      apps/explorer/lib/explorer/chain/transaction.ex

@ -1,6 +1,7 @@
## Current
### Features
- [#3834](https://github.com/blockscout/blockscout/pull/3834) - Method name in tx tile
- [#3792](https://github.com/blockscout/blockscout/pull/3792) - Cancel pending transaction
- [#3786](https://github.com/blockscout/blockscout/pull/3786) - Read contract: enable methods with StateMutability: pure
- [#3758](https://github.com/blockscout/blockscout/pull/3758) - Add pool metadata display/change to Staking DApp

@ -39,6 +39,9 @@
background: $secondary;
color: #fff;
}
&.method {
color: #1e2022;
}
&.from-dropdown {
margin-top: -3px;
}

@ -18,7 +18,11 @@
</div>
<!-- Content -->
<div class="col-md-7 col-lg-8 d-flex flex-column pr-2 pr-sm-2 pr-md-0">
<span>
<%= render "_link.html", transaction_hash: @transaction.hash %>
<% method_name = Transaction.get_method_name(@transaction) %>
<%= render BlockScoutWeb.FormView, "_tag.html", text: method_name, additional_classes: ["method", "ml-1"] %>
</span>
<span>
<%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %>
&rarr;

@ -633,7 +633,7 @@ msgstr ""
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:20
#: lib/block_scout_web/templates/layout/app.html.eex:33
#: 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/_tile.html.eex:33
#: lib/block_scout_web/templates/transaction/overview.html.eex:215
#: lib/block_scout_web/templates/transaction/overview.html.eex:268
#: lib/block_scout_web/views/wei_helpers.ex:78
@ -759,7 +759,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:38
#: lib/block_scout_web/templates/transaction/_tile.html.eex:72
#: lib/block_scout_web/templates/transaction/_tile.html.eex:76
msgid "IN"
msgstr ""
@ -777,7 +777,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:21
#: lib/block_scout_web/templates/transaction/_tile.html.eex:32
#: lib/block_scout_web/templates/transaction/_tile.html.eex:36
#: lib/block_scout_web/templates/transaction/overview.html.eex:118
msgid "TX Fee"
msgstr ""
@ -1104,7 +1104,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:36
#: lib/block_scout_web/templates/transaction/_tile.html.eex:68
#: lib/block_scout_web/templates/transaction/_tile.html.eex:72
msgid "OUT"
msgstr ""
@ -1610,12 +1610,12 @@ msgid "View Contract"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_tile.html.eex:53
#: lib/block_scout_web/templates/transaction/_tile.html.eex:57
msgid "View Less Transfers"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_tile.html.eex:52
#: lib/block_scout_web/templates/transaction/_tile.html.eex:56
msgid "View More Transfers"
msgstr ""

@ -633,7 +633,7 @@ msgstr ""
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:20
#: lib/block_scout_web/templates/layout/app.html.eex:33
#: 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/_tile.html.eex:33
#: lib/block_scout_web/templates/transaction/overview.html.eex:215
#: lib/block_scout_web/templates/transaction/overview.html.eex:268
#: lib/block_scout_web/views/wei_helpers.ex:78
@ -759,7 +759,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:38
#: lib/block_scout_web/templates/transaction/_tile.html.eex:72
#: lib/block_scout_web/templates/transaction/_tile.html.eex:76
msgid "IN"
msgstr ""
@ -777,7 +777,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:21
#: lib/block_scout_web/templates/transaction/_tile.html.eex:32
#: lib/block_scout_web/templates/transaction/_tile.html.eex:36
#: lib/block_scout_web/templates/transaction/overview.html.eex:118
msgid "TX Fee"
msgstr ""
@ -1104,7 +1104,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:36
#: lib/block_scout_web/templates/transaction/_tile.html.eex:68
#: lib/block_scout_web/templates/transaction/_tile.html.eex:72
msgid "OUT"
msgstr ""
@ -1610,12 +1610,12 @@ msgid "View Contract"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_tile.html.eex:53
#: lib/block_scout_web/templates/transaction/_tile.html.eex:57
msgid "View Less Transfers"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_tile.html.eex:52
#: lib/block_scout_web/templates/transaction/_tile.html.eex:56
msgid "View More Transfers"
msgstr ""

@ -476,6 +476,38 @@ defmodule Explorer.Chain.Transaction do
do: {:ok, identifier, text, mapping}
end
def get_method_name(
%__MODULE__{
input: %{bytes: <<method_id::binary-size(4), _::binary>>}
} = transaction
) do
case Transaction.decoded_input_data(%__MODULE__{
to_address: %{smart_contract: nil},
input: transaction.input,
hash: transaction.hash
}) do
{:error, :contract_not_verified, [{:ok, _method_id, decoded_func, _}]} ->
parse_method_name(decoded_func)
{:error, :contract_not_verified, []} ->
"0x" <> Base.encode16(method_id, case: :lower)
_ ->
"Transfer"
end
end
def get_method_name(_), do: "Transfer"
defp parse_method_name(method_desc) do
method_desc
|> String.split("(")
|> Enum.at(0)
|> upcase_first
end
defp upcase_first(<<first::utf8, rest::binary>>), do: String.upcase(<<first::utf8>>) <> rest
defp function_call(name, mapping) do
text =
mapping

Loading…
Cancel
Save