ts: only read .json files when parsing IDLs (#1214)
This commit is contained in:
parent
b6cbdb257e
commit
69299fb723
|
@ -47,19 +47,21 @@ const workspace = new Proxy({} as any, {
|
||||||
}
|
}
|
||||||
|
|
||||||
const idlMap = new Map<string, Idl>();
|
const idlMap = new Map<string, Idl>();
|
||||||
fs.readdirSync(idlFolder).forEach((file) => {
|
fs.readdirSync(idlFolder)
|
||||||
const filePath = `${idlFolder}/${file}`;
|
.filter((file) => file.endsWith(".json"))
|
||||||
const idlStr = fs.readFileSync(filePath);
|
.forEach((file) => {
|
||||||
const idl = JSON.parse(idlStr);
|
const filePath = `${idlFolder}/${file}`;
|
||||||
idlMap.set(idl.name, idl);
|
const idlStr = fs.readFileSync(filePath);
|
||||||
const name = camelCase(idl.name, { pascalCase: true });
|
const idl = JSON.parse(idlStr);
|
||||||
if (idl.metadata && idl.metadata.address) {
|
idlMap.set(idl.name, idl);
|
||||||
workspaceCache[name] = new Program(
|
const name = camelCase(idl.name, { pascalCase: true });
|
||||||
idl,
|
if (idl.metadata && idl.metadata.address) {
|
||||||
new PublicKey(idl.metadata.address)
|
workspaceCache[name] = new Program(
|
||||||
);
|
idl,
|
||||||
}
|
new PublicKey(idl.metadata.address)
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Override the workspace programs if the user put them in the config.
|
// Override the workspace programs if the user put them in the config.
|
||||||
const anchorToml = toml.parse(
|
const anchorToml = toml.parse(
|
||||||
|
|
Loading…
Reference in New Issue