-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
78 lines (73 loc) · 2.39 KB
/
hardhat.config.ts
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
import fs from 'fs';
import path from 'path';
import process from 'process';
import { task, HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';
import '@nomicfoundation/hardhat-ethers';
import 'hardhat-storage-layout';
import 'hardhat-tracer';
task('flatten:all', 'Flatten all contracts each file under flatten directory')
.setAction(async (taskArgs, hre) => {
const allFilesAndFolders = fs.readdirSync('contracts', { recursive: true }) as Array<string>;
const allFolders = allFilesAndFolders.filter(f => fs.statSync(path.join('contracts', f)).isDirectory());
const allFiles = allFilesAndFolders.filter(f => !allFolders.includes(f));
fs.rmSync('flatten', { force: true, recursive: true });
fs.mkdirSync('flatten');
allFolders.forEach(f => {
fs.mkdirSync(path.join('flatten', f), { recursive: true });
});
await Promise.all(allFiles.map(async (f) => {
const contract = path.join('contracts', f);
const contractTo = path.join('flatten', f);
try {
const flatten = await hre.run('flatten:get-flattened-sources', { files: [contract] });
fs.writeFileSync(contractTo, flatten);
console.log(`Wrote ${contractTo} contract`);
} catch (e) {
// Catching circular contracts
console.log(`Failed to write ${contractTo} contract`);
console.log(e);
}
}));
});
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
solidity: {
compilers: [
{
version: '0.8.25',
settings: {
evmVersion: 'paris',
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
networks: {
develop: {
url: process.env.RPC_URL || '',
accounts: {
mnemonic: process.env.MNEMONIC || 'test test test test test test test test test test test junk',
initialIndex: Number(process.env.MNEMONIC_INDEX) || 0,
},
},
polygon: {
url: process.env.RPC_URL || 'https://polygon-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607',
accounts: {
mnemonic: process.env.MNEMONIC || 'test test test test test test test test test test test junk',
initialIndex: Number(process.env.MNEMONIC_INDEX) || 0,
},
},
hardhat: {},
},
etherscan: {
apiKey: process.env.ETHERSCAN
},
sourcify: {
enabled: true
}
};
export default config;