-
Notifications
You must be signed in to change notification settings - Fork 40
/
hardhat.config.js
101 lines (96 loc) · 2.29 KB
/
hardhat.config.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/** @type import('hardhat/config').HardhatUserConfig */
const fs = require("fs");
require("@nomicfoundation/hardhat-foundry");
task('diamondABI', 'Generates ABI file for diamond, includes all ABIs of facets and subdirectories', async () => {
var walk = function (dir) {
var results = [];
var list = fs.readdirSync(dir);
list.forEach(function (file) {
file = dir + '/' + file;
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
/* Recurse into a subdirectory */
results = results.concat(walk(file));
} else {
/* Is a file */
results.push(file.substring(1));
}
});
return results;
}
const basePath = '/src/infinity/facets'
let files = walk('.' + basePath)
let abi = []
for (var file of files) {
var jsonFile
if (file.includes('Facet') || file.includes('Quoter')) {
var baseName = /[^/]*$/.exec(file)[0];
jsonFile = baseName.replace('sol', 'json');
let json = fs.readFileSync(`./artifacts${file}/${jsonFile}`)
json = JSON.parse(json)
abi.push(...json.abi)
}
}
abi = JSON.stringify(abi.filter((item, pos) => abi.map((a) => a.name).indexOf(item.name) == pos), null, 4)
fs.writeFileSync('./abi/KlimaInfinity.json', abi)
console.log('ABI written to abi/KlimaInfinity.json')
})
module.exports = {
solidity: {
compilers: [
{
version: "0.8.19",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}, {
version: "0.8.16",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
{
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.7.5",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.6.12",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
}
};