MCPcopy
hub / github.com/subquery/subql / tsExtractor

Function tsExtractor

packages/cli/src/controller/generate-controller.ts:363–388  ·  view source on GitHub ↗
(dataSources, casedInputAddress)

Source from the content-addressed store, hash-verified

361};
362
363export const tsExtractor: ManifestExtractor<string> = (dataSources, casedInputAddress) => {
364 const existingEvents: string[] = [];
365 const existingFunctions: string[] = [];
366
367 splitArrayString(dataSources)
368 .filter((d) => {
369 const match = d.match(ADDRESS_REG);
370 return match && match.length >= 2 && match[1].toLowerCase() === casedInputAddress;
371 })
372 .forEach((d) => {
373 const extractedValue = extractFromTs(d, {handlers: undefined}) as {handlers: string};
374
375 const regResult = extractFromTs(extractedValue.handlers, {
376 topics: TOPICS_REG,
377 function: FUNCTION_REG,
378 });
379 if (regResult.topics !== null) {
380 existingEvents.push(regResult.topics[0]);
381 }
382 if (regResult.function !== null) {
383 existingFunctions.push(regResult.function as string);
384 }
385 });
386
387 return {existingEvents, existingFunctions};
388};
389
390export async function getManifestData(manifestPath: string): Promise<Document> {
391 const existingManifest = await fs.promises.readFile(path.join(manifestPath), 'utf8');

Callers 1

Calls 2

splitArrayStringFunction · 0.90
extractFromTsFunction · 0.90

Tested by

no test coverage detected