Add zkEVM transaction status to API v2 response for transaction page

pull/7584/head
POA 2 years ago
parent 9b50f4d796
commit ec5240edd4
  1. 19
      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

Loading…
Cancel
Save