Merge branch 'master' into ab-increase-rewards-timeout

pull/2502/head
Ayrat Badykov 5 years ago committed by GitHub
commit 520c15ae20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 2
      apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex
  3. 4
      apps/block_scout_web/lib/block_scout_web/views/tokens/helpers.ex
  4. 19
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
  5. 36
      apps/block_scout_web/priv/gettext/default.pot
  6. 36
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  7. 16
      apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs
  8. 9
      apps/indexer/lib/indexer/block/catchup/bound_interval_supervisor.ex
  9. 2
      apps/indexer/lib/indexer/block/catchup/fetcher.ex

@ -1,12 +1,14 @@
## Current
### Features
- [#2477](https://github.com/poanetwork/blockscout/pull/2477) - aggregate token transfers on transaction page
- [#2458](https://github.com/poanetwork/blockscout/pull/2458) - Add LAST_BLOCK var to add ability indexing in the range of blocks
- [#2456](https://github.com/poanetwork/blockscout/pull/2456) - fetch pending transactions for geth
### Fixes
- [#2502](https://github.com/poanetwork/blockscout/pull/2502) - increase reward task timeout
- [#2496](https://github.com/poanetwork/blockscout/pull/2496) - fix docker build
- [#2495](https://github.com/poanetwork/blockscout/pull/2495) - fix logs for indexed chain
- [#2459](https://github.com/poanetwork/blockscout/pull/2459) - fix top addresses query
- [#2425](https://github.com/poanetwork/blockscout/pull/2425) - Force to show address view for checksummed address even if it is not in DB

@ -177,7 +177,7 @@
<div class="card-body card-body-flex-column-space-between">
<h2 class="card-title balance-card-title"><%= token_type_name(type)%><%= gettext " Token Transfer" %></h2>
<div class="text-right">
<%= for transfer <- transaction_with_transfers.token_transfers do %>
<%= for transfer <- aggregate_token_transfers(transaction_with_transfers.token_transfers) do %>
<h3 class="address-balance-text">
<%= token_transfer_amount(transfer) %>

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.Tokens.Helpers do
"""
alias BlockScoutWeb.{CurrencyHelpers}
alias Explorer.Chain.{Address, Token, TokenTransfer}
alias Explorer.Chain.{Address, Token}
@doc """
Returns the token transfers' amount according to the token's type and decimals.
@ -16,7 +16,7 @@ defmodule BlockScoutWeb.Tokens.Helpers do
When the token's type is ERC-721, the function will return a string with the token_id that
represents the ERC-721 token since this kind of token doesn't have amount and decimals.
"""
def token_transfer_amount(%TokenTransfer{token: token, amount: amount, token_id: token_id}) do
def token_transfer_amount(%{token: token, amount: amount, token_id: token_id}) do
do_token_transfer_amount(token, amount, token_id)
end

@ -39,6 +39,25 @@ defmodule BlockScoutWeb.TransactionView do
if type, do: {type, transaction_with_transfers}
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
}
existing_entry = Map.get(acc, token_transfer.token_contract_address, %{new_entry | amount: Decimal.new(0)})
Map.put(acc, token_transfer.token_contract_address, %{
new_entry
| amount: Decimal.add(new_entry.amount, existing_entry.amount)
})
end)
|> Enum.map(fn {_key, value} -> value end)
end
def token_type_name(type) do
case type do
:erc20 -> gettext("ERC-20 ")

@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:144
#: lib/block_scout_web/views/transaction_view.ex:163
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:221
#: lib/block_scout_web/views/transaction_view.ex:240
msgid "Contract Call"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:220
#: lib/block_scout_web/views/transaction_view.ex:239
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:148
#: lib/block_scout_web/views/transaction_view.ex:167
msgid "Error: %{reason}"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:146
#: lib/block_scout_web/views/transaction_view.ex:165
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:274
#: lib/block_scout_web/views/transaction_view.ex:293
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:275
#: lib/block_scout_web/views/transaction_view.ex:294
msgid "Logs"
msgstr ""
@ -506,8 +506,8 @@ msgid "Market Cap"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:129
#: lib/block_scout_web/views/transaction_view.ex:129
#: lib/block_scout_web/views/transaction_view.ex:148
#: lib/block_scout_web/views/transaction_view.ex:148
msgid "Max of"
msgstr ""
@ -598,8 +598,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:54
#: lib/block_scout_web/views/transaction_view.ex:143
#: lib/block_scout_web/views/transaction_view.ex:177
#: lib/block_scout_web/views/transaction_view.ex:162
#: lib/block_scout_web/views/transaction_view.ex:196
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:145
#: lib/block_scout_web/views/transaction_view.ex:164
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:219
#: lib/block_scout_web/views/transaction_view.ex:238
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:273
#: lib/block_scout_web/views/transaction_view.ex:292
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:222
#: lib/block_scout_web/views/transaction_view.ex:241
msgid "Transaction"
msgstr ""
@ -1495,7 +1495,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:276
#: lib/block_scout_web/views/transaction_view.ex:295
msgid "Raw Trace"
msgstr ""
@ -1703,12 +1703,12 @@ msgid "Change Network"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:44
#: lib/block_scout_web/views/transaction_view.ex:63
msgid "ERC-20 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:45
#: lib/block_scout_web/views/transaction_view.ex:64
msgid "ERC-721 "
msgstr ""

@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:144
#: lib/block_scout_web/views/transaction_view.ex:163
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:221
#: lib/block_scout_web/views/transaction_view.ex:240
msgid "Contract Call"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:220
#: lib/block_scout_web/views/transaction_view.ex:239
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:148
#: lib/block_scout_web/views/transaction_view.ex:167
msgid "Error: %{reason}"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:146
#: lib/block_scout_web/views/transaction_view.ex:165
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:274
#: lib/block_scout_web/views/transaction_view.ex:293
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:275
#: lib/block_scout_web/views/transaction_view.ex:294
msgid "Logs"
msgstr ""
@ -506,8 +506,8 @@ msgid "Market Cap"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:129
#: lib/block_scout_web/views/transaction_view.ex:129
#: lib/block_scout_web/views/transaction_view.ex:148
#: lib/block_scout_web/views/transaction_view.ex:148
msgid "Max of"
msgstr ""
@ -598,8 +598,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:54
#: lib/block_scout_web/views/transaction_view.ex:143
#: lib/block_scout_web/views/transaction_view.ex:177
#: lib/block_scout_web/views/transaction_view.ex:162
#: lib/block_scout_web/views/transaction_view.ex:196
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:145
#: lib/block_scout_web/views/transaction_view.ex:164
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:219
#: lib/block_scout_web/views/transaction_view.ex:238
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:273
#: lib/block_scout_web/views/transaction_view.ex:292
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:222
#: lib/block_scout_web/views/transaction_view.ex:241
msgid "Transaction"
msgstr ""
@ -1496,7 +1496,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:276
#: lib/block_scout_web/views/transaction_view.ex:295
msgid "Raw Trace"
msgstr ""
@ -1704,12 +1704,12 @@ msgid "Change Network"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:44
#: lib/block_scout_web/views/transaction_view.ex:63
msgid "ERC-20 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:45
#: lib/block_scout_web/views/transaction_view.ex:64
msgid "ERC-721 "
msgstr ""

@ -253,4 +253,20 @@ defmodule BlockScoutWeb.TransactionViewTest do
assert TransactionView.current_tab_name(logs_path) == "Logs"
end
end
describe "aggregate_token_transfers/1" do
test "aggregates token transfers" do
transaction =
:transaction
|> insert()
|> with_block()
token_transfer = insert(:token_transfer, transaction: transaction, amount: Decimal.new(1))
result = TransactionView.aggregate_token_transfers([token_transfer, token_transfer, token_transfer])
assert Enum.count(result) == 1
assert List.first(result).amount == Decimal.new(3)
end
end
end

@ -185,7 +185,12 @@ defmodule Indexer.Block.Catchup.BoundIntervalSupervisor do
def handle_info(
{ref,
%{first_block_number: first_block_number, missing_block_count: missing_block_count, shrunk: false = shrunk}},
%{
first_block_number: first_block_number,
last_block_number: last_block_number,
missing_block_count: missing_block_count,
shrunk: false = shrunk
}},
%__MODULE__{
bound_interval: bound_interval,
task: %Task{ref: ref}
@ -197,7 +202,7 @@ defmodule Indexer.Block.Catchup.BoundIntervalSupervisor do
0 ->
Logger.info("Index already caught up.",
first_block_number: first_block_number,
last_block_number: 0,
last_block_number: last_block_number,
missing_block_count: 0,
shrunk: shrunk
)

@ -123,7 +123,7 @@ defmodule Indexer.Block.Catchup.Fetcher do
Shrinkable.shrunk?(sequence)
end
%{first_block_number: first, missing_block_count: missing_block_count, shrunk: shrunk}
%{first_block_number: first, last_block_number: last, missing_block_count: missing_block_count, shrunk: shrunk}
end
end

Loading…
Cancel
Save