mirror of https://github.com/poanetwork/ex_abi.git
fix credo
This commit is contained in:
parent
e922a14262
commit
1d08c1f10b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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]}
|
||||
|
@ -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]}
|
||||
|
|
Loading…
Reference in New Issue