|
|
@ -201,16 +201,21 @@ defmodule Explorer.Chain.Token do |
|
|
|
Chain.paging_options() |
|
|
|
Chain.paging_options() |
|
|
|
| {:sorting, SortingHelper.sorting_params()} |
|
|
|
| {:sorting, SortingHelper.sorting_params()} |
|
|
|
| {:token_type, [String.t()]} |
|
|
|
| {:token_type, [String.t()]} |
|
|
|
|
|
|
|
| {:necessity_by_association, map()} |
|
|
|
]) :: [Token.t()] |
|
|
|
]) :: [Token.t()] |
|
|
|
def list_top(filter, options \\ []) do |
|
|
|
def list_top(filter, options \\ []) do |
|
|
|
paging_options = Keyword.get(options, :paging_options, Chain.default_paging_options()) |
|
|
|
paging_options = Keyword.get(options, :paging_options, Chain.default_paging_options()) |
|
|
|
token_type = Keyword.get(options, :token_type, nil) |
|
|
|
token_type = Keyword.get(options, :token_type, nil) |
|
|
|
sorting = Keyword.get(options, :sorting, []) |
|
|
|
sorting = Keyword.get(options, :sorting, []) |
|
|
|
|
|
|
|
|
|
|
|
query = from(t in Token, preload: [:contract_address]) |
|
|
|
necessity_by_association = |
|
|
|
|
|
|
|
Keyword.get(options, :necessity_by_association, %{ |
|
|
|
|
|
|
|
:contract_address => :optional |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
sorted_paginated_query = |
|
|
|
sorted_paginated_query = |
|
|
|
query |
|
|
|
Token |
|
|
|
|
|
|
|
|> Chain.join_associations(necessity_by_association) |
|
|
|
|> ExplorerHelper.maybe_hide_scam_addresses(:contract_address_hash) |
|
|
|
|> ExplorerHelper.maybe_hide_scam_addresses(:contract_address_hash) |
|
|
|
|> apply_filter(token_type) |
|
|
|
|> apply_filter(token_type) |
|
|
|
|> SortingHelper.apply_sorting(sorting, @default_sorting) |
|
|
|
|> SortingHelper.apply_sorting(sorting, @default_sorting) |
|
|
|