diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_decompiled_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_decompiled_contract_controller.ex new file mode 100644 index 0000000000..b0ae0e3d4d --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_decompiled_contract_controller.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 diff --git a/apps/block_scout_web/lib/block_scout_web/router.ex b/apps/block_scout_web/lib/block_scout_web/router.ex index d13ff1a85e..bf687134dd 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -129,6 +129,13 @@ defmodule BlockScoutWeb.Router do as: :contract ) + resources( + "/decompiled_contracts", + AddressDecompiledContractController, + only: [:index], + as: :decompiled_contract + ) + resources( "/contract_verifications", AddressContractVerificationController,