Skip to content

Commit

Permalink
fix credo
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrat555 committed Mar 12, 2024
1 parent e922a14 commit 1d08c1f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/abi/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ defmodule ABI.Event do

defp indexed_arg_values([{_, type, _} | rest_args], [topic | rest_topics], acc) do
value =
if ABI.FunctionSelector.is_dynamic?(type) do
if ABI.FunctionSelector.dynamic?(type) do
{bytes, _} = ABI.TypeDecoder.decode_bytes(topic, 32, :left)

# This is explained in the docstring. The caller will almost certainly
Expand Down
14 changes: 7 additions & 7 deletions lib/abi/function_selector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ defmodule ABI.FunctionSelector do
defp get_type(els), do: raise("Unsupported type: #{inspect(els)}")

@doc false
@spec is_dynamic?(ABI.FunctionSelector.type()) :: boolean
def is_dynamic?(:bytes), do: true
def is_dynamic?(:string), do: true
def is_dynamic?({:array, _type}), do: true
def is_dynamic?({:array, type, len}) when len > 0, do: is_dynamic?(type)
def is_dynamic?({:tuple, types}), do: Enum.any?(types, &is_dynamic?/1)
def is_dynamic?(_), do: false
@spec dynamic?(ABI.FunctionSelector.type()) :: boolean
def dynamic?(:bytes), do: true
def dynamic?(:string), do: true
def dynamic?({:array, _type}), do: true
def dynamic?({:array, type, len}) when len > 0, do: dynamic?(type)
def dynamic?({:tuple, types}), do: Enum.any?(types, &dynamic?/1)
def dynamic?(_), do: false

@doc false
def from_params(params) when is_map(params) do
Expand Down
6 changes: 3 additions & 3 deletions lib/abi/type_decoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ defmodule ABI.TypeDecoder do
{reversed_result, binary_rest} =
Enum.reduce(types, {[], binary_data}, fn type, {acc, binary} ->
{value, rest} =
if FunctionSelector.is_dynamic?(type) do
if FunctionSelector.dynamic?(type) do
decode_type(type, binary, binary_data)
else
decode_type(type, binary)
Expand Down Expand Up @@ -262,7 +262,7 @@ defmodule ABI.TypeDecoder do
defp decode_type({:tuple, types}, data) do
{reversed_result, _, binary} =
Enum.reduce(types, {[], [], data}, fn type, {acc, dynamic, binary} ->
if FunctionSelector.is_dynamic?(type) do
if FunctionSelector.dynamic?(type) do
{val, binary} = decode_type(type, binary, data)
{[val | acc], [type | dynamic], binary}
else
Expand Down Expand Up @@ -323,7 +323,7 @@ defmodule ABI.TypeDecoder do

{reversed_result, _, _binary} =
Enum.reduce(types, {[], [], tuple_data}, fn type, {acc, dynamic, binary} ->
if FunctionSelector.is_dynamic?(type) do
if FunctionSelector.dynamic?(type) do
{val, binary} = decode_type(type, binary, tuple_data)
{[val | acc], [type | dynamic], binary}
else
Expand Down
4 changes: 2 additions & 2 deletions lib/abi/type_encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ defmodule ABI.TypeEncoder do
types = List.duplicate(type, size)
result = do_encode(data, types, mode)

if FunctionSelector.is_dynamic?(type) do
if FunctionSelector.dynamic?(type) do
data_bytes_size = byte_size(result)

{[{:dynamic, data_bytes_size} | static_acc], [result | dynamic_acc]}
Expand Down Expand Up @@ -227,7 +227,7 @@ defmodule ABI.TypeEncoder do
when is_list(list_parameters) do
result = do_encode(list_parameters, types, :standard)

if FunctionSelector.is_dynamic?(type) do
if FunctionSelector.dynamic?(type) do
data_bytes_size = byte_size(result)

{[{:dynamic, data_bytes_size} | static_acc], [result | dynamic_acc]}
Expand Down

0 comments on commit 1d08c1f

Please sign in to comment.