Merge branch 'master' into ab-geth-index-range

pull/2495/head
Victor Baranov 5 years ago committed by GitHub
commit 0c68dba907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 1
      PULL_REQUEST_TEMPLATE.md
  3. 2
      apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex
  4. 4
      apps/block_scout_web/lib/block_scout_web/views/tokens/helpers.ex
  5. 19
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
  6. 36
      apps/block_scout_web/priv/gettext/default.pot
  7. 36
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  8. 16
      apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs
  9. 2
      docker/Dockerfile
  10. 2
      mix.exs

@ -1,10 +1,12 @@
## 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
- [#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

@ -35,3 +35,4 @@
- [ ] If I added new functionality, I added tests covering it.
- [ ] If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
- [ ] I checked whether I should update the docs and did so if necessary
- [ ] If I added/changed/removed ENV var, I should update the list of env vars in https://github.com/poanetwork/blockscout/blob/master/docs/env-variables.md to reflect changes in the table here https://poanetwork.github.io/blockscout/#/env-variables?id=blockscout-env-variables

@ -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

@ -1,4 +1,4 @@
FROM bitwalker/alpine-elixir-phoenix:1.9.1
FROM bitwalker/alpine-elixir-phoenix:1.9.0
RUN apk --no-cache --update add alpine-sdk gmp-dev automake libtool inotify-tools autoconf python

@ -14,7 +14,7 @@ defmodule BlockScout.Mixfile do
plt_add_apps: ~w(ex_unit mix)a,
ignore_warnings: ".dialyzer-ignore"
],
elixir: "~> 1.9.1",
elixir: "~> 1.9",
preferred_cli_env: [
coveralls: :test,
"coveralls.detail": :test,

Loading…
Cancel
Save