-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathhardhat.config.ts
122 lines (112 loc) · 3.44 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
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
import path from "path";
import { HardhatUserConfig } from "hardhat/config";
import { HttpNetworkUserConfig } from "hardhat/types";
import { getSingletonFactoryInfo } from "@safe-global/safe-singleton-factory";
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-verify";
import "@typechain/hardhat";
import "hardhat-deploy";
import "hardhat-abi-exporter";
import "hardhat-gas-reporter";
import {
Chain,
arbitrum,
arbitrumGoerli,
mainnet,
optimism,
optimismGoerli,
sepolia,
} from "@wagmi/chains";
// read MNEMONIC from env variable
let mnemonic = process.env.MNEMONIC;
const ppath = (packageName: string, pathname: string) => {
return path.join(
path.dirname(require.resolve(`${packageName}/package.json`)),
pathname
);
};
const networkConfig = (chain: Chain): HttpNetworkUserConfig => {
let url = process.env.RPC_URL || chain.rpcUrls.public.http.at(0);
// support for infura and alchemy URLs through env variables
if (process.env.INFURA_ID && chain.rpcUrls.infura?.http) {
url = `${chain.rpcUrls.infura.http}/${process.env.INFURA_ID}`;
} else if (process.env.ALCHEMY_ID && chain.rpcUrls.alchemy?.http) {
url = `${chain.rpcUrls.alchemy.http}/${process.env.ALCHEMY_ID}`;
}
return {
chainId: chain.id,
url,
accounts: mnemonic ? { mnemonic } : undefined,
};
};
const config: HardhatUserConfig = {
networks: {
hardhat: mnemonic ? { accounts: { mnemonic } } : {},
localhost: {
url: process.env.RPC_URL || "http://localhost:8545",
accounts: mnemonic ? { mnemonic } : undefined,
},
arbitrum: networkConfig(arbitrum),
arbitrum_goerli: networkConfig(arbitrumGoerli),
mainnet: networkConfig(mainnet),
sepolia: networkConfig(sepolia),
optimism: networkConfig(optimism),
optimism_goerli: networkConfig(optimismGoerli),
},
solidity: {
version: "0.8.19",
settings: {
optimizer: {
enabled: true,
},
},
},
paths: {
artifacts: "artifacts",
deploy: "deploy",
deployments: "deployments",
},
deterministicDeployment: (network: string) => {
// networks will use another deterministic deployment proxy
// https://github.com/safe-global/safe-singleton-factory
const chainId = parseInt(network);
const info = getSingletonFactoryInfo(chainId);
if (info) {
return {
factory: info.address,
deployer: info.signerAddress,
funding: (
BigInt(info.gasPrice) * BigInt(info.gasLimit)
).toString(),
signedTx: info.transaction,
};
} else {
console.warn(
`unsupported deterministic deployment for network ${network}`
);
return undefined;
}
},
abiExporter: {
runOnCompile: true,
clear: true,
},
typechain: {
outDir: "src/types",
target: "ethers-v5",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
namedAccounts: {
deployer: {
default: 0,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
},
};
export default config;