-
Notifications
You must be signed in to change notification settings - Fork 12
/
hardhat.config.ts
69 lines (59 loc) · 1.93 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
import { HardhatUserConfig } from "hardhat/config"
import "@typechain/hardhat"
import "@openzeppelin/hardhat-upgrades"
import "@nomicfoundation/hardhat-foundry"
import "@nomicfoundation/hardhat-ethers"
import "hardhat-contract-sizer"
import { readFileSync } from "fs"
import "dotenv/config"
let extractedSolcVersion: string
try {
const tomlData = readFileSync("./foundry.toml", { encoding: "utf8", flag: "r" })
extractedSolcVersion = tomlData.split(`solc`)[1].split("=")[1].split("\n")[0].replaceAll(" ", "").replaceAll('"', "").replaceAll("'", "")
} catch {
console.log({ error: "Solc version in foundry.toml not set (Hardhat needs to be run from projects root)" })
process.exit(1)
}
const HH_NETWORK = process.env.HH_NETWORK != undefined ? process.env.HH_NETWORK : "localnet"
const SUPPORTED_NETWORKS = {
localnet: {
url: "http://127.0.0.1:1234/rpc/v1",
chainId: 31415926,
gas: 1_000_000_000,
blockGasLimit: 1_000_000_000,
},
calibnet: {
url: "https://filecoin-calibration.chainup.net/rpc/v1",
chainId: 314159,
accounts: [process.env.ETH_PK],
},
localhost: {
url: "http://0.0.0.0:8545",
chainId: 31337,
accounts: [process.env.ETH_PK], // Acc. 0 - npx hardhat node generated
},
}
if (HH_NETWORK === undefined || SUPPORTED_NETWORKS[HH_NETWORK] == null) {
console.log({ error: `HH_NETWORK env var (val:${HH_NETWORK}) not supported! (Must be: ${Object.keys(SUPPORTED_NETWORKS).join(" | ")})` })
process.exit(1)
}
const config: HardhatUserConfig = {
solidity: {
version: extractedSolcVersion,
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
defaultNetwork: HH_NETWORK,
networks: SUPPORTED_NETWORKS,
mocha: {
timeout: 1000000000,
},
paths: {
tests: `./hh-test/${HH_NETWORK}`,
},
}
export default config