-
Notifications
You must be signed in to change notification settings - Fork 1
/
generateTypes.js
32 lines (27 loc) · 1.15 KB
/
generateTypes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { runTypeChain, glob } = require("typechain");
const fs = require("fs");
async function main() {
const cwd = process.cwd();
const interfaces = fs.readdirSync(`${cwd}/lib/mento-core/contracts/interfaces`);
const governanceContracts = fs.readdirSync(`${cwd}/lib/mento-core/contracts/governance`);
const lockingContracts = fs.readdirSync(`${cwd}/lib/mento-core/contracts/governance/locking`);
const oracleContracts = fs.readdirSync(`${cwd}/lib/mento-core/contracts/oracles`);
const breakerContracts = fs.readdirSync(`${cwd}/lib/mento-core/contracts/oracles/breakers`);
const swapContracts = fs.readdirSync(`${cwd}/lib/mento-core/contracts/swap`);
const allContracts = interfaces
.concat(governanceContracts)
.concat(lockingContracts)
.concat(oracleContracts)
.concat(breakerContracts)
.concat(swapContracts);
const allContractsPath = allContracts.map(contract => `${contract}/${contract.replace(".sol", ".json")}`);
const allFiles = glob(`${cwd}/out`, allContractsPath);
await runTypeChain({
cwd,
filesToProcess: allFiles,
allFiles,
outDir: "src",
target: "ethers-v5",
});
}
main().catch(console.error);