From c8618796810b34097f75dad8247db099c5020b37 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Wed, 27 Feb 2019 13:29:08 -0500 Subject: [PATCH] feat: remove dropped/replaced transactions in pending transactions list --- .../transaction/_pending_tile.html.eex | 3 +- .../templates/transaction/_tile.html.eex | 3 +- .../templates/transaction/overview.html.eex | 7 +- .../block_scout_web/views/transaction_view.ex | 10 ++- apps/block_scout_web/priv/gettext/default.pot | 81 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 81 +++++++++---------- .../pending_transaction_controller_test.exs | 14 ++++ .../views/transaction_view_test.exs | 15 ++-- apps/explorer/lib/explorer/chain.ex | 2 + 9 files changed, 120 insertions(+), 96 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_pending_tile.html.eex index f11c1707e4..f89a393501 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_pending_tile.html.eex @@ -1,8 +1,9 @@ +<% status = BlockScoutWeb.TransactionView.transaction_status(@transaction) %>
<%= BlockScoutWeb.TransactionView.transaction_display_type(@transaction) %> -
<%= BlockScoutWeb.TransactionView.formatted_status(@transaction) %>
+
<%= BlockScoutWeb.TransactionView.formatted_status(status) %>
<%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @transaction.hash %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex index 1beae0a073..a254d02c04 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex @@ -1,3 +1,4 @@ +<% status = transaction_status(@transaction) %>
@@ -11,7 +12,7 @@
<% end %> - <%= formatted_status(@transaction) %> + <%= formatted_status(status) %>
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 9acb212994..373f74c443 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,5 +1,6 @@ <% block = @transaction.block %> <% decoded_input_data = decoded_input_data(@transaction) %> +<% status = transaction_status(@transaction) %>
@@ -15,7 +16,7 @@

<%= gettext "Transaction Details" %>

- <%= if !block do %> + <%= if status == :pending do %>
@@ -33,7 +34,7 @@
<%= BlockScoutWeb.TransactionView.transaction_display_type(@transaction) %> - <%= BlockScoutWeb.TransactionView.formatted_status(@transaction) %> + <%= BlockScoutWeb.TransactionView.formatted_status(status) %> <%= if block do %> @@ -52,7 +53,7 @@ to: block_path(@conn, :show, block) ) %> <% else %> - <%= gettext "Pending" %> + <%= formatted_status(status) %> <% 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 14a20481b8..c80af00eea 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 @@ -113,10 +113,12 @@ defmodule BlockScoutWeb.TransactionView do end end - def formatted_status(transaction) do - transaction - |> Chain.transaction_to_status() - |> case do + def transaction_status(transaction) do + Chain.transaction_to_status(transaction) + end + + def formatted_status(status) do + case status do :pending -> gettext("Pending") :awaiting_internal_transactions -> gettext("(Awaiting internal transactions for status)") :success -> gettext("Success") diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index ae553639bc..7a3166af63 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:121 +#: lib/block_scout_web/views/transaction_view.ex:123 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -145,7 +145,7 @@ msgid "Block %{block_number} - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:60 +#: lib/block_scout_web/templates/transaction/overview.html.eex:61 msgid "Block Confirmations" msgstr "" @@ -160,7 +160,7 @@ msgid "Block Mined, awaiting import..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:46 +#: lib/block_scout_web/templates/transaction/overview.html.eex:47 msgid "Block Number" msgstr "" @@ -271,19 +271,19 @@ msgid "Contract Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:15 +#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:16 #: lib/block_scout_web/views/address_view.ex:35 #: lib/block_scout_web/views/address_view.ex:69 msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:198 +#: lib/block_scout_web/views/transaction_view.ex:200 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:197 +#: lib/block_scout_web/views/transaction_view.ex:199 msgid "Contract Creation" msgstr "" @@ -317,13 +317,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:9 -#: lib/block_scout_web/templates/transaction/overview.html.eex:11 +#: lib/block_scout_web/templates/transaction/overview.html.eex:12 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:11 +#: lib/block_scout_web/templates/transaction/overview.html.eex:12 msgid "Copy Txn Hash" msgstr "" @@ -377,12 +377,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:125 +#: lib/block_scout_web/views/transaction_view.ex:127 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:123 +#: lib/block_scout_web/views/transaction_view.ex:125 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -390,9 +390,9 @@ msgstr "" #: lib/block_scout_web/templates/address/_balance_card.html.eex:13 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16 #: 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:140 +#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:27 +#: lib/block_scout_web/templates/transaction/overview.html.eex:141 #: 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:153 +#: lib/block_scout_web/templates/transaction/overview.html.eex:154 msgid "Gas" msgstr "" @@ -467,7 +467,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:32 -#: lib/block_scout_web/templates/transaction/_tile.html.eex:46 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:47 msgid "IN" 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:251 +#: lib/block_scout_web/views/transaction_view.ex:253 msgid "Internal Transactions" msgstr "" @@ -513,7 +513,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:165 +#: lib/block_scout_web/templates/transaction/overview.html.eex:166 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:252 +#: lib/block_scout_web/views/transaction_view.ex:254 msgid "Logs" msgstr "" @@ -609,13 +609,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:71 -#: lib/block_scout_web/templates/transaction/overview.html.eex:67 +#: lib/block_scout_web/templates/transaction/overview.html.eex:68 msgid "Nonce" msgstr "" #, elixir-format #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:30 -#: lib/block_scout_web/templates/transaction/_tile.html.eex:42 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:43 msgid "OUT" msgstr "" @@ -661,9 +661,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:120 -#: lib/block_scout_web/views/transaction_view.ex:154 +#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:156 msgid "Pending" msgstr "" @@ -768,14 +767,14 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 -#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:124 msgid "Success" 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:72 +#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:21 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:30 +#: lib/block_scout_web/templates/transaction/overview.html.eex:73 msgid "TX Fee" msgstr "" @@ -841,7 +840,7 @@ msgid "There are no transfers for this Token." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:24 +#: lib/block_scout_web/templates/transaction/overview.html.eex:25 msgid "This transaction is pending confirmation." msgstr "" @@ -879,7 +878,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:196 +#: lib/block_scout_web/views/transaction_view.ex:198 msgid "Token Transfer" msgstr "" @@ -891,7 +890,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:250 +#: lib/block_scout_web/views/transaction_view.ex:252 msgid "Token Transfers" msgstr "" @@ -932,7 +931,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:199 +#: lib/block_scout_web/views/transaction_view.ex:201 msgid "Transaction" msgstr "" @@ -948,7 +947,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:14 -#: lib/block_scout_web/templates/transaction/overview.html.eex:16 +#: lib/block_scout_web/templates/transaction/overview.html.eex:17 msgid "Transaction Details" msgstr "" @@ -999,7 +998,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:158 +#: lib/block_scout_web/templates/transaction/overview.html.eex:159 msgid "Used" msgstr "" @@ -1020,7 +1019,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:140 +#: lib/block_scout_web/templates/transaction/overview.html.eex:141 msgid "Value" msgstr "" @@ -1050,12 +1049,12 @@ msgid "View Contract" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_tile.html.eex:70 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:71 msgid "View Less Transfers" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_tile.html.eex:69 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:70 msgid "View More Transfers" msgstr "" @@ -1216,7 +1215,7 @@ msgid "This API is provided for developers transitioning their applications from msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:94 +#: lib/block_scout_web/templates/transaction/overview.html.eex:95 msgid "Raw Input" msgstr "" @@ -1639,17 +1638,17 @@ msgid "Transactions Sent" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:85 +#: lib/block_scout_web/templates/transaction/overview.html.eex:86 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 +#: lib/block_scout_web/templates/transaction/overview.html.eex:117 +#: lib/block_scout_web/templates/transaction/overview.html.eex:122 msgid "Hex (Default)" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:125 +#: lib/block_scout_web/templates/transaction/overview.html.eex:126 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 31ed957db2..0edf337eaf 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:121 +#: lib/block_scout_web/views/transaction_view.ex:123 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -145,7 +145,7 @@ msgid "Block %{block_number} - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:60 +#: lib/block_scout_web/templates/transaction/overview.html.eex:61 msgid "Block Confirmations" msgstr "" @@ -160,7 +160,7 @@ msgid "Block Mined, awaiting import..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:46 +#: lib/block_scout_web/templates/transaction/overview.html.eex:47 msgid "Block Number" msgstr "" @@ -271,19 +271,19 @@ msgid "Contract Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:15 +#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:16 #: lib/block_scout_web/views/address_view.ex:35 #: lib/block_scout_web/views/address_view.ex:69 msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:198 +#: lib/block_scout_web/views/transaction_view.ex:200 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:197 +#: lib/block_scout_web/views/transaction_view.ex:199 msgid "Contract Creation" msgstr "" @@ -317,13 +317,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:9 -#: lib/block_scout_web/templates/transaction/overview.html.eex:11 +#: lib/block_scout_web/templates/transaction/overview.html.eex:12 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:11 +#: lib/block_scout_web/templates/transaction/overview.html.eex:12 msgid "Copy Txn Hash" msgstr "" @@ -377,12 +377,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:125 +#: lib/block_scout_web/views/transaction_view.ex:127 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:123 +#: lib/block_scout_web/views/transaction_view.ex:125 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -390,9 +390,9 @@ msgstr "" #: lib/block_scout_web/templates/address/_balance_card.html.eex:13 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16 #: 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:140 +#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:27 +#: lib/block_scout_web/templates/transaction/overview.html.eex:141 #: 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:153 +#: lib/block_scout_web/templates/transaction/overview.html.eex:154 msgid "Gas" msgstr "" @@ -467,7 +467,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:32 -#: lib/block_scout_web/templates/transaction/_tile.html.eex:46 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:47 msgid "IN" 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:251 +#: lib/block_scout_web/views/transaction_view.ex:253 msgid "Internal Transactions" msgstr "" @@ -513,7 +513,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:165 +#: lib/block_scout_web/templates/transaction/overview.html.eex:166 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:252 +#: lib/block_scout_web/views/transaction_view.ex:254 msgid "Logs" msgstr "" @@ -609,13 +609,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:71 -#: lib/block_scout_web/templates/transaction/overview.html.eex:67 +#: lib/block_scout_web/templates/transaction/overview.html.eex:68 msgid "Nonce" msgstr "" #, elixir-format #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:30 -#: lib/block_scout_web/templates/transaction/_tile.html.eex:42 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:43 msgid "OUT" msgstr "" @@ -661,9 +661,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:120 -#: lib/block_scout_web/views/transaction_view.ex:154 +#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:156 msgid "Pending" msgstr "" @@ -768,14 +767,14 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 -#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:124 msgid "Success" 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:72 +#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:21 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:30 +#: lib/block_scout_web/templates/transaction/overview.html.eex:73 msgid "TX Fee" msgstr "" @@ -841,7 +840,7 @@ msgid "There are no transfers for this Token." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:24 +#: lib/block_scout_web/templates/transaction/overview.html.eex:25 msgid "This transaction is pending confirmation." msgstr "" @@ -879,7 +878,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:196 +#: lib/block_scout_web/views/transaction_view.ex:198 msgid "Token Transfer" msgstr "" @@ -891,7 +890,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:250 +#: lib/block_scout_web/views/transaction_view.ex:252 msgid "Token Transfers" msgstr "" @@ -932,7 +931,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:199 +#: lib/block_scout_web/views/transaction_view.ex:201 msgid "Transaction" msgstr "" @@ -948,7 +947,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/not_found.html.eex:14 -#: lib/block_scout_web/templates/transaction/overview.html.eex:16 +#: lib/block_scout_web/templates/transaction/overview.html.eex:17 msgid "Transaction Details" msgstr "" @@ -999,7 +998,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:158 +#: lib/block_scout_web/templates/transaction/overview.html.eex:159 msgid "Used" msgstr "" @@ -1020,7 +1019,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:140 +#: lib/block_scout_web/templates/transaction/overview.html.eex:141 msgid "Value" msgstr "" @@ -1050,12 +1049,12 @@ msgid "View Contract" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_tile.html.eex:70 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:71 msgid "View Less Transfers" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_tile.html.eex:69 +#: lib/block_scout_web/templates/transaction/_tile.html.eex:70 msgid "View More Transfers" msgstr "" @@ -1216,7 +1215,7 @@ msgid "This API is provided for developers transitioning their applications from msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:94 +#: lib/block_scout_web/templates/transaction/overview.html.eex:95 msgid "Raw Input" msgstr "" @@ -1639,17 +1638,17 @@ msgid "Transactions Sent" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:85 +#: lib/block_scout_web/templates/transaction/overview.html.eex:86 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 +#: lib/block_scout_web/templates/transaction/overview.html.eex:117 +#: lib/block_scout_web/templates/transaction/overview.html.eex:122 msgid "Hex (Default)" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:125 +#: lib/block_scout_web/templates/transaction/overview.html.eex:126 msgid "UTF-8" msgstr "" diff --git a/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs index 4fa4ad79d1..d535b309f8 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs @@ -23,6 +23,20 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do assert hd(json_response(conn, 200)["items"]) =~ to_string(transaction.hash) end + test "does not show dropped/replaced transactions", %{conn: conn} do + transaction = insert(:transaction) + + dropped_replaced = + :transaction + |> insert(status: 0, error: "dropped/replaced") + |> with_block() + + conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, %{"type" => "JSON"})) + + assert hd(json_response(conn, 200)["items"]) =~ to_string(transaction.hash) + refute hd(json_response(conn, 200)["items"]) =~ to_string(dropped_replaced.hash) + end + test "returns a count of pending transactions", %{conn: conn} do insert(:transaction) diff --git a/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs index d7320abfa8..2a3e5492ed 100644 --- a/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs @@ -159,7 +159,8 @@ defmodule BlockScoutWeb.TransactionViewTest do |> insert() |> Repo.preload(:block) - assert TransactionView.formatted_status(transaction) == "Pending" + status = TransactionView.transaction_status(transaction) + assert TransactionView.formatted_status(status) == "Pending" end test "with block without status (pre-Byzantium/Ethereum Class)" do @@ -170,7 +171,8 @@ defmodule BlockScoutWeb.TransactionViewTest do |> insert() |> with_block(block, status: nil) - assert TransactionView.formatted_status(transaction) == "(Awaiting internal transactions for status)" + status = TransactionView.transaction_status(transaction) + assert TransactionView.formatted_status(status) == "(Awaiting internal transactions for status)" end test "with receipt with status :ok" do @@ -181,7 +183,8 @@ defmodule BlockScoutWeb.TransactionViewTest do |> insert(gas: gas) |> with_block(gas_used: gas - 1, status: :ok) - assert TransactionView.formatted_status(transaction) == "Success" + status = TransactionView.transaction_status(transaction) + assert TransactionView.formatted_status(status) == "Success" end test "with block with status :error without internal transactions indexed" do @@ -192,7 +195,8 @@ defmodule BlockScoutWeb.TransactionViewTest do |> insert() |> with_block(block, status: :error) - assert TransactionView.formatted_status(transaction) == "Error: (Awaiting internal transactions for reason)" + status = TransactionView.transaction_status(transaction) + assert TransactionView.formatted_status(status) == "Error: (Awaiting internal transactions for reason)" end test "with block with status :error with internal transactions indexed uses `error`" do @@ -201,7 +205,8 @@ defmodule BlockScoutWeb.TransactionViewTest do |> insert() |> with_block(status: :error, internal_transactions_indexed_at: DateTime.utc_now(), error: "Out of Gas") - assert TransactionView.formatted_status(transaction) == "Error: Out of Gas" + status = TransactionView.transaction_status(transaction) + assert TransactionView.formatted_status(status) == "Error: Out of Gas" end end diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index cd7b970a86..b40af9a343 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1644,6 +1644,7 @@ defmodule Explorer.Chain do |> page_pending_transaction(paging_options) |> limit(^paging_options.page_size) |> pending_transactions_query() + |> where([transaction], is_nil(transaction.error) or transaction.error != "dropped/replaced") |> order_by([transaction], desc: transaction.inserted_at, desc: transaction.hash) |> join_associations(necessity_by_association) |> preload([{:token_transfers, [:token, :from_address, :to_address]}]) @@ -1866,6 +1867,7 @@ defmodule Explorer.Chain do | :success | {:error, :awaiting_internal_transactions} | {:error, reason :: String.t()} + def transaction_to_status(%Transaction{error: "dropped/replaced"}), do: {:error, "dropped/replaced"} def transaction_to_status(%Transaction{block_hash: nil, status: nil}), do: :pending def transaction_to_status(%Transaction{status: nil}), do: :awaiting_internal_transactions def transaction_to_status(%Transaction{status: :ok}), do: :success