Skip to content

Commit

Permalink
chore: update dialyzer to catch further errors (#2078)
Browse files Browse the repository at this point in the history
  • Loading branch information
sborrazas authored Feb 5, 2025
1 parent 1465614 commit bd2fd2f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 37 deletions.
6 changes: 0 additions & 6 deletions lib/ae_mdw/aex141.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,9 @@ defmodule AeMdw.Aex141 do
{:owner, call_contract(contract_pk, "owner", [token_id])} do
{:ok, render_nft(contract_pk, account_pk, token_id, metadata_type, opts)}
else
:error ->
{:error, ErrInput.NotFound.exception(value: token_id)}

{:int, _invalid_int} ->
{:error, ErrInput.NotFound.exception(value: token_id)}

:not_found ->
{:error, ErrInput.NotFound.exception(value: token_id)}

{:owner, {:ok, mismatch}} ->
{:error, ErrInput.ContractReturn.exception(value: inspect(mismatch))}

Expand Down
7 changes: 2 additions & 5 deletions lib/ae_mdw/dex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ defmodule AeMdw.Dex do
{:ok, paginated_swaps()} | {:error, Error.t()}
def fetch_contract_swaps(state, contract_id, pagination, _scope, cursor) do
with {:ok, token_pk} <- Validate.id(contract_id, [:contract_pubkey]),
{:ok, create_txis} <- get_pair_create_txis(state, token_pk),
{:ok, cursor} <- deserialize_contract_swaps_cursor(cursor) do
create_txis = get_pair_create_txis(state, token_pk)

state
|> build_contract_swaps_streamer(create_txis, cursor)
|> Collection.paginate(pagination, &render_swap(state, &1), &serialize_cursor/1)
|> then(fn paginated_swaps -> {:ok, paginated_swaps} end)
else
:not_found -> {:error, ErrInput.NotAex9.exception(value: contract_id)}
{:error, reason} -> {:error, reason}
end
end

Expand Down Expand Up @@ -440,6 +438,5 @@ defmodule AeMdw.Dex do
:not_found -> create_txis
end
end)
|> then(&{:ok, &1})
end
end
37 changes: 19 additions & 18 deletions lib/ae_mdw/sync/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -496,26 +496,27 @@ defmodule AeMdw.Sync.Server do
defp profile_sync(sync_type, height, exec_ts, blocks_mutations) do
mutations = Enum.map(blocks_mutations, &elem(&1, 2))

with [{_key, dryrun_ts}] <- :ets.lookup(:sync_profiling, {:dryrun, height}),
[{_key, txs_ts}] <- :ets.lookup(:sync_profiling, {:txs, height}) do
true = :ets.delete(:sync_profiling, {:dryrun, height - 1})
true = :ets.delete(:sync_profiling, {:txs, height - 1})

mutations_map =
mutations
|> List.flatten()
|> Enum.reject(&is_nil/1)
|> Enum.frequencies_by(fn
%mod{} -> mod
nil -> nil
end)
_lookup_return =
with [{_key, dryrun_ts}] <- :ets.lookup(:sync_profiling, {:dryrun, height}),
[{_key, txs_ts}] <- :ets.lookup(:sync_profiling, {:txs, height}) do
true = :ets.delete(:sync_profiling, {:dryrun, height - 1})
true = :ets.delete(:sync_profiling, {:txs, height - 1})

mutations_map =
mutations
|> List.flatten()
|> Enum.reject(&is_nil/1)
|> Enum.frequencies_by(fn
%mod{} -> mod
nil -> nil
end)

mutations_count = length(mutations)
mutations_count = length(mutations)

Log.info(
"[#{sync_type}] height=#{height}, exec=#{div(exec_ts, 1_000)}ms, txs=#{div(txs_ts, 1_000)}ms, dryrun=#{div(dryrun_ts, 1_000)}ms, mutations={#{mutations_count}, #{inspect(mutations_map)}}"
)
end
Log.info(
"[#{sync_type}] height=#{height}, exec=#{div(exec_ts, 1_000)}ms, txs=#{div(txs_ts, 1_000)}ms, dryrun=#{div(dryrun_ts, 1_000)}ms, mutations={#{mutations_count}, #{inspect(mutations_map)}}"
)
end

:ok
end
Expand Down
3 changes: 2 additions & 1 deletion lib/ae_mdw/validate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule AeMdw.Validate do

alias AeMdw.Node, as: AE
alias AeMdw.Db.State
alias AeMdw.Error
alias AeMdw.Error.Input, as: ErrInput
alias AeMdw.Names
alias :aeser_api_encoder, as: Enc
Expand Down Expand Up @@ -98,7 +99,7 @@ defmodule AeMdw.Validate do
def name_id!(name_ident), do: unwrap!(&name_id/1, name_ident)

@spec plain_name(State.t(), String.t()) ::
{:ok, pubkey()} | {:error, {ErrInput.t(), String.t()}}
{:ok, pubkey()} | {:error, Error.t()}
def plain_name(state, name_ident) do
case id(name_ident) do
{:ok, name_hash} ->
Expand Down
1 change: 0 additions & 1 deletion lib/ae_mdw_web/controllers/name_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ defmodule AeMdwWeb.NameController do
{{info, source}, _plain_name} <- {Name.locate(state, plain_name), plain_name} do
format_json(conn, Format.to_map(state, info, source, Util.expand?(opts)))
else
{:error, reason} -> {:error, reason}
{nil, plain_name} -> {:error, ErrInput.NotFound.exception(value: plain_name)}
end
end
Expand Down
9 changes: 5 additions & 4 deletions lib/ae_mdw_web/websocket/subscriptions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ defmodule AeMdwWeb.Websocket.Subscriptions do
end

defp maybe_demonitor(pid) do
with [{^pid, ref, _count}] <- :ets.lookup(@subs_pids, pid) do
Process.demonitor(ref, [:flush])
:ets.delete(@subs_pids, pid)
end
_lookup_return =
with [{^pid, ref, _count}] <- :ets.lookup(@subs_pids, pid) do
Process.demonitor(ref, [:flush])
:ets.delete(@subs_pids, pid)
end

:ok
end
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"cowlib": {:hex, :cowlib, "2.13.0", "db8f7505d8332d98ef50a3ef34b34c1afddec7506e4ee4dd4a3a266285d282ca", [:make, :rebar3], [], "hexpm", "e1e1284dc3fc030a64b1ad0d8382ae7e99da46c3246b815318a4b848873800a4"},
"credo": {:hex, :credo, "1.7.8", "9722ba1681e973025908d542ec3d95db5f9c549251ba5b028e251ad8c24ab8c5", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cb9e87cc64f152f3ed1c6e325e7b894dea8f5ef2e41123bd864e3cd5ceb44968"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"esbuild": {:hex, :esbuild, "0.8.2", "5f379dfa383ef482b738e7771daf238b2d1cfb0222bef9d3b20d4c8f06c7a7ac", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "558a8a08ed78eb820efbfda1de196569d8bfa9b51e8371a1934fbb31345feda7"},
"ex2ms": {:hex, :ex2ms, "1.6.1", "66d472eb14da43087c156e0396bac3cc7176b4f24590a251db53f84e9a0f5f72", [:mix], [], "hexpm", "a7192899d84af03823a8ec2f306fa858cbcce2c2e7fd0f1c49e05168fb9c740e"},
"excoveralls": {:hex, :excoveralls, "0.14.6", "610e921e25b180a8538229ef547957f7e04bd3d3e9a55c7c5b7d24354abbba70", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "0eceddaa9785cfcefbf3cd37812705f9d8ad34a758e513bb975b081dce4eb11e"},
Expand Down

0 comments on commit bd2fd2f

Please sign in to comment.