-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhardhat.export.ts
123 lines (117 loc) · 3.79 KB
/
hardhat.export.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
// Plugins
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-foundry';
import '@nomicfoundation/hardhat-toolbox';
import '@primitivefi/hardhat-dodoc';
import '@typechain/hardhat';
import 'hardhat-contract-sizer';
import 'hardhat-tracer';
import { HardhatUserConfig } from 'hardhat/config';
import { HttpNetworkConfig, HttpNetworkUserConfig } from 'hardhat/types';
// Utils
import { TAPIOCA_PROJECTS_NAME } from '@tapioca-sdk/api/config';
import { SDK, loadEnv } from 'tapioca-sdk';
import 'tapioca-sdk'; // Use directly the un-compiled code, no need to wait for the tarball to be published.
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
interface ProcessEnv {
ALCHEMY_API_KEY: string;
ENV: string;
}
}
}
// Load the env vars from the .env/<network>.env file. the <network> file name is the same as the network in hh `--network arbitrum_sepolia`
loadEnv();
// TODO refactor all of that in the SDK?
type TNetwork = ReturnType<
typeof SDK.API.utils.getSupportedChains
>[number]['name'];
const supportedChains = SDK.API.utils.getSupportedChains().reduce(
(sdkChains, chain) => ({
...sdkChains,
[chain.name]: <HttpNetworkUserConfig>{
accounts:
process.env.PRIVATE_KEY !== undefined
? [process.env.PRIVATE_KEY]
: [],
live: true,
url: chain.rpc.replace('<api_key>', process.env.ALCHEMY_API_KEY),
gasMultiplier: chain.tags[0] === 'testnet' ? 2 : 1,
chainId: Number(chain.chainId),
tags: [...chain.tags],
},
}),
{} as { [key in TNetwork]: HttpNetworkConfig },
);
const config: HardhatUserConfig & { dodoc: any } = {
SDK: { project: TAPIOCA_PROJECTS_NAME.YieldBox },
solidity: {
compilers: [
{
version: '0.8.22',
settings: {
evmVersion: 'paris', // Latest before Shanghai
optimizer: {
enabled: true,
runs: 9999,
},
},
},
],
},
paths: {
artifacts: './gen/artifacts',
cache: './gen/cache',
tests: './hardhat_test',
},
dodoc: {
runOnCompile: false,
freshOutput: false,
outputDir: 'gen/docs',
},
typechain: {
outDir: 'gen/typechain',
target: 'ethers-v5',
},
defaultNetwork: 'hardhat',
networks: {
hardhat: {
allowUnlimitedContractSize: true,
accounts: {
count: 5,
},
},
...supportedChains,
},
etherscan: {
apiKey: {
sepolia: process.env.SCAN_API_KEY ?? '',
arbitrumSepolia: process.env.SCAN_API_KEY ?? '',
optimismSepolia: process.env.SCAN_API_KEY ?? '',
avalancheFujiTestnet: process.env.SCAN_API_KEY ?? '',
bscTestnet: process.env.SCAN_API_KEY ?? '',
polygonMumbai: process.env.SCAN_API_KEY ?? '',
ftmTestnet: process.env.SCAN_API_KEY ?? '',
},
customChains: [
{
network: 'arbitrumSepolia',
chainId: 421614,
urls: {
apiURL: 'https://api-sepolia.arbiscan.io/api',
browserURL: 'https://sepolia.arbiscan.io/',
},
},
{
network: 'optimismSepolia',
chainId: 11155420,
urls: {
apiURL: 'https://api-sepolia-optimistic.etherscan.io/api',
browserURL: 'https://sepolia-optimism.etherscan.io/',
},
},
],
},
};
export default config;