forked from graphprotocol/token-distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
147 lines (127 loc) · 3.08 KB
/
hardhat.config.ts
File metadata and controls
147 lines (127 loc) · 3.08 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import * as dotenv from 'dotenv'
import { extendEnvironment, task } from 'hardhat/config'
dotenv.config()
// Plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-etherscan'
import '@nomiclabs/hardhat-waffle'
import 'hardhat-deploy'
import 'hardhat-abi-exporter'
import 'hardhat-typechain'
import 'hardhat-gas-reporter'
// Tasks
import './ops/create'
// Networks
interface NetworkConfig {
network: string
chainId: number
url?: string
gas?: number | 'auto'
gasPrice?: number | 'auto'
}
const networkConfigs: NetworkConfig[] = [
{ network: 'mainnet', chainId: 1 },
{ network: 'ropsten', chainId: 3 },
{ network: 'rinkeby', chainId: 4 },
{ network: 'kovan', chainId: 42 },
]
function getAccountMnemonic() {
return process.env.MNEMONIC || ''
}
function getDefaultProviderURL(network: string) {
return `https://${network}.infura.io/v3/${process.env.INFURA_KEY}`
}
function setupNetworkConfig(config) {
for (const netConfig of networkConfigs) {
config.networks[netConfig.network] = {
chainId: netConfig.chainId,
url: netConfig.url ? netConfig.url : getDefaultProviderURL(netConfig.network),
gas: netConfig.gas || 'auto',
gasPrice: netConfig.gasPrice || 'auto',
accounts: {
mnemonic: getAccountMnemonic(),
},
}
}
}
// Env
extendEnvironment(async (hre) => {
const accounts = await hre.ethers.getSigners()
try {
const deployment = await hre.deployments.get('GraphTokenLockManager')
const contract = await hre.ethers.getContractAt('GraphTokenLockManager', deployment.address)
await contract.deployed() // test if deployed
hre['c'] = {
GraphTokenLockManager: contract.connect(accounts[0]),
}
} catch (err) {
// do not load the contract
}
})
// Tasks
task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners()
for (const account of accounts) {
console.log(await account.getAddress())
}
})
// Config
const config = {
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './build/artifacts',
},
solidity: {
version: '0.7.3',
optimizer: {
enabled: true,
runs: 200,
},
},
defaultNetwork: 'hardhat',
networks: {
hardhat: {
chainId: 1337,
loggingEnabled: false,
gas: 12000000,
gasPrice: 'auto',
blockGasLimit: 12000000,
},
ganache: {
chainId: 1337,
url: 'http://localhost:8545',
},
},
namedAccounts: {
deployer: {
default: 0,
},
},
etherscan: {
url: process.env.ETHERSCAN_API_URL,
apiKey: process.env.ETHERSCAN_API_KEY,
},
typechain: {
outDir: 'build/typechain/contracts',
target: 'ethers-v5',
},
abiExporter: {
path: './build/abis',
clear: false,
flat: true,
},
contractSizer: {
alphaSort: true,
runOnCompile: false,
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
showTimeSpent: true,
currency: 'USD',
outputFile: 'reports/gas-report.log',
},
}
setupNetworkConfig(config)
export default config