forked from BoltzExchange/boltz-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateTypechain.js
More file actions
53 lines (43 loc) · 1.3 KB
/
Copy pathgenerateTypechain.js
File metadata and controls
53 lines (43 loc) · 1.3 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* eslint-disable @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');
const typechainPath = path.join(__dirname, 'node_modules/typechain');
const areDevDependenciesOmitted = () => {
const omittedDependencies = new Set(
(process.env.npm_config_omit || '')
.split(/[,\s]+/)
.filter((value) => value !== ''),
);
return omittedDependencies.has('dev');
};
if (!fs.existsSync(typechainPath)) {
const message = 'Missing typechain generation dependency: typechain';
if (areDevDependenciesOmitted()) {
console.warn(
`${message}; skipping typechain generation because dev dependencies were omitted.`,
);
return;
}
throw new Error(message);
}
const { runTypeChain } = require('typechain');
const cwd = process.cwd();
const outDir = 'lib/wallet/ethereum/typechain';
const files = [
'node_modules/boltz-core/out/ERC20.sol/ERC20.json',
'node_modules/boltz-core/out/ERC20Swap.sol/ERC20Swap.json',
'node_modules/boltz-core/out/EtherSwap.sol/EtherSwap.json',
].map((f) => path.resolve(cwd, f));
runTypeChain({
cwd,
filesToProcess: files,
allFiles: files,
outDir,
target: 'ethers-v6',
})
.then((res) => {
console.log(`Generated ${res.filesGenerated} typechain files in ${outDir}`);
})
.catch((err) => {
throw err;
});