|
|
@ -8,8 +8,7 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do |
|
|
|
split_list_by_page: 1 |
|
|
|
split_list_by_page: 1 |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
alias Explorer.{Chain, Repo} |
|
|
|
alias Explorer.Chain |
|
|
|
alias Explorer.Chain.ZkevmTxnBatch |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
action_fallback(BlockScoutWeb.API.V2.FallbackController) |
|
|
|
action_fallback(BlockScoutWeb.API.V2.FallbackController) |
|
|
|
|
|
|
|
|
|
|
@ -37,15 +36,9 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def batch_latest_number(conn, _params) do |
|
|
|
def batch_latest_number(conn, _params) do |
|
|
|
number = |
|
|
|
|
|
|
|
case Chain.zkevm_batch(:latest, api?: true) do |
|
|
|
|
|
|
|
{:ok, batch} -> batch.number |
|
|
|
|
|
|
|
{:error, :not_found} -> 0 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put_status(200) |
|
|
|
|> put_status(200) |
|
|
|
|> render(:zkevm_batch_latest_number, %{number: number}) |
|
|
|
|> render(:zkevm_batch_latest_number, %{number: batch_latest_number()}) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def batches(conn, params) do |
|
|
|
def batches(conn, params) do |
|
|
@ -68,11 +61,9 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def batches_count(conn, _params) do |
|
|
|
def batches_count(conn, _params) do |
|
|
|
count = Repo.replica().aggregate(ZkevmTxnBatch, :count, timeout: :infinity) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put_status(200) |
|
|
|
|> put_status(200) |
|
|
|
|> render(:zkevm_batches_count, %{count: count}) |
|
|
|
|> render(:zkevm_batches_count, %{count: batch_latest_number()}) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def batches_confirmed(conn, _params) do |
|
|
|
def batches_confirmed(conn, _params) do |
|
|
@ -87,4 +78,11 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do |
|
|
|
|> put_status(200) |
|
|
|
|> put_status(200) |
|
|
|
|> render(:zkevm_batches, %{batches: batches}) |
|
|
|
|> render(:zkevm_batches, %{batches: batches}) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defp batch_latest_number do |
|
|
|
|
|
|
|
case Chain.zkevm_batch(:latest, api?: true) do |
|
|
|
|
|
|
|
{:ok, batch} -> batch.number |
|
|
|
|
|
|
|
{:error, :not_found} -> 0 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|