@@ -29,8 +29,8 @@ defmodule Ethers.Multicall do
29
29
alias Ethers.Contracts.Multicall3
30
30
alias Ethers.TxData
31
31
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 ( ) }
34
34
35
35
@ doc """
36
36
Aggregates calls, ensuring each returns success if required, and returns a `Ethers.TxData` struct,
@@ -65,7 +65,7 @@ defmodule Ethers.Multicall do
65
65
"""
66
66
@ spec aggregate3 ( [
67
67
TxData . t ( )
68
- | { TxData . t ( ) , aggregate3_options }
68
+ | { TxData . t ( ) , [ aggregate3_option ( ) ] }
69
69
] ) :: TxData . t ( )
70
70
def aggregate3 ( data ) when is_list ( data ) do
71
71
data
@@ -93,7 +93,7 @@ defmodule Ethers.Multicall do
93
93
"""
94
94
@ spec aggregate3_encode_data (
95
95
TxData . t ( )
96
- | { TxData . t ( ) , aggregate3_options }
96
+ | { TxData . t ( ) , [ aggregate3_option ( ) ] }
97
97
) :: { Ethers.Types . t_address ( ) , boolean ( ) , binary ( ) }
98
98
def aggregate3_encode_data ( data )
99
99
@@ -132,7 +132,7 @@ defmodule Ethers.Multicall do
132
132
"""
133
133
@ spec aggregate2 ( [
134
134
TxData . t ( )
135
- | { TxData . t ( ) , aggregate2_options }
135
+ | { TxData . t ( ) , [ aggregate2_option ] }
136
136
] ) :: TxData . t ( )
137
137
def aggregate2 ( data ) when is_list ( data ) do
138
138
data
@@ -158,7 +158,7 @@ defmodule Ethers.Multicall do
158
158
"""
159
159
@ spec aggregate2_encode_data (
160
160
TxData . t ( )
161
- | { TxData . t ( ) , aggregate2_options }
161
+ | { TxData . t ( ) , [ aggregate2_option ] }
162
162
) :: { Ethers.Types . t_address ( ) , binary ( ) }
163
163
def aggregate2_encode_data ( data )
164
164
@@ -188,9 +188,9 @@ defmodule Ethers.Multicall do
188
188
```
189
189
"""
190
190
@ 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 ( ) } ]
194
194
def decode ( resps , calls )
195
195
196
196
def decode ( [ block , resps ] , calls ) when is_integer ( block ) do
@@ -218,9 +218,10 @@ defmodule Ethers.Multicall do
218
218
[ true: "bar", true: "baz" ]
219
219
```
220
220
"""
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 ( ) } ]
224
225
def aggregate3_decode ( resps , calls ) when length ( resps ) == length ( calls ) do
225
226
decode_calls ( calls )
226
227
|> Enum . zip ( resps )
@@ -246,7 +247,10 @@ defmodule Ethers.Multicall do
246
247
[ 1337, [ "bar", "baz" ]]
247
248
```
248
249
"""
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 ( ) | [ ... ] ]
250
254
def aggregate2_decode ( [ block , resps ] , calls ) when length ( resps ) == length ( calls ) do
251
255
[
252
256
block ,
0 commit comments