Skip to content

Commit af74406

Browse files
authored
Correct Multicall module typespecs (#111)
1 parent 8063469 commit af74406

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

lib/ethers/multicall.ex

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ defmodule Ethers.Multicall do
2929
alias Ethers.Contracts.Multicall3
3030
alias Ethers.TxData
3131

32-
@type aggregate3_options :: [to: Ethers.Types.t_address(), allow_failure: boolean()]
33-
@type aggregate2_options :: [to: Ethers.Types.t_address()]
32+
@type aggregate3_option :: {:to, Ethers.Types.t_address()} | {:allow_failure, boolean()}
33+
@type aggregate2_option :: {:to, Ethers.Types.t_address()}
3434

3535
@doc """
3636
Aggregates calls, ensuring each returns success if required, and returns a `Ethers.TxData` struct,
@@ -65,7 +65,7 @@ defmodule Ethers.Multicall do
6565
"""
6666
@spec aggregate3([
6767
TxData.t()
68-
| {TxData.t(), aggregate3_options}
68+
| {TxData.t(), [aggregate3_option()]}
6969
]) :: TxData.t()
7070
def aggregate3(data) when is_list(data) do
7171
data
@@ -93,7 +93,7 @@ defmodule Ethers.Multicall do
9393
"""
9494
@spec aggregate3_encode_data(
9595
TxData.t()
96-
| {TxData.t(), aggregate3_options}
96+
| {TxData.t(), [aggregate3_option()]}
9797
) :: {Ethers.Types.t_address(), boolean(), binary()}
9898
def aggregate3_encode_data(data)
9999

@@ -132,7 +132,7 @@ defmodule Ethers.Multicall do
132132
"""
133133
@spec aggregate2([
134134
TxData.t()
135-
| {TxData.t(), aggregate2_options}
135+
| {TxData.t(), [aggregate2_option]}
136136
]) :: TxData.t()
137137
def aggregate2(data) when is_list(data) do
138138
data
@@ -158,7 +158,7 @@ defmodule Ethers.Multicall do
158158
"""
159159
@spec aggregate2_encode_data(
160160
TxData.t()
161-
| {TxData.t(), aggregate2_options}
161+
| {TxData.t(), [aggregate2_option]}
162162
) :: {Ethers.Types.t_address(), binary()}
163163
def aggregate2_encode_data(data)
164164

@@ -188,9 +188,9 @@ defmodule Ethers.Multicall do
188188
```
189189
"""
190190
@spec decode(
191-
[%{(true | false) => term()}] | [integer() | [...]],
192-
[TxData.t() | binary()]
193-
) :: [%{(true | false) => term()}] | [integer() | [...]]
191+
[integer() | {boolean(), binary()}],
192+
[TxData.t() | {TxData.t(), Keyword.t()} | binary()]
193+
) :: [integer() | {boolean(), term()}]
194194
def decode(resps, calls)
195195

196196
def decode([block, resps], calls) when is_integer(block) do
@@ -218,9 +218,10 @@ defmodule Ethers.Multicall do
218218
[ true: "bar", true: "baz" ]
219219
```
220220
"""
221-
@spec aggregate3_decode([%{(true | false) => term()}], [TxData.t()] | [binary()]) :: [
222-
%{(true | false) => term()}
223-
]
221+
@spec aggregate3_decode(
222+
[{boolean(), term()}],
223+
[TxData.t() | {TxData.t() | [aggregate3_option()]}] | [binary()]
224+
) :: [{boolean(), term()}]
224225
def aggregate3_decode(resps, calls) when length(resps) == length(calls) do
225226
decode_calls(calls)
226227
|> Enum.zip(resps)
@@ -246,7 +247,10 @@ defmodule Ethers.Multicall do
246247
[ 1337, [ "bar", "baz" ]]
247248
```
248249
"""
249-
@spec aggregate2_decode([integer() | [...]], [TxData.t()] | [binary()]) :: [integer() | [...]]
250+
@spec aggregate2_decode(
251+
[integer() | [...]],
252+
[TxData.t() | {TxData.t(), [aggregate2_option()]}] | [binary()]
253+
) :: [integer() | [...]]
250254
def aggregate2_decode([block, resps], calls) when length(resps) == length(calls) do
251255
[
252256
block,

0 commit comments

Comments
 (0)