|
|
@ -1,10 +1,10 @@ |
|
|
|
defmodule BlockScoutWeb.Tokens.InventoryController do |
|
|
|
defmodule BlockScoutWeb.Tokens.InventoryController do |
|
|
|
use BlockScoutWeb, :controller |
|
|
|
use BlockScoutWeb, :controller |
|
|
|
|
|
|
|
|
|
|
|
alias BlockScoutWeb.{AccessHelpers, Controller} |
|
|
|
alias BlockScoutWeb.AccessHelpers |
|
|
|
alias BlockScoutWeb.Tokens.InventoryView |
|
|
|
alias BlockScoutWeb.Tokens.{HolderController, InventoryView} |
|
|
|
alias Explorer.{Chain, Market} |
|
|
|
alias Explorer.Chain |
|
|
|
alias Explorer.Chain.{Address, TokenTransfer} |
|
|
|
alias Explorer.Chain.TokenTransfer |
|
|
|
alias Phoenix.View |
|
|
|
alias Phoenix.View |
|
|
|
|
|
|
|
|
|
|
|
import BlockScoutWeb.Chain, only: [split_list_by_page: 1, default_paging_options: 0] |
|
|
|
import BlockScoutWeb.Chain, only: [split_list_by_page: 1, default_paging_options: 0] |
|
|
@ -66,29 +66,8 @@ defmodule BlockScoutWeb.Tokens.InventoryController do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def index(conn, %{"token_id" => address_hash_string} = params) do |
|
|
|
def index(conn, params) do |
|
|
|
options = [necessity_by_association: %{[contract_address: :smart_contract] => :optional}] |
|
|
|
HolderController.index(conn, params) |
|
|
|
|
|
|
|
|
|
|
|
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), |
|
|
|
|
|
|
|
{:ok, token} <- Chain.token_from_address_hash(address_hash, options), |
|
|
|
|
|
|
|
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do |
|
|
|
|
|
|
|
render( |
|
|
|
|
|
|
|
conn, |
|
|
|
|
|
|
|
"index.html", |
|
|
|
|
|
|
|
current_path: Controller.current_full_path(conn), |
|
|
|
|
|
|
|
token: Market.add_price(token), |
|
|
|
|
|
|
|
counters_path: token_path(conn, :token_counters, %{"id" => Address.checksum(address_hash)}) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{:restricted_access, _} -> |
|
|
|
|
|
|
|
not_found(conn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:error -> |
|
|
|
|
|
|
|
not_found(conn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
|
|
|
not_found(conn) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp unique_tokens_paging_options(%{"unique_token" => token_id}), |
|
|
|
defp unique_tokens_paging_options(%{"unique_token" => token_id}), |
|
|
|