diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex index 5917b953bb..635451c9bc 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex @@ -63,6 +63,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do @api_true [api?: true] + @spec transaction(Plug.Conn.t(), map()) :: Plug.Conn.t() def transaction(conn, %{"transaction_hash_param" => transaction_hash_string} = params) do necessity_by_association = @transaction_necessity_by_association @@ -89,6 +90,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do end end + @spec transactions(Plug.Conn.t(), map()) :: Plug.Conn.t() def transactions(conn, params) do filter_options = filter_options(params, :validated) @@ -112,6 +114,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do |> render(:transactions, %{transactions: transactions, next_page_params: next_page_params}) end + @spec zkevm_batch(Plug.Conn.t(), map()) :: Plug.Conn.t() def zkevm_batch(conn, %{"batch_number" => batch_number} = _params) do transactions = batch_number @@ -124,6 +127,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do |> render(:transactions, %{transactions: transactions}) end + @spec raw_trace(Plug.Conn.t(), map()) :: Plug.Conn.t() def raw_trace(conn, %{"transaction_hash_param" => transaction_hash_string} = params) do with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)}, {:not_found, {:ok, transaction}} <- @@ -153,6 +157,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do end end + @spec token_transfers(Plug.Conn.t(), map()) :: Plug.Conn.t() | {atom(), any()} def token_transfers(conn, %{"transaction_hash_param" => transaction_hash_string} = params) do with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)}, {:not_found, {:ok, transaction}} <- @@ -185,6 +190,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do end end + @spec internal_transactions(Plug.Conn.t(), map()) :: Plug.Conn.t() | {atom(), any()} def internal_transactions(conn, %{"transaction_hash_param" => transaction_hash_string} = params) do with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)}, {:not_found, {:ok, transaction}} <- @@ -213,6 +219,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do end end + @spec logs(Plug.Conn.t(), map()) :: Plug.Conn.t() | {atom(), any()} def logs(conn, %{"transaction_hash_param" => transaction_hash_string} = params) do with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)}, {:not_found, {:ok, transaction}} <- @@ -248,6 +255,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do end end + @spec state_changes(Plug.Conn.t(), map()) :: Plug.Conn.t() | {atom(), any()} def state_changes(conn, %{"transaction_hash_param" => transaction_hash_string} = params) do with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)}, {:not_found, {:ok, transaction}} <- @@ -274,6 +282,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do end end + @spec watchlist_transactions(Plug.Conn.t(), map()) :: Plug.Conn.t() | {atom(), any()} def watchlist_transactions(conn, params) do with {:auth, %{watchlist_id: watchlist_id}} <- {:auth, current_user(conn)} do full_options = diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex index b81cdea24b..a03cc0359c 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex @@ -8,7 +8,6 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do split_list_by_page: 1 ] - alias Explorer.Chain alias Explorer.Chain.Zkevm.Reader action_fallback(BlockScoutWeb.API.V2.FallbackController) @@ -23,6 +22,7 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do :sequence_transaction => :optional } + @spec batch(Plug.Conn.t(), map()) :: Plug.Conn.t() def batch(conn, %{"batch_number" => batch_number} = _params) do {:ok, batch} = Reader.batch( @@ -36,12 +36,14 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do |> render(:zkevm_batch, %{batch: batch}) end + @spec batch_latest_number(Plug.Conn.t(), map()) :: Plug.Conn.t() def batch_latest_number(conn, _params) do conn |> put_status(200) |> render(:zkevm_batch_latest_number, %{number: batch_latest_number()}) end + @spec batches(Plug.Conn.t(), map()) :: Plug.Conn.t() def batches(conn, params) do {batches, next_page} = params @@ -61,12 +63,14 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do }) end + @spec batches_count(Plug.Conn.t(), map()) :: Plug.Conn.t() def batches_count(conn, _params) do conn |> put_status(200) |> render(:zkevm_batches_count, %{count: batch_latest_number()}) end + @spec batches_confirmed(Plug.Conn.t(), map()) :: Plug.Conn.t() def batches_confirmed(conn, _params) do batches = [] diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex index a504f72d48..e0bc5b4355 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex @@ -1,6 +1,7 @@ defmodule BlockScoutWeb.API.V2.ZkevmView do use BlockScoutWeb, :view + @spec render(binary(), map()) :: map() | non_neg_integer() def render("zkevm_batch.json", %{batch: batch}) do sequence_tx_hash = if not is_nil(batch.sequence_transaction) do diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex index 997f53a517..2df1223945 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex @@ -24,6 +24,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do def option_key, do: :zkevm_batch_transactions @impl Import.Runner + @spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()} def imported_table_row do %{ value_type: "[#{ecto_schema_module()}.t()]", @@ -32,6 +33,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do end @impl Import.Runner + @spec run(Multi.t(), list(), map()) :: Multi.t() def run(multi, changes_list, %{timestamps: timestamps} = options) do insert_options = options diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex index 504b5e609a..7a5e4c1327 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex @@ -26,6 +26,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do def option_key, do: :zkevm_lifecycle_transactions @impl Import.Runner + @spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()} def imported_table_row do %{ value_type: "[#{ecto_schema_module()}.t()]", @@ -34,6 +35,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do end @impl Import.Runner + @spec run(Multi.t(), list(), map()) :: Multi.t() def run(multi, changes_list, %{timestamps: timestamps} = options) do insert_options = options diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex b/apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex index 3740443658..db9f2771ea 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex @@ -26,6 +26,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do def option_key, do: :zkevm_transaction_batches @impl Import.Runner + @spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()} def imported_table_row do %{ value_type: "[#{ecto_schema_module()}.t()]", @@ -34,6 +35,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do end @impl Import.Runner + @spec run(Multi.t(), list(), map()) :: Multi.t() def run(multi, changes_list, %{timestamps: timestamps} = options) do insert_options = options diff --git a/apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex b/apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex index 1dc780ebf2..64993ad2bf 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex +++ b/apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex @@ -23,6 +23,7 @@ defmodule Explorer.Chain.Zkevm.BatchTransaction do timestamps() end + @spec changeset(Ecto.Schema.t(), map()) :: Ecto.Schema.t() def changeset(%__MODULE__{} = transactions, attrs \\ %{}) do transactions |> cast(attrs, @required_attrs) diff --git a/apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex b/apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex index dc81b4a81b..83ddcfa296 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex +++ b/apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex @@ -24,6 +24,7 @@ defmodule Explorer.Chain.Zkevm.LifecycleTransaction do timestamps() end + @spec changeset(Ecto.Schema.t(), map()) :: Ecto.Schema.t() def changeset(%__MODULE__{} = txn, attrs \\ %{}) do txn |> cast(attrs, @required_attrs) diff --git a/apps/explorer/lib/explorer/chain/zkevm/reader.ex b/apps/explorer/lib/explorer/chain/zkevm/reader.ex index 782cf3f94a..436ae787e8 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/reader.ex +++ b/apps/explorer/lib/explorer/chain/zkevm/reader.ex @@ -15,6 +15,7 @@ defmodule Explorer.Chain.Zkevm.Reader do alias Explorer.Chain.Zkevm.{BatchTransaction, LifecycleTransaction, TransactionBatch} alias Explorer.{Chain, PagingOptions, Repo} + @spec batch(non_neg_integer() | :latest, list()) :: {:ok, map()} | {:error, :not_found} def batch(number, options \\ []) def batch(:latest, options) when is_list(options) do diff --git a/apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex b/apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex index 683daf9c1e..1b4aa046dc 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex +++ b/apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex @@ -45,6 +45,7 @@ defmodule Explorer.Chain.Zkevm.TransactionBatch do timestamps() end + @spec changeset(Ecto.Schema.t(), map()) :: Ecto.Schema.t() def changeset(%__MODULE__{} = batches, attrs \\ %{}) do batches |> cast(attrs, @required_attrs ++ @optional_attrs)