Add specs for public functions

pull/7584/head
POA 1 year ago
parent f563170d5b
commit d77f3f5ae7
  1. 9
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex
  2. 6
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex
  3. 1
      apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex
  4. 2
      apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex
  5. 2
      apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex
  6. 2
      apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex
  7. 1
      apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex
  8. 1
      apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex
  9. 1
      apps/explorer/lib/explorer/chain/zkevm/reader.ex
  10. 1
      apps/explorer/lib/explorer/chain/zkevm/transaction_batch.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 =

@ -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 =
[]

@ -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

@ -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

@ -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

@ -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

@ -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)

@ -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)

@ -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

@ -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)

Loading…
Cancel
Save