add decompiled contract tab endpoint

pull/1654/head
Ayrat Badykov 6 years ago
parent ebf5bcf558
commit 3b237562ef
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 30
      apps/block_scout_web/lib/block_scout_web/controllers/address_decompiled_contract_controller.ex
  2. 7
      apps/block_scout_web/lib/block_scout_web/router.ex

@ -0,0 +1,30 @@
defmodule BlockScoutWeb.AddressDecompiledContractController do
use BlockScoutWeb, :controller
import BlockScoutWeb.AddressController, only: [transaction_count: 1, validation_count: 1]
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Indexer.CoinBalance.OnDemandFetcher
def index(conn, %{"address_id" => address_hash_string}) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_decompiled_contract_address(address_hash) do
render(
conn,
"index.html",
address: address,
coin_balance_status: OnDemandFetcher.trigger_fetch(address),
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(),
transaction_count: transaction_count(address),
validation_count: validation_count(address)
)
else
:error ->
not_found(conn)
{:error, :not_found} ->
not_found(conn)
end
end
end

@ -129,6 +129,13 @@ defmodule BlockScoutWeb.Router do
as: :contract
)
resources(
"/decompiled_contracts",
AddressDecompiledContractController,
only: [:index],
as: :decompiled_contract
)
resources(
"/contract_verifications",
AddressContractVerificationController,

Loading…
Cancel
Save