From d1a7f29df504fd3fb08a97e3f1ec520c64e17c07 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Thu, 25 May 2023 09:25:56 +0800 Subject: [PATCH 01/44] feat: ui ops --- .../css/components/_custom_tooltips.scss | 34 +++++++++++++++++++ .../assets/css/components/_tooltip.scss | 6 ++-- .../controllers/chain_controller.ex | 16 ++++++++- .../controllers/l2_to_l1_txn_controller.ex | 28 +++++++++++++-- .../controllers/search_controller.ex | 3 ++ .../templates/l1_to_l2_txn/_tile.html.eex | 6 ++-- .../templates/l2_to_l1_txn/_tile.html.eex | 6 ++-- .../templates/l2_to_l1_txn/index.html.eex | 12 +++++++ .../block_scout_web/views/transaction_view.ex | 2 +- apps/block_scout_web/priv/gettext/default.pot | 2 +- .../priv/gettext/en/LC_MESSAGES/default.po | 2 +- apps/explorer/lib/explorer/chain.ex | 26 ++++++++++++-- 12 files changed, 127 insertions(+), 16 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_custom_tooltips.scss b/apps/block_scout_web/assets/css/components/_custom_tooltips.scss index 9328e761b3c1..1aa231302285 100644 --- a/apps/block_scout_web/assets/css/components/_custom_tooltips.scss +++ b/apps/block_scout_web/assets/css/components/_custom_tooltips.scss @@ -107,6 +107,40 @@ $tooltip-background-color: $btn-line-color !default; width: 150px !important; } } +.tooltip-inner { + .custom-tooltip-container{ + //width: 275px; + p{ + margin-bottom: 0; + } + + .custom-tooltip-total-title{ + font-family: 'Nunito'; + font-style: normal; + font-weight: 800; + font-size: 14px; + line-height: 22px; + color: #15181C; + overflow: visible; + padding-bottom: 8px; + border-bottom: 1px solid #AED9D6; + margin-bottom: 8px; + white-space: nowrap; + } + .custom-tooltip-title{ + font-style: normal; + font-weight: 900; + font-size: 14px; + text-align: start; + color: #585F65; + } + .custom-tooltip-content{ + font-size: 12px; + text-align: start; + color: #2B3034; + } + } +} .custom-tooltip { font-family: Nunito, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; diff --git a/apps/block_scout_web/assets/css/components/_tooltip.scss b/apps/block_scout_web/assets/css/components/_tooltip.scss index a9b0315f7a51..df9aa849bbc8 100644 --- a/apps/block_scout_web/assets/css/components/_tooltip.scss +++ b/apps/block_scout_web/assets/css/components/_tooltip.scss @@ -1,9 +1,10 @@ -$tooltip-background-color: $btn-line-color !default; +$tooltip-background-color: #CBE9E7 !default; $tooltip-color: #fff !default; .tooltip { - max-width: 250px; + max-width: 305px; min-width: 100px; + opacity: 1 !important; .tooltip-inner { background-color: $tooltip-background-color; @@ -11,6 +12,7 @@ $tooltip-color: #fff !default; color: $tooltip-color; padding: 15px; font-size: 12px; + max-width: 305px; } .arrow::before { 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 000fef010dcb..ac0e0966c9a8 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 @@ -6,7 +6,7 @@ defmodule BlockScoutWeb.ChainController do alias BlockScoutWeb.API.V2.Helper alias BlockScoutWeb.{ChainView, Controller} alias Explorer.{Chain, PagingOptions, Repo} - alias Explorer.Chain.{Address, Block, Transaction} + alias Explorer.Chain.{Address, Block, Transaction, DaBatch} alias Explorer.Chain.Cache.Block, as: BlockCache alias Explorer.Chain.Cache.GasUsage alias Explorer.Chain.Cache.Transaction, as: TransactionCache @@ -73,6 +73,7 @@ defmodule BlockScoutWeb.ChainController do |> BlockScoutWeb.Chain.from_param() |> case do {:ok, item} -> + Logger.info("0-0-0-0-") redirect_search_results(conn, item) {:error, :not_found} -> @@ -152,6 +153,7 @@ defmodule BlockScoutWeb.ChainController do end defp redirect_search_results(conn, %Address{} = item) do + Logger.info("0-0-0-0-444") address_path = conn |> address_path(:show, item) @@ -161,6 +163,7 @@ defmodule BlockScoutWeb.ChainController do end defp redirect_search_results(conn, %Block{} = item) do + Logger.info("0-0-0-0-333") block_path = conn |> block_path(:show, item) @@ -170,6 +173,7 @@ defmodule BlockScoutWeb.ChainController do end defp redirect_search_results(conn, %Transaction{} = item) do + Logger.info("0-0-0-0-111") transaction_path = conn |> transaction_path(:show, item) @@ -177,4 +181,14 @@ defmodule BlockScoutWeb.ChainController do redirect(conn, to: transaction_path) end + + defp redirect_search_results(conn, %DaBatch{} = item) do + Logger.info("0-0-0-0-2222") + eigenda_batch_path = + conn + |> eigenda_batch_path(:show, item) + |> Controller.full_path() + + redirect(conn, to: eigenda_batch_path) + end end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/l2_to_l1_txn_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/l2_to_l1_txn_controller.ex index cc452ff7ea44..3f2506daf204 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/l2_to_l1_txn_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/l2_to_l1_txn_controller.ex @@ -99,11 +99,35 @@ defmodule BlockScoutWeb.L2ToL1TxnController do conn, %{ items: - Enum.map(l2_to_l1, fn l2_to_l1 -> + Enum.map(l2_to_l1, fn l -> + display_status = case l.status do + "Waiting" -> + "Waiting for relay" + "Ready for Relay" -> + "Ready for Claim" + "Relayed" -> + "Claimed" + _ -> + l.status + end + + updated_l2_to_l1 = Map.put(l, :display_status, display_status) + + display_status_tooltip = case l.status do + "Waiting" -> + "Withdrawn on L2 but not ready for claim on L1" + "Ready for Relay" -> + "Ready for claim on L1" + "Relayed" -> + "Withdrawal has been claimed on L1" + _ -> + l.status + end + l2_to_l1_data = Map.put(updated_l2_to_l1, :display_status_tooltip, display_status_tooltip) View.render_to_string( L2ToL1TxnView, "_tile.html", - l2_to_l1: l2_to_l1, + l2_to_l1: l2_to_l1_data, conn: conn, l1_explorer: Application.get_env(:block_scout_web, :l1_explorer_url) ) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex index b2f639a6e3a9..898ba0cc590a 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex @@ -6,8 +6,10 @@ defmodule BlockScoutWeb.SearchController do alias BlockScoutWeb.{Controller, SearchView} alias Explorer.Chain alias Phoenix.View + require Logger def search_results(conn, %{"q" => query, "type" => "JSON"} = params) do + Logger.info("==========") [paging_options: paging_options] = paging_options(params) offset = (max(paging_options.page_number, 1) - 1) * paging_options.page_size @@ -58,6 +60,7 @@ defmodule BlockScoutWeb.SearchController do end def search_results(conn, %{"q" => query}) do + Logger.info("==========22") render( conn, "results.html", diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex index afc17b5c3f3d..5641455ae6e7 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex @@ -2,7 +2,7 @@ class="fade-in txn-list-table-item" data-identifier-hash="<%= @l1_to_l2.queue_index %>" > - + <%= @l1_to_l2.block %> @@ -11,7 +11,7 @@ <%= if @l1_to_l2.l2_hash == nil do %> -

NULL

+

Pending

<% else %> @@ -29,6 +29,6 @@ <%= @l1_to_l2.gas_limit %> - + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_tile.html.eex index 25103f9a2f6c..5499f85089ac 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_tile.html.eex @@ -13,11 +13,13 @@ - <%= @l2_to_l1.status %> + <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: Gettext.gettext(BlockScoutWeb.Gettext, @l2_to_l1.display_status_tooltip) %> + <%= @l2_to_l1.display_status %> <%= if @l2_to_l1.hash == nil do %> -

NULL

+

N/A

<% else %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/index.html.eex index 69ef9417b641..8e12a6f69168 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/index.html.eex @@ -45,6 +45,18 @@ Age + <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext(" +
+

Whole status about the L2-L1 withdrawal

+

· Waiting for Relay:

+

Withdrawn on L2 but not ready for claim on L1

+

· Ready for Claim:

+

Ready for claim on L1

+

· Claimed:

+

Withdrawal has been claimed on L1

+
+ ") %> Status
diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index 058fceb4512c..cd4eba443e2f 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -291,7 +291,7 @@ require Logger end _ -> - "" + "blocks" end end diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 5deab81b522c..bf71940f8540 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -3089,7 +3089,7 @@ msgstr "L1->L2 Transactions" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:49 msgid "L2 to L1 Transactions" -msgstr "L2->L1 Transactions" +msgstr "L2->L1 Withdrawals" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:49 diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index d9ee2d454b4c..6968370b017d 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -3091,7 +3091,7 @@ msgstr "L1->L2 Transactions" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:49 msgid "L2 to L1 Transactions" -msgstr "L2->L1 Transactions" +msgstr "L2->L1 Withdrawals" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:49 diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index e0a09b7af63c..dd2f4e5a26d2 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2141,8 +2141,8 @@ defmodule Explorer.Chain do `:required`, and the `t:Explorer.Chain.Transaction.t/0` has no associated record for that association, then the `t:Explorer.Chain.Transaction.t/0` will not be included in the page `entries`. """ - @spec hash_to_transaction(Hash.Full.t(), [necessity_by_association_option]) :: - {:ok, Transaction.t()} | {:error, :not_found} + @spec hash_to_transaction(Hash.Full.t() | String.t(), [necessity_by_association_option]) :: + {:ok, Transaction.t()} | {:ok, DaBatch.t()} | {:error, :not_found} def hash_to_transaction( %Hash{byte_count: unquote(Hash.Full.byte_count())} = hash, options \\ [] @@ -2156,13 +2156,33 @@ defmodule Explorer.Chain do |> Repo.one() |> case do nil -> - {:error, :not_found} + Logger.info("111111111111122") + hash_string = Hash.to_string(hash) + Logger.info("111111111111122") + DaBatch + |> where([da_batch], da_batch.da_hash == ^hash_string) + |> limit(1) + |> Repo.one() + |> case do + nil -> {:error, :not_found} + + da_transaction -> + Logger.info("1111111111111") + {:ok, da_transaction} + end transaction -> {:ok, transaction} end end + defp hash_to_da_transaction(da_hash) do + DaBatch + |> where([da_batch], da_batch.da_hash == ^da_hash) + |> limit(1) + |> Repo.one() + end + # preload_to_detect_tt?: we don't need to preload more than one token transfer in case the tx inside the list (we dont't show any token transfers on tx tile in new UI) def preload_token_transfers( %Transaction{hash: tx_hash, block_hash: block_hash} = transaction, From cb5cb5e3a1e70c05888ba1d47de06a61a8398b6c Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Thu, 25 May 2023 18:12:46 +0800 Subject: [PATCH 02/44] search da detail --- .../lib/block_scout_web/controllers/chain_controller.ex | 4 ++-- .../block_scout_web/controllers/eigenda_batch_controller.ex | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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 ac0e0966c9a8..3941b2f36ab4 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 @@ -187,8 +187,8 @@ defmodule BlockScoutWeb.ChainController do eigenda_batch_path = conn |> eigenda_batch_path(:show, item) - |> Controller.full_path() - + #|> Controller.full_path() + Logger.info("#{inspect(eigenda_batch_path)}") redirect(conn, to: eigenda_batch_path) end end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex index 129ef80d2453..d83eae767799 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex @@ -125,7 +125,9 @@ require Logger end def show(conn, %{"da_hash" => da_hash}) do + Logger.info("-1123123--------") %{da_batch: da_batch} = Chain.da_batch_detail(da_hash); + Logger.info("#{inspect(da_batch)}") render( conn, "overview.html", From 56f7d0fb93cd239bbc74b493020a2d0dcc351f40 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 30 May 2023 15:33:11 +0800 Subject: [PATCH 03/44] feat: remove txn batch, add eigenlayer batch to home page --- apps/block_scout_web/assets/js/pages/chain.js | 58 +++++++++---------- .../controllers/chain_controller.ex | 15 +---- .../controllers/eigenda_batch_controller.ex | 2 - .../recent_eigenda_batches_controller.ex | 33 +++++++++++ .../controllers/search_controller.ex | 2 - .../templates/chain/show.html.eex | 10 ++-- .../eigenda_batch/_recent_tile.html.eex | 23 ++++---- .../templates/layout/_topnav.html.eex | 14 +---- .../templates/txn_batch/_link.html.eex | 3 - .../views/eigenda_batch_view.ex | 2 +- .../lib/block_scout_web/web_router.ex | 4 +- apps/explorer/lib/explorer/chain.ex | 19 ++++++ .../src/schedule/tasks.service.ts | 4 +- 13 files changed, 108 insertions(+), 81 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex diff --git a/apps/block_scout_web/assets/js/pages/chain.js b/apps/block_scout_web/assets/js/pages/chain.js index 510810fd6ff1..c853f300ac81 100644 --- a/apps/block_scout_web/assets/js/pages/chain.js +++ b/apps/block_scout_web/assets/js/pages/chain.js @@ -25,14 +25,14 @@ export const initialState = { blocksLoading: true, blocksError: false, transactions: [], - txnBatches: [], + eigendaBatches: [], l1ToL2Txn: [], transactionsBatch: [], transactionsError: false, - txnBatchesError: false, + eigendaBatchesError: false, L1ToL2Error: false, transactionsLoading: true, - txnBatchesLoading: true, + eigendaBatchesLoading: true, L1ToL2Loading: true, transactionCount: null, totalGasUsageCount: null, @@ -150,17 +150,17 @@ function baseReducer(state = initialState, action) { case 'FINISH_TRANSACTIONS_FETCH': return Object.assign({}, state, { transactionsLoading: false }) - case 'START_TXN_BATCHES_FETCH': - return Object.assign({}, state, {txnBatchesError: false, txnBatchesLoading: true }) - case 'TXN_BATCHES_FETCHED': - return Object.assign({}, state, { txnBatches: [...action.msg.txnBatches] }) - case 'TXN_BATCHES_FETCH_ERROR': - return Object.assign({}, state, { txnBatchesError: true }) - case 'FINISH_TXN_BATCHES_FETCH': - return Object.assign({}, state, { txnBatchesLoading: false }) + case 'START_EIGENDA_BATCHES_FETCH': + return Object.assign({}, state, {eigendaBatchesError: false, eigendaBatchesLoading: true }) + case 'EIGENDA_BATCHES_FETCHED': + return Object.assign({}, state, { eigendaBatches: [...action.msg.eigendaBatches] }) + case 'EIGENDA_BATCHES_FETCH_ERROR': + return Object.assign({}, state, { eigendaBatchesError: true }) + case 'FINISH_EIGENDA_BATCHES_FETCH': + return Object.assign({}, state, { eigendaBatchesLoading: false }) case 'START_L1_TO_L2_FETCH': - return Object.assign({}, state, {L1ToL2Error: false, txnBatchesLoading: true }) + return Object.assign({}, state, {L1ToL2Error: false, eigendaBatchesLoading: true }) case 'L1_TO_L2_FETCHED': return Object.assign({}, state, { l1ToL2Txn: [...action.msg.l1ToL2Txn] }) case 'L1_TO_L2_FETCH_ERROR': @@ -322,25 +322,25 @@ const elements = { listMorph(container, newElements, { key: 'dataset.identifierHash' }) } }, - '[data-selector="txn-batch-list"] [data-selector="error-message"]': { + '[data-selector="eigenda-batch-list"] [data-selector="error-message"]': { render ($el, state, _oldState) { - $el.toggle(state.txnBatchesError) + $el.toggle(state.eigendaBatchesError) } }, - '[data-selector="txn-batch-list"] [data-selector="loading-message"]': { + '[data-selector="eigenda-batch-list"] [data-selector="loading-message"]': { render ($el, state, _oldState) { - showLoader(state.txnBatchesLoading, $el) + showLoader(state.eigendaBatchesLoading, $el) } }, - '[data-selector="txn-batch-list"]': { + '[data-selector="eigenda-batch-list"]': { load($el) { - return { txnBatchesPath: $el[0].dataset.txnBatchesPath } + return { eigendaBatchesPath: $el[0].dataset.eigendaBatchesPath } }, render($el, state, oldState) { - if (oldState.txnBatches === state.txnBatches) return + if (oldState.eigendaBatches === state.eigendaBatches) return const container = $el[0] - const newElements = map(state.txnBatches, ({ txnBatchesHtml }) => { - return $(txnBatchesHtml)[0] + const newElements = map(state.eigendaBatches, ({ eigendaBatchesHtml }) => { + return $(eigendaBatchesHtml)[0] }) listMorph(container, newElements, { key: 'dataset.identifierHash' }) } @@ -384,7 +384,7 @@ if ($chainDetailsPage.length) { connectElements({ store, elements }) loadTransactions(store) - loadTxnBatches(store) + loadEigendaBatches(store) loadl1ToL2Txn(store) bindTransactionErrorMessage(store) @@ -434,7 +434,7 @@ if ($chainDetailsPage.length) { $txReloadButton.on('click', (event) => { event.preventDefault() loadTransactions(store) - loadTxnBatches(store) + loadEigendaBatches(store) loadl1ToL2Txn(store) $channelBatching.hide() store.dispatch({ @@ -452,13 +452,13 @@ function loadTransactions(store) { .always(() => store.dispatch({ type: 'FINISH_TRANSACTIONS_FETCH' })) } -function loadTxnBatches(store) { - const path = store.getState().txnBatchesPath - store.dispatch({ type: 'START_TXN_BATCHES_FETCH' }) +function loadEigendaBatches(store) { + const path = store.getState().eigendaBatchesPath + store.dispatch({ type: 'START_EIGENDA_BATCHES_FETCH' }) $.getJSON(path) - .done(response => store.dispatch({ type: 'TXN_BATCHES_FETCHED', msg: humps.camelizeKeys(response) })) - .fail(() => store.dispatch({ type: 'TXN_BATCHES_FETCH_ERROR' })) - .always(() => store.dispatch({ type: 'FINISH_TXN_BATCHES_FETCH' })) + .done(response => store.dispatch({ type: 'EIGENDA_BATCHES_FETCHED', msg: humps.camelizeKeys(response) })) + .fail(() => store.dispatch({ type: 'EIGENDA_BATCHES_FETCH_ERROR' })) + .always(() => store.dispatch({ type: 'FINISH_EIGENDA_BATCHES_FETCH' })) } function loadl1ToL2Txn(store) { 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 3941b2f36ab4..1190c200e6e4 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 @@ -55,7 +55,7 @@ defmodule BlockScoutWeb.ChainController do transaction_estimated_count: transaction_estimated_count, total_gas_usage: total_gas_usage, transactions_path: recent_transactions_path(conn, :index), - txn_batches_path: recent_txn_batches_path(conn, :index), + eigenda_batches_path: recent_eigenda_batches_path(conn, :index), l1_to_l2_txn_path: recent_l1_to_l2_txn_path(conn, :index), transaction_stats: transaction_stats, block_count: block_count, @@ -153,7 +153,6 @@ defmodule BlockScoutWeb.ChainController do end defp redirect_search_results(conn, %Address{} = item) do - Logger.info("0-0-0-0-444") address_path = conn |> address_path(:show, item) @@ -163,7 +162,6 @@ defmodule BlockScoutWeb.ChainController do end defp redirect_search_results(conn, %Block{} = item) do - Logger.info("0-0-0-0-333") block_path = conn |> block_path(:show, item) @@ -173,22 +171,15 @@ defmodule BlockScoutWeb.ChainController do end defp redirect_search_results(conn, %Transaction{} = item) do - Logger.info("0-0-0-0-111") transaction_path = conn |> transaction_path(:show, item) |> Controller.full_path() - + Logger.info("#{inspect(transaction_path)}") redirect(conn, to: transaction_path) end defp redirect_search_results(conn, %DaBatch{} = item) do - Logger.info("0-0-0-0-2222") - eigenda_batch_path = - conn - |> eigenda_batch_path(:show, item) - #|> Controller.full_path() - Logger.info("#{inspect(eigenda_batch_path)}") - redirect(conn, to: eigenda_batch_path) + redirect(conn, to: "/eigenda-batch/#{item.da_hash}") end end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex index d83eae767799..129ef80d2453 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/eigenda_batch_controller.ex @@ -125,9 +125,7 @@ require Logger end def show(conn, %{"da_hash" => da_hash}) do - Logger.info("-1123123--------") %{da_batch: da_batch} = Chain.da_batch_detail(da_hash); - Logger.info("#{inspect(da_batch)}") render( conn, "overview.html", diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex new file mode 100644 index 000000000000..5fcab0201574 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex @@ -0,0 +1,33 @@ +defmodule BlockScoutWeb.RecentEigendaBatchesController do + use BlockScoutWeb, :controller + require Logger + + alias Explorer.{Chain, PagingOptions} + alias Phoenix.View + + + def index(conn, _params) do + if ajax?(conn) do + recent_eigenda_batches = + Chain.recent_collated_eigenda_batches( + paging_options: %PagingOptions{page_size: 6} + ) + + eigenda_batches = + Enum.map(recent_eigenda_batches, fn eigenda_batch -> + + %{ + eigenda_batches_html: + View.render_to_string(BlockScoutWeb.EigendaBatchView, "_recent_tile.html", + eigenda_batch: eigenda_batch, + conn: conn, + ) + } + end) + Logger.info("#{inspect(eigenda_batches)}") + json(conn, %{eigenda_batches: eigenda_batches}) + else + unprocessable_entity(conn) + end + end +end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex index 898ba0cc590a..8c46e0c11807 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/search_controller.ex @@ -9,7 +9,6 @@ defmodule BlockScoutWeb.SearchController do require Logger def search_results(conn, %{"q" => query, "type" => "JSON"} = params) do - Logger.info("==========") [paging_options: paging_options] = paging_options(params) offset = (max(paging_options.page_number, 1) - 1) * paging_options.page_size @@ -60,7 +59,6 @@ defmodule BlockScoutWeb.SearchController do end def search_results(conn, %{"q" => query}) do - Logger.info("==========22") render( conn, "results.html", 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 d1c2539c179a..5337a087cf58 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 @@ -200,12 +200,12 @@

- Latest L1 Batches + Latest EigenLayer Txn Batches

-
- + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex index c54cc432d5e8..54181dcef505 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex @@ -1,27 +1,28 @@ -
- Ba + Da
- <%= #render "_link.html", batch_index: @txn_batch .batch_index, data_test: "address_hash_link" %> - <%= render "_link.html", batch_index: @txn_batch.batch_index, data_test: "address_hash_link" %> + <%= #render "_link.html", batch_index: @eigenda_batch .batch_index, data_test: "address_hash_link" %> + <%= render "_link.html", batch_index: @eigenda_batch.batch_index, data_test: "address_hash_link" %> - -
- - <%= sub_hash_string(@txn_batch.hash, 15) %>... - + + <%= sub_hash_string(@eigenda_batch.da_hash, 15) %>... + - <%= @txn_batch .size %> txns + <%= @eigenda_batch .batch_size %> txns
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 7a5b7ea896ac..1647123750dd 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -54,23 +54,15 @@ to: l2_to_l1_txn_path(@conn, :index) ) %> <%= link( - gettext("L1 Txn Batches"), - class: "dropdown-item #{tab_status("txn-batches", @conn.request_path)}", - to: txn_batch_path(@conn, :index) + gettext("Eigenlayer Txn"), + class: "dropdown-item #{tab_status("eigenda-batches", @conn.request_path)}", + to: eigenda_batch_path(@conn, :index) ) %> <%= link( gettext("L1 State Batches"), class: "dropdown-item #{tab_status("state-batches", @conn.request_path)}", to: state_batch_path(@conn, :index) ) %> - - <%= link( - gettext("Eigenlayer Txn"), - class: "dropdown-item #{tab_status("eigenda-batches", @conn.request_path)}", - to: eigenda_batch_path(@conn, :index) - ) %> - - <%= if variant !== EthereumJSONRPC.Besu do %> <%= link( gettext("Pending"), diff --git a/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_link.html.eex index 6b3f17df2a4b..e69de29bb2d1 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_link.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_link.html.eex @@ -1,3 +0,0 @@ -<%= link( - @batch_index, - to: txn_batch_path(BlockScoutWeb.Endpoint, :show, @batch_index)) %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/eigenda_batch_view.ex b/apps/block_scout_web/lib/block_scout_web/views/eigenda_batch_view.ex index 46662402ffb2..c93a197f9fd3 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/eigenda_batch_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/eigenda_batch_view.ex @@ -5,7 +5,7 @@ defmodule BlockScoutWeb.EigendaBatchView do alias BlockScoutWeb.Cldr.Number alias Explorer.{Chain, CustomContractsHelpers, Repo} alias Explorer.Chain.Block.Reward - alias Explorer.Chain.{Address, Block, InternalTransaction, Transaction, Wei, TxnBatch} + alias Explorer.Chain.{Address, Block, InternalTransaction, Transaction, Wei, TxnBatch, DaBatch} alias Explorer.Counters.AverageBlockTime alias Explorer.ExchangeRates.Token alias Timex.Duration diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index 19ebc7cd71fb..54f8d852b811 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -120,16 +120,14 @@ defmodule BlockScoutWeb.WebRouter do resources("/pending-transactions", PendingTransactionController, only: [:index]) resources("/recent-transactions", RecentTransactionsController, only: [:index]) - resources("/recent-txn-batches", RecentTxnBatchesController, only: [:index]) resources("/recent-l1-to-l2-txn", RecentL1ToL2TxnController, only: [:index]) + resources("/recent-eigenda-batches", RecentEigendaBatchesController, only: [:index]) resources("/verified-contracts", VerifiedContractsController, only: [:index]) get("/txs", TransactionController, :index) get("/state-batches", StateBatchController, :index) resources("/state-batch", StateBatchController, only: [:show], param: "batch_index") - get("/txn-batches", TxnBatchController, :index) - resources("/txn-batch", TxnBatchController, only: [:show], param: "batch_index") get("/eigenda-batches", EigendaBatchController, :index) get("/da_batch_transactions", DaBatchTransactionController, :index, param: "batch_index") resources("/eigenda-batch", EigendaBatchController, only: [:show], param: "da_hash") diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index dd2f4e5a26d2..3d8909bb178a 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -3419,6 +3419,12 @@ defmodule Explorer.Chain do fetch_recent_collated_txn_batches(paging_options) end + @spec recent_collated_eigenda_batches([paging_options]) :: [DaBatch.t()] + def recent_collated_eigenda_batches(options \\ []) when is_list(options) do + paging_options = Keyword.get(options, :paging_options, @default_paging_options) + fetch_recent_collated_eigenda_batches(paging_options) + end + @spec recent_collated_l1_to_l2([paging_options]) :: [L1ToL2.t()] def recent_collated_l1_to_l2(options \\ []) when is_list(options) do paging_options = Keyword.get(options, :paging_options, @default_paging_options) @@ -3759,6 +3765,12 @@ defmodule Explorer.Chain do |> Repo.all() end + def fetch_recent_collated_eigenda_batches(paging_options) do + paging_options + |> fetch_eigenda_batches() + |> Repo.all() + end + def fetch_recent_collated_l1_to_l2(paging_options) do paging_options |> fetch_l1_to_l2() @@ -4776,6 +4788,13 @@ defmodule Explorer.Chain do |> handle_paging_options(paging_options) end + defp fetch_eigenda_batches(paging_options \\ nil, from_index \\ nil, to_index \\ nil) do + DaBatch + |> order_by([da_batch], desc: da_batch.batch_index) + |> where_batch_index_in_period(from_index, to_index) + |> handle_paging_options(paging_options) + end + defp fetch_l1_to_l2(paging_options \\ nil, from_index \\ nil, to_index \\ nil) do L1ToL2 |> order_by([l1_to_l2], desc: l1_to_l2.queue_index) diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index f358b4a27474..6f427fbd6783 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -259,7 +259,7 @@ export class TasksService { ); } } - @Interval(2000) + /* @Interval(2000) async txn_batch() { let end = 0; const currentBlockNumber = @@ -289,7 +289,7 @@ export class TasksService { `sync txn_batch finished and latest block number is: ${currentBlockNumber}`, ); } - } + } */ @Interval(10000) async l1l2_merge() { try { From 4a1fb144bd1152fd95201c3f223be1d370bddd98 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 30 May 2023 16:10:12 +0800 Subject: [PATCH 04/44] feat: coin name to env --- .../templates/da_batch_transaction/_pending_tile.html.eex | 2 +- .../templates/eigenda_batch/_pending_tile.html.eex | 2 +- .../templates/eigenda_batch/_recent_tile.html.eex | 2 ++ .../templates/l1_to_l2_txn/_pending_tile.html.eex | 2 +- .../templates/l2_to_l1_txn/_pending_tile.html.eex | 2 +- .../templates/state_batch/_pending_tile.html.eex | 2 +- .../block_scout_web/templates/txn_batch/_pending_tile.html.eex | 2 +- .../lib/block_scout_web/views/transaction_view.ex | 2 +- docker-compose/envs/common-blockscout.env | 2 +- docker/Dockerfile | 2 +- 10 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/da_batch_transaction/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/da_batch_transaction/_pending_tile.html.eex index 17e568ade4fe..e0369b69f423 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/da_batch_transaction/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/da_batch_transaction/_pending_tile.html.eex @@ -17,7 +17,7 @@ <% end %> - <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "BIT" %> + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_pending_tile.html.eex index 17e568ade4fe..e0369b69f423 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_pending_tile.html.eex @@ -17,7 +17,7 @@ <% end %> - <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "BIT" %> + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex index 54181dcef505..2d57b161db83 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/eigenda_batch/_recent_tile.html.eex @@ -12,6 +12,8 @@ <%= #render "_link.html", batch_index: @eigenda_batch .batch_index, data_test: "address_hash_link" %> <%= render "_link.html", batch_index: @eigenda_batch.batch_index, data_test: "address_hash_link" %> + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_pending_tile.html.eex index 2c64cd4010b1..5bb22b2fd80d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_pending_tile.html.eex @@ -17,7 +17,7 @@ <% end %> - <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "BIT" %> + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_pending_tile.html.eex index 29aaca0c3b70..74963d20187c 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l2_to_l1_txn/_pending_tile.html.eex @@ -17,7 +17,7 @@ <% end %> - <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "BIT" %> + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch/_pending_tile.html.eex index ddd71da5e516..5504a2dfe90b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/state_batch/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch/_pending_tile.html.eex @@ -17,7 +17,7 @@ <% end %> - <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "BIT" %> + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_pending_tile.html.eex index 17e568ade4fe..e0369b69f423 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_pending_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/txn_batch/_pending_tile.html.eex @@ -17,7 +17,7 @@ <% end %> - <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "BIT" %> + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index c86c85199eb3..ffba47148431 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -431,7 +431,7 @@ require Logger format_wei_value(l1_fee, unit) end - def da_fee(%Transaction{da_fee: nil}, _unit), do: "0 BIT" + def da_fee(%Transaction{da_fee: nil}, _unit), do: "0 #{Explorer.coin_name()}" def da_fee(%Transaction{da_fee: da_fee}, unit) when unit in ~w(wei gwei ether)a do format_wei_value(da_fee, unit) diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 458267e31160..25277746827b 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -4,7 +4,7 @@ ETHEREUM_JSONRPC_VARIANT=geth ETHEREUM_JSONRPC_HTTP_URL=https://rpc.testnet.mantlenetwork.io DATABASE_URL=postgresql://postgres:lsc949982212@localhost:5432/blockscout ETHEREUM_JSONRPC_TRACE_URL=https://rpc.testnet.mantlenetwork.io -L1_TOKEN_SYMBOL="BIT" +L1_TOKEN_SYMBOL="MNT" NETWORK= SUBNETWORK=Awesome chain LOGO=/images/mantle_logo.svg diff --git a/docker/Dockerfile b/docker/Dockerfile index bf13ef9d02b0..c7137003125b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,7 +49,7 @@ ADD apps/indexer/mix.exs ./apps/indexer/ ENV JSON_RPC=https://rpc.testnet.mantle.xyz ENV SUBNETWORK="Mantle Testnet" -ENV COIN_NAME=BIT +ENV COIN_NAME=MNT ENV CHAIN_ID=5001 RUN mix do deps.get, local.rebar --force, deps.compile From 583090625589a7a900a9fd7b312e2d0016a3fe1d Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 30 May 2023 16:10:51 +0800 Subject: [PATCH 05/44] feat: coin name to env --- apps/block_scout_web/config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 7df4edc027cc..0a02584ba408 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -27,7 +27,7 @@ api_path = config :block_scout_web, namespace: BlockScoutWeb, ecto_repos: [Explorer.Repo, Explorer.Repo.Account], - l1_token_symbol: System.get_env("L1_TOKEN_SYMBOL") || "BIT", + l1_token_symbol: System.get_env("L1_TOKEN_SYMBOL") || "MNT", cookie_domain: System.get_env("SESSION_COOKIE_DOMAIN") config :block_scout_web, From d9aef16b0da31144f150ce00c431cfbf155a8489 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Wed, 31 May 2023 10:15:41 +0800 Subject: [PATCH 06/44] #217 feat: add state batch info to tx detail page --- .../recent_eigenda_batches_controller.ex | 1 - .../controllers/transaction_controller.ex | 39 ++++++++++++- .../transaction/_batch_link.html.eex | 3 + .../transaction/_state_batch_link.html.eex | 3 + .../templates/transaction/overview.html.eex | 57 +++++++++++++++++++ apps/explorer/lib/explorer/chain.ex | 48 ++++++++++++++++ 6 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/transaction/_batch_link.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/transaction/_state_batch_link.html.eex diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex index 5fcab0201574..26c7abbd340f 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/recent_eigenda_batches_controller.ex @@ -24,7 +24,6 @@ defmodule BlockScoutWeb.RecentEigendaBatchesController do ) } end) - Logger.info("#{inspect(eigenda_batches)}") json(conn, %{eigenda_batches: eigenda_batches}) else unprocessable_entity(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 fcd3658d6503..7b1622567b46 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 @@ -156,8 +156,26 @@ require Logger transaction_hash, necessity_by_association: @necessity_by_association ), + {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + # TODO(Jayce) hash hard code + updated_transaction = case Chain.hash_to_batch("0xbea2e27d87299ab1f91b914b2acb1b08780199ad042958c854fc7992bea448fc",necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + # TODO(Jayce) hash hard code + updated_state_transaction = case Chain.block_to_state_batch(2536260,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + render( conn, "show_token_transfers.html", @@ -166,7 +184,7 @@ require Logger current_path: Controller.current_full_path(conn), current_user: current_user(conn), show_token_transfers: true, - transaction: transaction, + transaction: updated_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: @@ -196,6 +214,23 @@ require Logger ), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + # TODO(Jayce) hash hard code + updated_transaction = case Chain.hash_to_batch("0xbea2e27d87299ab1f91b914b2acb1b08780199ad042958c854fc7992bea448fc",necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + # TODO(Jayce) hash hard code + updated_state_transaction = case Chain.block_to_state_batch(2536260,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + render( conn, "show_internal_transactions.html", @@ -204,7 +239,7 @@ require Logger current_user: current_user(conn), block_height: Chain.block_height(), show_token_transfers: Chain.transaction_has_token_transfers?(transaction_hash), - transaction: transaction, + transaction: updated_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_batch_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_batch_link.html.eex new file mode 100644 index 000000000000..14dd4d5cefe2 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_batch_link.html.eex @@ -0,0 +1,3 @@ +<%= link( + @batch_index, + to: da_batch_transaction_path(BlockScoutWeb.Endpoint, :index, batch_index: @batch_index)) %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_state_batch_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_state_batch_link.html.eex new file mode 100644 index 000000000000..31054fa75861 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_state_batch_link.html.eex @@ -0,0 +1,3 @@ +<%= link( + @batch_index, + to: state_batch_path(BlockScoutWeb.Endpoint, :show, @batch_index)) %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index 5c3c2cfb8438..a3e63c377f83 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -192,6 +192,63 @@ <% end %> + + + <%= if Map.has_key?(@transaction, :batch_index) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Eigenlayer Txn Batch Index.") %> + <%= gettext "Eigenlayer Txn Batch Index" %> +
+
+ <%= render "_batch_link.html", batch_index: @transaction.batch_index, data_test: "address_hash_link" %> +
+
+ <% end %> + + + <%= if Map.has_key?(@transaction, :data_commitment) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Eigenlayer Submission Hash") %> + <%= gettext "Eigenlayer Submission Hash" %> +
+
<%= @transaction.data_commitment %>
+ +
+ <% end %> + + + <%= if Map.has_key?(@transaction, :state_batch_index) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext(" L1 State Batch Index.") %> + <%= gettext " L1 State Batch Index" %> +
+
+ <%= render "_state_batch_link.html", batch_index: @transaction.state_batch_index, data_test: "address_hash_link" %> +
+
+ <% end %> + + <%= if Map.has_key?(@transaction, :submission_tx_hash) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 State Root Submission Tx Hash") %> + <%= gettext "L1 State Root Submission Tx Hash" %> +
+
+ + <%= @transaction.submission_tx_hash %> + +
+ +
+ <% end %>
diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 3d8909bb178a..71105d64383f 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2176,6 +2176,54 @@ defmodule Explorer.Chain do end end + @spec hash_to_batch(String.t(), [necessity_by_association_option]) :: + {:ok, map()} | {:error, :not_found} + def hash_to_batch( + hash, + options \\ [] + ) + when is_list(options) do + query = + from( + t in DaBatchTransaction, + left_join: d in DaBatch, + on: d.batch_index == t.batch_index, + where: t.tx_hash == ^hash, + select: %{batch_index: t.batch_index, data_commitment: d.data_commitment} + ) + + Repo.one(query) + |> case do + nil -> + {:error, :not_found} + batch -> + {:ok, batch} + end + end + + @spec block_to_state_batch(Decimal.t(), [necessity_by_association_option]) :: + {:ok, StateBatch.t()} | {:error, :not_found} + def block_to_state_batch( + block_number, + options \\ [] + ) + when is_list(options) do + query = + from( + s in StateBatch, + where: ^block_number >= s.pre_total_elements and ^block_number < s.pre_total_elements + s.size, + select: %{batch_index: s.batch_index, submission_tx_hash: s.hash} + ) + + Repo.one(query) + |> case do + nil -> + {:error, :not_found} + batch -> + {:ok, batch} + end + end + defp hash_to_da_transaction(da_hash) do DaBatch |> where([da_batch], da_batch.da_hash == ^da_hash) From 50d20b21fe3f228f2cf8b0ee244d948d74d7273a Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Wed, 31 May 2023 15:55:15 +0800 Subject: [PATCH 07/44] #217 feat: add transaction link from state batch detail --- .../state_batch_transaction_controller.ex | 281 ++++++++ .../controllers/transaction_controller.ex | 3 +- .../templates/layout/app.html.eex | 1 + .../templates/state_batch/overview.html.eex | 14 +- .../_batch_link.html.eex | 3 + .../_decoded_input.html.eex | 44 ++ .../_decoded_input_body.html.eex | 62 ++ .../_emission_reward_tile.html.eex | 34 + .../state_batch_transaction/_link.html.eex | 4 + .../_link_to_token_instance.html.eex | 1 + .../_link_to_token_symbol.html.eex | 1 + .../_metatags.html.eex | 14 + .../_pending_tile.html.eex | 25 + .../_recent_tile.html.eex | 54 ++ .../_state_batch_link.html.eex | 3 + .../state_batch_transaction/_tabs.html.eex | 34 + .../state_batch_transaction/_tile.html.eex | 87 +++ .../_token_transfer.html.eex | 25 + .../_total_transfers.html.eex | 23 + .../_total_transfers_from_to.html.eex | 50 ++ .../_transfer_token_with_id.html.eex | 2 + .../state_batch_transaction/index.html.eex | 47 ++ .../not_found.html.eex | 16 + .../state_batch_transaction/overview.html.eex | 663 ++++++++++++++++++ .../show_internal_transactions.html.eex | 1 + .../show_token_transfers.html.eex | 1 + .../views/state_batch_transaction_view.ex | 653 +++++++++++++++++ .../lib/block_scout_web/web_router.ex | 1 + apps/explorer/lib/explorer/chain.ex | 33 + 29 files changed, 2172 insertions(+), 8 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/controllers/state_batch_transaction_controller.ex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_batch_link.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input_body.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_emission_reward_tile.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_instance.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_symbol.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_metatags.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_pending_tile.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_recent_tile.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_state_batch_link.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tabs.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tile.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_token_transfer.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers_from_to.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_transfer_token_with_id.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/index.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/not_found.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/overview.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_internal_transactions.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_token_transfers.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/views/state_batch_transaction_view.ex diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/state_batch_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/state_batch_transaction_controller.ex new file mode 100644 index 000000000000..050f31671d2f --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/controllers/state_batch_transaction_controller.ex @@ -0,0 +1,281 @@ +defmodule BlockScoutWeb.StateBatchTransactionController do + use BlockScoutWeb, :controller + + import BlockScoutWeb.Account.AuthController, only: [current_user: 1] + + import BlockScoutWeb.Chain, + only: [ + fetch_page_number: 1, + paging_options: 1, + next_page_params: 3, + update_page_parameters: 3, + split_list_by_page: 1 + ] + + import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2] + import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2] + + alias BlockScoutWeb.{ + AccessHelpers, + Controller, + TransactionInternalTransactionController, + TransactionTokenTransferController, + TransactionView + } +require Logger + alias Explorer.{Chain, Market} + alias Explorer.Chain.Cache.Transaction, as: TransactionCache + alias Explorer.ExchangeRates.Token + alias Phoenix.View + + @necessity_by_association %{ + :block => :optional, + [created_contract_address: :names] => :optional, + [from_address: :names] => :optional, + [to_address: :names] => :optional, + [to_address: :smart_contract] => :optional, + :token_transfers => :optional + } + + {:ok, burn_address_hash} = Chain.string_to_address_hash("0x0000000000000000000000000000000000000000") + @burn_address_hash burn_address_hash + + @default_options [ + necessity_by_association: %{ + :block => :required, + [created_contract_address: :names] => :optional, + [from_address: :names] => :optional, + [to_address: :names] => :optional, + [created_contract_address: :smart_contract] => :optional, + [from_address: :smart_contract] => :optional, + [to_address: :smart_contract] => :optional + } + ] + + def index(conn, %{"type" => "JSON", "elements"=> elements, "size"=> size} = params) do + options = + @default_options + |> Keyword.merge(paging_options(params)) + full_options = + options + |> Keyword.put( + :paging_options, + params + |> fetch_page_number() + |> update_page_parameters(Chain.default_page_size(), Keyword.get(options, :paging_options)) + ) + + elements_integer = String.to_integer(elements) + size_integer = String.to_integer(size) + + %{total_transactions_count: transactions_count, transactions: transactions_plus_one} = + Chain.recent_state_batch_transactions_for_rap(full_options, elements_integer, size_integer) + {transactions, next_page} = + if fetch_page_number(params) == 1 do + split_list_by_page(transactions_plus_one) + else + {transactions_plus_one, nil} + end + + next_page_params = + if fetch_page_number(params) == 1 do + page_size = Chain.default_page_size() + + pages_limit = transactions_count |> Kernel./(page_size) |> Float.ceil() |> trunc() + + case next_page_params(next_page, transactions, params) do + nil -> + nil + + next_page_params -> + next_page_params + |> Map.delete("type") + |> Map.delete("items_count") + |> Map.put("pages_limit", pages_limit) + |> Map.put("page_size", page_size) + |> Map.put("page_number", 1) + end + else + Map.delete(params, "type") + end + + json( + conn, + %{ + items: + Enum.map(transactions, fn transaction -> + View.render_to_string( + TransactionView, + "_tile.html", + transaction: transaction, + burn_address_hash: @burn_address_hash, + conn: conn + ) + end), + next_page_params: next_page_params + } + ) + end + + def index(conn, _params) do + transaction_estimated_count = TransactionCache.estimated_count() + + render( + conn, + "index.html", + current_path: Controller.current_full_path(conn), + transaction_estimated_count: transaction_estimated_count + ) + end + + def show(conn, %{"id" => transaction_hash_string, "type" => "JSON"}) do + case Chain.string_to_transaction_hash(transaction_hash_string) do + {:ok, transaction_hash} -> + if Chain.transaction_has_token_transfers?(transaction_hash) do + TransactionTokenTransferController.index(conn, %{ + "transaction_id" => transaction_hash_string, + "type" => "JSON" + }) + else + TransactionInternalTransactionController.index(conn, %{ + "transaction_id" => transaction_hash_string, + "type" => "JSON" + }) + end + + :error -> + set_not_found_view(conn, transaction_hash_string) + end + end + + def show(conn, %{"id" => id} = params) do + with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(id), + :ok <- Chain.check_transaction_exists(transaction_hash) do + if Chain.transaction_has_token_transfers?(transaction_hash) do + with {:ok, transaction} <- + Chain.hash_to_transaction( + transaction_hash, + necessity_by_association: @necessity_by_association + ), + + {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), + {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + # TODO(Jayce) hash hard code + updated_transaction = case Chain.hash_to_batch("0xbea2e27d87299ab1f91b914b2acb1b08780199ad042958c854fc7992bea448fc",necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + # TODO(Jayce) hash hard code + updated_state_transaction = case Chain.block_to_state_batch(2536260,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + render( + conn, + "show_token_transfers.html", + exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), + block_height: Chain.block_height(), + current_path: Controller.current_full_path(conn), + current_user: current_user(conn), + show_token_transfers: true, + transaction: updated_state_transaction, + from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), + to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), + tx_tags: + get_transaction_with_addresses_tags( + transaction, + current_user(conn) + ) + ) + else + :not_found -> + set_not_found_view(conn, id) + + :error -> + unprocessable_entity(conn) + + {:error, :not_found} -> + set_not_found_view(conn, id) + + {:restricted_access, _} -> + set_not_found_view(conn, id) + end + else + with {:ok, transaction} <- + Chain.hash_to_transaction( + transaction_hash, + necessity_by_association: @necessity_by_association + ), + {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), + {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + # TODO(Jayce) hash hard code + updated_transaction = case Chain.hash_to_batch("0xbea2e27d87299ab1f91b914b2acb1b08780199ad042958c854fc7992bea448fc",necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + # TODO(Jayce) hash hard code + updated_state_transaction = case Chain.block_to_state_batch(2536260,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + render( + conn, + "show_internal_transactions.html", + exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), + current_path: Controller.current_full_path(conn), + current_user: current_user(conn), + block_height: Chain.block_height(), + show_token_transfers: Chain.transaction_has_token_transfers?(transaction_hash), + transaction: updated_state_transaction, + from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), + to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), + tx_tags: + get_transaction_with_addresses_tags( + transaction, + current_user(conn) + ) + ) + else + :not_found -> + set_not_found_view(conn, id) + + :error -> + unprocessable_entity(conn) + + {:error, :not_found} -> + set_not_found_view(conn, id) + + {:restricted_access, _} -> + set_not_found_view(conn, id) + end + end + else + :error -> + unprocessable_entity(conn) + + :not_found -> + set_not_found_view(conn, id) + end + end + + def set_not_found_view(conn, transaction_hash_string) do + conn + |> put_status(404) + |> put_view(TransactionView) + |> render("not_found.html", transaction_hash: transaction_hash_string) + end +end 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 7b1622567b46..8e5058258f87 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 @@ -56,7 +56,8 @@ require Logger options = @default_options |> Keyword.merge(paging_options(params)) - +Logger.info("------") +Logger.info("#{inspect(params)}") full_options = options |> Keyword.put( diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex index 6e3ccf2eb020..5dbaaf540cf5 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex @@ -256,6 +256,7 @@ @view_module != Elixir.BlockScoutWeb.AddressView && @view_module != Elixir.BlockScoutWeb.TokensView && @view_module != Elixir.BlockScoutWeb.TransactionView && + @view_module != Elixir.BlockScoutWeb.StateBatchTransactionView && @view_module != Elixir.BlockScoutWeb.TxnBatchView && @view_module != Elixir.BlockScoutWeb.EigendaBatchView && @view_module != Elixir.BlockScoutWeb.DaBatchTransactionView && diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch/overview.html.eex index 1d5ec57b30ee..8c392c92b72d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/state_batch/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch/overview.html.eex @@ -19,7 +19,7 @@
- +
L1 Timestamp: @@ -33,9 +33,9 @@ Batch Size:
- - <%= @state_batch.size %> transactions - + + <%= @state_batch.size %> transactions +
@@ -43,8 +43,8 @@ L1 Transaction Hash:
- @@ -93,7 +93,7 @@
- + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_batch_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_batch_link.html.eex new file mode 100644 index 000000000000..14dd4d5cefe2 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_batch_link.html.eex @@ -0,0 +1,3 @@ +<%= link( + @batch_index, + to: da_batch_transaction_path(BlockScoutWeb.Endpoint, :index, batch_index: @batch_index)) %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input.html.eex new file mode 100644 index 000000000000..741344e79b2a --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input.html.eex @@ -0,0 +1,44 @@ +
+
+

<%= gettext "Input" %>

+ + <%= case @decoded_input_data do %> + <% {:error, :contract_not_verified, candidates} -> %> +
+ <%= unless Enum.empty?(candidates) do %> +

<%= gettext "Potential matches from our contract method database:" %>

+ <%= gettext "IMPORTANT: This information is a best guess based on similar functions from other verified contracts." %> + <%= gettext "To have guaranteed accuracy, use the link above to verify the contract's source code." %> + + <%= for {:ok, method_id, text, mapping} <- candidates do %> +
+

<%= text %>:

+ + <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping) %> + <% end %> + <% end %> + <% {:ok, method_id, text, mapping} -> %> + <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping) %> + <% {:error, :contract_verified, candidates} -> %> +

<%= gettext "Potential matches from our contract method database:" %>

+ <%= for {:ok, method_id, text, mapping} <- candidates do %> +
+

<%= text %>:

+ <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping) %> + <% end %> + <% _ -> %> +
+ <%= gettext "Failed to decode input data." %> +
+ <% end %> +
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input_body.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input_body.html.eex new file mode 100644 index 000000000000..3675d4c501a9 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_decoded_input_body.html.eex @@ -0,0 +1,62 @@ +
+ " class="table thead-light table-bordered"> + <%= if !assigns[:error] do %> + + + + + <% end %> + + + + +
<%= gettext "Method Id" %>0x<%= @method_id %>
<%= if assigns[:error], do: gettext("Error"), else: gettext("Call") %><%= @text %>
+
+ +<% max_length = get_max_length() %> +<%= unless Enum.empty?(@mapping) do %> +
+ " class="table thead-light table-bordered"> + + + + + + <%= for {name, type, value} <- @mapping do %> + + + + + + <% end %> +
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Data" %>
<%= name %><%= type %> + <%= case BlockScoutWeb.ABIEncodedValueView.value_html(type, value, true) do %> + <% :error -> %> +
+ <%= gettext "Error rendering value" %> +
+ <% value_with_no_links -> %> + <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> + <% :error -> %> + <%= nil %> + <% copy_text -> %> + + + + + + <% end %> + <% value_with_links = BlockScoutWeb.ABIEncodedValueView.value_html(type, value, false)%> + <% string = template_to_string(value_with_no_links) %> +
<%= if String.length(string) > max_length do %>
<% input = trim(max_length, string) %><%= input[:show] %>...<%= input[:hide] %>
<% else %><%= value_with_links %><% end %>
+ <% end %> +
+
+<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_emission_reward_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_emission_reward_tile.html.eex new file mode 100644 index 000000000000..4fb50efeb5ed --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_emission_reward_tile.html.eex @@ -0,0 +1,34 @@ +
+
+
+ + <%= gettext("Emission Contract") %> + + + <%= gettext("Success") %> + +
+
+ <%= link( + @validator.block.hash, + to: block_path(BlockScoutWeb.Endpoint, :show, @validator.block.hash), + class: "text-truncate") %> + + <%= @emission_funds |> BlockScoutWeb.AddressView.address_partial_selector(nil, @current_address) |> BlockScoutWeb.RenderHelpers.render_partial() %> + → + <%= @validator |> BlockScoutWeb.AddressView.address_partial_selector(nil, @current_address) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + + + <%= format_wei_value(@emission_funds.reward, :ether) %> + + +
+
+ + <%= @validator |> block_number() |> BlockScoutWeb.RenderHelpers.render_partial() %> + + +
+
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link.html.eex new file mode 100644 index 000000000000..9b0333f1c99f --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link.html.eex @@ -0,0 +1,4 @@ +<%= link(@transaction_hash, + to: transaction_path(BlockScoutWeb.Endpoint, :show, @transaction_hash), + "data-test": "transaction_hash_link", + class: "text-truncate") %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_instance.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_instance.html.eex new file mode 100644 index 000000000000..88273f4bc093 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_instance.html.eex @@ -0,0 +1 @@ +<%= "[" %><%= link(short_token_id(@token_id, 30), to: token_instance_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash, to_string(@token_id)), "data-test": "token_link") %><%= "]" %> \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_symbol.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_symbol.html.eex new file mode 100644 index 000000000000..73cb4a2c2cd5 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_link_to_token_symbol.html.eex @@ -0,0 +1 @@ +<%= link(token_symbol(@transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash), "data-test": "token_link") %> \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_metatags.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_metatags.html.eex new file mode 100644 index 000000000000..920306f219bb --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_metatags.html.eex @@ -0,0 +1,14 @@ +<%= if assigns[:transaction] do %> + + <%= gettext( + "Transaction %{transaction} - %{subnetwork} Explorer", + transaction: to_string(@transaction.hash), + subnetwork: BlockScoutWeb.LayoutView.subnetwork_title() + ) %> + + + "> + "> +<% else %> + <%= BlockScoutWeb.LayoutView.render("_default_title.html") %> +<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_pending_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_pending_tile.html.eex new file mode 100644 index 000000000000..d1b33ffeeb91 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_pending_tile.html.eex @@ -0,0 +1,25 @@ +<% status = BlockScoutWeb.TransactionView.transaction_status(@transaction) %> +
+
+
+ <%= BlockScoutWeb.TransactionView.transaction_display_type(@transaction) %> +
<%= BlockScoutWeb.TransactionView.formatted_result(status) %>
+
+
+ <%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @transaction.hash %> + + <%= render BlockScoutWeb.AddressView, "_link.html", address: @transaction.from_address, contract: BlockScoutWeb.AddressView.contract?(@transaction.from_address), use_custom_tooltip: false %> + → + <%= if @transaction.to_address_hash do %> + <%= render BlockScoutWeb.AddressView, "_link.html", address: @transaction.to_address, contract: BlockScoutWeb.AddressView.contract?(@transaction.to_address), use_custom_tooltip: false %> + <% else %> + <%= gettext("Contract Address Pending") %> + <% end %> + + + <%= BlockScoutWeb.TransactionView.value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> + <%= BlockScoutWeb.TransactionView.formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> + +
+
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_recent_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_recent_tile.html.eex new file mode 100644 index 000000000000..e2f8623f60b5 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_recent_tile.html.eex @@ -0,0 +1,54 @@ +
+ + Tx + +
+
+ + Tx#<%= @transaction.block_number %> + + + <%= render "_link.html", transaction_hash: @transaction.hash, data_test: "address_hash_link" %> + + +
+
+ From + + <%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + To + + <%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + +
+
+ + + + <%= value(@transaction) %> + +
+
+
+ + + + + + + + + + + + + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_state_batch_link.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_state_batch_link.html.eex new file mode 100644 index 000000000000..31054fa75861 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_state_batch_link.html.eex @@ -0,0 +1,3 @@ +<%= link( + @batch_index, + to: state_batch_path(BlockScoutWeb.Endpoint, :show, @batch_index)) %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tabs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tabs.html.eex new file mode 100644 index 000000000000..c99a8f1036bf --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tabs.html.eex @@ -0,0 +1,34 @@ +
+ <%= if @show_token_transfers do %> + <%= link( + gettext("Token Transfers"), + class: "card-tab #{tab_status("token-transfers", @conn.request_path, @show_token_transfers)}", + to: AccessHelpers.get_path(@conn, :transaction_token_transfer_path, :index, @transaction) + ) + %> + <% end %> + <%= link( + gettext("Internal Transactions"), + class: "card-tab #{tab_status("internal-transactions", @conn.request_path, @show_token_transfers)}", + to: AccessHelpers.get_path(@conn, :transaction_internal_transaction_path, :index, @transaction) + ) + %> + <%= link( + gettext("Logs"), + class: "card-tab #{tab_status("logs", @conn.request_path)}", + to: AccessHelpers.get_path(@conn, :transaction_log_path, :index, @transaction), + "data-test": "transaction_logs_link" + ) + %> + <%= link( + gettext("Raw Trace"), + class: "card-tab #{tab_status("raw-trace", @conn.request_path)}", + to: AccessHelpers.get_path(@conn, :transaction_raw_trace_path, :index, @transaction) + ) %> + <%= link( + gettext("State changes"), + class: "card-tab #{tab_status("state", @conn.request_path)}", + to: AccessHelpers.get_path(@conn, :transaction_state_path, :index, @transaction) + ) + %> +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tile.html.eex new file mode 100644 index 000000000000..24971d43aa2c --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_tile.html.eex @@ -0,0 +1,87 @@ +<% status = transaction_status(@transaction) %> +<% error_in_internal_tx = @transaction.has_error_in_internal_txs %> +<% current_user = AuthController.current_user(@conn) %> +<% tx_tags = BlockScoutWeb.Models.GetTransactionTags.get_transaction_with_addresses_tags(@transaction, current_user) %> +
+
+ +
+
+ <%= if error_in_internal_tx do %> + <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Error in internal transactions"), additional_classes: ["color-inherit"] %> + <% end %> + + <%= transaction_display_type(@transaction) %> + +
+ + <%= if status_class(@transaction) == "tile-status--pending" do %> +
+ + +
+ <% end %> + <%= formatted_result(status) %> +
+
+ +
+ +
+ <%= render "_link.html", transaction_hash: @transaction.hash, data_test: "address_hash_link" %> + <% method_name = Transaction.get_method_name(@transaction) %> + <%= if method_name do %> + <%= render BlockScoutWeb.FormView, "_tag.html", text: method_name, additional_classes: ["method", "ml-1"] %> + <% end %> + <%= if tx_tags.personal_tx_tag && tx_tags.personal_tx_tag.name !== :error do %> + <%= render BlockScoutWeb.FormView, "_tag.html", text: tx_tags.personal_tx_tag.name, additional_classes: [tag_name_to_label(tx_tags.personal_tx_tag.name), "ml-1"] %> + <% end %> + <%=# render BlockScoutWeb.AddressView, "_labels.html", tags: tx_tags %> +
+
+ + <%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> + → + <%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + + + <%= value(@transaction, include_label: false) %> <%= Explorer.coin_name() %> + + + <%= formatted_fee(@transaction, denomination: :ether, include_label: false) %> <%= gettext "TX Fee" %> + + + + + <%= if involves_token_transfers?(@transaction) do %> +
+ <% [first_token_transfer | remaining_token_transfers] = @transaction.token_transfers %> + + <%= render "_token_transfer.html", address: assigns[:current_address], token_transfer: first_token_transfer %> +
+ + <% end %> +
+ +
+ + <%= @transaction |> block_number() |> BlockScoutWeb.RenderHelpers.render_partial() %> + + + <%= if from_or_to_address?(@transaction, assigns[:current_address]) do %> + + <%= if @transaction.from_address_hash == assigns[:current_address].hash do %> + + <%= gettext "OUT" %> + + <% else %> + + <%= gettext "IN" %>WE + + <% end %> + + <% end %> +
+
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_token_transfer.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_token_transfer.html.eex new file mode 100644 index 000000000000..815d9bd82aea --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_token_transfer.html.eex @@ -0,0 +1,25 @@ +
+ + <%= if from_or_to_address?(@token_transfer, @address) do %> + <%= if @token_transfer.from_address_hash == @address.hash do %> + + ↳ + + <% else %> + + ↳ + + <% end %> + <% end %> + + <%= @token_transfer |> BlockScoutWeb.AddressView.address_partial_selector(:from, @address, true) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + → + + <%= @token_transfer |> BlockScoutWeb.AddressView.address_partial_selector(:to, @address, true) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + + + <%= render BlockScoutWeb.TransactionView, "_total_transfers.html", Map.put(assigns, :transfer, @token_transfer) %> + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers.html.eex new file mode 100644 index 000000000000..4896e6e85312 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers.html.eex @@ -0,0 +1,23 @@ +<%= case token_transfer_amount(@transfer) do %> + <% {:ok, :erc721_instance} -> %> + <%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: List.first(@transfer.token_ids) %> + <% {:ok, :erc1155_instance, value} -> %> + <% transfer_type = Chain.get_token_transfer_type(@transfer) %> + <%= if transfer_type == :token_spawning do %> + <%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: List.first(@transfer.token_ids) %> + <% else %> + <%= "#{value} " %> + <%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: List.first(@transfer.token_ids) %> + <% end %> + <% {:ok, :erc1155_instance, values, token_ids, _decimals} -> %> + <% values_ids = Enum.zip(values, token_ids) %> + <%= for {value, token_id} <- values_ids do %> +
+ <%= "#{value} "%> + <%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: token_id %> +
+ <% end %> + <% {:ok, value} -> %> + <%= value %> + <%= " " %><%= render BlockScoutWeb.TransactionView, "_link_to_token_symbol.html", transfer: @transfer %> +<% end %> \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers_from_to.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers_from_to.html.eex new file mode 100644 index 000000000000..fc59c567b817 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_total_transfers_from_to.html.eex @@ -0,0 +1,50 @@ +<%= with {:ok, from_address} <- Chain.hash_to_address(@transfer.from_address_hash), + {:ok, to_address} <- Chain.hash_to_address(@transfer.to_address_hash) do %> + <% from_tags = BlockScoutWeb.Models.GetAddressTags.get_address_tags_custom(@transfer.from_address_hash, @current_user) %> + <% to_tags = BlockScoutWeb.Models.GetAddressTags.get_address_tags_custom(@transfer.to_address_hash, @current_user) %> +
+
+ + From + + + <%= render BlockScoutWeb.AddressView, "_link.html", address: from_address, contract: BlockScoutWeb.AddressView.contract?(from_address), use_custom_tooltip: false, trimmed: false %> + <%= render BlockScoutWeb.AddressView, "_labels.html", tags: from_tags %> + + + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy_for_table.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders", "btn-copy-token-transfer"], + clipboard_text: from_address, + aria_label: gettext("Copy From Address"), + title: gettext("Copy From Address"), + style: "position: relative;" %> + + +
+
+ + To + + + <%= render BlockScoutWeb.AddressView, "_link.html", address: to_address, contract: BlockScoutWeb.AddressView.contract?(from_address), use_custom_tooltip: false, trimmed: false %> + <%= render BlockScoutWeb.AddressView, "_labels.html", tags: to_tags %> + + + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy_for_table.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders", "btn-copy-token-transfer"], + clipboard_text: to_address, + aria_label: gettext("Copy To Address"), + title: gettext("Copy To Address"), + style: "position: relative;" %> + +
+
+ + For + + + <%= render BlockScoutWeb.TransactionView, "_total_transfers.html", transfer: @transfer %> + +
+
+<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_transfer_token_with_id.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_transfer_token_with_id.html.eex new file mode 100644 index 000000000000..44a3444aa131 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/_transfer_token_with_id.html.eex @@ -0,0 +1,2 @@ +<%= "TokenID " %><%= render BlockScoutWeb.TransactionView, "_link_to_token_instance.html", transfer: @transfer, token_id: @token_id %> +<%= " " %><%= render BlockScoutWeb.TransactionView, "_link_to_token_symbol.html", transfer: @transfer %> \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/index.html.eex new file mode 100644 index 000000000000..39b62be7ffb0 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/index.html.eex @@ -0,0 +1,47 @@ + +
+ <%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %> +
+
+

+ <%= gettext "Validated Transactions" %> + For State Batch <%= @conn.params["batch"] %> +

+
+ <%= render BlockScoutWeb.CommonComponentsView, "_rap_pagination_container.html", position: "top", showing_limit: if Chain.transactions_available_count() >= Chain.limit_showing_transactions(), do: Chain.limit_showing_transactions(), else: nil %> +
+ + + <%= render BlockScoutWeb.CommonComponentsView, "_channel_disconnected_message.html", text: gettext("Connection Lost, click to load newer transactions") %> + + + +
+
+ + <%= gettext "There are no transactions." %> + +
+
+ +
+ <%= render BlockScoutWeb.CommonComponentsView, "_tile-loader.html" %> +
+ <%= render BlockScoutWeb.CommonComponentsView, "_rap_pagination_container.html", position: "bottom" %> + +
+ + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/not_found.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/not_found.html.eex new file mode 100644 index 000000000000..440206247735 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/not_found.html.eex @@ -0,0 +1,16 @@ +
+
+
+ Transaction not found +
+

<%= gettext("Sorry, we are unable to locate this transaction hash") %>

+
+

<%= gettext("1. If you have just submitted this transaction please wait for at least 30 seconds before refreshing this page.") %>

+

<%= gettext("2. It could still be in the TX Pool of a different node, waiting to be broadcasted.") %>

+

<%= gettext("3. During times when the network is busy (i.e during ICOs) it can take a while for your transaction to propagate through the network and for us to index it.") %>

+

<%= gettext("4. If it still does not show up after 1 hour, please check with your sender/exchange/wallet/transaction provider for additional information.") %>

+
+ <%= gettext("Back to home") %> +
+ +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/overview.html.eex new file mode 100644 index 000000000000..a3e63c377f83 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/overview.html.eex @@ -0,0 +1,663 @@ +<% block = @transaction.block %> +<% from_address_hash = @transaction.from_address_hash %> +<% from_address = @transaction.from_address %> +<% to_address_hash = @transaction.to_address_hash %> +<% created_address_hash = @transaction.created_contract_address_hash %> +<% type = if @transaction.type == 2, do: "2 (EIP-1559)", else: @transaction.type %> +<% base_fee_per_gas = if block, do: block.base_fee_per_gas, else: nil %> +<% max_priority_fee_per_gas = @transaction.max_priority_fee_per_gas %> +<% max_fee_per_gas = @transaction.max_fee_per_gas %> +<% burned_fee = + if !is_nil(max_fee_per_gas) and !is_nil(@transaction.gas_used) and !is_nil(base_fee_per_gas) do + if Decimal.compare(max_fee_per_gas.value, 0) == :eq do + %Wei{value: Decimal.new(0)} + else + Wei.mult(base_fee_per_gas, @transaction.gas_used) + end + else + nil + end %> +<% %Wei{value: burned_fee_decimal} = if is_nil(burned_fee), do: %Wei{value: Decimal.new(0)}, else: burned_fee %> +<% priority_fee_per_gas = if is_nil(max_priority_fee_per_gas) or is_nil(base_fee_per_gas), do: nil, else: Enum.min_by([max_priority_fee_per_gas, Wei.sub(max_fee_per_gas, base_fee_per_gas)], fn x -> Wei.to(x, :wei) end) %> +<% priority_fee = if is_nil(priority_fee_per_gas), do: nil, else: Wei.mult(priority_fee_per_gas, @transaction.gas_used) %> +<% decoded_input_data = decoded_input_data(@transaction) %> +<% status = transaction_status(@transaction) %> +<% circles_addresses_list = CustomContractsHelpers.get_custom_addresses_list(:circles_addresses) %> +<% address_hash_str = if to_address_hash, do: "0x" <> Base.encode16(to_address_hash.bytes, case: :lower), else: nil %> +<% {:ok, created_from_address} = if to_address_hash, do: Chain.hash_to_address(to_address_hash), else: {:ok, nil} %> +<% created_from_address_hash_str = if from_address_hash(created_from_address), do: "0x" <> Base.encode16(from_address_hash(created_from_address).bytes, case: :lower), else: nil %> +<%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %> +
+
+
+ +
+
+ <%= cond do %> + <% Enum.member?(circles_addresses_list, address_hash_str) -> %> +
+ +
+ <% Enum.member?(circles_addresses_list, created_from_address_hash_str) -> %> +
+ +
+ <% true -> %> + <%= nil %> + <% end %> +

+
+ <%= gettext "Transaction Details" %> + <% personal_tx_tag = if assigns[:tx_tags], do: @tx_tags.personal_tx_tag, else: nil %> + <%= if personal_tx_tag && personal_tx_tag.name !== :error do %> + <%= render BlockScoutWeb.FormView, "_tag.html", text: personal_tx_tag.name, additional_classes: [tag_name_to_label(personal_tx_tag.name), "ml-1"] %> + <% end %> + <%= render BlockScoutWeb.AddressView, "_labels.html", tags: @tx_tags %> +
+

+ <%= if status == :pending do %> +
+
+ + +
+ <%= gettext("This transaction is pending confirmation.") %> +
+ <% end %> +
+ <%= if show_tenderly_link?() do %> +
+ <%= render BlockScoutWeb.CommonComponentsView, "_tenderly_link.html", + transaction_hash: @transaction.hash, + tenderly_chain_path: tenderly_chain_path() %> +
+ <% end %> +
+
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Unique character string (TxID) assigned to every verified transaction.") %> + <%= gettext "Transaction Hash" %> +
+
+ <%= @transaction %> + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders"], + clipboard_text: @transaction, + aria_label: gettext("Copy Transaction Hash"), + title: gettext("Copy Txn Hash") %> +
+
+ + + +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Current transaction state: Success, Failed (Error), or Pending (In Process)") %> + <%= gettext "Result" %> +
+
+ <% formatted_result = BlockScoutWeb.TransactionView.formatted_result(status) %> + <%= render BlockScoutWeb.CommonComponentsView, "_status_icon.html", status: status %><%= formatted_result %> +
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("The status of the transaction: Confirmed or Unconfirmed.") %> + <%= gettext "Status" %> +
+
+ <% formatted_status = BlockScoutWeb.TransactionView.formatted_status(status) %> + <% confirmations = confirmations(@transaction, block_height: @block_height) %> + + + <%= if status == :pending do %> + <%= render BlockScoutWeb.FormView, "_tag.html", text: formatted_status, additional_classes: ["large"] %> + <% else %> + <%= render BlockScoutWeb.FormView, "_tag.html", text: formatted_status, additional_classes: ["success", "large"] %> + <% end %> + + <%= if confirmations > 0 do %> + <%= gettext "Confirmed by " %><%= confirmations %><%= " " <> confirmations_ds_name(confirmations) %> + <% end %> + +
+
+ + <%= if status == {:error, "Reverted"} || status == {:error, "execution reverted"} do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("The revert reason of the transaction.") %> + <%= gettext "Revert reason" %>
+
+ <%= case BlockScoutWeb.TransactionView.transaction_revert_reason(@transaction) do %> + <% {:error, _contract_not_verified, candidates} when candidates != [] -> %> + <% {:ok, method_id, text, mapping} = Enum.at(candidates, 0) %> + <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping, error: true) %> + <% {:ok, method_id, text, mapping} -> %> + <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping, error: true) %> + <% _ -> %> + <% hex = BlockScoutWeb.TransactionView.get_pure_transaction_revert_reason(@transaction) %> + <% utf8 = BlockScoutWeb.TransactionView.decoded_revert_reason(@transaction) %> +
+
Raw:<%= raw("\t") %><%= hex %><%= raw("\n") %>UTF-8:<%= raw("\t") %><%= utf8 %>
+
+ <% end %> +
+
+ <% end %> + +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Block number containing the transaction.") %> + <%= gettext "Block" %>
+
+ <%= if block do %> + <%= link( + block, + class: "transaction__link", + to: block_path(@conn, :show, block) + ) %> + <% else %> + <%= formatted_result(status) %> + <% end %> +
+
+ + <%= if block && block.timestamp do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Date & time of transaction inclusion, including length of time for confirmation.") %> + <%= gettext "Timestamp" %> +
+
+ + + + + <%= case processing_time_duration(@transaction) do %> + <% :pending -> %> + <% nil %> + <% :unknown -> %> + <% nil %> + <% {:ok, interval_string} -> %> + | <%= gettext("Confirmed within") %> <%= interval_string %> + <% end %> +
+
+ <% end %> + + + <%= if Map.has_key?(@transaction, :batch_index) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Eigenlayer Txn Batch Index.") %> + <%= gettext "Eigenlayer Txn Batch Index" %> +
+
+ <%= render "_batch_link.html", batch_index: @transaction.batch_index, data_test: "address_hash_link" %> +
+
+ <% end %> + + + <%= if Map.has_key?(@transaction, :data_commitment) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Eigenlayer Submission Hash") %> + <%= gettext "Eigenlayer Submission Hash" %> +
+
<%= @transaction.data_commitment %>
+ +
+ <% end %> + + + <%= if Map.has_key?(@transaction, :state_batch_index) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext(" L1 State Batch Index.") %> + <%= gettext " L1 State Batch Index" %> +
+
+ <%= render "_state_batch_link.html", batch_index: @transaction.state_batch_index, data_test: "address_hash_link" %> +
+
+ <% end %> + + <%= if Map.has_key?(@transaction, :submission_tx_hash) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 State Root Submission Tx Hash") %> + <%= gettext "L1 State Root Submission Tx Hash" %> +
+
+ + <%= @transaction.submission_tx_hash %> + +
+ +
+ <% end %> + +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Address (external or contract) sending the transaction.") %> + <%= gettext "From" %>
+
+ <%= render BlockScoutWeb.AddressView, "_link.html", address: from_address, contract: BlockScoutWeb.AddressView.contract?(from_address), use_custom_tooltip: false, trimmed: false %> + <%= render BlockScoutWeb.AddressView, "_labels.html", tags: @from_tags %> + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders"], + clipboard_text: Address.checksum(from_address_hash), + aria_label: gettext("Copy From Address"), + title: gettext("Copy From Address") %> +
+
+ + <% to_address = @transaction |> Map.get(:to_address) || @transaction |> Map.get(:created_contract_address) %> + <% recipient_address_hash = to_address_hash || created_address_hash %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Address (external or contract) receiving the transaction.") %> + <%= if BlockScoutWeb.AddressView.contract?(to_address) && !created_address_hash do %> + <%= gettext "Interacted With (To)" %> + <% else %> + <%= gettext "To" %> + <% end %> +
+
+ <%= cond do %> + <% created_address_hash -> %> + [<%= gettext("Contract") %>  + <%= render BlockScoutWeb.AddressView, "_link.html", address: to_address, contract: BlockScoutWeb.AddressView.contract?(to_address), use_custom_tooltip: false, trimmed: false %> + <%= render BlockScoutWeb.AddressView, "_labels.html", tags: @to_tags %> +  <%= gettext("created") %>] + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders"], + clipboard_text: Address.checksum(recipient_address_hash), + aria_label: gettext("Copy To Address"), + title: gettext("Copy To Address") %> + <% recipient_address_hash -> %> + <%= render BlockScoutWeb.AddressView, "_link.html", address: to_address, contract: BlockScoutWeb.AddressView.contract?(to_address), use_custom_tooltip: false, trimmed: false %> + <%= render BlockScoutWeb.AddressView, "_labels.html", tags: @to_tags %> + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders"], + clipboard_text: Address.checksum(recipient_address_hash), + aria_label: gettext("Copy To Address"), + title: gettext("Copy To Address") %> + <% true -> %> + <% end %> +
+
+ <%= case token_transfer_type(@transaction) do %> + <% {_type, %{token_transfers: token_transfers} = transaction_with_transfers} when is_list(token_transfers) and token_transfers != [] -> %> + + <% %{transfers: transfers, mintings: mintings, burnings: burnings, creations: creations} = aggregate_token_transfers(transaction_with_transfers.token_transfers) %> + <%= if Enum.count(transfers) > 0 do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("List of token transferred in the transaction.") %> + <%= gettext "Tokens Transferred" %>
+
"> + <%= if Enum.count(transfers) > 8 do %> +
+ "/> + + Scroll for more + +
+ <% end %> +
+ <%= for transfer <- transfers do %> + <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, transfer) %> + <% end %> +
+
+
+ <% end %> + + <%= if Enum.count(mintings) > 0 do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("List of token minted in the transaction.") %> + <%= gettext "Tokens Minted" %> +
+
+ + <%= for minting <- mintings do %> + <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, minting) %> + <% end %> +
+
+
+ <% end %> + + <%= if Enum.count(burnings) > 0 do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("List of token burnt in the transaction.") %> + <%= gettext "Tokens Burnt" %>
+
+ <%= for burning <- burnings do %> + + <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, burning) %> +
+ <% end %> +
+
+ <% end %> + + <%= if Enum.count(creations) > 0 do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("List of ERC-1155 tokens created in the transaction.") %> + <%= gettext "Tokens Created" %>
+
+ <%= for creation <- creations do %> + + <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, creation) %> +
+ <% end %> +
+
+ <% end %> + <% _ -> %> + <% end %> + +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Value sent in the native token (and USD) if applicable.") %> + <%= gettext "Value" %> +
+
<%= value(@transaction) %> + <%= if !empty_exchange_rate?(@exchange_rate) do %> + ( + data-usd-exchange-rate=<%= @exchange_rate.usd_value %>> + ) + <% end %> +
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Total transaction fee spent on L1 and L2.") %> + <%= gettext "Transaction Fee" %> +
+
+ <%= formatted_fee(@transaction, denomination: :ether) %> +
+
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Price per unit of gas specified by the sender. Higher gas prices can prioritize transaction inclusion during times of high usage.") %> + <%= gettext "Gas Price on L2" %> +
+
<%= gas_price(@transaction, :gwei) %>
+
+ <%= if !is_nil(type) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Transaction type, introduced in EIP-2718.") %> + <%= gettext "Transaction Type" %> +
+
<%= type %>
+
+ <% end %> + +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Maximum gas amount approved for the transaction.") %> + <%= gettext "Gas Limit" %> +
+
<%= format_gas_limit(@transaction.gas) %>
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Transaction fee on layer2.") %> + <%= gettext "L2 Fee" %> +
+
<%= l2_fee(@transaction, :gwei) %> <%= Explorer.coin_name() %>
+
+ <%= if !is_nil(max_fee_per_gas) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Maximum total amount per unit of gas a user is willing to pay for a transaction, including base fee and priority fee.") %> + <%= gettext "Max Fee per Gas" %> +
+
<%= format_wei_value(max_fee_per_gas, :gwei) %>
+
+ <% end %> + <%= if !is_nil(max_priority_fee_per_gas) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("User defined maximum fee (tip) per unit of gas paid to validator for transaction prioritization.") %> + <%= gettext "Max Priority Fee per Gas" %> +
+
<%= format_wei_value(max_priority_fee_per_gas, :gwei) %>
+
+ <% end %> + <%= if !is_nil(priority_fee) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("User-defined tip sent to validator for transaction priority/inclusion.") %> + <%= gettext "Priority Fee / Tip" %> +
+
<%= format_wei_value(priority_fee, :ether) %>
+
+ <% end %> + <%= if !is_nil(burned_fee) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Amount of") <> " " <> Explorer.coin_name() <> " " <> gettext("burned for this transaction. Equals Block Base Fee per Gas * Gas Used.") %> + <%= gettext "Transaction Burnt Fee" %> +
+
<%= format_wei_value(burned_fee, :ether) %> + <%= unless empty_exchange_rate?(@exchange_rate) do %> + ( data-usd-exchange-rate=<%= @exchange_rate.usd_value %>>) + <% end %> +
+
+ <% end %> + +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Actual gas amount used by the transaction.") %> + <%= gettext "Gas Used by Transaction" %> +
+ <% gas_used_perc = gas_used_perc(@transaction) %> +
<%= gas_used(@transaction) %> <%= if gas_used_perc, do: "| #{gas_used_perc}%" %>
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Transaction number from the sending address. Each transaction sent from an address increments the nonce by 1.") %> + <%= gettext "Nonce" %>"><%= gettext "Position" %> +
+
<%= @transaction.nonce %><%= if block, do: @transaction.index, else: formatted_result(status) %>
+
+ <%= unless value_transfer?(@transaction) do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Binary data included with the transaction. See input / logs below for additional info.") %> + <%= gettext "Raw Input" %> +
+
+
+ + +
+ + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", + id: "tx-raw-input", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-no-borders", "btn-copy-icon-ml-0", "btn-copy-tx-raw-input", "tx-raw-input"], + clipboard_text: @transaction.input, + aria_label: gettext("Copy Value"), + title: gettext("Copy Txn Hex Input") %> + + <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", + additional_classes: ["btn-copy-icon-small", "btn-copy-icon-no-borders", "btn-copy-icon-ml-0", "btn-copy-tx-raw-input", "tx-utf8-input"], + clipboard_text: @transaction.input.bytes, + aria_label: gettext("Copy Value"), + title: gettext("Copy Txn UTF-8 Input"), + style: "display: none;" %> +
+
+ +
+
+
<%= @transaction.input %>
+
+
+ + +
+
+ <% end %> +
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 Gas Price") %> + <%= gettext "L1 Gas Price" %> +
+
+ + <%= l1_gas_price(@transaction, :gwei) %> + + + Display with gwei on Mantle, converted from L1 gas price + +
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 Fee") %> + <%= gettext "L1 Fee" %> +
+
<%= l1_fee(@transaction, :ether) %>
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 Fee Scalar") %> + <%= gettext "L1 Fee Scalar" %> +
+
<%= l1_fee_scalar(@transaction) %>
+
+ +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 Gas Used") %> + <%= gettext "L1 Gas Used" %> +
+
<%= l1_gas_used(@transaction) %>
+
+ + <%= if @transaction.l1_origin_tx_hash do %> +
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("L1 Origin Tx Hash") %> + <%= gettext "L1 Origin Tx Hash" %> +
+
<%= @transaction.l1_origin_tx_hash %>
+
+ <% end %> +
+
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("DA Gas Price") %> + <%= gettext "DA Gas Price" %> +
+
<%= da_gas_price(@transaction, :gwei) %>
+
+
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("DA Fee") %> + <%= gettext "DA Fee" %> +
+
<%= da_fee(@transaction, :ether) %>
+
+
+
+ <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("DA Gas Used") %> + <%= gettext "DA Gas Used" %> +
+
<%= da_gas_used(@transaction) %>
+
+
+
+
+
+ + <%= render BlockScoutWeb.Advertisement.BannersAdView, "_banner_728.html", conn: @conn %> + + <%= unless skip_decoding?(@transaction) do %> +
+
+ <%= render BlockScoutWeb.TransactionView, "_decoded_input.html", Map.put(assigns, :decoded_input_data, decoded_input_data) %> +
+
+ <% end %> + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_internal_transactions.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_internal_transactions.html.eex new file mode 100644 index 000000000000..cbfb925cf8b5 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_internal_transactions.html.eex @@ -0,0 +1 @@ +<%= render BlockScoutWeb.TransactionInternalTransactionView, "index.html", assigns %> \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_token_transfers.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_token_transfers.html.eex new file mode 100644 index 000000000000..b524c8e1ffbb --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/state_batch_transaction/show_token_transfers.html.eex @@ -0,0 +1 @@ +<%= render BlockScoutWeb.TransactionTokenTransferView, "index.html", assigns %> \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/views/state_batch_transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/state_batch_transaction_view.ex new file mode 100644 index 000000000000..74bc4800babb --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/views/state_batch_transaction_view.ex @@ -0,0 +1,653 @@ +defmodule BlockScoutWeb.StateBatchTransactionView do + use BlockScoutWeb, :view + + alias BlockScoutWeb.{AccessHelpers, AddressView, BlockView, TabHelpers} + alias BlockScoutWeb.Account.AuthController + alias BlockScoutWeb.Cldr.Number + alias Explorer.{Chain, CustomContractsHelpers, Repo} + alias Explorer.Chain.Block.Reward + alias Explorer.Chain.{Address, Block, InternalTransaction, Transaction, Wei} + alias Explorer.Counters.AverageBlockTime + alias Explorer.ExchangeRates.Token + alias Timex.Duration +require Logger + import BlockScoutWeb.Gettext + import BlockScoutWeb.AddressView, only: [from_address_hash: 1, short_token_id: 2, tag_name_to_label: 1] + import BlockScoutWeb.Tokens.Helpers + + @tabs ["token-transfers", "internal-transactions", "logs", "raw-trace", "state"] + + @token_burning_title "Token Burning" + @token_minting_title "Token Minting" + @token_transfer_title "Token Transfer" + @token_creation_title "Token Creation" + + @token_burning_type :token_burning + @token_minting_type :token_minting + @token_creation_type :token_spawning + @token_transfer_type :token_transfer + + defguardp is_transaction_type(mod) when mod in [InternalTransaction, Transaction] + + defdelegate formatted_timestamp(block), to: BlockView + + def block_number(%Transaction{block_number: nil}), do: gettext("Block Pending") + def block_number(%Transaction{block: block}), do: [view_module: BlockView, partial: "_link.html", block: block] + def block_number(%Reward{block: block}), do: [view_module: BlockView, partial: "_link.html", block: block] + + def block_timestamp(%Transaction{block_number: nil, inserted_at: time}), do: time + def block_timestamp(%Transaction{block: %Block{timestamp: time}}), do: time + def block_timestamp(%Reward{block: %Block{timestamp: time}}), do: time + + def value_transfer?(%Transaction{input: %{bytes: bytes}}) when bytes in [<<>>, nil] do + true + end + + def value_transfer?(_), do: false + + def token_transfer_type(transaction) do + transaction_with_transfers = Repo.preload(transaction, token_transfers: :token) + + token_transfers_filtered_by_block_hash = + transaction_with_transfers + |> Map.get(:token_transfers, []) + |> Enum.filter(fn token_transfer -> + token_transfer.block_hash == transaction.block_hash + end) + + transaction_with_transfers_filtered = + Map.put(transaction_with_transfers, :token_transfers, token_transfers_filtered_by_block_hash) + + type = Chain.transaction_token_transfer_type(transaction) + if type, do: {type, transaction_with_transfers_filtered}, else: {nil, transaction_with_transfers_filtered} + end + + def aggregate_token_transfers(token_transfers) do + %{ + transfers: {ft_transfers, nft_transfers}, + mintings: {ft_mintings, nft_mintings}, + burnings: {ft_burnings, nft_burnings}, + creations: {ft_creations, nft_creations} + } = + token_transfers + |> Enum.reduce( + %{ + transfers: {[], []}, + mintings: {[], []}, + burnings: {[], []}, + creations: {[], []} + }, + fn token_transfer, acc -> + token_transfer_type = Chain.get_token_transfer_type(token_transfer) + + case token_transfer_type do + :token_transfer -> + transfers = aggregate_reducer(token_transfer, acc.transfers) + + %{ + transfers: transfers, + mintings: acc.mintings, + burnings: acc.burnings, + creations: acc.creations + } + + :token_burning -> + burnings = aggregate_reducer(token_transfer, acc.burnings) + + %{ + transfers: acc.transfers, + mintings: acc.mintings, + burnings: burnings, + creations: acc.creations + } + + :token_minting -> + mintings = aggregate_reducer(token_transfer, acc.mintings) + + %{ + transfers: acc.transfers, + mintings: mintings, + burnings: acc.burnings, + creations: acc.creations + } + + :token_spawning -> + creations = aggregate_reducer(token_transfer, acc.creations) + + %{ + transfers: acc.transfers, + mintings: acc.mintings, + burnings: acc.burnings, + creations: creations + } + end + end + ) + + transfers = ft_transfers ++ nft_transfers + + mintings = ft_mintings ++ nft_mintings + + burnings = ft_burnings ++ nft_burnings + + creations = ft_creations ++ nft_creations + + %{transfers: transfers, mintings: mintings, burnings: burnings, creations: creations} + end + + defp aggregate_reducer(%{amount: amount, amounts: amounts} = token_transfer, {acc1, acc2}) + when is_nil(amount) and is_nil(amounts) do + new_entry = %{ + token: token_transfer.token, + amount: nil, + amounts: [], + token_ids: token_transfer.token_ids, + to_address_hash: token_transfer.to_address_hash, + from_address_hash: token_transfer.from_address_hash + } + + {acc1, [new_entry | acc2]} + end + + defp aggregate_reducer(%{amount: amount, amounts: amounts} = token_transfer, {acc1, acc2}) + when is_nil(amount) and not is_nil(amounts) do + new_entry = %{ + token: token_transfer.token, + amount: nil, + amounts: amounts, + token_ids: token_transfer.token_ids, + to_address_hash: token_transfer.to_address_hash, + from_address_hash: token_transfer.from_address_hash + } + + {acc1, [new_entry | acc2]} + end + + defp aggregate_reducer(token_transfer, {acc1, acc2}) do + new_entry = %{ + token: token_transfer.token, + amount: token_transfer.amount, + amounts: [], + token_ids: token_transfer.token_ids, + to_address_hash: token_transfer.to_address_hash, + from_address_hash: token_transfer.from_address_hash + } + + existing_entry = + acc1 + |> Enum.find(fn entry -> + entry.to_address_hash == token_transfer.to_address_hash && + entry.from_address_hash == token_transfer.from_address_hash && + entry.token == token_transfer.token + end) + + new_acc1 = + if existing_entry do + acc1 + |> Enum.map(fn entry -> + if entry.to_address_hash == token_transfer.to_address_hash && + entry.from_address_hash == token_transfer.from_address_hash && + entry.token == token_transfer.token do + updated_entry = %{ + entry + | amount: Decimal.add(new_entry.amount, entry.amount) + } + + updated_entry + else + entry + end + end) + else + [new_entry | acc1] + end + + {new_acc1, acc2} + end + + def token_type_name(type) do + case type do + :erc20 -> gettext("ERC-20 ") + :erc721 -> gettext("ERC-721 ") + :erc1155 -> gettext("ERC-1155 ") + _ -> "" + end + end + + def processing_time_duration(%Transaction{block: nil}) do + :pending + end + + def processing_time_duration(%Transaction{earliest_processing_start: nil}) do + avg_time = AverageBlockTime.average_block_time() + + if avg_time == {:error, :disabled} do + :unknown + else + avg_time_in_secs = + avg_time + |> Duration.to_seconds() + + {:ok, "<= #{avg_time_in_secs} seconds"} + end + end + + def processing_time_duration(%Transaction{ + block: %Block{timestamp: end_time}, + earliest_processing_start: earliest_processing_start, + inserted_at: inserted_at + }) do + with {:ok, long_interval} <- humanized_diff(earliest_processing_start, end_time), + {:ok, short_interval} <- humanized_diff(inserted_at, end_time) do + {:ok, merge_intervals(short_interval, long_interval)} + else + _ -> + :ignore + end + end + + defp merge_intervals(short, long) when short == long, do: short + + defp merge_intervals(short, long) do + [short_time, short_unit] = String.split(short, " ") + [long_time, long_unit] = String.split(long, " ") + + if short_unit == long_unit do + short_time <> "-" <> long_time <> " " <> short_unit + else + short <> " - " <> long + end + end + + defp humanized_diff(left, right) do + left + |> Timex.diff(right, :milliseconds) + |> Duration.from_milliseconds() + |> Timex.format_duration(Explorer.Counters.AverageBlockTimeDurationFormat) + |> case do + {:error, _} = error -> error + duration -> {:ok, duration} + end + end + + def confirmations(%Transaction{block: block}, named_arguments) when is_list(named_arguments) do + case block do + %Block{consensus: true} -> + {:ok, confirmations} = Chain.confirmations(block, named_arguments) + BlockScoutWeb.Cldr.Number.to_string!(confirmations, format: "#,###") + + _ -> + 0 + end + end + + def confirmations_ds_name(blocks_amount_str) do + case Integer.parse(blocks_amount_str) do + {blocks_amount, ""} -> + if rem(blocks_amount, 10) == 1 do + "block" + else + "blocks" + end + + _ -> + "blocks" + end + end + + def contract_creation?(%Transaction{to_address: nil}), do: true + + def contract_creation?(_), do: false + + def fee(%Transaction{} = transaction) do + {_, value} = Chain.fee(transaction, :wei) + value + end + + def format_gas_limit(gas) do + Number.to_string!(gas) + end + + def formatted_fee(%Transaction{} = transaction, opts) do + l1_fee = if transaction.l1_fee == nil, do: Wei.from(Decimal.new(0), :wei), else: transaction.l1_fee + da_fee = if transaction.da_fee == nil, do: Wei.from(Decimal.new(0), :wei), else: transaction.da_fee + transaction + |> Chain.fee(:wei) + |> fee_to_denomination(l1_fee, da_fee, opts) + |> case do + {:actual, value} -> value + {:maximum, value} -> "#{gettext("Max of")} #{value}" + end + end + + def transaction_status(transaction) do + Chain.transaction_to_status(transaction) + end + + def transaction_revert_reason(transaction) do + transaction |> Chain.transaction_to_revert_reason() |> decoded_revert_reason(transaction) + end + + def get_pure_transaction_revert_reason(nil), do: nil + + def get_pure_transaction_revert_reason(transaction), do: Chain.transaction_to_revert_reason(transaction) + + def empty_exchange_rate?(exchange_rate) do + Token.null?(exchange_rate) + end + + def formatted_status(status) do + case status do + :pending -> gettext("Unconfirmed") + _ -> gettext("Confirmed") + end + end + + def formatted_result(status) do + case status do + :pending -> gettext("Pending") + :awaiting_internal_transactions -> gettext("(Awaiting internal transactions for status)") + :success -> gettext("Success") + {:error, :awaiting_internal_transactions} -> gettext("Error: (Awaiting internal transactions for reason)") + # The pool of possible error reasons is unknown or even if it is enumerable, so we can't translate them + {:error, reason} when is_binary(reason) -> gettext("Error: %{reason}", reason: reason) + end + end + + def from_or_to_address?(_token_transfer, nil), do: false + + def from_or_to_address?(%{from_address_hash: from_hash, to_address_hash: to_hash}, %Address{hash: hash}) do + from_hash == hash || to_hash == hash + end + + def gas(%type{gas: gas}) when is_transaction_type(type) do + BlockScoutWeb.Cldr.Number.to_string!(gas) + end + + def skip_decoding?(transaction) do + contract_creation?(transaction) || value_transfer?(transaction) + end + + def decoded_input_data(transaction) do + Transaction.decoded_input_data(transaction) + end + + def decoded_revert_reason(revert_reason, transaction) do + Transaction.decoded_revert_reason(transaction, revert_reason) + end + + @doc """ + Converts a transaction's gas price to a displayable value. + """ + def gas_price(%Transaction{gas_price: gas_price}, unit) when unit in ~w(wei gwei ether)a do + format_wei_value(gas_price, unit) + end + + def da_gas_price(%Transaction{da_gas_price: da_gas_price}, unit) when unit in ~w(wei gwei ether)a do + if da_gas_price == nil, do: format_wei_value(%Wei{value: Decimal.new(0)}, unit), else: format_wei_value(da_gas_price, unit) + end + + def l2_fee(%Transaction{gas_price: gas_price, gas: gas, gas_used: gas_used}, unit) when unit in ~w(wei gwei ether)a do + actual_gas = if gas_used == nil, do: gas, else: gas_used + gas_price + |> Wei.multi(actual_gas) + |> Decimal.to_string(:normal) + end + + def gas_used(%Transaction{gas_used: nil}), do: gettext("Pending") + + def gas_used(%Transaction{gas_used: gas_used}) do + Number.to_string!(gas_used) + end + + def gas_used_perc(%Transaction{gas_used: nil}), do: nil + + def gas_used_perc(%Transaction{gas_used: gas_used, gas: gas}) do + if Decimal.compare(gas, 0) == :gt do + gas_used + |> Decimal.div(gas) + |> Decimal.mult(100) + |> Decimal.round(2) + |> Number.to_string!() + else + nil + end + end + + #def l1_gas_price(%Transaction{l1_gas_price: nil}, _unit), do: gettext("Pending") + + #def l1_gas_price(%Transaction{l1_gas_price: l1_gas_price}, unit) when unit in ~w(wei gwei ether)a do + # format_wei_value(l1_gas_price, unit) + #end + + def l1_gas_price(%Transaction{} = transaction, unit) when unit in ~w(wei gwei ether)a do + l1_gas_price = if transaction.l1_gas_price == nil, do: 0, else: transaction.l1_gas_price + format_wei_value(l1_gas_price, unit) + end + + def l1_fee(%Transaction{l1_fee: nil}, _unit), do: gettext("Pending") + + def l1_fee(%Transaction{l1_fee: l1_fee}, unit) when unit in ~w(wei gwei ether)a do + format_wei_value(l1_fee, unit) + end + + def da_fee(%Transaction{da_fee: nil}, _unit), do: "0 #{Explorer.coin_name()}" + + def da_fee(%Transaction{da_fee: da_fee}, unit) when unit in ~w(wei gwei ether)a do + format_wei_value(da_fee, unit) + end + + def l1_gas_used(%Transaction{l1_gas_used: nil}), do: gettext("Pending") + + def l1_gas_used(%Transaction{l1_gas_used: l1_gas_used}) do + l1_gas_used + end + + def da_gas_used(%Transaction{da_gas_used: nil}), do: "0" + + def da_gas_used(%Transaction{da_gas_used: da_gas_used}) do + da_gas_used + end + + def l1_fee_scalar(%Transaction{l1_fee_scalar: nil}), do: gettext("Pending") + + def l1_fee_scalar(%Transaction{l1_fee_scalar: l1_fee_scalar}) do + l1_fee_scalar + end + + def hash(%Transaction{hash: hash}) do + to_string(hash) + end + + def involves_contract?(%Transaction{from_address: from_address, to_address: to_address}) do + AddressView.contract?(from_address) || AddressView.contract?(to_address) + end + + def involves_token_transfers?(%Transaction{token_transfers: []}), do: false + def involves_token_transfers?(%Transaction{token_transfers: transfers}) when is_list(transfers), do: true + def involves_token_transfers?(_), do: false + + def qr_code(%Transaction{hash: hash}) do + hash + |> to_string() + |> QRCode.to_png() + |> Base.encode64() + end + + def status_class(transaction) do + case Chain.transaction_to_status(transaction) do + :pending -> "tile-status--pending" + :awaiting_internal_transactions -> "tile-status--awaiting-internal-transactions" + :success -> "tile-status--success" + # TODO(Jayce) internal transaction feature has not been completed, use success temporary. + #{:error, :awaiting_internal_transactions} -> "tile-status--error--awaiting-internal-transactions" + {:error, :awaiting_internal_transactions} -> "tile-status--success" + {:error, reason} when is_binary(reason) -> "tile-status--error--reason" + end + end + + # This is the address to be shown in the to field + def to_address_hash(%Transaction{to_address_hash: nil, created_contract_address_hash: address_hash}), + do: address_hash + + def to_address_hash(%Transaction{to_address_hash: address_hash}), do: address_hash + + def transaction_display_type(%Transaction{} = transaction) do + cond do + involves_token_transfers?(transaction) -> + token_transfer_type = get_transaction_type_from_token_transfers(transaction.token_transfers) + + case token_transfer_type do + @token_minting_type -> gettext(@token_minting_title) + @token_burning_type -> gettext(@token_burning_title) + @token_creation_type -> gettext(@token_creation_title) + @token_transfer_type -> gettext(@token_transfer_title) + end + + contract_creation?(transaction) -> + gettext("Contract Creation") + + involves_contract?(transaction) -> + gettext("Contract Call") + + true -> + gettext("Transaction") + end + end + + def type_suffix(%Transaction{} = transaction) do + cond do + involves_token_transfers?(transaction) -> "token-transfer" + contract_creation?(transaction) -> "contract-creation" + involves_contract?(transaction) -> "contract-call" + true -> "transaction" + end + end + + @doc """ + Converts a transaction's Wei value to Ether and returns a formatted display value. + + ## Options + + * `:include_label` - Boolean. Defaults to true. Flag for displaying unit with value. + """ + def value(%mod{value: value}, opts \\ []) when is_transaction_type(mod) do + include_label? = Keyword.get(opts, :include_label, true) + format_wei_value(value, :ether, include_unit_label: include_label?) + end + + def format_wei_value(value) do + format_wei_value(value, :ether, include_unit_label: false) + end + + defp fee_to_denomination({fee_type, fee}, l1_fee, da_fee, opts) do + denomination = Keyword.get(opts, :denomination) + include_label? = Keyword.get(opts, :include_label, true) + l1_and_da_fee = Wei.sum(l1_fee, da_fee) + {fee_type, format_wei_value(Wei.sum(Wei.from(fee, :wei), l1_and_da_fee), denomination, include_unit_label: include_label?)} + end + + @doc """ + Get the current tab name/title from the request path and possible tab names. + + The tabs on mobile are represented by a dropdown list, which has a title. This title is the currently selected tab name. This function returns that name, properly gettext'ed. + + The list of possible tab names for this page is represented by the attribute @tab. + + Raises an error if there is no match, so a developer of a new tab must include it in the list. + + """ + def current_tab_name(request_path) do + @tabs + |> Enum.filter(&TabHelpers.tab_active?(&1, request_path)) + |> tab_name() + end + + defp tab_name(["token-transfers"]), do: gettext("Token Transfers") + defp tab_name(["internal-transactions"]), do: gettext("Internal Transactions") + defp tab_name(["logs"]), do: gettext("Logs") + defp tab_name(["raw-trace"]), do: gettext("Raw Trace") + defp tab_name(["state"]), do: gettext("State changes") + + defp get_transaction_type_from_token_transfers(token_transfers) do + token_transfers_types = + token_transfers + |> Enum.map(fn token_transfer -> + Chain.get_token_transfer_type(token_transfer) + end) + + burnings_count = + Enum.count(token_transfers_types, fn token_transfers_type -> token_transfers_type == @token_burning_type end) + + mintings_count = + Enum.count(token_transfers_types, fn token_transfers_type -> token_transfers_type == @token_minting_type end) + + creations_count = + Enum.count(token_transfers_types, fn token_transfers_type -> token_transfers_type == @token_creation_type end) + + cond do + Enum.count(token_transfers_types) == burnings_count -> @token_burning_type + Enum.count(token_transfers_types) == mintings_count -> @token_minting_type + Enum.count(token_transfers_types) == creations_count -> @token_creation_type + true -> @token_transfer_type + end + end + + defp show_tenderly_link? do + System.get_env("SHOW_TENDERLY_LINK") == "true" + end + + defp tenderly_chain_path do + System.get_env("TENDERLY_CHAIN_PATH") || "/" + end + + def get_max_length do + string_value = Application.get_env(:block_scout_web, :max_length_to_show_string_without_trimming) + + case Integer.parse(string_value) do + {integer, ""} -> integer + _ -> 2040 + end + end + + def trim(length, string) do + %{show: String.slice(string, 0..length), hide: String.slice(string, (length + 1)..String.length(string))} + end + + defp template_to_string(template) when is_list(template) do + template_to_string(Enum.at(template, 1)) + end + + defp template_to_string(template) when is_tuple(template) do + safe_to_string(template) + end + + # Function decodes revert reason of the transaction + @spec decoded_revert_reason(Transaction.t() | nil) :: binary() | nil + def decoded_revert_reason(transaction) do + revert_reason = get_pure_transaction_revert_reason(transaction) + + case revert_reason do + "0x" <> hex_part -> + proccess_hex_revert_reason(hex_part) + + hex_part -> + proccess_hex_revert_reason(hex_part) + end + end + + # Function converts hex revert reason to the binary + @spec proccess_hex_revert_reason(nil) :: nil + defp proccess_hex_revert_reason(nil), do: nil + + @spec proccess_hex_revert_reason(binary()) :: binary() + defp proccess_hex_revert_reason(hex_revert_reason) do + case Integer.parse(hex_revert_reason, 16) do + {number, ""} -> + :binary.encode_unsigned(number) + + _ -> + hex_revert_reason + end + end +end diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index 54f8d852b811..ac5f39f696a6 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -126,6 +126,7 @@ defmodule BlockScoutWeb.WebRouter do resources("/verified-contracts", VerifiedContractsController, only: [:index]) get("/txs", TransactionController, :index) + get("/state-batch-txs/:elements/:size/:batch", StateBatchTransactionController, :index) get("/state-batches", StateBatchController, :index) resources("/state-batch", StateBatchController, only: [:show], param: "batch_index") get("/eigenda-batches", EigendaBatchController, :index) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 71105d64383f..9be161e5ffa1 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -3509,6 +3509,21 @@ defmodule Explorer.Chain do %{total_transactions_count: total_transactions_count, transactions: fetched_transactions} end + + @spec recent_state_batch_transactions_for_rap([paging_options | necessity_by_association_option], Decimal.t(), Decimal.t()) :: %{ + :total_transactions_count => non_neg_integer(), + :transactions => [Transaction.t()] + } + def recent_state_batch_transactions_for_rap(options \\ [], elements, size) when is_list(options) do + necessity_by_association = Keyword.get(options, :necessity_by_association, %{}) + paging_options = Keyword.get(options, :paging_options, @default_paging_options) + total_transactions_count = state_batch_transactions_available_count(elements, size) + fetched_transactions = fetch_recent_collated_state_batch_transactions_for_rap(paging_options, necessity_by_association, elements, size) + + %{total_transactions_count: total_transactions_count, transactions: fetched_transactions} + end + + def default_page_size, do: @default_page_size @spec recent_collated_state_batches_for_rap([paging_options]) :: %{ @@ -3560,6 +3575,16 @@ defmodule Explorer.Chain do |> Repo.all() end + def fetch_recent_collated_state_batch_transactions_for_rap(paging_options, necessity_by_association, elements, size) do + max = elements + size + fetch_transactions_for_rap() + |> where([transaction], not is_nil(transaction.block_number) and not is_nil(transaction.index) and transaction.block_number >= ^elements and transaction.block_number < ^max) + |> handle_random_access_paging_options(paging_options) + |> join_associations(necessity_by_association) + |> preload([{:token_transfers, [:token, :from_address, :to_address]}]) + |> Repo.all() + end + def fetch_recent_collated_l2_to_l1_for_rap(paging_options) do fetch_l2_to_l1_for_rap() |> no_cache_handle_options(paging_options) @@ -3783,6 +3808,14 @@ defmodule Explorer.Chain do |> Repo.aggregate(:count, :hash) end + def state_batch_transactions_available_count(elements, size) do + max = elements + size + Transaction + |> where([transaction], not is_nil(transaction.block_number) and not is_nil(transaction.index) and transaction.block_number >= ^elements and transaction.block_number < ^max) + |> limit(^@limit_showing_transactions) + |> Repo.aggregate(:count, :hash) + end + def fetch_recent_collated_transactions( old_ui?, paging_options, From 4c02739ec8befed17fcf48da8eca87cbd965ab47 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Wed, 31 May 2023 19:29:04 +0800 Subject: [PATCH 08/44] #219 add tx filter from l1->l2 page --- .../controllers/l1_to_l2_txn_controller.ex | 21 ++++-- .../templates/l1_to_l2_txn/_tile.html.eex | 13 ++-- .../templates/l1_to_l2_txn/index.html.eex | 64 ++++++++++++++----- .../lib/block_scout_web/web_router.ex | 1 + apps/explorer/lib/explorer/chain.ex | 38 +++++++---- apps/explorer/lib/explorer/chain/l1_to_l2.ex | 2 + 6 files changed, 104 insertions(+), 35 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex index 90382dad4e16..ad6ea6623ca5 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex @@ -61,9 +61,10 @@ defmodule BlockScoutWeb.L1ToL2TxnController do |> fetch_page_number() |> update_page_parameters(Chain.default_page_size(), Keyword.get(options, :paging_options)) ) + tx_type = if Map.has_key?(params, "tx_type"), do: String.to_integer(params["tx_type"]), else: nil %{total_l1_to_l2_count: l1_to_l2_count, l1_to_l2: l1_to_l2_plus_one} = - Chain.recent_collated_l1_to_l2_for_rap(full_options) + Chain.recent_collated_l1_to_l2_for_rap(full_options, tx_type) {l1_to_l2, next_page} = if fetch_page_number(params) == 1 do @@ -71,6 +72,7 @@ defmodule BlockScoutWeb.L1ToL2TxnController do else {l1_to_l2_plus_one, nil} end + next_page_params = if fetch_page_number(params) == 1 do page_size = Chain.default_page_size() @@ -92,16 +94,27 @@ defmodule BlockScoutWeb.L1ToL2TxnController do else Map.delete(params, "type") end - json( conn, %{ items: - Enum.map(l1_to_l2, fn l1_to_l2 -> + Enum.map(l1_to_l2, fn l -> + display_type = case l.type do + 0 -> + "Tss Reward" + 1 -> + "User Deposit" + 2 -> + "L2 Txn Rollback" + _ -> + l.type + end + + updated_l1_to_l2 = Map.put(l, :display_type, display_type) View.render_to_string( L1ToL2TxnView, "_tile.html", - l1_to_l2: l1_to_l2, + l1_to_l2: updated_l1_to_l2, conn: conn, l1_explorer: Application.get_env(:block_scout_web, :l1_explorer_url) ) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex index 5641455ae6e7..946917237383 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex @@ -10,23 +10,26 @@ <%= @l1_to_l2.queue_index %> <%= if @l1_to_l2.l2_hash == nil do %> - +

Pending

<% else %> - + <%= sub_hash_string(@l1_to_l2.l2_hash) %>... <% end %> + + <%= @l1_to_l2.display_type %> + - + <%= sub_hash_string(@l1_to_l2.hash) %>... - + <%= sub_hash_string(@l1_to_l2.tx_origin) %>... - + <%= @l1_to_l2.gas_limit %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex index b7d68f625986..2d76534fd9a0 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex @@ -4,13 +4,45 @@ } window.onload = ShowLayoutContainer() +<% tx_type = if Map.has_key?(@conn.path_params, "tx_type"), do: String.to_integer(@conn.path_params["tx_type"]), else: nil %> +<% display_type = case tx_type do + 0 -> + "Tss Reward" + 1 -> + "User Deposit" + 2 -> + "L2 Txn Rollback" + _ -> + "All" + end %>
<%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %>
-

<%= gettext "L1 to L2 Transactions" %>

-
- <%= render BlockScoutWeb.CommonComponentsView, "_rap_pagination_container.html", position: "top", showing_limit: if Chain.l1_to_l2_available_count() == Chain.limit_showing_transactions(), do: Chain.limit_showing_transactions(), else: nil %> + +
+

<%= gettext "L1 to L2 Transactions" %>

+
+ <%= render BlockScoutWeb.CommonComponentsView, "_rap_pagination_container.html", position: "top", showing_limit: if Chain.l1_to_l2_available_count() == Chain.limit_showing_transactions(), do: Chain.limit_showing_transactions(), else: nil %> +
@@ -23,14 +55,6 @@ - -
-
- - <%= gettext "There are no transactions." %> - -
-
Block No @@ -38,23 +62,33 @@ Queue Index - + L2 Tx Hash + + Txn Type + Age - + L1 Txn Hash - + L1 Tx Origin - + Gas Limit
+
+
+ + <%= gettext "There are no transactions." %> + +
+
<%= render BlockScoutWeb.CommonComponentsView, "_tile-loader.html" %>
diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index ac5f39f696a6..d1afbe242e65 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -133,6 +133,7 @@ defmodule BlockScoutWeb.WebRouter do get("/da_batch_transactions", DaBatchTransactionController, :index, param: "batch_index") resources("/eigenda-batch", EigendaBatchController, only: [:show], param: "da_hash") get("/l1-to-l2-txns", L1ToL2TxnController, :index) + get("/l1-to-l2-txns/:tx_type", L1ToL2TxnController, :index) get("/l2-to-l1-txns", L2ToL1TxnController, :index) resources "/tx", TransactionController, only: [:show] do diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 9be161e5ffa1..d04efc0a5742 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -3553,16 +3553,15 @@ defmodule Explorer.Chain do %{total_l2_to_l1_count: l2_to_l1_count, l2_to_l1: fetched_l2_to_l1} end - @spec recent_collated_l1_to_l2_for_rap([paging_options]) :: %{ + @spec recent_collated_l1_to_l2_for_rap([paging_options], Decimal.t()) :: %{ :total_l1_to_l2_count => non_neg_integer(), :l1_to_l2 => [L1ToL2.t()] } - def recent_collated_l1_to_l2_for_rap(options \\ []) when is_list(options) do + def recent_collated_l1_to_l2_for_rap(options \\ [], tx_type) when is_list(options) do paging_options = Keyword.get(options, :paging_options, @default_paging_options) - - l1_to_l2_count = l1_to_l2_available_count() - fetched_l1_to_l2=fetch_recent_collated_l1_to_l2_for_rap(paging_options) + l1_to_l2_count = l1_to_l2_available_count(tx_type) + fetched_l1_to_l2=fetch_recent_collated_l1_to_l2_for_rap(paging_options, tx_type) %{total_l1_to_l2_count: l1_to_l2_count, l1_to_l2: fetched_l1_to_l2} end @@ -3591,8 +3590,8 @@ defmodule Explorer.Chain do |> Repo.all() end - def fetch_recent_collated_l1_to_l2_for_rap(paging_options) do - fetch_l1_to_l2_for_rap() + def fetch_recent_collated_l1_to_l2_for_rap(paging_options, tx_type) do + fetch_l1_to_l2_for_rap(tx_type) |> no_cache_handle_options(paging_options) |> Repo.all() end @@ -3749,9 +3748,15 @@ defmodule Explorer.Chain do |> Repo.one() end - defp fetch_l1_to_l2_for_rap do - L1ToL2 - |> order_by([l1_to_l2], desc: l1_to_l2.queue_index) + defp fetch_l1_to_l2_for_rap(tx_type) do + if is_nil(tx_type) do + L1ToL2 + |> order_by([l1_to_l2], desc: l1_to_l2.queue_index) + else + L1ToL2 + |> order_by([l1_to_l2], desc: l1_to_l2.queue_index) + |> where([l1_to_l2], l1_to_l2.type == ^tx_type) + end end defp fetch_l2_to_l1_for_rap do @@ -3787,7 +3792,18 @@ defmodule Explorer.Chain do |> Repo.aggregate(:count, :hash) end - def l1_to_l2_available_count do + def l1_to_l2_available_count(tx_type) do + if is_nil(tx_type) do + l1_to_l2_available_count() + else + L1ToL2 + |> where([l1_to_l2], not is_nil(l1_to_l2.queue_index) and l1_to_l2.type == ^tx_type) + |> limit(^@limit_showing_transactions) + |> Repo.aggregate(:count, :hash) + end + end + + def l1_to_l2_available_count() do L1ToL2 |> where([l1_to_l2], not is_nil(l1_to_l2.queue_index)) |> limit(^@limit_showing_transactions) diff --git a/apps/explorer/lib/explorer/chain/l1_to_l2.ex b/apps/explorer/lib/explorer/chain/l1_to_l2.ex index e992d5cc2b6d..2d680c991def 100644 --- a/apps/explorer/lib/explorer/chain/l1_to_l2.ex +++ b/apps/explorer/lib/explorer/chain/l1_to_l2.ex @@ -9,6 +9,7 @@ defmodule Explorer.Chain.L1ToL2 do timestamp: DateTime.t(), tx_origin: %Ecto.Association.NotLoaded{} | Address.t(), queue_index: integer(), + type: integer(), target: %Ecto.Association.NotLoaded{} | Address.t(), gas_limit: Gas.t(), } @@ -18,6 +19,7 @@ defmodule Explorer.Chain.L1ToL2 do field(:hash, :string) field(:l2_hash, :string) field(:block, :integer) + field(:type, :integer) field(:timestamp, :utc_datetime_usec) field(:tx_origin, :string) field(:target, :string) From 9a1f67dd9cb3e8d07371c44a001c6b0a816bfa6e Mon Sep 17 00:00:00 2001 From: "albert.zhang" Date: Fri, 2 Jun 2023 10:13:45 +0800 Subject: [PATCH 09/44] feat: update rollBackL2Chain --- data-sync-service/src/l1Ingestion/l1Ingestion.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts b/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts index 09849648d07d..922d9993d8ed 100644 --- a/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts +++ b/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts @@ -306,6 +306,7 @@ export class L1IngestionService { const iface = new utils.Interface([ 'function claimReward(uint256 _blockStartHeight, uint32 _length, uint256 _batchTime, address[] calldata _tssMembers)', 'function finalizeDeposit(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes calldata _data)', + 'function rollBackL2Chain(uint256 _shouldRollBack, uint256 _shouldStartAtElement, bytes memory _signature)', ]); let l1_token = '0x0000000000000000000000000000000000000000'; let l2_token = '0x0000000000000000000000000000000000000000'; @@ -338,6 +339,9 @@ export class L1IngestionService { const decodeMsg = iface.decodeFunctionData('claimReward', message); type = 0; // reward this.logger.log(`reward tssMembers is [${decodeMsg._tssMembers}]`); + } else if (funName === '0xf523f40d') { + const decodeMsg = iface.decodeFunctionData('rollBackL2Chain', message); + type = 2; // rollBackL2Chain } const { timestamp } = await this.web3.eth.getBlock(blockNumber); const msgHash = this.verifyDomainCalldataHash({ From f3e4f3d57b5226b4a63ae9876d34586092cdbbd5 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Fri, 2 Jun 2023 14:07:32 +0800 Subject: [PATCH 10/44] #220 replace home txn batch into eigenlayer txn batch --- .../assets/css/components/_card.scss | 24 +++++++++++ .../controllers/transaction_controller.ex | 39 ++++++++++++------ .../templates/transaction/overview.html.eex | 41 +++++++++++++++---- .../block_scout_web/views/transaction_view.ex | 37 +++++++++++++++++ 4 files changed, 120 insertions(+), 21 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index 9958509354b3..997ecaa3b200 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -161,6 +161,30 @@ $card-tab-icon-color-active: #fff !default; display:none; } } + .transaction_detail_status_container{ + display: flex; + align-items: center; + .transaction_detail_status_item { + height: 36px; + padding: 0 16px 0 18px; + text-align: center; + line-height: 36px; + border-radius: 18px; + background: #F0F1F2; + margin: 0 9px; + font-size: 14px; + font-family: Nunito; + font-weight: 700; + color: #6E767D; + &:first-child { + margin-left: 0; + } + } + .transaction_detail_status_item_active { + color: #15181C; + background: rgba(6, 221, 118, 0.5); + } + } } .txn-list-container{ 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 8e5058258f87..90cb9a088dc0 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 @@ -28,6 +28,10 @@ require Logger alias Explorer.ExchangeRates.Token alias Phoenix.View + #alias EthereumJSONRPC.HTTP.HTTPoison + import HTTPoison + import EthereumJSONRPC + @necessity_by_association %{ :block => :optional, [created_contract_address: :names] => :optional, @@ -56,8 +60,6 @@ require Logger options = @default_options |> Keyword.merge(paging_options(params)) -Logger.info("------") -Logger.info("#{inspect(params)}") full_options = options |> Keyword.put( @@ -151,6 +153,20 @@ Logger.info("#{inspect(params)}") def show(conn, %{"id" => id} = params) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(id), :ok <- Chain.check_transaction_exists(transaction_hash) do + + tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [id]}) + |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) + |> case do + {:ok, tx} -> + tx["status"] + {:error, _} -> + nil + end + + Logger.info("0-0-0-0-0-0") + Logger.info("#{inspect(tx_status)}") + + if Chain.transaction_has_token_transfers?(transaction_hash) do with {:ok, transaction} <- Chain.hash_to_transaction( @@ -160,16 +176,14 @@ Logger.info("#{inspect(params)}") {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do - # TODO(Jayce) hash hard code - updated_transaction = case Chain.hash_to_batch("0xbea2e27d87299ab1f91b914b2acb1b08780199ad042958c854fc7992bea448fc",necessity_by_association: @necessity_by_association) do + updated_transaction = case Chain.hash_to_batch(id,necessity_by_association: @necessity_by_association) do {:error, _} -> transaction {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> res = Map.put(transaction, :batch_index, batch_index) Map.put(res, :data_commitment, data_commitment) end - # TODO(Jayce) hash hard code - updated_state_transaction = case Chain.block_to_state_batch(2536260,necessity_by_association: @necessity_by_association) do + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do {:error, _} -> updated_transaction {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> @@ -177,6 +191,7 @@ Logger.info("#{inspect(params)}") Map.put(res, :submission_tx_hash, submission_tx_hash) end + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) render( conn, "show_token_transfers.html", @@ -185,7 +200,7 @@ Logger.info("#{inspect(params)}") current_path: Controller.current_full_path(conn), current_user: current_user(conn), show_token_transfers: true, - transaction: updated_state_transaction, + transaction: updated_display_tx_status_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: @@ -215,16 +230,14 @@ Logger.info("#{inspect(params)}") ), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do - # TODO(Jayce) hash hard code - updated_transaction = case Chain.hash_to_batch("0xbea2e27d87299ab1f91b914b2acb1b08780199ad042958c854fc7992bea448fc",necessity_by_association: @necessity_by_association) do + updated_transaction = case Chain.hash_to_batch(id,necessity_by_association: @necessity_by_association) do {:error, _} -> transaction {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> res = Map.put(transaction, :batch_index, batch_index) Map.put(res, :data_commitment, data_commitment) end - # TODO(Jayce) hash hard code - updated_state_transaction = case Chain.block_to_state_batch(2536260,necessity_by_association: @necessity_by_association) do + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do {:error, _} -> updated_transaction {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> @@ -232,6 +245,8 @@ Logger.info("#{inspect(params)}") Map.put(res, :submission_tx_hash, submission_tx_hash) end + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) + render( conn, "show_internal_transactions.html", @@ -240,7 +255,7 @@ Logger.info("#{inspect(params)}") current_user: current_user(conn), block_height: Chain.block_height(), show_token_transfers: Chain.transaction_has_token_transfers?(transaction_hash), - transaction: updated_state_transaction, + transaction: updated_display_tx_status_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index a3e63c377f83..ab9127d3ec60 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -112,18 +112,41 @@
<% formatted_status = BlockScoutWeb.TransactionView.formatted_status(status) %> <% confirmations = confirmations(@transaction, block_height: @block_height) %> - - - <%= if status == :pending do %> - <%= render BlockScoutWeb.FormView, "_tag.html", text: formatted_status, additional_classes: ["large"] %> - <% else %> - <%= render BlockScoutWeb.FormView, "_tag.html", text: formatted_status, additional_classes: ["success", "large"] %> - <% end %> +
+ <%= if Map.has_key?(@transaction, :tx_status) do %> +
+ + ✔️ + Accepted on L2 + + > + + ✔️ + Rollup to L1 + + > + + ✔️ + Finalized on L1 + + > + + ✔️ + Challenge Period Passed + +
+ <% end %> <%= if confirmations > 0 do %> - <%= gettext "Confirmed by " %><%= confirmations %><%= " " <> confirmations_ds_name(confirmations) %> + + <%= gettext "Confirmed by " %> + + <%= confirmations %> + + <%= " " <> confirmations_ds_name(confirmations) %> + <% end %> - +
diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index ffba47148431..9d1488482f53 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -343,6 +343,43 @@ require Logger end end + def get_tx_status_cls1(tx_status) do + case tx_status do + "0x1" -> + "transaction_detail_status_item_active" + "0x2" -> + "transaction_detail_status_item_active" + "0x3" -> + "transaction_detail_status_item_active" + end + end + + def get_tx_status_cls2(tx_status) do + case tx_status do + "0x1" -> + "" + "0x2" -> + "transaction_detail_status_item_active" + "0x3" -> + "transaction_detail_status_item_active" + end + end + + def get_tx_status_cls3(tx_status) do + case tx_status do + "0x1" -> + "" + "0x2" -> + "" + "0x3" -> + "transaction_detail_status_item_active" + end + end + + def get_tx_status_cls1(%{tx_status: nil}), do: "" + def get_tx_status_cls2(%{tx_status: nil}), do: "" + def get_tx_status_cls3(%{tx_status: nil}), do: "" + def formatted_result(status) do case status do :pending -> gettext("Pending") From 5e245bc9cfeee4f91f1379d812b938a0580f3705 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Fri, 2 Jun 2023 15:06:54 +0800 Subject: [PATCH 11/44] #220 replace home txn batch into eigenlayer txn batch --- .../templates/l1_to_l2_txn/index.html.eex | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex index 2d76534fd9a0..70203bd18ac1 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex @@ -19,25 +19,7 @@ <%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %>
-

<%= gettext "L1 to L2 Transactions" %>

@@ -66,7 +48,23 @@ L2 Tx Hash - Txn Type + + + Age From fc99769f004801d15c387f8b403ff40c04051f05 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Sat, 3 Jun 2023 08:30:10 +0800 Subject: [PATCH 12/44] fix: first tx status --- .../assets/css/components/_card.scss | 48 +++++++++++++++++++ .../block_scout_web/views/transaction_view.ex | 8 +++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index 997ecaa3b200..9d592b79a148 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -201,6 +201,30 @@ $card-tab-icon-color-active: #fff !default; border-bottom:1px solid #F0F1F2; color:#6c757e; min-width: 1130px; + .nav-link{ + color:#6c757e; + } + .dropdown-menu{ + background: #F8F8F9; + border: 1px solid #F0F1F2; + box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.02); + border-radius: 6px; + padding: 6px; + min-width: 100px; + width: auto; + .dropdown-item{ + color: #15181C; + border-radius: 4px; + width: 120px; + line-height: 38px; + padding:0 8px; + &:hover{ + font-weight: 700; + background: rgba(207, 210, 212, 0.3); + + } + } + } } .recent-tx-list-page{ min-width: 1130px; @@ -224,6 +248,30 @@ $card-tab-icon-color-active: #fff !default; background: rgba(255, 255, 255, 0.05); color:#ffffff; border-color: rgba(255, 255, 255, 0.15); + .nav-link{ + color:#ffffff; + } + .dropdown-menu{ + background: #F8F8F9; + border: 1px solid #F0F1F2; + box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.02); + border-radius: 6px; + padding: 6px; + min-width: 100px; + width: auto; + .dropdown-item{ + color: #ffffff; + border-radius: 4px; + width: 120px; + line-height: 38px; + padding:0 8px; + &:hover{ + font-weight: 700; + background: rgba(207, 210, 212, 0.3); + + } + } + } } .txn-list-table-item{ border-color:rgba(255,255,255,.1); diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index 9d1488482f53..9492d3832874 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -345,8 +345,10 @@ require Logger def get_tx_status_cls1(tx_status) do case tx_status do + "0x0" -> + "" "0x1" -> - "transaction_detail_status_item_active" + "transaction_detail_status_item_active" "0x2" -> "transaction_detail_status_item_active" "0x3" -> @@ -356,6 +358,8 @@ require Logger def get_tx_status_cls2(tx_status) do case tx_status do + "0x0" -> + "" "0x1" -> "" "0x2" -> @@ -367,6 +371,8 @@ require Logger def get_tx_status_cls3(tx_status) do case tx_status do + "0x0" -> + "" "0x1" -> "" "0x2" -> From 20658cd54d49bbf2ae0f2342c74f32a3b238b7fc Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Sat, 3 Jun 2023 12:21:10 +0800 Subject: [PATCH 13/44] fix: first tx status --- .../assets/css/components/_card.scss | 50 +++++++++++++------ .../css/components/_custom_tooltips.scss | 10 ++-- .../assets/css/components/_tooltip.scss | 2 +- .../assets/css/theme/_mantle-theme.scss | 19 +++++-- .../controllers/transaction_controller.ex | 4 +- .../templates/l1_to_l2_txn/index.html.eex | 2 +- .../templates/l2_to_l1_txn/_tile.html.eex | 22 +++++--- .../templates/l2_to_l1_txn/index.html.eex | 10 ++-- 8 files changed, 81 insertions(+), 38 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index 9d592b79a148..3b27b5f95372 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -164,6 +164,7 @@ $card-tab-icon-color-active: #fff !default; .transaction_detail_status_container{ display: flex; align-items: center; + flex-wrap: wrap; .transaction_detail_status_item { height: 36px; padding: 0 16px 0 18px; @@ -189,6 +190,7 @@ $card-tab-icon-color-active: #fff !default; .txn-list-container{ + .txn-list-table-head-container{ background:#F8F8F9;; display:flex; @@ -201,7 +203,7 @@ $card-tab-icon-color-active: #fff !default; border-bottom:1px solid #F0F1F2; color:#6c757e; min-width: 1130px; - .nav-link{ + .l1-to-l2-tx-type-head{ color:#6c757e; } .dropdown-menu{ @@ -238,6 +240,12 @@ $card-tab-icon-color-active: #fff !default; padding:0 10px; border-bottom:1px solid #e7eaf3; } + .display_tx_status_tooltip{ + color: #212529; + &:hover { + color: #212529; + } + } } .dark-theme-applied{ .card-body { @@ -248,27 +256,18 @@ $card-tab-icon-color-active: #fff !default; background: rgba(255, 255, 255, 0.05); color:#ffffff; border-color: rgba(255, 255, 255, 0.15); - .nav-link{ + .l1-to-l2-tx-type-head{ color:#ffffff; } .dropdown-menu{ - background: #F8F8F9; - border: 1px solid #F0F1F2; + background: #152928; box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.02); - border-radius: 6px; - padding: 6px; - min-width: 100px; - width: auto; + border:none; .dropdown-item{ color: #ffffff; - border-radius: 4px; - width: 120px; - line-height: 38px; - padding:0 8px; + background: #152928 !important; &:hover{ - font-weight: 700; - background: rgba(207, 210, 212, 0.3); - + background: #21413F !important; } } } @@ -276,6 +275,12 @@ $card-tab-icon-color-active: #fff !default; .txn-list-table-item{ border-color:rgba(255,255,255,.1); } + .display_tx_status_tooltip{ + color: #ffffff; + &:hover { + color: #ffffff; + } + } } } @@ -495,7 +500,20 @@ $card-tab-icon-color-active: #fff !default; } } } - + .transaction_detail_status_container{ + + .transaction_detail_status_item { + background: #21413F; + color: #4F8F8B; + &:first-child { + margin-left: 0; + } + } + .transaction_detail_status_item_active { + color: #ffffff; + background: rgba(6, 221, 118, 0.5); + } + } } .card-tabs { diff --git a/apps/block_scout_web/assets/css/components/_custom_tooltips.scss b/apps/block_scout_web/assets/css/components/_custom_tooltips.scss index 1aa231302285..761ed624b801 100644 --- a/apps/block_scout_web/assets/css/components/_custom_tooltips.scss +++ b/apps/block_scout_web/assets/css/components/_custom_tooltips.scss @@ -128,16 +128,20 @@ $tooltip-background-color: $btn-line-color !default; white-space: nowrap; } .custom-tooltip-title{ - font-style: normal; + font-family: 'Nunito'; font-weight: 900; font-size: 14px; text-align: start; - color: #585F65; + color: #2B3034; + line-height: 22px; } .custom-tooltip-content{ + font-family: 'Nunito'; + font-weight: 600; font-size: 12px; text-align: start; - color: #2B3034; + color: #585F65; + line-height: 22px; } } } diff --git a/apps/block_scout_web/assets/css/components/_tooltip.scss b/apps/block_scout_web/assets/css/components/_tooltip.scss index df9aa849bbc8..c109d2f21c03 100644 --- a/apps/block_scout_web/assets/css/components/_tooltip.scss +++ b/apps/block_scout_web/assets/css/components/_tooltip.scss @@ -9,7 +9,7 @@ $tooltip-color: #fff !default; .tooltip-inner { background-color: $tooltip-background-color; border-radius: 5px; - color: $tooltip-color; + color: #15181C; padding: 15px; font-size: 12px; max-width: 305px; diff --git a/apps/block_scout_web/assets/css/theme/_mantle-theme.scss b/apps/block_scout_web/assets/css/theme/_mantle-theme.scss index 72c31bc87d6a..b8baffd535cb 100644 --- a/apps/block_scout_web/assets/css/theme/_mantle-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_mantle-theme.scss @@ -136,6 +136,9 @@ $dark-primary-alternate: #65B3AE !default; fill: $dark-text-content-color; } } + .transfers-list-mobile-container{ + background: none; + } // navbar .navbar.navbar-primary { @@ -617,12 +620,22 @@ $dark-primary-alternate: #65B3AE !default; //tooltips .tooltip .arrow:before { - border-top-color: $dark-primary; - border-bottom-color: $dark-primary; + border-top-color: #21413F; + border-bottom-color: #21413F; } .tooltip>.tooltip-inner { - background-color: $dark-primary; + background-color: #21413F; + color: #ffffff; + .custom-tooltip-total-title{ + color: #ffffff; + } + .custom-tooltip-title{ + color: #BFF6F2 + } + .custom-tooltip-content{ + color: #65B3AE + } } .tooltip-pale-color.bs-tooltip-top .arrow::before, 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 90cb9a088dc0..710f24d59adc 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 @@ -153,7 +153,7 @@ require Logger def show(conn, %{"id" => id} = params) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(id), :ok <- Chain.check_transaction_exists(transaction_hash) do - + Logger.info("query tx status beginning...") tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [id]}) |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) |> case do @@ -163,7 +163,7 @@ require Logger nil end - Logger.info("0-0-0-0-0-0") + Logger.info("query tx status finished...") Logger.info("#{inspect(tx_status)}") diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex index 70203bd18ac1..719de5d63926 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex @@ -52,7 +52,7 @@
- + Msg Nonce - + From - + L2 Tx Hash Age - + + Status <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("
@@ -57,7 +58,6 @@

Withdrawal has been claimed on L1

") %> - Status
L1 Tx Hash From 36e110cc93d78beb5b9e4055fa2d30afd6129b17 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Mon, 5 Jun 2023 08:01:45 +0800 Subject: [PATCH 14/44] fix: first tx status --- .../assets/css/components/_card.scss | 13 +- .../templates/address/_tabs.html.eex | 2 +- .../templates/transaction/overview.html.eex | 154 +++++++++--------- apps/block_scout_web/priv/gettext/default.pot | 6 +- .../priv/gettext/en/LC_MESSAGES/default.po | 6 +- 5 files changed, 97 insertions(+), 84 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index 3b27b5f95372..00a109cc22af 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -172,14 +172,15 @@ $card-tab-icon-color-active: #fff !default; line-height: 36px; border-radius: 18px; background: #F0F1F2; - margin: 0 9px; + margin: 0 9px 8px 0; font-size: 14px; font-family: Nunito; font-weight: 700; color: #6E767D; - &:first-child { - margin-left: 0; - } + } + .transaction_detail_status_item_true{ + margin-right: 9px; + margin-bottom: 8px; } .transaction_detail_status_item_active { color: #15181C; @@ -414,6 +415,10 @@ $card-tab-icon-color-active: #fff !default; color:#091312; background:rgba(175, 208, 232, .35); height:20px; + max-width: 148px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; .recent-preview-item-content-latest-txs-tag{ position:absolute; left:0; diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex index 2e8c8e2d0b0f..8eb97cbfff44 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex @@ -10,7 +10,7 @@ ) %> <%= if Chain.check_if_token_transfers_at_address(@address.hash) do %> <%= link( - gettext("Token Transfers"), + gettext("Token Transfers(ERC20)"), class: "card-tab #{tab_status("token-transfers", @conn.request_path)}", "data-test": "token_transfers_tab_link", to: AccessHelpers.get_path(@conn, :address_token_transfers_path, :index, @address.hash) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index ab9127d3ec60..32721d0d8030 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -74,12 +74,12 @@ <% end %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Unique character string (TxID) assigned to every verified transaction.") %> <%= gettext "Transaction Hash" %>
-
+
<%= @transaction %> <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders"], @@ -92,24 +92,24 @@
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Current transaction state: Success, Failed (Error), or Pending (In Process)") %> <%= gettext "Result" %>
-
+
<% formatted_result = BlockScoutWeb.TransactionView.formatted_result(status) %> <%= render BlockScoutWeb.CommonComponentsView, "_status_icon.html", status: status %><%= formatted_result %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("The status of the transaction: Confirmed or Unconfirmed.") %> <%= gettext "Status" %>
-
+
<% formatted_status = BlockScoutWeb.TransactionView.formatted_status(status) %> <% confirmations = confirmations(@transaction, block_height: @block_height) %>
@@ -119,17 +119,17 @@ ✔️ Accepted on L2 - > + > ✔️ Rollup to L1 - > + > ✔️ Finalized on L1 - > + > ✔️ Challenge Period Passed @@ -152,11 +152,11 @@ <%= if status == {:error, "Reverted"} || status == {:error, "execution reverted"} do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("The revert reason of the transaction.") %> <%= gettext "Revert reason" %>
-
+
<%= case BlockScoutWeb.TransactionView.transaction_revert_reason(@transaction) do %> <% {:error, _contract_not_verified, candidates} when candidates != [] -> %> <% {:ok, method_id, text, mapping} = Enum.at(candidates, 0) %> @@ -175,11 +175,11 @@ <% end %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Block number containing the transaction.") %> <%= gettext "Block" %>
-
+
<%= if block do %> <%= link( block, @@ -194,12 +194,12 @@ <%= if block && block.timestamp do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Date & time of transaction inclusion, including length of time for confirmation.") %> <%= gettext "Timestamp" %>
-
+
@@ -219,12 +219,12 @@ <%= if Map.has_key?(@transaction, :batch_index) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Eigenlayer Txn Batch Index.") %> <%= gettext "Eigenlayer Txn Batch Index" %>
-
+
<%= render "_batch_link.html", batch_index: @transaction.batch_index, data_test: "address_hash_link" %>
@@ -233,12 +233,12 @@ <%= if Map.has_key?(@transaction, :data_commitment) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Eigenlayer Submission Hash") %> <%= gettext "Eigenlayer Submission Hash" %>
-
<%= @transaction.data_commitment %>
+
<%= @transaction.data_commitment %>
<% end %> @@ -246,12 +246,12 @@ <%= if Map.has_key?(@transaction, :state_batch_index) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext(" L1 State Batch Index.") %> <%= gettext " L1 State Batch Index" %>
-
+
<%= render "_state_batch_link.html", batch_index: @transaction.state_batch_index, data_test: "address_hash_link" %>
@@ -259,12 +259,12 @@ <%= if Map.has_key?(@transaction, :submission_tx_hash) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("L1 State Root Submission Tx Hash") %> <%= gettext "L1 State Root Submission Tx Hash" %>
-
+
<%= @transaction.submission_tx_hash %> @@ -274,11 +274,11 @@ <% end %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Address (external or contract) sending the transaction.") %> <%= gettext "From" %>
-
+
<%= render BlockScoutWeb.AddressView, "_link.html", address: from_address, contract: BlockScoutWeb.AddressView.contract?(from_address), use_custom_tooltip: false, trimmed: false %> <%= render BlockScoutWeb.AddressView, "_labels.html", tags: @from_tags %> <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy.html", @@ -292,7 +292,7 @@ <% to_address = @transaction |> Map.get(:to_address) || @transaction |> Map.get(:created_contract_address) %> <% recipient_address_hash = to_address_hash || created_address_hash %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Address (external or contract) receiving the transaction.") %> <%= if BlockScoutWeb.AddressView.contract?(to_address) && !created_address_hash do %> @@ -301,7 +301,7 @@ <%= gettext "To" %> <% end %>
-
+
<%= cond do %> <% created_address_hash -> %> [<%= gettext("Contract") %>  @@ -331,11 +331,11 @@ <% %{transfers: transfers, mintings: mintings, burnings: burnings, creations: creations} = aggregate_token_transfers(transaction_with_transfers.token_transfers) %> <%= if Enum.count(transfers) > 0 do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("List of token transferred in the transaction.") %> <%= gettext "Tokens Transferred" %>
-
"> +
"> <%= if Enum.count(transfers) > 8 do %>
"/> @@ -355,12 +355,12 @@ <%= if Enum.count(mintings) > 0 do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("List of token minted in the transaction.") %> <%= gettext "Tokens Minted" %>
-
+
<%= for minting <- mintings do %> <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, minting) %> @@ -372,11 +372,11 @@ <%= if Enum.count(burnings) > 0 do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("List of token burnt in the transaction.") %> <%= gettext "Tokens Burnt" %>
-
+
<%= for burning <- burnings do %>
<%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, burning) %> @@ -388,11 +388,11 @@ <%= if Enum.count(creations) > 0 do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("List of ERC-1155 tokens created in the transaction.") %> <%= gettext "Tokens Created" %>
-
+
<%= for creation <- creations do %>
<%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, creation) %> @@ -405,12 +405,12 @@ <% end %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Value sent in the native token (and USD) if applicable.") %> <%= gettext "Value" %>
-
<%= value(@transaction) %> +
<%= value(@transaction) %> <%= if !empty_exchange_rate?(@exchange_rate) do %> ( @@ -421,91 +421,91 @@
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Total transaction fee spent on L1 and L2.") %> <%= gettext "Transaction Fee" %>
-
+
<%= formatted_fee(@transaction, denomination: :ether) %>

-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Price per unit of gas specified by the sender. Higher gas prices can prioritize transaction inclusion during times of high usage.") %> <%= gettext "Gas Price on L2" %>
-
<%= gas_price(@transaction, :gwei) %>
+
<%= gas_price(@transaction, :gwei) %>
<%= if !is_nil(type) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Transaction type, introduced in EIP-2718.") %> <%= gettext "Transaction Type" %>
-
<%= type %>
+
<%= type %>
<% end %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Maximum gas amount approved for the transaction.") %> <%= gettext "Gas Limit" %>
-
<%= format_gas_limit(@transaction.gas) %>
+
<%= format_gas_limit(@transaction.gas) %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Transaction fee on layer2.") %> <%= gettext "L2 Fee" %>
-
<%= l2_fee(@transaction, :gwei) %> <%= Explorer.coin_name() %>
+
<%= l2_fee(@transaction, :gwei) %> <%= Explorer.coin_name() %>
<%= if !is_nil(max_fee_per_gas) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Maximum total amount per unit of gas a user is willing to pay for a transaction, including base fee and priority fee.") %> <%= gettext "Max Fee per Gas" %>
-
<%= format_wei_value(max_fee_per_gas, :gwei) %>
+
<%= format_wei_value(max_fee_per_gas, :gwei) %>
<% end %> <%= if !is_nil(max_priority_fee_per_gas) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("User defined maximum fee (tip) per unit of gas paid to validator for transaction prioritization.") %> <%= gettext "Max Priority Fee per Gas" %>
-
<%= format_wei_value(max_priority_fee_per_gas, :gwei) %>
+
<%= format_wei_value(max_priority_fee_per_gas, :gwei) %>
<% end %> <%= if !is_nil(priority_fee) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("User-defined tip sent to validator for transaction priority/inclusion.") %> <%= gettext "Priority Fee / Tip" %>
-
<%= format_wei_value(priority_fee, :ether) %>
+
<%= format_wei_value(priority_fee, :ether) %>
<% end %> <%= if !is_nil(burned_fee) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Amount of") <> " " <> Explorer.coin_name() <> " " <> gettext("burned for this transaction. Equals Block Base Fee per Gas * Gas Used.") %> <%= gettext "Transaction Burnt Fee" %>
-
<%= format_wei_value(burned_fee, :ether) %> +
<%= format_wei_value(burned_fee, :ether) %> <%= unless empty_exchange_rate?(@exchange_rate) do %> ( data-usd-exchange-rate=<%= @exchange_rate.usd_value %>>) <% end %> @@ -514,33 +514,33 @@ <% end %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Actual gas amount used by the transaction.") %> <%= gettext "Gas Used by Transaction" %>
<% gas_used_perc = gas_used_perc(@transaction) %> -
<%= gas_used(@transaction) %> <%= if gas_used_perc, do: "| #{gas_used_perc}%" %>
+
<%= gas_used(@transaction) %> <%= if gas_used_perc, do: "| #{gas_used_perc}%" %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Transaction number from the sending address. Each transaction sent from an address increments the nonce by 1.") %> <%= gettext "Nonce" %>"><%= gettext "Position" %>
-
<%= @transaction.nonce %><%= if block, do: @transaction.index, else: formatted_result(status) %>
+
<%= @transaction.nonce %><%= if block, do: @transaction.index, else: formatted_result(status) %>
<%= unless value_transfer?(@transaction) do %>
-
+
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", text: gettext("Binary data included with the transaction. See input / logs below for additional info.") %> <%= gettext "Raw Input" %>
-
+
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index bf71940f8540..341baa96cf10 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -2744,7 +2744,7 @@ msgstr "" msgid "Token Transfer" msgstr "" -#: lib/block_scout_web/templates/address/_tabs.html.eex:13 + #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 #: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16 @@ -2760,6 +2760,10 @@ msgstr "" msgid "Token Transfers" msgstr "" +#: lib/block_scout_web/templates/address/_tabs.html.eex:13 +msgid "Token Transfers(ERC20)" +msgstr "" + #: lib/block_scout_web/templates/address/overview.html.eex:54 #, elixir-autogen, elixir-format msgid "Token name and symbol." diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 6968370b017d..31534bfcff3b 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -2741,7 +2741,7 @@ msgstr "" msgid "Token Transfer" msgstr "" -#: lib/block_scout_web/templates/address/_tabs.html.eex:13 + #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 #: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16 @@ -2757,6 +2757,10 @@ msgstr "" msgid "Token Transfers" msgstr "" +#: lib/block_scout_web/templates/address/_tabs.html.eex:13 +msgid "Token Transfers(ERC20)" +msgstr "" + #: lib/block_scout_web/templates/address/overview.html.eex:54 #, elixir-autogen, elixir-format msgid "Token name and symbol." From 37096b0e8ac7d75edcb1718f6ea5479806cdaa60 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Mon, 5 Jun 2023 08:35:41 +0800 Subject: [PATCH 15/44] fix: first tx status --- .../assets/css/components/_card.scss | 3 ++ .../l1_to_l2_txn/_recent_tile.html.eex | 29 +++++++++++-------- .../transaction/_recent_tile.html.eex | 23 ++++----------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index 00a109cc22af..035fe8359054 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -405,6 +405,9 @@ $card-tab-icon-color-active: #fff !default; width:80px; } } + .recent-preview-item-content-latest-txs-tag-wrap-time{ + min-width: 100px; + } .recent-preview-item-content-latest-txs-tag-wrap{ margin-left:5px; font-size:12px;position:relative; diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_recent_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_recent_tile.html.eex index f172f4c6fba4..9e676f5d228d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_recent_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_recent_tile.html.eex @@ -1,4 +1,4 @@ -
@@ -15,23 +15,28 @@
L1 Tx# - <%= sub_hash_string(@l1_to_l2.hash, 15) %>... - L2 Tx# - - <%= @l1_to_l2.l2_hash %>... - + L2 Tx + <%= if @l1_to_l2.l2_hash do %> + + #<%= @l1_to_l2.l2_hash %> + ... + <% else %> + Pendding + <% end %> +
- - + + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_recent_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_recent_tile.html.eex index e2f8623f60b5..2c912839bac2 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_recent_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_recent_tile.html.eex @@ -1,4 +1,4 @@ -
@@ -15,7 +15,7 @@ <%= render "_link.html", transaction_hash: @transaction.hash, data_test: "address_hash_link" %> - +
From @@ -26,11 +26,11 @@ <%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %> - +
- - + @@ -39,16 +39,3 @@
- - - - - - - - - - - - - From 1d6a4803d17fb212e9dbd12dd5dd82808a5bd0a8 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Mon, 5 Jun 2023 14:19:52 +0800 Subject: [PATCH 16/44] debug code --- .../block_scout_web/controllers/l1_to_l2_txn_controller.ex | 2 ++ .../block_scout_web/templates/l1_to_l2_txn/index.html.eex | 5 ++++- data-sync-service/src/l2Ingestion/l2Ingestion.service.ts | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex index ad6ea6623ca5..99c7dff09680 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/l1_to_l2_txn_controller.ex @@ -106,6 +106,8 @@ defmodule BlockScoutWeb.L1ToL2TxnController do "User Deposit" 2 -> "L2 Txn Rollback" + 3 -> + "Tss Slash" _ -> l.type end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex index 719de5d63926..02c54c15263e 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex @@ -12,6 +12,8 @@ "User Deposit" 2 -> "L2 Txn Rollback" + 3 -> + "Tss Slash" _ -> "All" end %> @@ -58,7 +60,8 @@ diff --git a/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts b/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts index 9454aba963c1..6aaf9751b043 100644 --- a/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts +++ b/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts @@ -238,6 +238,13 @@ export class L2IngestionService { startBlock, endBlock, ); + + if(list.length > 0){ + console.log('-------') + console.log('from and to', `${startBlock}, ${endBlock}`) + console.log(list) + } + const result: any = []; const l2RelayedMessageEventsInsertData: any = []; for (const item of list) { From e83b78e90ed68078409a47aad66648d55c05ad80 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Mon, 5 Jun 2023 15:01:01 +0800 Subject: [PATCH 17/44] debug code --- data-sync-service/src/l2Ingestion/l2Ingestion.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts b/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts index 6aaf9751b043..e74a7d35467c 100644 --- a/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts +++ b/data-sync-service/src/l2Ingestion/l2Ingestion.service.ts @@ -239,11 +239,11 @@ export class L2IngestionService { endBlock, ); - if(list.length > 0){ + //if(list.length > 0){ console.log('-------') console.log('from and to', `${startBlock}, ${endBlock}`) console.log(list) - } + //} const result: any = []; const l2RelayedMessageEventsInsertData: any = []; From 8fdd8a7a737064012a9e8e58f1a9fd1bb88e6d73 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 6 Jun 2023 17:59:30 +0800 Subject: [PATCH 18/44] fix: search input auto complete & transaction_detail tags some field does not display --- .../assets/css/components/_navbar.scss | 9 +++-- .../assets/js/lib/autocomplete.js | 8 +++-- .../controllers/chain_controller.ex | 17 ++++++--- .../controllers/transaction_controller.ex | 6 ---- ...saction_internal_transaction_controller.ex | 32 +++++++++++++++-- .../controllers/transaction_log_controller.ex | 27 +++++++++++++- .../transaction_raw_trace_controller.ex | 33 ++++++++++++++--- .../transaction_state_controller.ex | 27 +++++++++++++- .../transaction_token_transfer_controller.ex | 27 +++++++++++++- .../templates/layout/_topnav.html.eex | 2 +- .../templates/search/_tile.html.eex | 4 +++ .../views/api/v2/search_view.ex | 11 ++++-- apps/explorer/lib/explorer/chain.ex | 35 +++++++++++++++---- .../src/l2Ingestion/l2Ingestion.service.ts | 7 ---- 14 files changed, 206 insertions(+), 39 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_navbar.scss b/apps/block_scout_web/assets/css/components/_navbar.scss index b5c080a9f9b8..188ee63bd6d8 100644 --- a/apps/block_scout_web/assets/css/components/_navbar.scss +++ b/apps/block_scout_web/assets/css/components/_navbar.scss @@ -92,6 +92,11 @@ $navbar-logo-width: 100% !default; } } } + .navbar-nav-custom{ + .dropdown-toggle::after{ + display: none; + } + } .navbar-toggler { outline: none; @@ -133,7 +138,7 @@ $navbar-logo-width: 100% !default; position: relative; width: 100%; z-index: 1; - min-width: 320px; + min-width: 343px; &[placeholder]{ text-overflow: ellipsis !important; } @@ -158,7 +163,7 @@ $navbar-logo-width: 100% !default; min-width: 320px; } */ @media (min-width: 1500px) { - width: 350px; + width: 383px; } @media (min-width: 1540px) { width: 550px; diff --git a/apps/block_scout_web/assets/js/lib/autocomplete.js b/apps/block_scout_web/assets/js/lib/autocomplete.js index ba34e8468ce3..1a2b9f3a96e5 100644 --- a/apps/block_scout_web/assets/js/lib/autocomplete.js +++ b/apps/block_scout_web/assets/js/lib/autocomplete.js @@ -6,7 +6,7 @@ import { appendTokenIcon } from './token_icon' import { escapeHtml } from './utils' import xss from 'xss' -let placeHolder = 'Address/Txn hash/Block/Token' +let placeHolder = 'Address/Txn Hash/Block/Token/DA Hash' const dataSrc = async (query, id) => { try { // Loading placeholder text @@ -47,13 +47,17 @@ const resultsListElement = (list, data) => { fetchTextAdData() } export const searchEngine = (query, record) => { + console.log(123123) + console.log(query) + console.log(record) const queryLowerCase = query.toLowerCase() if (record && ( (record.name && record.name.toLowerCase().includes(queryLowerCase)) || (record.symbol && record.symbol.toLowerCase().includes(queryLowerCase)) || (record.address_hash && record.address_hash.toLowerCase().includes(queryLowerCase)) || (record.tx_hash && record.tx_hash.toLowerCase().includes(queryLowerCase)) || - (record.block_hash && record.block_hash.toLowerCase().includes(queryLowerCase)) + (record.block_hash && record.block_hash.toLowerCase().includes(queryLowerCase)) || + (record.tx_hash && record.type === 'eigenda') ) ) { let searchResult = '
' 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 1190c200e6e4..b717154fa4ec 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 @@ -101,11 +101,20 @@ defmodule BlockScoutWeb.ChainController do |> Enum.map(fn item -> tx_hash_bytes = Map.get(item, :tx_hash) block_hash_bytes = Map.get(item, :block_hash) + type = Map.get(item, :type) item = if tx_hash_bytes do - item - |> Map.replace(:tx_hash, "0x" <> Base.encode16(tx_hash_bytes, case: :lower)) + + if type == "eigenda" do + Logger.info("123123-------") + Logger.info("#{inspect(type)}") + item + else + item + |> Map.replace(:tx_hash, "0x" <> Base.encode16(tx_hash_bytes, case: :lower)) + end + else item end @@ -120,7 +129,8 @@ defmodule BlockScoutWeb.ChainController do item end) - + Logger.info("123123") + Logger.info("#{inspect(encoded_results)}") json(conn, encoded_results) end @@ -175,7 +185,6 @@ defmodule BlockScoutWeb.ChainController do conn |> transaction_path(:show, item) |> Controller.full_path() - Logger.info("#{inspect(transaction_path)}") redirect(conn, to: transaction_path) end 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 710f24d59adc..b8be5c3653d3 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 @@ -153,7 +153,6 @@ require Logger def show(conn, %{"id" => id} = params) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(id), :ok <- Chain.check_transaction_exists(transaction_hash) do - Logger.info("query tx status beginning...") tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [id]}) |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) |> case do @@ -162,11 +161,6 @@ require Logger {:error, _} -> nil end - - Logger.info("query tx status finished...") - Logger.info("#{inspect(tx_status)}") - - if Chain.transaction_has_token_transfers?(transaction_hash) do with {:ok, transaction} <- Chain.hash_to_transaction( 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 155e95d2d714..15f8b78f8a6d 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 @@ -5,11 +5,12 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do import BlockScoutWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1] import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2] import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2] - + require Logger alias BlockScoutWeb.{AccessHelpers, Controller, InternalTransactionView, TransactionController} alias Explorer.{Chain, Market} alias Explorer.ExchangeRates.Token alias Phoenix.View + import EthereumJSONRPC def index(conn, %{"transaction_id" => transaction_hash_string, "type" => "JSON"} = params) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(transaction_hash_string), @@ -99,6 +100,33 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do ), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + + tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [transaction_hash_string]}) + |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) + |> case do + {:ok, tx} -> + tx["status"] + {:error, _} -> + nil + end + updated_transaction = case Chain.hash_to_batch(transaction_hash_string,necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) + + render( conn, "index.html", @@ -107,7 +135,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do current_user: current_user(conn), block_height: Chain.block_height(), show_token_transfers: Chain.transaction_has_token_transfers?(transaction_hash), - transaction: transaction, + transaction: updated_display_tx_status_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: 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 ed44e98184e1..e28ad0e2d69d 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 @@ -10,6 +10,7 @@ defmodule BlockScoutWeb.TransactionLogController do alias Explorer.{Chain, Market} alias Explorer.ExchangeRates.Token alias Phoenix.View + import EthereumJSONRPC def index(conn, %{"transaction_id" => transaction_hash_string, "type" => "JSON"} = params) do with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(transaction_hash_string), @@ -92,6 +93,30 @@ defmodule BlockScoutWeb.TransactionLogController do ), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [transaction_hash_string]}) + |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) + |> case do + {:ok, tx} -> + tx["status"] + {:error, _} -> + nil + end + updated_transaction = case Chain.hash_to_batch(transaction_hash_string,necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) render( conn, "index.html", @@ -99,7 +124,7 @@ defmodule BlockScoutWeb.TransactionLogController do show_token_transfers: Chain.transaction_has_token_transfers?(transaction_hash), current_path: Controller.current_full_path(conn), current_user: current_user(conn), - transaction: transaction, + transaction: updated_display_tx_status_state_transaction, exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), 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 fc83d0fa1646..0e8bec6a9e18 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 @@ -11,6 +11,7 @@ defmodule BlockScoutWeb.TransactionRawTraceController do alias Explorer.Chain.Import alias Explorer.Chain.Import.Runner.InternalTransactions alias Explorer.ExchangeRates.Token + import EthereumJSONRPC def index(conn, %{"transaction_id" => hash_string} = params) do with {:ok, hash} <- Chain.string_to_transaction_hash(hash_string), @@ -29,7 +30,7 @@ defmodule BlockScoutWeb.TransactionRawTraceController do {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do if is_nil(transaction.block_number) do - render_raw_trace(conn, [], transaction, hash) + render_raw_trace(conn, [], transaction, hash, hash_string) else internal_transactions = Chain.all_transaction_to_internal_transactions(hash) @@ -75,7 +76,7 @@ defmodule BlockScoutWeb.TransactionRawTraceController do end end - render_raw_trace(conn, internal_transactions, transaction, hash) + render_raw_trace(conn, internal_transactions, transaction, hash, hash_string) end else {:restricted_access, _} -> @@ -89,7 +90,31 @@ defmodule BlockScoutWeb.TransactionRawTraceController do end end - defp render_raw_trace(conn, internal_transactions, transaction, hash) do + defp render_raw_trace(conn, internal_transactions, transaction, hash, transaction_hash_string) do + tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [transaction_hash_string]}) + |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) + |> case do + {:ok, tx} -> + tx["status"] + {:error, _} -> + nil + end + updated_transaction = case Chain.hash_to_batch(transaction_hash_string,necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) render( conn, "index.html", @@ -98,7 +123,7 @@ defmodule BlockScoutWeb.TransactionRawTraceController do block_height: Chain.block_height(), current_user: current_user(conn), show_token_transfers: Chain.transaction_has_token_transfers?(hash), - transaction: transaction, + transaction: updated_display_tx_status_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_state_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_state_controller.ex index b28a24296a34..59cc593384cd 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/transaction_state_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/transaction_state_controller.ex @@ -16,6 +16,7 @@ defmodule BlockScoutWeb.TransactionStateController do import BlockScoutWeb.Account.AuthController, only: [current_user: 1] import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2] import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2] + import EthereumJSONRPC {:ok, burn_address_hash} = Chain.string_to_address_hash("0x0000000000000000000000000000000000000000") @@ -90,6 +91,30 @@ defmodule BlockScoutWeb.TransactionStateController do AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [transaction_hash_string]}) + |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) + |> case do + {:ok, tx} -> + tx["status"] + {:error, _} -> + nil + end + updated_transaction = case Chain.hash_to_batch(transaction_hash_string,necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) render( conn, "index.html", @@ -97,7 +122,7 @@ defmodule BlockScoutWeb.TransactionStateController do block_height: Chain.block_height(), current_path: Controller.current_full_path(conn), show_token_transfers: Chain.transaction_has_token_transfers?(transaction_hash), - transaction: transaction, + transaction: updated_display_tx_status_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: 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 2bbcea82984b..4dbece33b1d8 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,6 +10,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do alias Explorer.{Chain, Market} alias Explorer.ExchangeRates.Token alias Phoenix.View + import EthereumJSONRPC require Logger {:ok, burn_address_hash} = Chain.string_to_address_hash("0x0000000000000000000000000000000000000000") @burn_address_hash burn_address_hash @@ -102,6 +103,30 @@ require Logger ), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params), {:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do + tx_status = EthereumJSONRPC.request(%{id: 0, method: "eth_getTxStatusDetailByHash", params: [transaction_hash_string]}) + |> json_rpc(Application.get_env(:indexer, :json_rpc_named_arguments)) + |> case do + {:ok, tx} -> + tx["status"] + {:error, _} -> + nil + end + updated_transaction = case Chain.hash_to_batch(transaction_hash_string,necessity_by_association: @necessity_by_association) do + {:error, _} -> + transaction + {:ok, %{batch_index: batch_index, data_commitment: data_commitment}} -> + res = Map.put(transaction, :batch_index, batch_index) + Map.put(res, :data_commitment, data_commitment) + end + updated_state_transaction = case Chain.block_to_state_batch(transaction.block_number,necessity_by_association: @necessity_by_association) do + {:error, _} -> + updated_transaction + {:ok, %{batch_index: batch_index, submission_tx_hash: submission_tx_hash}} -> + res = Map.put(updated_transaction, :state_batch_index, batch_index) + Map.put(res, :submission_tx_hash, submission_tx_hash) + end + + updated_display_tx_status_state_transaction = if tx_status == nil, do: updated_state_transaction, else: Map.put(updated_state_transaction, :tx_status, tx_status) render( conn, "index.html", @@ -110,7 +135,7 @@ require Logger current_path: Controller.current_full_path(conn), current_user: current_user(conn), show_token_transfers: true, - transaction: transaction, + transaction: updated_display_tx_status_state_transaction, from_tags: get_address_tags(transaction.from_address_hash, current_user(conn)), to_tags: get_address_tags(transaction.to_address_hash, current_user(conn)), tx_tags: diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 1647123750dd..9bf13dee7d29 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -13,7 +13,7 @@
@@ -609,13 +609,13 @@
<%= l1_gas_used(@transaction) %>
- + <%= if @transaction.l1_origin_tx_hash do %>
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", - text: gettext("L1 Origin Tx Hash") %> - <%= gettext "L1 Origin Tx Hash" %> + text: gettext("L1 Origin Txn Hash") %> + <%= gettext "L1 Origin Txn Hash" %>
<%= @transaction.l1_origin_tx_hash %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index 32721d0d8030..72970ae261aa 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -256,13 +256,13 @@
<% end %> - + <%= if Map.has_key?(@transaction, :submission_tx_hash) do %>
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", - text: gettext("L1 State Root Submission Tx Hash") %> - <%= gettext "L1 State Root Submission Tx Hash" %> + text: gettext("L1 State Root Submission Txn Hash") %> + <%= gettext "L1 State Root Submission Txn Hash" %>
@@ -632,13 +632,13 @@
<%= l1_gas_used(@transaction) %>
- + <%= if @transaction.l1_origin_tx_hash do %>
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", - text: gettext("L1 Origin Tx Hash") %> - <%= gettext "L1 Origin Tx Hash" %> + text: gettext("L1 Origin Txn Hash") %> + <%= gettext "L1 Origin Txn Hash" %>
<%= @transaction.l1_origin_tx_hash %>
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 341baa96cf10..579b074ac330 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -3072,7 +3072,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:49 -msgid "Eigenlayer Txn" +msgid "Eigenlayer Txn Batches" msgstr "" #, elixir-format diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 31534bfcff3b..8e656ff26aca 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -3069,7 +3069,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:49 -msgid "Eigenlayer Txn" +msgid "Eigenlayer Txn Batches" msgstr "" #, elixir-format diff --git a/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts b/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts index a8d3ec439e14..7b8381272655 100644 --- a/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts +++ b/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts @@ -269,6 +269,7 @@ export class L1IngestionService { _extraData, }, } = item; + console.log(`the state batch index will be insert into db: ${_batchIndex}`) const { timestamp } = await this.web3.eth.getBlock(blockNumber); stateBatchesInsertData.push({ batch_index: _batchIndex, @@ -290,14 +291,21 @@ export class L1IngestionService { await queryRunner.connect(); try { await queryRunner.startTransaction(); - const savedResult = await queryRunner.manager.insert(StateBatches, stateBatchesInsertData); + const savedResult = await queryRunner.manager + .createQueryBuilder() + .insert() + .into(StateBatches) + .values(stateBatchesInsertData) + .onConflict(`("batch_index") DO NOTHING`) + .execute() result.push(savedResult); await queryRunner.commitTransaction(); } catch (error) { this.logger.error( - `l1 createStateBatchesEvents ${error}`, + `l1 createStateBatchesEvents ${error}, insert state batch failed, start and end block number ${startBlock} ${endBlock}`, ); await queryRunner.rollbackTransaction(); + return Promise.reject(`insert state batch failed`) } finally { await queryRunner.release(); } diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index ab9025a5a91c..7523adcf8f49 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -235,6 +235,7 @@ export class TasksService { await this.l1IngestionService.getCurrentBlockNumber(); console.log('state batch currentBlockNumber: ', currentBlockNumber); const start = Number(await this.cacheManager.get(STATE_BATCH)); + // current = 100 start = 94 SYNC_STEP = 10 if (currentBlockNumber - start > SYNC_STEP) { end = start + SYNC_STEP; } else { @@ -248,8 +249,7 @@ export class TasksService { start + 1, end, ).catch(e=> { - console.error('==========', start) - console.error(e) + console.error(`insert state batch failed, number: ${start} ${end}`) }); if(result){ const insertData = !result || result.length <= 0 ? [] : result[0].identifiers || [] @@ -258,7 +258,7 @@ export class TasksService { ); await this.cacheManager.set(STATE_BATCH, end, { ttl: 0 }); }else { - console.error('---------------- insert state batch data failed', start) + console.error('result insert state batch data failed') } } else { From 402bbea365e6a06978e86cc1fb8882b7604855a6 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Fri, 9 Jun 2023 07:58:04 +0800 Subject: [PATCH 27/44] fix: some state batch was missed --- .../templates/l1_to_l2_txn/_tile.html.eex | 4 ++-- .../templates/l1_to_l2_txn/index.html.eex | 9 +++++++-- .../block_scout_web/templates/layout/_topnav.html.eex | 8 -------- data-sync-service/src/schedule/tasks.service.ts | 8 +++++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex index 946917237383..882a1321e821 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/_tile.html.eex @@ -3,10 +3,10 @@ data-identifier-hash="<%= @l1_to_l2.queue_index %>" > - + <%= @l1_to_l2.block %> - + <%= @l1_to_l2.queue_index %> <%= if @l1_to_l2.l2_hash == nil do %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex index fee10509369e..12c47838c8ed 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/l1_to_l2_txn/index.html.eex @@ -40,11 +40,14 @@ <%= gettext("Something went wrong, click to reload.") %>
- + Block No - + Queue Index + <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Indicates the L1-L2 transactions volume") %> + L2 Txn Hash @@ -77,6 +80,8 @@ L1 Txn Origin + <%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html", + text: gettext("Indicates by which contract was this Txn synced to Mantle Bridge") %> Gas Limit diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 526d2d931367..9e6adaea9ec2 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -63,14 +63,6 @@ class: "dropdown-item #{tab_status("state-batches", @conn.request_path)}", to: state_batch_path(@conn, :index) ) %> - <%= if variant !== EthereumJSONRPC.Besu do %> - <%= link( - gettext("Pending"), - class: "dropdown-item #{tab_status("pending-transactions", @conn.request_path)}", - "data-test": "pending_transactions_link", - to: pending_transaction_path(@conn, :index) - ) %> - <% end %> <%= link(gettext("Verified contracts"), to: verified_contracts_path(@conn, :index), class: "dropdown-item #{tab_status("reorgs", @conn.request_path)}")%> diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index 7523adcf8f49..046b619b526e 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -228,12 +228,14 @@ export class TasksService { ); } } - @Interval(2000) + @Interval(3000) async state_batch() { let end = 0; - const currentBlockNumber = + const currentL1BlockNumber = await this.l1IngestionService.getCurrentBlockNumber(); - console.log('state batch currentBlockNumber: ', currentBlockNumber); + console.log('state batch currentBlockNumber: ', currentL1BlockNumber); + // the latest block might get empty passed events + const currentBlockNumber = currentL1BlockNumber - 1; const start = Number(await this.cacheManager.get(STATE_BATCH)); // current = 100 start = 94 SYNC_STEP = 10 if (currentBlockNumber - start > SYNC_STEP) { From d92dcb36973dd6764c842e6a5766c3f72e7f88ab Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Fri, 9 Jun 2023 10:16:05 +0800 Subject: [PATCH 28/44] fix: some state batch was missed --- .../src/l1Ingestion/l1Ingestion.service.ts | 68 +++++++++++++++++++ .../src/schedule/tasks.service.ts | 18 +++++ 2 files changed, 86 insertions(+) diff --git a/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts b/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts index 34e032f8e13d..490e156ec1c0 100644 --- a/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts +++ b/data-sync-service/src/l1Ingestion/l1Ingestion.service.ts @@ -250,6 +250,74 @@ export class L1IngestionService { } return result; } + + // save missed data, need be deleted + async saveStateBatchMissedScript(startBlock) { + console.log('state batch start block', startBlock) + const list = await this.getSccStateBatchAppendedByBlockNumber( + startBlock, + startBlock+1999, + ); + const stateBatchesInsertData: any[] = []; + console.log('data list length', list.length) + for (const item of list) { + const { + blockNumber, + transactionHash, + returnValues: { + _batchIndex, + _batchRoot, + _batchSize, + _prevTotalElements, + _extraData, + }, + } = item; + console.log(`the state batch index will be insert into db: ${_batchIndex}`) + const { timestamp } = await this.web3.eth.getBlock(blockNumber); + stateBatchesInsertData.push({ + batch_index: _batchIndex, + block_number: blockNumber.toString(), + hash: transactionHash, + size: _batchSize, + l1_block_number: blockNumber, + batch_root: _batchRoot, + extra_data: _extraData, + pre_total_elements: _prevTotalElements, + timestamp: new Date(Number(timestamp) * 1000).toISOString(), + inserted_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + }) + } + const result: any[] = []; + const dataSource = getConnection(); + const queryRunner = dataSource.createQueryRunner(); + await queryRunner.connect(); + console.log('start insert into db') + try { + await queryRunner.startTransaction(); + const savedResult = await queryRunner.manager + .createQueryBuilder() + .insert() + .into(StateBatches) + .values(stateBatchesInsertData) + .onConflict(`("batch_index") DO NOTHING`) + .execute() + result.push(savedResult); + await queryRunner.commitTransaction(); + } catch (error) { + this.logger.error( + `l1 createStateBatchesEvents ${error}, insert state batch failed, start and end block number ${startBlock}`, + ); + await queryRunner.rollbackTransaction(); + return Promise.reject(`insert state batch failed`) + } finally { + await queryRunner.release(); + } + return startBlock+2000; + } + + + async createStateBatchesEvents(startBlock, endBlock) { console.log('state batch start block', startBlock, endBlock) const list = await this.getSccStateBatchAppendedByBlockNumber( diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index 046b619b526e..f2e6440e6420 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -103,6 +103,8 @@ export class TasksService { ttl: 0, }); console.log('================end init cache================'); + // TODO (Jayce) state batch missed data sync script + this.miss_data_script_start(8489739) } @Interval(2000) async l1_sent() { @@ -269,6 +271,22 @@ export class TasksService { ); } } + + + async miss_data_script_start(block) { + console.log('-------------- start script , start block', block) + const result = await this.l1IngestionService.saveStateBatchMissedScript(block).catch(e=> { + console.error(`insert state batch failed,`) + }); + console.log('list sync completed, the next block:', result) + if(result && result < 9146135){ + this.miss_data_script_start(result) + }else { + console.error('result insert state batch data failed, or sync completed!', result) + } + } + + /* @Interval(2000) async txn_batch() { let end = 0; From 683b60ccbbdcf796b6a19c5c55c451b57b4c6bcd Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Fri, 9 Jun 2023 11:00:55 +0800 Subject: [PATCH 29/44] fix: some state batch was missed --- data-sync-service/src/schedule/tasks.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index f2e6440e6420..bce42bde807d 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -104,7 +104,7 @@ export class TasksService { }); console.log('================end init cache================'); // TODO (Jayce) state batch missed data sync script - this.miss_data_script_start(8489739) + //this.miss_data_script_start(8489739) } @Interval(2000) async l1_sent() { From 7e78f42535932051c54db7a49b6b70d957f1bc6c Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Fri, 9 Jun 2023 15:15:49 +0800 Subject: [PATCH 30/44] fix: ui --- .../assets/css/components/_dropdown.scss | 2 +- .../assets/css/theme/_mantle-theme.scss | 17 ++++++++++++----- .../templates/layout/_topnav.html.eex | 13 ++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_dropdown.scss b/apps/block_scout_web/assets/css/components/_dropdown.scss index ee0fc93e044b..cb2ae4e695a1 100644 --- a/apps/block_scout_web/assets/css/components/_dropdown.scss +++ b/apps/block_scout_web/assets/css/components/_dropdown.scss @@ -38,7 +38,7 @@ $dropdown-menu-item-hover-background: rgba($secondary, 0.1) !default; .dropdown-item { color: $dropdown-menu-item-color; font-size: 12px; - padding: 10px 20px; + padding: 10px 15px; transition: $transition-cont; white-space: initial; diff --git a/apps/block_scout_web/assets/css/theme/_mantle-theme.scss b/apps/block_scout_web/assets/css/theme/_mantle-theme.scss index b8baffd535cb..52fbb7479bb9 100644 --- a/apps/block_scout_web/assets/css/theme/_mantle-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_mantle-theme.scss @@ -49,7 +49,7 @@ $dark-primary-alternate: #65B3AE !default; .transfers-list-mobile-container { max-height: 320px; - padding: 12px 0 12px 16px; + padding: 12px 16px 12px 16px; background: #F8F8F9; border-radius: 12px; position: relative; @@ -75,13 +75,19 @@ $dark-primary-alternate: #65B3AE !default; height: 100%; overflow-y: auto; } + &:last-child{ + .token-transfer-item{ + margin-bottom:0; + border: none; + padding-bottom: 0; + } + } .token-transfer-item { display: flex; - margin-bottom: 10px; + padding-bottom: 10px; flex-direction: column; - &:last-child{ - margin-bottom:0; - } + border-bottom: 1px solid #CFD2D4; + .token-transfer-item-item { display: flex; margin-right: 40px; @@ -93,6 +99,7 @@ $dark-primary-alternate: #65B3AE !default; .token-transfer-item-item-title { margin-right: 16px; + width: 34px; } .token-transfer-item-item-address{ min-width: 130px; diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 9e6adaea9ec2..99479603bb1c 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -16,17 +16,12 @@
-
<%= @result.type %>
+
<%= @result.type %>111
+
<%= for minting <- mintings do %> <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, minting) %> <% end %> -
+
<% end %> @@ -379,9 +379,9 @@ <%= gettext "Tokens Burnt" %>
<%= for burning <- burnings do %> - +
<%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, burning) %> -
+
<% end %>
@@ -395,9 +395,9 @@ <%= gettext "Tokens Created" %>
<%= for creation <- creations do %> - +
<%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, creation) %> -
+
<% end %> From 6a904c417d31188e32affd557401db5b40d4f876 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 13 Jun 2023 15:21:47 +0800 Subject: [PATCH 40/44] fix: transaction detail token mint list ui --- apps/block_scout_web/assets/css/components/_tooltip.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_tooltip.scss b/apps/block_scout_web/assets/css/components/_tooltip.scss index 3ab867e8f0fc..c6613529f868 100644 --- a/apps/block_scout_web/assets/css/components/_tooltip.scss +++ b/apps/block_scout_web/assets/css/components/_tooltip.scss @@ -2,7 +2,7 @@ $tooltip-background-color: #CBE9E7 !default; $tooltip-color: #fff !default; .tooltip { - max-width: 325px; + max-width: 335px; min-width: 100px; opacity: 1 !important; @@ -12,7 +12,7 @@ $tooltip-color: #fff !default; color: #15181C; padding: 15px; font-size: 12px; - max-width: 325px; + max-width: 335px; } .arrow::before { From b5bda37c003bbea14207743f148daed48e44112b Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 13 Jun 2023 19:31:29 +0800 Subject: [PATCH 41/44] fix: transaction detail token mint list ui --- .../assets/css/theme/_mantle-theme.scss | 12 +++--- .../_total_transfers_from_to.html.eex | 39 +++++++++++++------ .../templates/transaction/overview.html.eex | 9 +---- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/apps/block_scout_web/assets/css/theme/_mantle-theme.scss b/apps/block_scout_web/assets/css/theme/_mantle-theme.scss index 530c45fda4ae..e7b7f3650bb7 100644 --- a/apps/block_scout_web/assets/css/theme/_mantle-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_mantle-theme.scss @@ -54,9 +54,9 @@ $dark-primary-alternate: #65B3AE !default; border-radius: 12px; position: relative; max-width: 650px; - ::-webkit-scrollbar { - background-color: transparent; - } + overflow-y: auto; + box-sizing: border-box; + .transfers-list-mobile-scroll-notice{ position: absolute; bottom: 0; @@ -74,8 +74,8 @@ $dark-primary-alternate: #65B3AE !default; } .transfers-list-mobile-container-wrap{ width: 100%; - height: 100%; - overflow-y: auto; + //height: 100%; + } .token-transfer-item { @@ -83,7 +83,7 @@ $dark-primary-alternate: #65B3AE !default; padding-bottom: 10px; margin-bottom: 10px; flex-direction: column; - border-bottom: 1px solid #CFD2D4; + border-bottom: 1px solid rgba(207, 210, 212, 0.5); &:last-child{ margin-bottom:0; border: none; diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex index fc59c567b817..9903ff030274 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex @@ -12,12 +12,20 @@ <%= render BlockScoutWeb.AddressView, "_labels.html", tags: from_tags %> - <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy_for_table.html", - additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders", "btn-copy-token-transfer"], - clipboard_text: from_address, - aria_label: gettext("Copy From Address"), - title: gettext("Copy From Address"), - style: "position: relative;" %> + + + + + +
@@ -30,12 +38,19 @@ <%= render BlockScoutWeb.AddressView, "_labels.html", tags: to_tags %> - <%= render BlockScoutWeb.CommonComponentsView, "_btn_copy_for_table.html", - additional_classes: ["btn-copy-icon-small", "btn-copy-icon-custom", "btn-copy-icon-no-borders", "btn-copy-token-transfer"], - clipboard_text: to_address, - aria_label: gettext("Copy To Address"), - title: gettext("Copy To Address"), - style: "position: relative;" %> + + + + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index 3fa3475e6eeb..0da27cbb51a9 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -337,14 +337,7 @@ text: gettext("List of token transferred in the transaction.") %> <%= gettext "Tokens Transferred" %>
"> - <%= if Enum.count(transfers) > 8 do %> -
- "/> - - Scroll for more - -
- <% end %> +
<%= for transfer <- transfers do %> <%= render BlockScoutWeb.TransactionView, "_total_transfers_from_to.html", Map.put(assigns, :transfer, transfer) %> From cd9b14bf2709f8b57a9a29c5b0f3c586e015a009 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Tue, 13 Jun 2023 20:07:13 +0800 Subject: [PATCH 42/44] fix: transaction detail token mint list ui --- .../templates/transaction/_total_transfers_from_to.html.eex | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex index 9903ff030274..495523a939c6 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers_from_to.html.eex @@ -19,7 +19,6 @@ class="btn-copy-icon btn-copy-icon-small btn-copy-icon-custom btn-copy-icon-no-borders" data-placement='top' data-toggle='tooltip' - title='<%= gettext("Copy From Address") %>' > @@ -45,7 +44,6 @@ class="btn-copy-icon btn-copy-icon-small btn-copy-icon-custom btn-copy-icon-no-borders" data-placement='top' data-toggle='tooltip' - title='<%= gettext("Copy To Address") %>' > From 882cd31bdd9976a9dd2e50db73a2ebb90a3f7b91 Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Wed, 14 Jun 2023 12:05:39 +0800 Subject: [PATCH 43/44] feat: sync state batches missed --- data-sync-service/src/schedule/tasks.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index 4bf3356c63dd..f9eca96554c5 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -105,7 +105,7 @@ export class TasksService { }); console.log('================end init cache================'); // TODO (Jayce) state batch missed data sync script - //this.miss_data_script_start(8489739) + //this.miss_data_script_start(9006135) } @Interval(2000) async l1_sent() { From c4997902dfce838963cd1f6adabd2c8f3928dc0a Mon Sep 17 00:00:00 2001 From: Jaycelv Date: Wed, 14 Jun 2023 12:12:11 +0800 Subject: [PATCH 44/44] feat: sync state batches missed --- data-sync-service/src/schedule/tasks.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-sync-service/src/schedule/tasks.service.ts b/data-sync-service/src/schedule/tasks.service.ts index f9eca96554c5..504ae4b0ff1b 100644 --- a/data-sync-service/src/schedule/tasks.service.ts +++ b/data-sync-service/src/schedule/tasks.service.ts @@ -105,7 +105,7 @@ export class TasksService { }); console.log('================end init cache================'); // TODO (Jayce) state batch missed data sync script - //this.miss_data_script_start(9006135) + this.miss_data_script_start(9006135) } @Interval(2000) async l1_sent() {