-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhardhat.config.ts
124 lines (108 loc) · 3.34 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
import * as dotenv from 'dotenv'
import '@nomiclabs/hardhat-waffle'
import '@typechain/hardhat'
import { HardhatUserConfig } from 'hardhat/config'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-etherscan'
import "hardhat-deploy-ethers";
import 'solidity-coverage'
import * as fs from 'fs'
dotenv.config()
const mnemonicFileName = process.env.MNEMONIC_FILE ?? `${process.env.HOME}/.secret/testnet-mnemonic.txt`
let mnemonic = 'test '.repeat(11) + 'junk'
if (fs.existsSync(mnemonicFileName)) { mnemonic = fs.readFileSync(mnemonicFileName, 'ascii') } else { mnemonic = 'test test test test test test test test test test test junk' }
function getNetwork1 (url: string): { url: string, accounts: { mnemonic: string } } {
return {
url,
accounts: { mnemonic }
}
}
function getNetwork (name: string): { url: string, accounts: { mnemonic: string } } {
return getNetwork1(`https://${name}.infura.io/v3/${process.env.INFURA_ID}`)
// return getNetwork1(`wss://${name}.infura.io/ws/v3/${process.env.INFURA_ID}`)
}
function getAccounts (): string[] | { mnemonic: string} {
const accs = []
if (process.env.DEPLOYER_PRIVATE_KEY !== undefined) {
accs.push(process.env.DEPLOYER_PRIVATE_KEY)
}
if (process.env.PAYMASTER_OWNER_PRIVATE_KEY !== undefined) {
accs.push(process.env.PAYMASTER_OWNER_PRIVATE_KEY)
}
if (accs.length === 0) {
return { mnemonic }
} else {
return accs
}
}
const optimizedComilerSettings = {
version: '0.8.17',
settings: {
optimizer: { enabled: true, runs: 1000000 },
viaIR: true
}
}
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
const config: HardhatUserConfig = {
solidity: {
compilers: [{
version: '0.8.17',
settings: {
optimizer: { enabled: true, runs: 1000000 }
}
}],
overrides: {
'contracts/core/EntryPoint.sol': optimizedComilerSettings,
'contracts/samples/SimpleAccount.sol': optimizedComilerSettings
}
},
networks: {
dev: { url: 'http://localhost:8545' },
// github action starts localgeth service, for gas calculations
localgeth: { url: 'http://localgeth:8545' },
proxy: getNetwork1('http://localhost:8545'),
kovan: getNetwork('kovan'),
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${process.env.INFURA_ID}`,
accounts: getAccounts()
},
polygon: {
url: `https://polygon-mainnet.infura.io/v3/${process.env.INFURA_ID}`,
accounts: getAccounts()
},
avalanche: {
url: `https://avalanche-mainnet.infura.io/v3/${process.env.INFURA_ID}`,
accounts: getAccounts()
},
fuji: {
url: `https://avalanche-fuji.infura.io/v3/${process.env.INFURA_ID}`,
accounts: getAccounts()
},
goerli: {
url: `https://goerli.infura.io/v3/${process.env.INFURA_ID}`,
accounts: getAccounts()
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_ID}`,
accounts: getAccounts()
}
},
namedAccounts: {
paymasterOwner: {
default: `privatekey://${process.env.PAYMASTER_OWNER_PRIVATE_KEY!}`
}
},
mocha: {
timeout: 10000
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
}
}
// coverage chokes on the "compilers" settings
if (process.env.COVERAGE != null) {
// @ts-ignore
config.solidity = config.solidity.compilers[0]
}
export default config