@@ -22,9 +22,11 @@ export function renderSystemLibrary(options: RenderSystemLibraryOptions) {
22
22
storeImportPath,
23
23
} = options ;
24
24
25
- // Remove `payable` from stateMutability for library functions
26
25
const functions = functionsInput . map ( ( func ) => ( {
27
26
...func ,
27
+ // Format parameters (add auxiliary argument names, replace calldata location)
28
+ parameters : formatParams ( func . parameters ) ,
29
+ // Remove `payable` from stateMutability for library functions
28
30
stateMutability : func . stateMutability . replace ( "payable" , "" ) ,
29
31
} ) ) ;
30
32
@@ -158,7 +160,7 @@ function renderErrors(errors: ContractInterfaceError[]) {
158
160
function renderUserTypeFunction ( contractFunction : ContractInterfaceFunction , userTypeName : string ) {
159
161
const { name, parameters, stateMutability, returnParameters } = contractFunction ;
160
162
161
- const args = [ `${ userTypeName } self` , ...parameters ] . map ( ( arg ) => arg . replace ( / c a l l d a t a / , " memory " ) ) ;
163
+ const args = [ `${ userTypeName } self` , ...parameters ] ;
162
164
163
165
const functionSignature = `
164
166
function ${ name } (
@@ -183,7 +185,7 @@ function renderCallWrapperFunction(
183
185
) {
184
186
const { name, parameters, stateMutability, returnParameters } = contractFunction ;
185
187
186
- const args = [ `CallWrapper memory self` , ...parameters ] . map ( ( arg ) => arg . replace ( / c a l l d a t a / , " memory " ) ) ;
188
+ const args = [ `CallWrapper memory self` , ...parameters ] ;
187
189
188
190
const functionSignature = `
189
191
function ${ name } (
@@ -236,7 +238,7 @@ function renderRootCallWrapperFunction(contractFunction: ContractInterfaceFuncti
236
238
return "" ;
237
239
}
238
240
239
- const args = [ "RootCallWrapper memory self" , ...parameters ] . map ( ( arg ) => arg . replace ( / c a l l d a t a / , " memory " ) ) ;
241
+ const args = [ "RootCallWrapper memory self" , ...parameters ] ;
240
242
241
243
const functionSignature = `
242
244
function ${ name } (
@@ -312,3 +314,16 @@ function renderReturnParameters(returnParameters: string[]) {
312
314
313
315
return `returns (${ renderArguments ( returnParameters ) } )` ;
314
316
}
317
+
318
+ function formatParams ( params : string [ ] ) {
319
+ // Use auxiliary argument names for arguments without names
320
+ let auxCount = 0 ;
321
+
322
+ return params
323
+ . map ( ( arg ) => arg . replace ( / c a l l d a t a / , " memory " ) )
324
+ . map ( ( arg ) => {
325
+ const items = arg . split ( " " ) ;
326
+ const needsAux = items . length === 1 || ( items . length === 2 && items [ 1 ] === "memory" ) ;
327
+ return needsAux ? `${ arg } __aux${ auxCount ++ } ` : arg ;
328
+ } ) ;
329
+ }
0 commit comments