MCPcopy Index your code
hub / github.com/subquery/subql / generateHandlers

Function generateHandlers

packages/cli/src/controller/generate-controller.ts:460–479  ·  view source on GitHub ↗
(
  selectedMethods: [SelectedMethod[], SelectedMethod[]],
  projectPath: string,
  abiName: string
)

Source from the content-addressed store, hash-verified

458}
459
460export 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
481export function tsStringify(
482 obj: SubqlRuntimeHandler | SubqlRuntimeHandler[] | string,

Callers 2

generateAdapterFunction · 0.90

Calls 2

renderTemplateFunction · 0.90
constructHandlerPropsFunction · 0.85

Tested by

no test coverage detected