<%= unless is_nil(@log.data) do %>
<%= @log.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 d4b8b68f1a..53d64555dd 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
@@ -40,22 +40,43 @@ defmodule BlockScoutWeb.TransactionView do
end
def aggregate_token_transfers(token_transfers) do
- token_transfers
- |> Enum.reduce(%{}, fn token_transfer, acc ->
- new_entry = %{
- token: token_transfer.token,
- amount: token_transfer.amount,
- token_id: token_transfer.token_id
- }
+ {transfers, nft_transfers} =
+ token_transfers
+ |> Enum.reduce({%{}, []}, fn token_transfer, acc ->
+ aggregate_reducer(token_transfer, acc)
+ end)
- existing_entry = Map.get(acc, token_transfer.token_contract_address, %{new_entry | amount: Decimal.new(0)})
+ final_transfers = Map.values(transfers)
- Map.put(acc, token_transfer.token_contract_address, %{
+ final_transfers ++ nft_transfers
+ end
+
+ defp aggregate_reducer(%{amount: amount} = token_transfer, {acc1, acc2}) when is_nil(amount) do
+ new_entry = %{
+ token: token_transfer.token,
+ amount: nil,
+ token_id: token_transfer.token_id
+ }
+
+ {acc1, [new_entry | acc2]}
+ end
+
+ defp aggregate_reducer(token_transfer, {acc1, acc2}) do
+ new_entry = %{
+ token: token_transfer.token,
+ amount: token_transfer.amount,
+ token_id: token_transfer.token_id
+ }
+
+ existing_entry = Map.get(acc1, token_transfer.token_contract_address, %{new_entry | amount: Decimal.new(0)})
+
+ new_acc1 =
+ Map.put(acc1, token_transfer.token_contract_address, %{
new_entry
| amount: Decimal.add(new_entry.amount, existing_entry.amount)
})
- end)
- |> Enum.map(fn {_key, value} -> value end)
+
+ {new_acc1, acc2}
end
def token_type_name(type) do
diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs
index 46867df947..27a1e6aa74 100644
--- a/apps/block_scout_web/mix.exs
+++ b/apps/block_scout_web/mix.exs
@@ -64,7 +64,7 @@ defmodule BlockScoutWeb.Mixfile do
# Integrates Absinthe subscriptions with Phoenix
{:absinthe_phoenix, git: "https://github.com/ayrat555/absinthe_phoenix.git", branch: "master"},
# Plug support for Absinthe
- {:absinthe_plug, git: "https://github.com/ayrat555/absinthe_plug.git", branch: "ab-allow-to-set-default-query"},
+ {:absinthe_plug, git: "https://github.com/ayrat555/absinthe_plug.git", branch: "ab-enable-default-query"},
# Absinthe support for the Relay framework
{:absinthe_relay, "~> 1.4"},
{:bypass, "~> 1.0", only: :test},
@@ -102,7 +102,7 @@ defmodule BlockScoutWeb.Mixfile do
{:phoenix, "~> 1.4"},
{:phoenix_ecto, "~> 4.0"},
{:phoenix_html, "~> 2.10"},
- {:phoenix_live_reload, "~> 1.0", only: [:dev]},
+ {:phoenix_live_reload, "~> 1.2", only: [:dev]},
{:phoenix_pubsub, "~> 1.0"},
# use `:cowboy` for WebServer with `:plug`
{:plug_cowboy, "~> 2.0"},
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot
index 7a14bc26f4..560f272493 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:163
+#: lib/block_scout_web/views/transaction_view.ex:184
msgid "(Awaiting internal transactions for status)"
msgstr ""
@@ -276,12 +276,12 @@ msgid "Contract Address Pending"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:240
+#: lib/block_scout_web/views/transaction_view.ex:261
msgid "Contract Call"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:239
+#: lib/block_scout_web/views/transaction_view.ex:260
msgid "Contract Creation"
msgstr ""
@@ -356,12 +356,12 @@ msgid "Error trying to fetch balances."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:167
+#: lib/block_scout_web/views/transaction_view.ex:188
msgid "Error: %{reason}"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:165
+#: lib/block_scout_web/views/transaction_view.ex:186
msgid "Error: (Awaiting internal transactions for reason)"
msgstr ""
@@ -466,7 +466,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
#: lib/block_scout_web/views/address_view.ex:306
-#: lib/block_scout_web/views/transaction_view.ex:293
+#: lib/block_scout_web/views/transaction_view.ex:314
msgid "Internal Transactions"
msgstr ""
@@ -493,7 +493,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8
#: lib/block_scout_web/views/address_view.ex:312
-#: lib/block_scout_web/views/transaction_view.ex:294
+#: lib/block_scout_web/views/transaction_view.ex:315
msgid "Logs"
msgstr ""
@@ -506,8 +506,8 @@ msgid "Market Cap"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:148
-#: lib/block_scout_web/views/transaction_view.ex:148
+#: lib/block_scout_web/views/transaction_view.ex:169
+#: lib/block_scout_web/views/transaction_view.ex:169
msgid "Max of"
msgstr ""
@@ -598,8 +598,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:59
-#: lib/block_scout_web/views/transaction_view.ex:162
-#: lib/block_scout_web/views/transaction_view.ex:196
+#: lib/block_scout_web/views/transaction_view.ex:183
+#: lib/block_scout_web/views/transaction_view.ex:217
msgid "Pending"
msgstr ""
@@ -686,7 +686,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8
-#: lib/block_scout_web/views/transaction_view.ex:164
+#: lib/block_scout_web/views/transaction_view.ex:185
msgid "Success"
msgstr ""
@@ -791,7 +791,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:5
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4
-#: lib/block_scout_web/views/transaction_view.ex:238
+#: lib/block_scout_web/views/transaction_view.ex:259
msgid "Token Transfer"
msgstr ""
@@ -801,7 +801,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/tokens/overview_view.ex:35
-#: lib/block_scout_web/views/transaction_view.ex:292
+#: lib/block_scout_web/views/transaction_view.ex:313
msgid "Token Transfers"
msgstr ""
@@ -835,7 +835,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3
-#: lib/block_scout_web/views/transaction_view.ex:241
+#: lib/block_scout_web/views/transaction_view.ex:262
msgid "Transaction"
msgstr ""
@@ -1499,7 +1499,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:24
#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7
-#: lib/block_scout_web/views/transaction_view.ex:295
+#: lib/block_scout_web/views/transaction_view.ex:316
msgid "Raw Trace"
msgstr ""
@@ -1707,12 +1707,12 @@ msgid "Change Network"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:63
+#: lib/block_scout_web/views/transaction_view.ex:84
msgid "ERC-20 "
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:64
+#: lib/block_scout_web/views/transaction_view.ex:85
msgid "ERC-721 "
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 fab233e648..841f349e58 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:163
+#: lib/block_scout_web/views/transaction_view.ex:184
msgid "(Awaiting internal transactions for status)"
msgstr ""
@@ -276,12 +276,12 @@ msgid "Contract Address Pending"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:240
+#: lib/block_scout_web/views/transaction_view.ex:261
msgid "Contract Call"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:239
+#: lib/block_scout_web/views/transaction_view.ex:260
msgid "Contract Creation"
msgstr ""
@@ -356,12 +356,12 @@ msgid "Error trying to fetch balances."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:167
+#: lib/block_scout_web/views/transaction_view.ex:188
msgid "Error: %{reason}"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:165
+#: lib/block_scout_web/views/transaction_view.ex:186
msgid "Error: (Awaiting internal transactions for reason)"
msgstr ""
@@ -466,7 +466,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
#: lib/block_scout_web/views/address_view.ex:306
-#: lib/block_scout_web/views/transaction_view.ex:293
+#: lib/block_scout_web/views/transaction_view.ex:314
msgid "Internal Transactions"
msgstr ""
@@ -493,7 +493,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8
#: lib/block_scout_web/views/address_view.ex:312
-#: lib/block_scout_web/views/transaction_view.ex:294
+#: lib/block_scout_web/views/transaction_view.ex:315
msgid "Logs"
msgstr ""
@@ -506,8 +506,8 @@ msgid "Market Cap"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:148
-#: lib/block_scout_web/views/transaction_view.ex:148
+#: lib/block_scout_web/views/transaction_view.ex:169
+#: lib/block_scout_web/views/transaction_view.ex:169
msgid "Max of"
msgstr ""
@@ -598,8 +598,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:59
-#: lib/block_scout_web/views/transaction_view.ex:162
-#: lib/block_scout_web/views/transaction_view.ex:196
+#: lib/block_scout_web/views/transaction_view.ex:183
+#: lib/block_scout_web/views/transaction_view.ex:217
msgid "Pending"
msgstr ""
@@ -686,7 +686,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8
-#: lib/block_scout_web/views/transaction_view.ex:164
+#: lib/block_scout_web/views/transaction_view.ex:185
msgid "Success"
msgstr ""
@@ -791,7 +791,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:5
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4
-#: lib/block_scout_web/views/transaction_view.ex:238
+#: lib/block_scout_web/views/transaction_view.ex:259
msgid "Token Transfer"
msgstr ""
@@ -801,7 +801,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/tokens/overview_view.ex:35
-#: lib/block_scout_web/views/transaction_view.ex:292
+#: lib/block_scout_web/views/transaction_view.ex:313
msgid "Token Transfers"
msgstr ""
@@ -835,7 +835,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3
-#: lib/block_scout_web/views/transaction_view.ex:241
+#: lib/block_scout_web/views/transaction_view.ex:262
msgid "Transaction"
msgstr ""
@@ -1500,7 +1500,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:24
#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7
-#: lib/block_scout_web/views/transaction_view.ex:295
+#: lib/block_scout_web/views/transaction_view.ex:316
msgid "Raw Trace"
msgstr ""
@@ -1708,12 +1708,12 @@ msgid "Change Network"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:63
+#: lib/block_scout_web/views/transaction_view.ex:84
msgid "ERC-20 "
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:64
+#: lib/block_scout_web/views/transaction_view.ex:85
msgid "ERC-721 "
msgstr ""
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 8598f3826a..69cca69f41 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
@@ -268,5 +268,19 @@ defmodule BlockScoutWeb.TransactionViewTest do
assert Enum.count(result) == 1
assert List.first(result).amount == Decimal.new(3)
end
+
+ test "does not aggregate NFT tokens" do
+ transaction =
+ :transaction
+ |> insert()
+ |> with_block()
+
+ token_transfer = insert(:token_transfer, transaction: transaction, amount: nil)
+
+ result = TransactionView.aggregate_token_transfers([token_transfer, token_transfer, token_transfer])
+
+ assert Enum.count(result) == 3
+ assert List.first(result).amount == nil
+ end
end
end
diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs
index 37bfc881eb..4d73894d5e 100644
--- a/apps/explorer/mix.exs
+++ b/apps/explorer/mix.exs
@@ -74,13 +74,13 @@ defmodule Explorer.Mixfile do
{:decimal, "~> 1.0"},
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
# `override: true` for `ex_machina` compatibility
- {:ecto, "~> 3.0", override: true},
+ {:ecto, "~> 3.1", override: true},
# Storing blockchain data and derived data in PostgreSQL.
{:ecto_sql, "~> 3.1"},
# JSONRPC access to query smart contracts
{:ethereum_jsonrpc, in_umbrella: true},
# Data factory for testing
- {:ex_machina, "~> 2.1", only: [:test]},
+ {:ex_machina, "~> 2.3", only: [:test]},
# Code coverage
{:excoveralls, "~> 0.10.0", only: [:test], github: "KronicDeth/excoveralls", branch: "circle-workflows"},
{:exvcr, "~> 0.10", only: :test},
diff --git a/mix.lock b/mix.lock
index d225be02ca..92fd054cb6 100644
--- a/mix.lock
+++ b/mix.lock
@@ -2,8 +2,8 @@
"abi": {:hex, :abi, "0.1.12", "87ae04cb09e2308db7b3c350584dc3934de0e308f6a056ba82be5756b081a1ca", [:mix], [{:exth_crypto, "~> 0.1.4", [hex: :exth_crypto, repo: "hexpm", optional: false]}], "hexpm"},
"abnf2": {:hex, :abnf2, "0.1.2", "6f8792b8ac3288dba5fc889c2bceae9fe78f74e1a7b36bea9726ffaa9d7bef95", [:mix], []},
"absinthe": {:hex, :absinthe, "1.4.14", "fef224a6aac63d6eaafbc0cb96040a8abcd572275b9b4db69d46329acdcae7c7", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
- "absinthe_phoenix": {:git, "https://github.com/ayrat555/absinthe_phoenix.git", "4104c7213c328c3698b52710d49cd6d85449305c", [branch: "master"]},
- "absinthe_plug": {:git, "https://github.com/ayrat555/absinthe_plug.git", "e74da0a6e004fe4126885b5f5f60a3e72abd70bb", [branch: "ab-allow-to-set-default-query"]},
+ "absinthe_phoenix": {:git, "https://github.com/ayrat555/absinthe_phoenix.git", "0f5127844a9e4e1c5fecb1fcee225894a2af6336", [branch: "master"]},
+ "absinthe_plug": {:git, "https://github.com/ayrat555/absinthe_plug.git", "cbe1c170e11e60b3b0146b925a1ce6ec562840ce", [branch: "ab-enable-default-query"]},
"absinthe_relay": {:hex, :absinthe_relay, "1.4.6", "ec0e2288994b388556247cf9601245abec785cdf206d6e844f2992d29de21624", [:mix], [{:absinthe, "~> 1.4.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:ecto, "~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
"accept": {:hex, :accept, "0.3.3", "548ebb6fb2e8b0d170e75bb6123aea6ceecb0189bb1231eeadf52eac08384a97", [:rebar3], [], "hexpm"},
"artificery": {:hex, :artificery, "0.2.6", "f602909757263f7897130cbd006b0e40514a541b148d366ad65b89236b93497a", [:mix], [], "hexpm"},
@@ -43,7 +43,7 @@
"ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.6.4", "5b1ac8451f889576bb29dee70412de1170974298727ab944aa4d17e91bdd3472", [:mix], [{:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.6", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.3", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"ex_cldr_units": {:hex, :ex_cldr_units, "2.5.1", "0e65067a22a7c5146266c313d6333c2700868c32aa6d536f47c6c0d84aac3ac1", [:mix], [{:ex_cldr, "~> 2.6", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_lists, "~> 2.2", [hex: :ex_cldr_lists, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.6", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.2", "6f4081ccd9ed081b6dc0bd5af97a41e87f5554de469e7d76025fba535180565f", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
- "ex_machina": {:hex, :ex_machina, "2.2.2", "d84217a6fb7840ff771d2561b8aa6d74a0d8968e4b10ecc0d7e9890dc8fb1c6a", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm"},
+ "ex_machina": {:hex, :ex_machina, "2.3.0", "92a5ad0a8b10ea6314b876a99c8c9e3f25f4dde71a2a835845b136b9adaf199a", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm"},
"ex_rlp": {:hex, :ex_rlp, "0.5.2", "7f4ce7bd55e543c054ce6d49629b01e9833c3462e3d547952be89865f39f2c58", [:mix], [], "hexpm"},
"ex_utils": {:hex, :ex_utils, "0.1.7", "2c133e0bcdc49a858cf8dacf893308ebc05bc5fba501dc3d2935e65365ec0bf3", [:mix], [], "hexpm"},
"exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], []},