( selectedMethods: [SelectedMethod[], SelectedMethod[]], projectPath: string, abiName: string )
| 458 | } |
| 459 | |
| 460 | export async function generateHandlers( |
| 461 | selectedMethods: [SelectedMethod[], SelectedMethod[]], |
| 462 | projectPath: string, |
| 463 | abiName: string |
| 464 | ): Promise<void> { |
| 465 | const abiProps = constructHandlerProps(selectedMethods, abiName); |
| 466 | |
| 467 | const fileName = `${abiName}Handlers`; |
| 468 | try { |
| 469 | await renderTemplate(SCAFFOLD_HANDLER_TEMPLATE_PATH, path.join(projectPath, ROOT_MAPPING_DIR, `${fileName}.ts`), { |
| 470 | props: { |
| 471 | abis: [abiProps], |
| 472 | }, |
| 473 | helper: {upperFirst}, |
| 474 | }); |
| 475 | fs.appendFileSync(path.join(projectPath, 'src/index.ts'), `\nexport * from "./mappings/${fileName}"`); |
| 476 | } catch (e: any) { |
| 477 | throw new Error(`Unable to generate handler scaffolds. ${e.message}`); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | export function tsStringify( |
| 482 | obj: SubqlRuntimeHandler | SubqlRuntimeHandler[] | string, |
no test coverage detected