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

Function prepareAbiDirectory

packages/cli/src/controller/generate-controller.ts:64–86  ·  view source on GitHub ↗
(abiPath: string, rootPath: string)

Source from the content-addressed store, hash-verified

62 * Copies the provided ABI file to the default ABI directory in the project root.
63 */
64export async function prepareAbiDirectory(abiPath: string, rootPath: string): Promise<void> {
65 const abiDirPath = path.join(rootPath, DEFAULT_ABI_DIR);
66
67 if (!fs.existsSync(abiDirPath)) {
68 await fs.promises.mkdir(abiDirPath, {recursive: true});
69 }
70
71 if (fs.existsSync(path.join(abiDirPath, abiPath))) {
72 return;
73 }
74
75 // Ensure abiPath is an absolute path
76 const ensuredAbiPath = resolveToAbsolutePath(abiPath);
77
78 try {
79 await fs.promises.copyFile(ensuredAbiPath, path.join(abiDirPath, path.basename(ensuredAbiPath)));
80 } catch (e: any) {
81 if (e.code === 'ENOENT') {
82 throw new Error(`Unable to find abi at: ${abiPath}`);
83 }
84 throw new Error(`Unable to copy abi file: ${e.message}`);
85 }
86}
87
88/**
89 * Saves the provided ABI to a file in the default ABI directory.

Callers 2

generateAdapterFunction · 0.90

Calls 1

resolveToAbsolutePathFunction · 0.90

Tested by

no test coverage detected