-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
address_decompiled_contract_controller.ex
35 lines (30 loc) · 1.2 KB
/
address_decompiled_contract_controller.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
defmodule BlockScoutWeb.AddressDecompiledContractController do
use BlockScoutWeb, :controller
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.AccessHelper
alias Explorer.{Chain, Market}
alias Indexer.Fetcher.CoinBalanceOnDemand
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_decompiled_contract_address(address_hash),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",
address: address,
coin_balance_status: CoinBalanceOnDemand.trigger_fetch(address),
exchange_rate: Market.get_coin_exchange_rate(),
counters_path: address_path(conn, :address_counters, %{"id" => address_hash_string}),
tags: get_address_tags(address_hash, current_user(conn))
)
else
{:restricted_access, _} ->
not_found(conn)
:error ->
not_found(conn)
{:error, :not_found} ->
not_found(conn)
end
end
end