diff --git a/CHANGELOG.md b/CHANGELOG.md index da24792d19..85f3dcfc33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Fixes ### Chore +- [#5119](https://github.com/blockscout/blockscout/pull/5119) - Inventory controller refactoring - [#5118](https://github.com/blockscout/blockscout/pull/5118) - Fix top navigation template diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/tokens/inventory_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/tokens/inventory_controller.ex index fe356ff9ff..5129856a18 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/tokens/inventory_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/tokens/inventory_controller.ex @@ -1,10 +1,10 @@ defmodule BlockScoutWeb.Tokens.InventoryController do use BlockScoutWeb, :controller - alias BlockScoutWeb.{AccessHelpers, Controller} - alias BlockScoutWeb.Tokens.InventoryView - alias Explorer.{Chain, Market} - alias Explorer.Chain.{Address, TokenTransfer} + alias BlockScoutWeb.AccessHelpers + alias BlockScoutWeb.Tokens.{HolderController, InventoryView} + alias Explorer.Chain + alias Explorer.Chain.TokenTransfer alias Phoenix.View import BlockScoutWeb.Chain, only: [split_list_by_page: 1, default_paging_options: 0] @@ -66,29 +66,8 @@ defmodule BlockScoutWeb.Tokens.InventoryController do end end - def index(conn, %{"token_id" => address_hash_string} = params) do - options = [necessity_by_association: %{[contract_address: :smart_contract] => :optional}] - - 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 + def index(conn, params) do + HolderController.index(conn, params) end defp unique_tokens_paging_options(%{"unique_token" => token_id}),