-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
160 lines (145 loc) · 4.4 KB
/
hardhat.config.ts
File metadata and controls
160 lines (145 loc) · 4.4 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
148
149
150
151
152
153
154
155
156
157
158
159
160
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import dotenv from 'dotenv';
import 'hardhat-deploy';
import 'hardhat-ignore-warnings';
import { type HardhatUserConfig, extendProvider } from 'hardhat/config';
import { task } from 'hardhat/config';
import type { NetworkUserConfig } from 'hardhat/types';
import { resolve } from 'path';
export const ADDRESSES_DIR = resolve(__dirname, 'addresses');
export const HOST_ADDRESSES_ENV_FILE_NAME = '.env.host';
import CustomProvider from './CustomProvider';
import './tasks/accounts';
import './tasks/addPausers';
import './tasks/blockExplorerVerify';
import './tasks/ownership';
import './tasks/pauseContracts';
import './tasks/taskDeploy';
import './tasks/taskUtils';
import './tasks/upgradeContracts';
const NUM_ACCOUNTS = 15;
extendProvider(async (provider, config, network) => {
const newProvider = new CustomProvider(provider);
return newProvider;
});
task('compile:specific', 'Compiles only the specified contract')
.addParam('contract', "The contract's path")
.setAction(async ({ contract }, hre) => {
// Adjust the configuration to include only the specified contract
hre.config.paths.sources = contract;
await hre.run('compile');
});
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || './.env';
dotenv.config({ path: resolve(__dirname, dotenvConfigPath) });
// Ensure that we have all the environment variables we need.
let mnemonic: string | undefined = process.env.MNEMONIC;
if (!mnemonic) {
mnemonic = 'adapt mosquito move limb mobile illegal tree voyage juice mosquito burger raise father hope layer'; // default mnemonic in case it is undefined (needed to avoid panicking when deploying on real network)
}
task('coverage').setAction(async (taskArgs, hre, runSuper) => {
hre.config.networks.hardhat.allowUnlimitedContractSize = true;
hre.config.networks.hardhat.blockGasLimit = 1099511627775;
await runSuper(taskArgs);
});
task('test', async (taskArgs, hre, runSuper) => {
// Run modified test task
if (hre.network.name === 'hardhat') {
await hre.run('task:deployAllHostContracts');
// Contrary to deployment, here we consider the PauserSet address from the `addresses/` directory
// for local testing
await hre.run('task:addHostPausers', { useInternalProxyAddress: true });
}
await hre.run('compile:specific', { contract: 'examples' });
await runSuper();
});
const chainIds = {
localHostChain: 123456,
sepolia: 11155111,
staging: 12345,
zwsDev: 1337,
mainnet: 1,
custom: 9999,
};
function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
let jsonRpcUrl: string | undefined = process.env.RPC_URL;
if (!jsonRpcUrl) {
jsonRpcUrl = 'http://127.0.0.1:8756';
}
return {
accounts: {
count: NUM_ACCOUNTS,
mnemonic,
path: "m/44'/60'/0'/0",
},
chainId: process.env.CHAIN_ID ? Number(process.env.CHAIN_ID) : chainIds[chain],
url: jsonRpcUrl,
};
}
const config: HardhatUserConfig = {
namedAccounts: {
deployer: 0,
},
mocha: {
timeout: 500000,
},
gasReporter: {
currency: 'USD',
enabled: process.env.REPORT_GAS ? true : false,
excludeContracts: [],
src: './contracts',
},
networks: {
hardhat: {
accounts: {
count: 20,
mnemonic,
path: "m/44'/60'/0'/0",
},
},
staging: getChainConfig('staging'),
zwsDev: getChainConfig('zwsDev'),
sepolia: getChainConfig('sepolia'),
localHostChain: getChainConfig('localHostChain'),
mainnet: getChainConfig('mainnet'),
custom: getChainConfig('custom'),
},
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
},
solidity: {
version: '0.8.24',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/hardhat-template/issues/31
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 800,
},
evmVersion: 'cancun',
viaIR: false,
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY!,
},
warnings: {
'*': {
'transient-storage': false,
},
'examples/TracingSubCalls.sol': { default: 'off' },
},
typechain: {
outDir: 'types',
target: 'ethers-v6',
},
};
export default config;