diff --git a/CHANGELOG.md b/CHANGELOG.md index 21dafca1b1..0b621bd681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,17 @@ ## Current ### Features -- [#2366](https://github.com/poanetwork/blockscout/pull/2366) - paginate eth logs +- [#2391](https://github.com/poanetwork/blockscout/pull/2391) - Controllers Improvements - [#2379](https://github.com/poanetwork/blockscout/pull/2379) - Disable network selector when is empty +- [#2374](https://github.com/poanetwork/blockscout/pull/2374) - decode constructor arguments for verified smart contracts +- [#2366](https://github.com/poanetwork/blockscout/pull/2366) - paginate eth logs - [#2360](https://github.com/poanetwork/blockscout/pull/2360) - add default evm version to smart contract verification - [#2352](https://github.com/poanetwork/blockscout/pull/2352) - Fetch rewards in parallel with transactions - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint +- [#2324](https://github.com/poanetwork/blockscout/pull/2324) - set timeout for loading message on the main page ### Fixes +- [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2405](https://github.com/poanetwork/blockscout/pull/2405) - added templates for table loader and tile loader - [#2398](https://github.com/poanetwork/blockscout/pull/2398) - show only one decoded candidate - [#2395](https://github.com/poanetwork/blockscout/pull/2395) - new block loading animation @@ -29,6 +33,8 @@ - [#2326](https://github.com/poanetwork/blockscout/pull/2326) - fix nested constructor arguments ### Chore +- [#2418](https://github.com/poanetwork/blockscout/pull/2418) - Remove parentheses in market cap percentage +- [#2401](https://github.com/poanetwork/blockscout/pull/2401) - add ENV vars to manage updating period of average block time and market history cache - [#2363](https://github.com/poanetwork/blockscout/pull/2363) - add parameters example for eth rpc - [#2342](https://github.com/poanetwork/blockscout/pull/2342) - Upgrade Postgres image version in Docker setup - [#2325](https://github.com/poanetwork/blockscout/pull/2325) - Reduce function input to address' hash only where possible diff --git a/apps/block_scout_web/assets/js/lib/market_history_chart.js b/apps/block_scout_web/assets/js/lib/market_history_chart.js index 615f888d8a..d54d998580 100644 --- a/apps/block_scout_web/assets/js/lib/market_history_chart.js +++ b/apps/block_scout_web/assets/js/lib/market_history_chart.js @@ -4,6 +4,7 @@ import humps from 'humps' import numeral from 'numeral' import { formatUsdValue } from '../lib/currency' import sassVariables from '../../css/app.scss' +import { showLoader } from '../lib/utils' const config = { type: 'line', @@ -129,6 +130,10 @@ class MarketHistoryChart { export function createMarketHistoryChart (el) { const dataPath = el.dataset.market_history_chart_path const $chartLoading = $('[data-chart-loading-message]') + + const isTimeout = true + const timeoutID = showLoader(isTimeout, $chartLoading) + const $chartError = $('[data-chart-error-message]') const chart = new MarketHistoryChart(el, 0, []) $.getJSON(dataPath, {type: 'JSON'}) @@ -143,6 +148,7 @@ export function createMarketHistoryChart (el) { }) .always(() => { $chartLoading.hide() + clearTimeout(timeoutID) }) return chart } diff --git a/apps/block_scout_web/assets/js/lib/utils.js b/apps/block_scout_web/assets/js/lib/utils.js index e275580812..e00d06ec1b 100644 --- a/apps/block_scout_web/assets/js/lib/utils.js +++ b/apps/block_scout_web/assets/js/lib/utils.js @@ -11,3 +11,16 @@ export function batchChannel (func) { debouncedFunc() } } + +export function showLoader (isTimeout, loader) { + if (isTimeout) { + const timeout = setTimeout(function () { + loader.removeAttr('hidden') + loader.show() + }, 1000) + return timeout + } else { + loader.hide() + return null + } +} diff --git a/apps/block_scout_web/assets/js/pages/chain.js b/apps/block_scout_web/assets/js/pages/chain.js index 154c73e455..df89d92f36 100644 --- a/apps/block_scout_web/assets/js/pages/chain.js +++ b/apps/block_scout_web/assets/js/pages/chain.js @@ -9,7 +9,7 @@ import numeral from 'numeral' import socket from '../socket' import { exchangeRateChannel, formatUsdValue } from '../lib/currency' import { createStore, connectElements } from '../lib/redux_helpers.js' -import { batchChannel } from '../lib/utils' +import { batchChannel, showLoader } from '../lib/utils' import listMorph from '../lib/list_morph' import { createMarketHistoryChart } from '../lib/market_history_chart' @@ -214,11 +214,7 @@ const elements = { }, '[data-selector="chain-block-list"] [data-selector="loading-message"]': { render ($el, state, oldState) { - if (state.blocksLoading) { - $el.show() - } else { - $el.hide() - } + showLoader(state.blocksLoading, $el) } }, '[data-selector="transactions-list"] [data-selector="error-message"]': { @@ -228,7 +224,7 @@ const elements = { }, '[data-selector="transactions-list"] [data-selector="loading-message"]': { render ($el, state, oldState) { - $el.toggle(state.transactionsLoading) + showLoader(state.transactionsLoading, $el) } }, '[data-selector="transactions-list"]': { diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex index 33a01959c9..9267c0dcab 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex @@ -16,7 +16,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), - {:ok, address} <- Chain.hash_to_address(address_hash, [], false) do + :ok <- Chain.check_address_exists(address_hash) do full_options = paging_options(params) coin_balances_plus_one = Chain.address_to_coin_balances(address_hash, full_options) @@ -32,7 +32,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do address_coin_balance_path( conn, :index, - address, + address_hash, Map.delete(next_page_params, "type") ) end @@ -52,7 +52,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do :error -> unprocessable_entity(conn) - {:error, :not_found} -> + :not_found -> not_found(conn) end end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_controller.ex index bc4df8c4be..5db900b12b 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_controller.ex @@ -8,8 +8,18 @@ defmodule BlockScoutWeb.AddressContractController do alias Indexer.Fetcher.CoinBalanceOnDemand def index(conn, %{"address_id" => address_hash_string}) do + address_options = [ + necessity_by_association: %{ + :contracts_creation_internal_transaction => :optional, + :names => :optional, + :smart_contract => :optional, + :token => :optional, + :contracts_creation_transaction => :optional + } + ] + with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), - {:ok, address} <- Chain.find_contract_address(address_hash) do + {:ok, address} <- Chain.find_contract_address(address_hash, address_options, true) do render( conn, "index.html", diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex index e349ecd9ef..9e05643187 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex @@ -16,7 +16,7 @@ defmodule BlockScoutWeb.AddressLogsController do def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), - {:ok, address} <- Chain.hash_to_address(address_hash, [], false) do + :ok <- Chain.check_address_exists(address_hash) do logs_plus_one = Chain.address_to_logs(address_hash, paging_options(params)) {results, next_page} = split_list_by_page(logs_plus_one) @@ -26,7 +26,7 @@ defmodule BlockScoutWeb.AddressLogsController do nil next_page_params -> - address_logs_path(conn, :index, address, Map.delete(next_page_params, "type")) + address_logs_path(conn, :index, address_hash, Map.delete(next_page_params, "type")) end items = @@ -74,7 +74,7 @@ defmodule BlockScoutWeb.AddressLogsController do def search_logs(conn, %{"topic" => topic, "address_id" => address_hash_string} = params) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), - {:ok, address} <- Chain.hash_to_address(address_hash, [], false) do + :ok <- Chain.check_address_exists(address_hash) do topic = String.trim(topic) formatted_topic = if String.starts_with?(topic, "0x"), do: topic, else: "0x" <> topic @@ -89,7 +89,7 @@ defmodule BlockScoutWeb.AddressLogsController do nil next_page_params -> - address_logs_path(conn, :index, address, Map.delete(next_page_params, "type")) + address_logs_path(conn, :index, address_hash, Map.delete(next_page_params, "type")) end items = diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_read_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_read_contract_controller.ex index d57aa30807..0849689dce 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_read_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_read_contract_controller.ex @@ -15,8 +15,18 @@ defmodule BlockScoutWeb.AddressReadContractController do import BlockScoutWeb.AddressController, only: [transaction_count: 1, validation_count: 1] def index(conn, %{"address_id" => address_hash_string}) do + address_options = [ + necessity_by_association: %{ + :contracts_creation_internal_transaction => :optional, + :names => :optional, + :smart_contract => :optional, + :token => :optional, + :contracts_creation_transaction => :optional + } + ] + with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), - {:ok, address} <- Chain.find_contract_address(address_hash) do + {:ok, address} <- Chain.find_contract_address(address_hash, address_options, true) do render( conn, "index.html", diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex index 91569a96da..835e19bf3e 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex @@ -8,9 +8,8 @@ defmodule BlockScoutWeb.API.RPC.BlockController do def getblockreward(conn, params) do with {:block_param, {:ok, unsafe_block_number}} <- {:block_param, Map.fetch(params, "blockno")}, {:ok, block_number} <- ChainWeb.param_to_block_number(unsafe_block_number), - block_options = [necessity_by_association: %{transactions: :optional}], - {:ok, block} <- Chain.number_to_block(block_number, block_options) do - reward = Chain.block_reward(block) + {:ok, block} <- Chain.number_to_block(block_number) do + reward = Chain.block_reward(block_number) render(conn, :block_reward, block: block, reward: reward) else diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/transaction_controller.ex index 344dbe1037..565ea4b6a5 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/transaction_controller.ex @@ -10,7 +10,7 @@ defmodule BlockScoutWeb.API.RPC.TransactionController do {:format, {:ok, transaction_hash}} <- to_transaction_hash(txhash_param), {:transaction, {:ok, transaction}} <- transaction_from_hash(transaction_hash), paging_options <- paging_options(params) do - logs = Chain.transaction_to_logs(transaction, paging_options) + logs = Chain.transaction_to_logs(transaction_hash, paging_options) {logs, next_page} = split_list_by_page(logs) render(conn, :gettxinfo, %{ diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex index 1eec849380..7b783b9761 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex @@ -7,8 +7,9 @@ defmodule BlockScoutWeb.API.V1.DecompiledSmartContractController do def create(conn, params) do if auth_token(conn) == actual_token() do with {:ok, hash} <- validate_address_hash(params["address_hash"]), - :ok <- smart_contract_exists?(hash), - :ok <- decompiled_contract_exists?(params["address_hash"], params["decompiler_version"]) do + :ok <- Chain.check_address_exists(hash), + {:contract, :not_found} <- + {:contract, Chain.check_decompiled_contract_exists(params["address_hash"], params["decompiler_version"])} do case Chain.create_decompiled_smart_contract(params) do {:ok, decompiled_smart_contract} -> send_resp(conn, :created, Jason.encode!(decompiled_smart_contract)) @@ -29,7 +30,7 @@ defmodule BlockScoutWeb.API.V1.DecompiledSmartContractController do :not_found -> send_resp(conn, :unprocessable_entity, encode(%{error: "address is not found"})) - :contract_exists -> + {:contract, :ok} -> send_resp( conn, :unprocessable_entity, @@ -41,13 +42,6 @@ defmodule BlockScoutWeb.API.V1.DecompiledSmartContractController do end end - defp smart_contract_exists?(address_hash) do - case Chain.hash_to_address(address_hash) do - {:ok, _address} -> :ok - _ -> :not_found - end - end - defp validate_address_hash(address_hash) do case Address.cast(address_hash) do {:ok, hash} -> {:ok, hash} @@ -55,13 +49,6 @@ defmodule BlockScoutWeb.API.V1.DecompiledSmartContractController do end end - defp decompiled_contract_exists?(address_hash, decompiler_version) do - case Chain.decompiled_code(address_hash, decompiler_version) do - {:ok, _} -> :contract_exists - _ -> :ok - end - end - defp auth_token(conn) do case get_req_header(conn, "auth_token") do [token] -> token diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/verified_smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/verified_smart_contract_controller.ex index 50334a1a45..8b3d3d71eb 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/verified_smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/verified_smart_contract_controller.ex @@ -7,8 +7,8 @@ defmodule BlockScoutWeb.API.V1.VerifiedSmartContractController do def create(conn, params) do with {:ok, hash} <- validate_address_hash(params["address_hash"]), - :ok <- smart_contract_exists?(hash), - :ok <- verified_smart_contract_exists?(hash) do + :ok <- Chain.check_address_exists(hash), + {:contract, :not_found} <- {:contract, Chain.check_verified_smart_contract_exists(hash)} do external_libraries = fetch_external_libraries(params) case Publisher.publish(hash, params, external_libraries) do @@ -31,7 +31,7 @@ defmodule BlockScoutWeb.API.V1.VerifiedSmartContractController do :not_found -> send_resp(conn, :unprocessable_entity, encode(%{error: "address is not found"})) - :contract_exists -> + {:contract, :ok} -> send_resp( conn, :unprocessable_entity, @@ -40,13 +40,6 @@ defmodule BlockScoutWeb.API.V1.VerifiedSmartContractController do end end - defp smart_contract_exists?(address_hash) do - case Chain.hash_to_address(address_hash) do - {:ok, _address} -> :ok - _ -> :not_found - end - end - defp validate_address_hash(address_hash) do case Address.cast(address_hash) do {:ok, hash} -> {:ok, hash} @@ -54,14 +47,6 @@ defmodule BlockScoutWeb.API.V1.VerifiedSmartContractController do end end - defp verified_smart_contract_exists?(address_hash) do - if Chain.address_hash_to_smart_contract(address_hash) do - :contract_exists - else - :ok - end - end - defp encode(data) do Jason.encode!(data) end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/block_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/block_transaction_controller.ex index 15b06f1edd..a1e4cbeb09 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/block_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/block_transaction_controller.ex @@ -26,7 +26,7 @@ defmodule BlockScoutWeb.BlockTransactionController do paging_options(params) ) - transactions_plus_one = Chain.block_to_transactions(block, full_options) + transactions_plus_one = Chain.block_to_transactions(block.hash, full_options) {transactions, next_page} = split_list_by_page(transactions_plus_one) @@ -89,7 +89,7 @@ defmodule BlockScoutWeb.BlockTransactionController do :rewards => :optional } ) do - block_transaction_count = Chain.block_to_transaction_count(block) + block_transaction_count = Chain.block_to_transaction_count(block.hash) render( conn, diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex index 40a0fd3bbb..2c16cd1b03 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex @@ -2,7 +2,7 @@ defmodule BlockScoutWeb.ChainController do use BlockScoutWeb, :controller alias BlockScoutWeb.ChainView - alias Explorer.{Chain, PagingOptions, Repo} + alias Explorer.{Chain, PagingOptions} alias Explorer.Chain.{Address, Block, Transaction} alias Explorer.Chain.Supply.RSK alias Explorer.Counters.AverageBlockTime @@ -72,9 +72,15 @@ defmodule BlockScoutWeb.ChainController do def chain_blocks(conn, _params) do if ajax?(conn) do blocks = - [paging_options: %PagingOptions{page_size: 4}] + [ + paging_options: %PagingOptions{page_size: 4}, + necessity_by_association: %{ + [miner: :names] => :optional, + :transactions => :optional, + :rewards => :optional + } + ] |> Chain.list_blocks() - |> Repo.preload([[miner: :names], :transactions, :rewards]) |> Enum.map(fn block -> %{ chain_block_html: diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex index 70ec6219f3..311feb4591 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex @@ -33,7 +33,7 @@ defmodule BlockScoutWeb.SmartContractController do def show(conn, params) do with true <- ajax?(conn), {:ok, address_hash} <- Chain.string_to_address_hash(params["id"]), - {:ok, _address} <- Chain.find_contract_address(address_hash), + :ok <- Chain.check_contract_address_exists(address_hash), outputs = Reader.query_function( address_hash, @@ -51,7 +51,7 @@ defmodule BlockScoutWeb.SmartContractController do :error -> unprocessable_entity(conn) - {:error, :not_found} -> + :not_found -> not_found(conn) _ -> diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex index 1bedf97c1d..3f849c0e7c 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex @@ -62,15 +62,15 @@ defmodule BlockScoutWeb.TransactionController do def show(conn, %{"id" => id}) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(id), - {:ok, %Chain.Transaction{} = transaction} <- Chain.hash_to_transaction(transaction_hash) do - if Chain.transaction_has_token_transfers?(transaction.hash) do + :ok <- Chain.check_transaction_exists(transaction_hash) do + if Chain.transaction_has_token_transfers?(transaction_hash) do redirect(conn, to: transaction_token_transfer_path(conn, :index, id)) else redirect(conn, to: transaction_internal_transaction_path(conn, :index, id)) end else :error -> conn |> put_status(422) |> render("invalid.html", transaction_hash: id) - {:error, :not_found} -> conn |> put_status(404) |> render("not_found.html", transaction_hash: id) + :not_found -> conn |> put_status(404) |> render("not_found.html", transaction_hash: id) end end end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_internal_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_internal_transaction_controller.ex index 159d144cdd..ca154a0136 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_internal_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_internal_transaction_controller.ex @@ -10,7 +10,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do def index(conn, %{"transaction_id" => hash_string, "type" => "JSON"} = params) do with {:ok, hash} <- Chain.string_to_transaction_hash(hash_string), - {:ok, transaction} <- Chain.hash_to_transaction(hash) do + :ok <- Chain.check_transaction_exists(hash) do full_options = Keyword.merge( [ @@ -24,7 +24,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do paging_options(params) ) - internal_transactions_plus_one = Chain.transaction_to_internal_transactions(transaction, full_options) + internal_transactions_plus_one = Chain.transaction_to_internal_transactions(hash, full_options) {internal_transactions, next_page} = split_list_by_page(internal_transactions_plus_one) @@ -37,7 +37,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do transaction_internal_transaction_path( conn, :index, - transaction, + hash, Map.delete(next_page_params, "type") ) end @@ -66,7 +66,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do |> put_view(TransactionView) |> render("invalid.html", transaction_hash: hash_string) - {:error, :not_found} -> + :not_found -> conn |> put_status(404) |> put_view(TransactionView) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex index 0a87d12493..e076b9ee7b 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex @@ -11,7 +11,9 @@ defmodule BlockScoutWeb.TransactionLogController do def index(conn, %{"transaction_id" => transaction_hash_string, "type" => "JSON"} = params) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(transaction_hash_string), {:ok, transaction} <- - Chain.hash_to_transaction(transaction_hash) do + Chain.hash_to_transaction(transaction_hash, + necessity_by_association: %{[to_address: :smart_contract] => :optional} + ) do full_options = Keyword.merge( [ @@ -22,7 +24,7 @@ defmodule BlockScoutWeb.TransactionLogController do paging_options(params) ) - logs_plus_one = Chain.transaction_to_logs(transaction, full_options) + logs_plus_one = Chain.transaction_to_logs(transaction_hash, full_options) {logs, next_page} = split_list_by_page(logs_plus_one) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_raw_trace_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_raw_trace_controller.ex index 3d090e8a9b..250a6b4442 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_raw_trace_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_raw_trace_controller.ex @@ -19,7 +19,7 @@ defmodule BlockScoutWeb.TransactionRawTraceController do :token_transfers => :optional } ) do - internal_transactions = Chain.transaction_to_internal_transactions(transaction) + internal_transactions = Chain.transaction_to_internal_transactions(hash) render( conn, diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_token_transfer_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_token_transfer_controller.ex index cfb215da3e..585a01301f 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_token_transfer_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_token_transfer_controller.ex @@ -10,8 +10,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do def index(conn, %{"transaction_id" => hash_string, "type" => "JSON"} = params) do with {:ok, hash} <- Chain.string_to_transaction_hash(hash_string), - {:ok, transaction} <- - Chain.hash_to_transaction(hash) do + :ok <- Chain.check_transaction_exists(hash) do full_options = Keyword.merge( [ @@ -24,7 +23,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do paging_options(params) ) - token_transfers_plus_one = Chain.transaction_to_token_transfers(transaction, full_options) + token_transfers_plus_one = Chain.transaction_to_token_transfers(hash, full_options) {token_transfers, next_page} = split_list_by_page(token_transfers_plus_one) @@ -34,7 +33,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do nil next_page_params -> - transaction_token_transfer_path(conn, :index, transaction, Map.delete(next_page_params, "type")) + transaction_token_transfer_path(conn, :index, hash, Map.delete(next_page_params, "type")) end items = @@ -62,7 +61,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do |> put_view(TransactionView) |> render("invalid.html", transaction_hash: hash_string) - {:error, :not_found} -> + :not_found -> conn |> put_status(404) |> put_view(TransactionView) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex index 9680faa2a8..56f1a2bbb2 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex @@ -21,7 +21,7 @@ <%= if @total_supply do %> - (<%= balance_percentage(@address, @total_supply) %>) + <%= balance_percentage(@address, @total_supply) %> <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex index 340765a97f..e8d6501e02 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex @@ -46,14 +46,18 @@
<%= @address.smart_contract.evm_version %>
<% end %> - <%= if @address.smart_contract.constructor_arguments do %> -
-
<%= gettext "Constructor arguments" %>
-
<%= @address.smart_contract.constructor_arguments %>
-
- <% end %> -
+ <%= if @address.smart_contract.constructor_arguments do %> +
+
+

<%= gettext "Constructor Arguments" %>

+
+
+
<%= raw(format_constructor_arguments(@address.smart_contract)) %>
+              
+
+
+ <% end %>

<%= gettext "Contract source code" %>

@@ -116,7 +120,7 @@

<%= gettext "External libraries" %>

-
<%= format_external_libraries(@address.smart_contract.external_libraries) %>
+              
<%= raw(format_external_libraries(@address.smart_contract.external_libraries)) %>
               
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex index f0ffa52ca2..5e136a1007 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex @@ -5,7 +5,7 @@
-
+