-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
128 lines (120 loc) · 2.76 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
require("@nomicfoundation/hardhat-foundry");
import "@nomicfoundation/hardhat-toolbox";
import "@tenderly/hardhat-tenderly";
import "hardhat-abi-exporter";
import "hardhat-preprocessor";
import "hardhat-deploy";
import * as fs from "fs";
import { HardhatUserConfig } from "hardhat/config";
const deployerPath = "./deployer.json";
/**
* Tasks
*/
import { mnemonic } from "./hardhat-tasks/getWallet";
/**
* Configuration
*/
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.15",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
],
},
networks: {
localhost: {
live: false,
saveDeployments: true,
deploy: [`deploy/networks/${getTestDeployNetwork()}`],
gas: 21000000,
gasPrice: 80000000000,
},
hardhat: {
live: false,
saveDeployments: true,
deploy: [`deploy/networks/${getTestDeployNetwork()}`],
},
mainnet: {
live: true,
saveDeployments: true,
deploy: ["deploy/networks/mainnet"],
url: `${process.env.RPC_MAINNET}`,
accounts: process.env.PRIVATE_KEY
? [process.env.PRIVATE_KEY]
: { mnemonic: mnemonic(deployerPath) },
},
goerli: {
live: true,
saveDeployments: true,
deploy: ["deploy/networks/goerli"],
url: `${process.env.RPC_GOERLI}`,
accounts: process.env.PRIVATE_KEY
? [process.env.PRIVATE_KEY]
: { mnemonic: mnemonic(deployerPath) },
},
},
etherscan: {
apiKey: {
goerli: process.env.ETHERSCAN_KEY ?? "",
},
},
preprocess: {
eachLine: () => ({
transform: (line: string) => {
getRemappings().forEach(([find, replace]) => {
if (line.match(find)) {
line = line.replace(find, replace);
}
});
return line;
},
}),
},
paths: {
sources: "./src",
cache: "./cache_hardhat",
},
abiExporter: {
path: "./abis",
runOnCompile: false,
clear: true,
spacing: 2,
},
namedAccounts: {
deployer: {
default: 0,
},
alice: { default: 1 },
bob: { default: 2 },
rando: { default: 3 },
},
typechain: {
dontOverrideCompile: true,
},
tenderly: {
project: process.env.TENDERLY_PROJECT || "",
username: process.env.TENDERLY_USERNAME || "",
},
};
function getTestDeployNetwork() {
if (!process.env.TEST_DEPLOY_NETWORK) {
throw "Set TEST_DEPLOY_NETWORK in .env";
} else {
return process.env.TEST_DEPLOY_NETWORK;
}
}
function getRemappings() {
return fs
.readFileSync("remappings_hardhat.txt", "utf8")
.split("\n")
.filter(Boolean) // remove empty lines
.map((line: string) => line.trim().split("="));
}
export default config;