|
|
|
@ -34,7 +34,32 @@ defmodule BlockScoutWeb.API.V2.ZkevmView do |
|
|
|
|
batches: batches, |
|
|
|
|
next_page_params: next_page_params |
|
|
|
|
}) do |
|
|
|
|
items = |
|
|
|
|
%{ |
|
|
|
|
items: render_zkevm_batches(batches), |
|
|
|
|
next_page_params: next_page_params |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def render("zkevm_batches.json", %{batches: batches}) do |
|
|
|
|
%{items: render_zkevm_batches(batches)} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def render("zkevm_batches_count.json", %{count: count}) do |
|
|
|
|
count |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp batch_status(batch) do |
|
|
|
|
sequence_id = Map.get(batch, :sequence_id) |
|
|
|
|
verify_id = Map.get(batch, :verify_id) |
|
|
|
|
|
|
|
|
|
cond do |
|
|
|
|
is_nil(sequence_id) && is_nil(verify_id) -> "Unfinalized" |
|
|
|
|
!is_nil(sequence_id) && is_nil(verify_id) -> "L1 Sequence Confirmed" |
|
|
|
|
!is_nil(verify_id) -> "Finalized" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp render_zkevm_batches(batches) do |
|
|
|
|
batches |
|
|
|
|
|> Enum.map(fn batch -> |
|
|
|
|
Task.async(fn -> |
|
|
|
@ -63,25 +88,5 @@ defmodule BlockScoutWeb.API.V2.ZkevmView do |
|
|
|
|
end) |
|
|
|
|
|> Task.yield_many(:infinity) |
|
|
|
|
|> Enum.map(fn {_task, {:ok, item}} -> item end) |
|
|
|
|
|
|
|
|
|
%{ |
|
|
|
|
items: items, |
|
|
|
|
next_page_params: next_page_params |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def render("zkevm_batches_count.json", %{count: count}) do |
|
|
|
|
count |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp batch_status(batch) do |
|
|
|
|
sequence_id = Map.get(batch, :sequence_id) |
|
|
|
|
verify_id = Map.get(batch, :verify_id) |
|
|
|
|
|
|
|
|
|
cond do |
|
|
|
|
is_nil(sequence_id) && is_nil(verify_id) -> "Unfinalized" |
|
|
|
|
!is_nil(sequence_id) && is_nil(verify_id) -> "L1 Sequence Confirmed" |
|
|
|
|
!is_nil(verify_id) -> "Finalized" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|