Skip to content

Commit

Permalink
Merge pull request blockscout#5119 from blockscout/vb-inventory-contr…
Browse files Browse the repository at this point in the history
…oller-refactoring

Inventory controller refactoring
  • Loading branch information
vbaranov authored and jagdeep sidhu committed Jan 21, 2022
1 parent 3420645 commit b9ccace
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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}),
Expand Down

0 comments on commit b9ccace

Please sign in to comment.