forked from yieldprotocol/vault-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
147 lines (138 loc) · 3.86 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import * as fs from 'fs'
import * as path from 'path'
import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-etherscan'
import 'hardhat-abi-exporter'
import 'hardhat-contract-sizer'
import 'hardhat-gas-reporter'
import 'hardhat-typechain'
import 'solidity-coverage'
import 'hardhat-deploy'
import { task } from 'hardhat/config'
import { TASK_TEST } from 'hardhat/builtin-tasks/task-names'
import { TaskArguments, HardhatRuntimeEnvironment, RunSuperFunction } from 'hardhat/types'
// REQUIRED TO ENSURE METADATA IS SAVED IN DEPLOYMENTS (because solidity-coverage disable it otherwise)
/* import {
TASK_COMPILE_GET_COMPILER_INPUT
} from "hardhat/builtin-tasks/task-names"
task(TASK_COMPILE_GET_COMPILER_INPUT).setAction(async (_, bre, runSuper) => {
const input = await runSuper()
input.settings.metadata.useLiteralContent = bre.network.name !== "coverage"
return input
}) */
// Periodically, one needs to remove the 'artifacts' and 'typechain' folder (and hence, do a yarn build). Yet, if running yarn build, the tests shouldn't run the compilation again, so the hook below accomplishes just that.
task(
TASK_TEST,
"Runs the tests",
async (args: TaskArguments, hre: HardhatRuntimeEnvironment, runSuper: RunSuperFunction<TaskArguments>) => {
return runSuper({...args, noCompile: true});
}
);
task("lint:collisions", "Checks all contracts for function signatures collisions with ROOT (0x00000000) and LOCK (0xffffffff)",
async (taskArguments, hre, runSuper) => {
let ROOT = "0x00000000"
let LOCK = "0xffffffff"
const abiPath = path.join(__dirname, 'abi')
for (let contract of fs.readdirSync(abiPath)) {
const iface = new hre.ethers.utils.Interface(require(abiPath + "/" + contract))
for (let func in iface.functions) {
const sig = iface.getSighash(func)
if (sig == ROOT) {
console.error("Function " + func + " of contract " + contract.slice(0, contract.length - 5) + " has a role-colliding signature with ROOT.")
}
if (sig == LOCK) {
console.error("Function " + func + " of contract " + contract.slice(0, contract.length - 5) + " has a role-colliding signature with LOCK.")
}
}
}
console.log("No collisions, check passed.")
}
)
function nodeUrl(network: any) {
let infuraKey
try {
infuraKey = fs.readFileSync(path.resolve(__dirname, '.infuraKey')).toString().trim()
} catch(e) {
infuraKey = ''
}
return `https://${network}.infura.io/v3/${infuraKey}`
}
let mnemonic = process.env.MNEMONIC
if (!mnemonic) {
try {
mnemonic = fs.readFileSync(path.resolve(__dirname, '.secret')).toString().trim()
} catch(e){}
}
const accounts = mnemonic ? {
mnemonic,
}: undefined
let etherscanKey = process.env.ETHERSCANKEY
if (!etherscanKey) {
try {
etherscanKey = fs.readFileSync(path.resolve(__dirname, '.etherscanKey')).toString().trim()
} catch(e){}
}
module.exports = {
solidity: {
version: '0.8.6',
settings: {
optimizer: {
enabled: true,
runs: 1000,
}
}
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
abiExporter: {
path: './abi',
clear: true,
flat: true,
// only: [':ERC20$'],
spacing: 2
},
contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},
gasReporter: {
enabled: false,
},
defaultNetwork: 'hardhat',
namedAccounts: {
deployer: 0,
owner: 1,
other: 2,
},
networks: {
kovan: {
accounts,
url: nodeUrl('kovan')
},
goerli: {
accounts,
url: nodeUrl('goerli'),
},
rinkeby: {
accounts,
url: nodeUrl('rinkeby')
},
ropsten: {
accounts,
url: nodeUrl('ropsten')
},
mainnet: {
accounts,
url: nodeUrl('mainnet')
},
coverage: {
url: 'http://127.0.0.1:8555',
},
},
etherscan: {
apiKey: etherscanKey
},
}