|
|
|
@ -1,16 +1,40 @@ |
|
|
|
|
defmodule BlockScoutWeb.AddressController do |
|
|
|
|
use BlockScoutWeb, :controller |
|
|
|
|
|
|
|
|
|
import BlockScoutWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1] |
|
|
|
|
|
|
|
|
|
alias Explorer.{Chain, Market} |
|
|
|
|
alias Explorer.Chain.Address |
|
|
|
|
alias Explorer.ExchangeRates.Token |
|
|
|
|
|
|
|
|
|
def index(conn, _params) do |
|
|
|
|
def index(conn, params) do |
|
|
|
|
addresses = |
|
|
|
|
params |
|
|
|
|
|> paging_options() |
|
|
|
|
|> Chain.list_top_addresses() |
|
|
|
|
|
|
|
|
|
{addresses_page, next_page} = split_list_by_page(addresses) |
|
|
|
|
|
|
|
|
|
next_page_path = |
|
|
|
|
case next_page_params(next_page, addresses_page, params) do |
|
|
|
|
nil -> |
|
|
|
|
nil |
|
|
|
|
|
|
|
|
|
next_page_params -> |
|
|
|
|
address_path( |
|
|
|
|
conn, |
|
|
|
|
:index, |
|
|
|
|
next_page_params |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
render(conn, "index.html", |
|
|
|
|
address_tx_count_pairs: Chain.list_top_addresses(), |
|
|
|
|
address_tx_count_pairs: addresses_page, |
|
|
|
|
page_address_count: Enum.count(addresses_page), |
|
|
|
|
address_count: Chain.count_addresses_with_balance_from_cache(), |
|
|
|
|
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), |
|
|
|
|
total_supply: Chain.total_supply() |
|
|
|
|
total_supply: Chain.total_supply(), |
|
|
|
|
next_page_path: next_page_path |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|