Merge pull request #973 from poanetwork/gsf-hide-token-holder-count-when-not-consolidating

hide token holder count when not consolidating
pull/987/head
Gustavo 6 years ago committed by GitHub
commit d358366880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/holder_controller.ex
  2. 1
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/inventory_controller.ex
  3. 1
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/read_contract_controller.ex
  4. 1
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/transfer_controller.ex
  5. 1
      apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex
  6. 1
      apps/block_scout_web/lib/block_scout_web/templates/tokens/inventory/index.html.eex
  7. 4
      apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex
  8. 1
      apps/block_scout_web/lib/block_scout_web/templates/tokens/read_contract/index.html.eex
  9. 94
      apps/block_scout_web/lib/block_scout_web/templates/tokens/token/show.html.eex
  10. 1
      apps/block_scout_web/lib/block_scout_web/templates/tokens/transfer/index.html.eex
  11. 34
      apps/block_scout_web/priv/gettext/default.pot
  12. 34
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  13. 40
      apps/block_scout_web/priv/gettext/errors.pot
  14. 5
      apps/explorer/lib/explorer/chain.ex
  15. 29
      apps/explorer/lib/explorer/counters/token_holders_counter.ex

@ -21,6 +21,7 @@ defmodule BlockScoutWeb.Tokens.HolderController do
"index.html",
token: token,
token_balances: token_balances_paginated,
holders_count_consolidation_enabled: Chain.token_holders_counter_consolidation_enabled?(),
total_token_transfers: Chain.count_token_transfers_from_token_hash(address_hash),
total_token_holders: Chain.count_token_holders_from_token_hash(address_hash),
next_page_params: next_page_params(next_page, token_balances_paginated, params)

@ -22,6 +22,7 @@ defmodule BlockScoutWeb.Tokens.InventoryController do
"index.html",
token: token,
unique_tokens: unique_tokens_paginated,
holders_count_consolidation_enabled: Chain.token_holders_counter_consolidation_enabled?(),
total_token_transfers: Chain.count_token_transfers_from_token_hash(address_hash),
total_token_holders: Chain.count_token_holders_from_token_hash(address_hash),
next_page_params: unique_tokens_next_page(next_page, unique_tokens_paginated, params)

@ -10,6 +10,7 @@ defmodule BlockScoutWeb.Tokens.ReadContractController do
conn,
"index.html",
token: token,
holders_count_consolidation_enabled: Chain.token_holders_counter_consolidation_enabled?(),
total_token_transfers: Chain.count_token_transfers_from_token_hash(address_hash),
total_token_holders: Chain.count_token_holders_from_token_hash(address_hash)
)

@ -16,6 +16,7 @@ defmodule BlockScoutWeb.Tokens.TransferController do
"index.html",
transfers: token_transfers_paginated,
token: token,
holders_count_consolidation_enabled: Chain.token_holders_counter_consolidation_enabled?(),
total_token_transfers: Chain.count_token_transfers_from_token_hash(address_hash),
total_token_holders: Chain.count_token_holders_from_token_hash(address_hash),
next_page_params: next_page_params(next_page, token_transfers_paginated, params)

@ -3,6 +3,7 @@
OverviewView,
"_details.html",
token: @token,
holders_count_consolidation_enabled: @holders_count_consolidation_enabled,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders,
conn: @conn

@ -3,6 +3,7 @@
OverviewView,
"_details.html",
token: @token,
holders_count_consolidation_enabled: @holders_count_consolidation_enabled,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders,
conn: @conn

@ -36,7 +36,9 @@
</span>
<div class="d-flex flex-row justify-content-start text-muted">
<span class="mr-4"> <%= @token.type %> </span>
<span class="mr-4"><%= @total_token_holders %> <%= gettext "addresses" %></span>
<%= if @holders_count_consolidation_enabled do %>
<span class="mr-4"><%= @total_token_holders %> <%= gettext "addresses" %></span>
<% end %>
<span class="mr-4"><%= @total_token_transfers %> <%= gettext "Transfers" %></span>
<%= if decimals?(@token) do %>
<span class="mr-4"><%= @token.decimals %> <%= gettext "decimals" %></span>

@ -3,6 +3,7 @@
OverviewView,
"_details.html",
token: @token,
holders_count_consolidation_enabled: @holders_count_consolidation_enabled,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders,
conn: @conn

@ -1,94 +0,0 @@
<section class="container">
<%= render(
OverviewView,
"_details.html",
token: @token,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders,
conn: @conn
) %>
<section>
<div class="card">
<div class="card-header">
<!-- DESKTOP TAB NAV -->
<ul class="nav nav-tabs card-header-tabs d-none d-md-inline-flex">
<li class="nav-item">
<%= link(
gettext("Token Transfers"),
class: "nav-link active",
to: token_path(@conn, :show, @token.contract_address_hash)
) %>
</li>
<%= if smart_contract_with_read_only_functions?(@token) do %>
<li class="nav-item">
<%= link(
gettext("Read Contract"),
to: token_read_contract_path(@conn, :index, @conn.params["id"]),
class: "nav-link")%>
</li>
<% end %>
<li class="nav-item"i>
<%= link(
gettext("Token Holders"),
class: "nav-link",
"data-test": "token_holders_tab",
to: token_holder_path(@conn, :index, @token.contract_address_hash)
) %>
</li>
</ul>
<!-- MOBILE DROPDOWN NAV -->
<ul class="nav nav-tabs card-header-tabs d-md-none">
<li class="nav-item dropdown flex-fill text-center">
<a class="nav-link active dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><%= gettext("Token Transfers") %></a>
<div class="dropdown-menu">
<%= link(
gettext("Token Transfers"),
class: "dropdown-item active",
to: token_path(@conn, :show, @token.contract_address_hash)
) %>
<%= if smart_contract_with_read_only_functions?(@token) do %>
<%= link(
gettext("Read Contract"),
to: "#",
class: "dropdown-item")%>
<% end %>
<%= link(
gettext("Token Holders"),
class: "dropdown-item",
to: token_holder_path(@conn, :index, @token.contract_address_hash)
) %>
</div>
</li>
</ul>
</div>
<div class="card-body">
<h2 class="card-title"><%= gettext "Token Transfers" %></h2>
<%= if Enum.any?(@transfers) do %>
<%= for transfer <- @transfers do %>
<%= render("_token_transfer.html", token: @token, transfer: transfer) %>
<% end %>
<% else %>
<div class="tile tile-muted text-center">
<span data-selector="empty-transactions-list">
<%= gettext "There are no transfers for this Token." %>
</span>
</div>
<% end %>
<%= if @next_page_params do %>
<%= link(
gettext("Older"),
class: "button button-secondary button-small float-right mt-4",
to: token_path(@conn, :show, @token.contract_address_hash, @next_page_params)
) %>
<% end %>
</div>
</div>
</section>
</section>

@ -3,6 +3,7 @@
OverviewView,
"_details.html",
token: @token,
holders_count_consolidation_enabled: @holders_count_consolidation_enabled,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders,
conn: @conn

@ -220,8 +220,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:74
#: lib/block_scout_web/templates/address/overview.html.eex:82
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:82
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:90
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:84
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:92
msgid "Close"
msgstr ""
@ -519,7 +519,7 @@ msgid "Internal Transactions"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:18
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:19
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:23
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:67
#: lib/block_scout_web/views/tokens/overview_view.ex:38
@ -614,8 +614,8 @@ msgid "Next"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:35
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:34
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:36
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:35
msgid "Next Page"
msgstr ""
@ -643,7 +643,7 @@ msgstr ""
#: lib/block_scout_web/templates/block/index.html.eex:20
#: lib/block_scout_web/templates/block_transaction/index.html.eex:50
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:31
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:34
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:35
#: lib/block_scout_web/templates/transaction/index.html.eex:31
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:24
msgid "Older"
@ -715,7 +715,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:73
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:81
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:83
msgid "QR Code"
msgstr ""
@ -817,7 +817,7 @@ msgid "Telegram"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:28
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:29
msgid "There are no holders for this Token."
msgstr ""
@ -853,7 +853,7 @@ msgid "There are no tokens for this address."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:27
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:28
msgid "There are no tokens."
msgstr ""
@ -868,7 +868,7 @@ msgid "There are no transactions for this block."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:27
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:28
msgid "There are no transfers for this Token."
msgstr ""
@ -901,7 +901,7 @@ msgid "Token Details"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:19
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:20
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:60
#: lib/block_scout_web/views/tokens/overview_view.ex:36
@ -923,7 +923,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:5
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:54
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:18
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:19
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:6
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:36
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10
@ -960,7 +960,7 @@ msgid "Total Difficulty"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:54
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:56
msgid "Total Supply"
msgstr ""
@ -1012,7 +1012,7 @@ msgid "Transactions sent"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:40
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
msgid "Transfers"
msgstr ""
@ -1134,7 +1134,7 @@ msgid "Yes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:39
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:40
msgid "addresses"
msgstr ""
@ -1144,7 +1144,7 @@ msgid "at"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:44
msgid "decimals"
msgstr ""
@ -1155,7 +1155,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:12
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:19
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:20
msgid "loading..."
msgstr ""

@ -220,8 +220,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:74
#: lib/block_scout_web/templates/address/overview.html.eex:82
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:82
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:90
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:84
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:92
msgid "Close"
msgstr ""
@ -519,7 +519,7 @@ msgid "Internal Transactions"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:18
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:19
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:23
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:67
#: lib/block_scout_web/views/tokens/overview_view.ex:38
@ -614,8 +614,8 @@ msgid "Next"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:35
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:34
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:36
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:35
msgid "Next Page"
msgstr ""
@ -643,7 +643,7 @@ msgstr ""
#: lib/block_scout_web/templates/block/index.html.eex:20
#: lib/block_scout_web/templates/block_transaction/index.html.eex:50
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:31
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:34
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:35
#: lib/block_scout_web/templates/transaction/index.html.eex:31
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:24
msgid "Older"
@ -715,7 +715,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:73
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:81
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:83
msgid "QR Code"
msgstr ""
@ -817,7 +817,7 @@ msgid "Telegram"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:28
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:29
msgid "There are no holders for this Token."
msgstr ""
@ -853,7 +853,7 @@ msgid "There are no tokens for this address."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:27
#: lib/block_scout_web/templates/tokens/inventory/index.html.eex:28
msgid "There are no tokens."
msgstr ""
@ -868,7 +868,7 @@ msgid "There are no transactions for this block."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:27
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:28
msgid "There are no transfers for this Token."
msgstr ""
@ -901,7 +901,7 @@ msgid "Token Details"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:19
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:20
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:60
#: lib/block_scout_web/views/tokens/overview_view.ex:36
@ -923,7 +923,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:5
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:54
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:18
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:19
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:6
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:36
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10
@ -960,7 +960,7 @@ msgid "Total Difficulty"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:54
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:56
msgid "Total Supply"
msgstr ""
@ -1012,7 +1012,7 @@ msgid "Transactions sent"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:40
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
msgid "Transfers"
msgstr ""
@ -1134,7 +1134,7 @@ msgid "Yes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:39
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:40
msgid "addresses"
msgstr ""
@ -1144,7 +1144,7 @@ msgid "at"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:44
msgid "decimals"
msgstr ""
@ -1155,7 +1155,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:12
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:19
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:20
msgid "loading..."
msgstr ""

@ -1,52 +1,52 @@
## This file is a PO Template file.
##
## `msgid`s here are often extracted from source code.
## Add new translations manually only if they're dynamic
## translations that can't be statically extracted.
##
## Run `mix gettext.extract` to bring this file up to
## date. Leave `msgstr`s empty as changing them here as no
## effect: edit them in PO (`.po`) files instead.
## From Ecto.Changeset.cast/4
## This file is a PO Template file.
##
## `msgid`s here are often extracted from source code.
## Add new translations manually only if they're dynamic
## translations that can't be statically extracted.
##
## Run `mix gettext.extract` to bring this file up to
## date. Leave `msgstr`s empty as changing them here as no
## effect: edit them in PO (`.po`) files instead.
## From Ecto.Changeset.cast/4
msgid "can't be blank"
msgstr ""
## From Ecto.Changeset.unique_constraint/3
## From Ecto.Changeset.unique_constraint/3
msgid "has already been taken"
msgstr ""
## From Ecto.Changeset.put_change/3
## From Ecto.Changeset.put_change/3
msgid "is invalid"
msgstr ""
## From Ecto.Changeset.validate_acceptance/3
## From Ecto.Changeset.validate_acceptance/3
msgid "must be accepted"
msgstr ""
## From Ecto.Changeset.validate_format/3
## From Ecto.Changeset.validate_format/3
msgid "has invalid format"
msgstr ""
## From Ecto.Changeset.validate_subset/3
## From Ecto.Changeset.validate_subset/3
msgid "has an invalid entry"
msgstr ""
## From Ecto.Changeset.validate_exclusion/3
## From Ecto.Changeset.validate_exclusion/3
msgid "is reserved"
msgstr ""
## From Ecto.Changeset.validate_confirmation/3
## From Ecto.Changeset.validate_confirmation/3
msgid "does not match confirmation"
msgstr ""
## From Ecto.Changeset.no_assoc_constraint/3
## From Ecto.Changeset.no_assoc_constraint/3
msgid "is still associated with this entry"
msgstr ""
msgid "are still associated with this entry"
msgstr ""
## From Ecto.Changeset.validate_length/3
## From Ecto.Changeset.validate_length/3
msgid "should be %{count} character(s)"
msgid_plural "should be %{count} character(s)"
msgstr[0] ""
@ -77,7 +77,7 @@ msgid_plural "should have at most %{count} item(s)"
msgstr[0] ""
msgstr[1] ""
## From Ecto.Changeset.validate_number/3
## From Ecto.Changeset.validate_number/3
msgid "must be less than %{number}"
msgstr ""

@ -2079,6 +2079,11 @@ defmodule Explorer.Chain do
TokenHoldersCounter.fetch(contract_address_hash)
end
@spec token_holders_counter_consolidation_enabled? :: boolean()
def token_holders_counter_consolidation_enabled? do
TokenHoldersCounter.enable_consolidation?()
end
@spec address_to_unique_tokens(Hash.Address.t(), [paging_options]) :: [TokenTransfer.t()]
def address_to_unique_tokens(contract_address_hash, options \\ []) do
paging_options = Keyword.get(options, :paging_options, @default_paging_options)

@ -10,6 +10,11 @@ defmodule Explorer.Counters.TokenHoldersCounter do
@table :token_holders_counter
# It is undesirable to automatically start the consolidation in all environments.
# Consider the test environment: if the consolidation initiates but does not
# finish before a test ends, that test will fail. This way, hundreds of
# tests were failing before disabling the consolidation and the scheduler in
# the test env.
config = Application.get_env(:explorer, Explorer.Counters.TokenHoldersCounter)
@enable_consolidation Keyword.get(config, :enable_consolidation)
@ -94,15 +99,17 @@ defmodule Explorer.Counters.TokenHoldersCounter do
{:noreply, state}
end
# We don't want to automatically start the consolidation in all environments.
# Consider the test environment: if the consolidation initiates but does not
# finishes before a test ends, that test will fail. This way, hundreds o
# tests were failing before disabling the consolidation and the scheduler in
# the test env.
#
# In order to choose whether or not to enable the scheduler and the initial
# consolidation, change the following Explorer config:
#
# config :explorer, Explorer.Counters.TokenHoldersCounter, enable_consolidation: false
defp enable_consolidation?, do: @enable_consolidation
@doc """
Returns a boolean that indicates whether consolidation is enabled
In order to choose whether or not to enable the scheduler and the initial
consolidation, change the following Explorer config:
`config :explorer, Explorer.Counters.TokenHoldersCounter, enable_consolidation: true`
to:
`config :explorer, Explorer.Counters.TokenHoldersCounter, enable_consolidation: false`
"""
def enable_consolidation?, do: @enable_consolidation
end

Loading…
Cancel
Save