@@ -99,6 +99,25 @@ describe('ABI code generation', () => {
99
99
stateMutability : 'view' ,
100
100
type : 'function' ,
101
101
} ,
102
+ {
103
+ type : 'function' ,
104
+ stateMutability : 'view' ,
105
+ payable : 'false' ,
106
+ name : 'getProposals' ,
107
+ outputs : [
108
+ {
109
+ type : 'uint256' ,
110
+ name : 'size' ,
111
+ } ,
112
+ {
113
+ type : 'tuple[]' ,
114
+ components : [
115
+ { name : 'first' , type : 'uint256' } ,
116
+ { name : 'second' , type : 'string' } ,
117
+ ] ,
118
+ } ,
119
+ ] ,
120
+ } ,
102
121
{
103
122
type : 'function' ,
104
123
stateMutability : 'view' ,
@@ -165,6 +184,8 @@ describe('ABI code generation', () => {
165
184
'Contract__getProposalResultValue0Struct' ,
166
185
'Contract__getProposalInputParam1Struct' ,
167
186
'Contract__getProposalInputParam1BarStruct' ,
187
+ 'Contract__getProposalsResultValue1Struct' ,
188
+ 'Contract__getProposalsResult' ,
168
189
'Contract' ,
169
190
] )
170
191
} )
@@ -212,6 +233,8 @@ describe('ABI code generation', () => {
212
233
ts . param ( 'param1' , 'Contract__getProposalInputParam1Struct' ) ,
213
234
] ) ,
214
235
] ,
236
+ [ 'getProposals' , immutable . List ( ) ] ,
237
+ [ 'try_getProposals' , immutable . List ( ) ] ,
215
238
[ 'overloaded' , immutable . List ( [ ts . param ( 'param0' , 'string' ) ] ) ] ,
216
239
[ 'try_overloaded' , immutable . List ( [ ts . param ( 'param0' , 'string' ) ] ) ] ,
217
240
[ 'overloaded1' , immutable . List ( [ ts . param ( 'param0' , 'BigInt' ) ] ) ] ,
@@ -232,6 +255,8 @@ describe('ABI code generation', () => {
232
255
'try_getProposal' ,
233
256
'ethereum.CallResult<Contract__getProposalResultValue0Struct>' ,
234
257
] ,
258
+ [ 'getProposals' , ts . namedType ( 'Contract__getProposalsResult' ) ] ,
259
+ [ 'try_getProposals' , 'ethereum.CallResult<Contract__getProposalsResult>' ] ,
235
260
[ 'overloaded' , ts . namedType ( 'string' ) ] ,
236
261
[ 'try_overloaded' , 'ethereum.CallResult<string>' ] ,
237
262
[ 'overloaded1' , ts . namedType ( 'string' ) ] ,
@@ -295,5 +320,15 @@ describe('ABI code generation', () => {
295
320
[ 'get noCount' , 'BigInt' ] ,
296
321
] )
297
322
} )
323
+
324
+ test ( 'Function bodies are generated correctly for tuple arrays' , ( ) => {
325
+ let contract = generatedTypes . find ( type => type . name === 'Contract' )
326
+ let getter = contract . methods . find ( method => method . name === 'getProposals' )
327
+
328
+ expect ( getter . body ) . not . toContain ( 'toTupleArray<undefined>' )
329
+ expect ( getter . body ) . toContain (
330
+ 'result[1].toTupleArray<Contract__getProposalsResultValue1Struct>()' ,
331
+ )
332
+ } )
298
333
} )
299
334
} )
0 commit comments