( functions: CodeGenFunction[], structTypeName: string, structStorageName: string, libraryName: string, )
| 50 | } |
| 51 | |
| 52 | export function generateExternalCoder( |
| 53 | functions: CodeGenFunction[], |
| 54 | structTypeName: string, |
| 55 | structStorageName: string, |
| 56 | libraryName: string, |
| 57 | ) { |
| 58 | const code: ArrayJoinInput<string>[] = []; |
| 59 | const externalFunctions: CodeGenFunction[] = [] |
| 60 | for (const fn of functions) { |
| 61 | const externalFn = generateExternalFunction(fn, structStorageName, libraryName) |
| 62 | if (!externalFn) continue; |
| 63 | code.push('', ...generateFunctionCode(externalFn)) |
| 64 | externalFunctions.push(externalFn) |
| 65 | } |
| 66 | const externalCode = [ |
| 67 | // ...generateFileHeader(true, false, [`import "./${libraryName}.sol";`]), |
| 68 | // '', |
| 69 | `contract External${libraryName} {`, |
| 70 | [ |
| 71 | `${structTypeName} internal ${structStorageName};`, |
| 72 | ...code |
| 73 | ], |
| 74 | '}' |
| 75 | ] |
| 76 | return { |
| 77 | externalCode, |
| 78 | externalFunctions |
| 79 | } |
| 80 | } |
no test coverage detected