@@ -2,30 +2,23 @@ import { vars } from 'hardhat/config'
22
33import type { HardhatUserConfig , NetworksUserConfig , ProjectPathsUserConfig , SolidityUserConfig } from 'hardhat/types'
44import type { EtherscanConfig } from '@nomicfoundation/hardhat-verify/types'
5+ import type { GraphRuntimeEnvironmentOptions } from '../types'
56
6- // This next import ensures secure accounts config is correctly typed
7- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8- import 'hardhat-secure-accounts'
9-
10- // Environment variables
11- const ARBISCAN_API_KEY = vars . get ( 'ARBISCAN_API_KEY' , undefined )
7+ // TODO: this should be imported from hardhat-secure-accounts, but currently it's not exported
8+ interface SecureAccountsOptions {
9+ enabled ?: boolean
10+ }
1211
1312// RPCs
14- const VIRTUAL_ARBITRUM_SEPOLIA_RPC = vars . has ( 'VIRTUAL_ARBITRUM_SEPOLIA_RPC' ) ? vars . get ( 'VIRTUAL_ARBITRUM_SEPOLIA_RPC' ) : undefined
13+ const ARBITRUM_ONE_RPC = vars . get ( 'ARBITRUM_ONE_RPC' , 'https://arb1.arbitrum.io/rpc' )
1514const ARBITRUM_SEPOLIA_RPC = vars . get ( 'ARBITRUM_SEPOLIA_RPC' , 'https://sepolia-rollup.arbitrum.io/rpc' )
16- const VIRTUAL_ARBITRUM_ONE_RPC = vars . has ( 'VIRTUAL_ARBITRUM_ONE_RPC' ) ? vars . get ( 'VIRTUAL_ARBITRUM_ONE_RPC' ) : undefined
17-
18- // Tenderly API Key
19- const TENDERLY_API_KEY = vars . has ( 'TENDERLY_API_KEY' ) ? vars . get ( 'TENDERLY_API_KEY' ) : undefined
2015
2116// Accounts
22- const DEPLOYER_PRIVATE_KEY = vars . get ( 'DEPLOYER_PRIVATE_KEY' , undefined )
23- const GOVERNOR_PRIVATE_KEY = vars . get ( 'GOVERNOR_PRIVATE_KEY' , undefined )
2417const getTestnetAccounts = ( ) => {
2518 const accounts : string [ ] = [ ]
26- if ( DEPLOYER_PRIVATE_KEY ) accounts . push ( DEPLOYER_PRIVATE_KEY )
27- if ( GOVERNOR_PRIVATE_KEY ) accounts . push ( GOVERNOR_PRIVATE_KEY )
28- return accounts . length > 0 ? accounts : undefined
19+ if ( vars . has ( ' DEPLOYER_PRIVATE_KEY' ) ) accounts . push ( vars . get ( ' DEPLOYER_PRIVATE_KEY' ) )
20+ if ( vars . has ( ' GOVERNOR_PRIVATE_KEY' ) ) accounts . push ( vars . get ( ' GOVERNOR_PRIVATE_KEY' ) )
21+ return accounts
2922}
3023const getHardhatAccounts = ( ) => {
3124 return {
@@ -50,42 +43,43 @@ export const projectPathsUserConfig: ProjectPathsUserConfig = {
5043
5144export const etherscanUserConfig : Partial < EtherscanConfig > = {
5245 apiKey : {
53- arbitrumSepolia : ARBISCAN_API_KEY ,
54- ...( TENDERLY_API_KEY && {
55- virtualArbitrumSepolia : TENDERLY_API_KEY ,
56- virtualArbitrumOne : TENDERLY_API_KEY ,
46+ ...( vars . has ( 'ARBISCAN_API_KEY' ) && {
47+ arbitrumSepolia : vars . get ( 'ARBISCAN_API_KEY' ) ,
48+ } ) ,
49+ ...( vars . has ( 'TENDERLY_API_KEY' ) && {
50+ virtualArbitrumSepolia : vars . get ( 'TENDERLY_API_KEY' ) ,
51+ virtualArbitrumOne : vars . get ( 'TENDERLY_API_KEY' ) ,
5752 } ) ,
5853 } ,
5954 customChains : [
60- {
61- network : 'arbitrumSepolia' ,
62- chainId : 421614 ,
63- urls : { apiURL : 'https://api-sepolia.arbiscan.io/api' , browserURL : 'https://sepolia.arbiscan.io/' } ,
64- } ,
65- {
66- network : 'virtualArbitrumSepolia' ,
67- chainId : 421615 ,
68- urls : {
69- apiURL : VIRTUAL_ARBITRUM_SEPOLIA_RPC + '/verify/etherscan' ,
70- browserURL : VIRTUAL_ARBITRUM_SEPOLIA_RPC || 'https://sepolia.arbiscan.io/' ,
71- } ,
72- } ,
73- {
74- network : 'virtualArbitrumOne' ,
75- chainId : 42162 ,
76- urls : {
77- apiURL : VIRTUAL_ARBITRUM_ONE_RPC + '/verify/etherscan' ,
78- browserURL : VIRTUAL_ARBITRUM_SEPOLIA_RPC || 'https://arbiscan.io/' ,
79- } ,
80- } ,
55+ ...( vars . has ( 'VIRTUAL_ARBITRUM_SEPOLIA_RPC' )
56+ ? [ {
57+ network : 'virtualArbitrumSepolia' ,
58+ chainId : 421615 ,
59+ urls : {
60+ apiURL : `${ vars . get ( 'VIRTUAL_ARBITRUM_SEPOLIA_RPC' ) } /verify/etherscan` ,
61+ browserURL : vars . get ( 'VIRTUAL_ARBITRUM_SEPOLIA_RPC' ) || 'https://sepolia.arbiscan.io/' ,
62+ } ,
63+ } ]
64+ : [ ] ) ,
65+ ...( vars . has ( 'VIRTUAL_ARBITRUM_ONE_RPC' )
66+ ? [ {
67+ network : 'virtualArbitrumOne' ,
68+ chainId : 42162 ,
69+ urls : {
70+ apiURL : `${ vars . get ( 'VIRTUAL_ARBITRUM_ONE_RPC' ) } /verify/etherscan` ,
71+ browserURL : vars . get ( 'VIRTUAL_ARBITRUM_ONE_RPC' ) || 'https://arbiscan.io/' ,
72+ } ,
73+ } ]
74+ : [ ] ) ,
8175 ] ,
8276}
8377
8478// In general:
8579// - hardhat is used for unit tests
8680// - localhost is used for local development on a hardhat network or fork
8781// - virtualArbitrumSepolia is for Tenderly Virtual Testnet
88- export const networksUserConfig : NetworksUserConfig = {
82+ export const networksUserConfig : NetworksUserConfig & Record < string , { secureAccounts ?: SecureAccountsOptions } > = {
8983 hardhat : {
9084 chainId : 31337 ,
9185 accounts : getHardhatAccounts ( ) ,
@@ -95,30 +89,41 @@ export const networksUserConfig: NetworksUserConfig = {
9589 url : 'http://localhost:8545' ,
9690 accounts : getTestnetAccounts ( ) ,
9791 } ,
92+ arbitrumOne : {
93+ chainId : 42161 ,
94+ url : ARBITRUM_ONE_RPC ,
95+ secureAccounts : {
96+ enabled : true ,
97+ } ,
98+ } ,
9899 arbitrumSepolia : {
99100 chainId : 421614 ,
100101 url : ARBITRUM_SEPOLIA_RPC ,
101102 secureAccounts : {
102103 enabled : true ,
103104 } ,
104105 } ,
105- ...( VIRTUAL_ARBITRUM_SEPOLIA_RPC && {
106+ ...( vars . has ( ' VIRTUAL_ARBITRUM_SEPOLIA_RPC' ) && {
106107 virtualArbitrumSepolia : {
107108 chainId : 421615 ,
108- url : VIRTUAL_ARBITRUM_SEPOLIA_RPC ,
109+ url : vars . get ( ' VIRTUAL_ARBITRUM_SEPOLIA_RPC' ) ,
109110 accounts : getTestnetAccounts ( ) ,
110111 } ,
111112 } ) ,
112- ...( VIRTUAL_ARBITRUM_ONE_RPC && {
113+ ...( vars . has ( ' VIRTUAL_ARBITRUM_ONE_RPC' ) && {
113114 virtualArbitrumOne : {
114115 chainId : 42162 ,
115- url : VIRTUAL_ARBITRUM_ONE_RPC ,
116+ url : vars . get ( ' VIRTUAL_ARBITRUM_ONE_RPC' ) ,
116117 accounts : getTestnetAccounts ( ) ,
117118 } ,
118119 } ) ,
119120}
120121
121- export const hardhatBaseConfig : HardhatUserConfig & { etherscan : Partial < EtherscanConfig > } = {
122+ type HardhatBaseConfig = HardhatUserConfig &
123+ { etherscan : Partial < EtherscanConfig > } &
124+ { graph : GraphRuntimeEnvironmentOptions } &
125+ { secureAccounts : SecureAccountsOptions }
126+ export const hardhatBaseConfig : HardhatBaseConfig = {
122127 solidity : solidityUserConfig ,
123128 paths : projectPathsUserConfig ,
124129 secureAccounts : {
0 commit comments