@@ -22,9 +22,11 @@ export function renderSystemLibrary(options: RenderSystemLibraryOptions) {
2222 storeImportPath,
2323 } = options ;
2424
25- // Remove `payable` from stateMutability for library functions
2625 const functions = functionsInput . map ( ( func ) => ( {
2726 ...func ,
27+ // Format parameters (add auxiliary argument names, replace calldata location)
28+ parameters : formatParams ( func . parameters ) ,
29+ // Remove `payable` from stateMutability for library functions
2830 stateMutability : func . stateMutability . replace ( "payable" , "" ) ,
2931 } ) ) ;
3032
@@ -158,7 +160,7 @@ function renderErrors(errors: ContractInterfaceError[]) {
158160function renderUserTypeFunction ( contractFunction : ContractInterfaceFunction , userTypeName : string ) {
159161 const { name, parameters, stateMutability, returnParameters } = contractFunction ;
160162
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 ] ;
162164
163165 const functionSignature = `
164166 function ${ name } (
@@ -183,7 +185,7 @@ function renderCallWrapperFunction(
183185) {
184186 const { name, parameters, stateMutability, returnParameters } = contractFunction ;
185187
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 ] ;
187189
188190 const functionSignature = `
189191 function ${ name } (
@@ -236,7 +238,7 @@ function renderRootCallWrapperFunction(contractFunction: ContractInterfaceFuncti
236238 return "" ;
237239 }
238240
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 ] ;
240242
241243 const functionSignature = `
242244 function ${ name } (
@@ -312,3 +314,16 @@ function renderReturnParameters(returnParameters: string[]) {
312314
313315 return `returns (${ renderArguments ( returnParameters ) } )` ;
314316}
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