From ec5240edd4b84aa9ed7916ad707e6b7717fd8caf Mon Sep 17 00:00:00 2001 From: POA <33550681+poa@users.noreply.github.com> Date: Wed, 17 May 2023 11:50:34 +0300 Subject: [PATCH] Add zkEVM transaction status to API v2 response for transaction page --- .../views/api/v2/transaction_view.ex | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex index 5dc6214247..8d8a13a46f 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex @@ -415,10 +415,13 @@ defmodule BlockScoutWeb.API.V2.TransactionView do |> Map.put("polygon_edge_withdrawal", polygon_edge_withdrawal(transaction.hash, conn)) "polygon_zkevm" -> - result - |> add_optional_transaction_field(transaction, "zkevm_batch_number", :zkevm_batch, :number) - |> add_optional_transaction_field(transaction, "zkevm_sequence_hash", :zkevm_sequence_txn, :hash) - |> add_optional_transaction_field(transaction, "zkevm_verify_hash", :zkevm_verify_txn, :hash) + extended_result = + result + |> add_optional_transaction_field(transaction, "zkevm_batch_number", :zkevm_batch, :number) + |> add_optional_transaction_field(transaction, "zkevm_sequence_hash", :zkevm_sequence_txn, :hash) + |> add_optional_transaction_field(transaction, "zkevm_verify_hash", :zkevm_verify_txn, :hash) + + Map.put(extended_result, "zkevm_status", zkevm_status(extended_result)) _ -> result end @@ -431,6 +434,14 @@ defmodule BlockScoutWeb.API.V2.TransactionView do end end + defp zkevm_status(result_map) do + if is_nil(Map.get(result_map, "zkevm_sequence_hash")) do + "Confirmed by Sequencer" + else + "L1 Confirmed" + end + end + def token_transfers(_, _conn, false), do: nil def token_transfers(%NotLoaded{}, _conn, _), do: nil