Skip to content

Commit 6d64b7e

Browse files
committed
fix: rework base config file
Signed-off-by: Tomás Migone <[email protected]>
1 parent dfc6c97 commit 6d64b7e

File tree

8 files changed

+74
-109
lines changed

8 files changed

+74
-109
lines changed

packages/hardhat-graph-protocol/src/sdk/hardhat.base.config.ts

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,23 @@ import { vars } from 'hardhat/config'
22

33
import type { HardhatUserConfig, NetworksUserConfig, ProjectPathsUserConfig, SolidityUserConfig } from 'hardhat/types'
44
import 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')
1514
const 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)
2417
const 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
}
3023
const getHardhatAccounts = () => {
3124
return {
@@ -50,42 +43,43 @@ export const projectPathsUserConfig: ProjectPathsUserConfig = {
5043

5144
export 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: {

packages/horizon/hardhat.config.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
import { HardhatUserConfig } from 'hardhat/config'
21
import { hardhatBaseConfig } from 'hardhat-graph-protocol/sdk'
2+
import { HardhatUserConfig } from 'hardhat/config'
33

44
// Hardhat plugins
55
import '@nomicfoundation/hardhat-foundry'
66
import '@nomicfoundation/hardhat-toolbox'
77
import '@nomicfoundation/hardhat-ignition-ethers'
8-
import "@tenderly/hardhat-tenderly"
8+
import '@tenderly/hardhat-tenderly'
99
import 'hardhat-storage-layout'
1010
import 'hardhat-contract-sizer'
11+
import 'hardhat-secure-accounts'
1112

13+
// Skip importing hardhat-graph-protocol when building the project, it has circular dependency
1214
if (process.env.BUILD_RUN !== 'true') {
1315
require('hardhat-graph-protocol')
1416
}
1517

1618
const config: HardhatUserConfig = {
1719
...hardhatBaseConfig,
1820
tenderly: {
19-
project: "graph-network",
20-
username: "graphprotocol",
21-
}
21+
project: 'graph-network',
22+
username: 'graphprotocol',
23+
},
2224
}
2325

24-
export default config
26+
export default config

packages/horizon/ignition/modules/core/HorizonStaking.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { upgradeGraphProxy } from '../proxy/GraphProxy'
21
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
32
import { deployImplementation } from '../proxy/implementation'
3+
import { upgradeGraphProxy } from '../proxy/GraphProxy'
44

55
import GraphPeripheryModule, { MigratePeripheryModule } from '../periphery/periphery'
66
import HorizonProxiesModule from './HorizonProxies'

packages/horizon/ignition/modules/periphery/Curation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { upgradeGraphProxy, deployWithGraphProxy } from '../proxy/GraphProxy'
21
import { buildModule, IgnitionModuleBuilder } from '@nomicfoundation/ignition-core'
2+
import { deployWithGraphProxy, upgradeGraphProxy } from '../proxy/GraphProxy'
33
import { deployImplementation } from '../proxy/implementation'
44

55
import ControllerModule from './Controller'

packages/horizon/ignition/modules/periphery/RewardsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { upgradeGraphProxy, deployWithGraphProxy } from '../proxy/GraphProxy'
21
import { buildModule, IgnitionModuleBuilder } from '@nomicfoundation/ignition-core'
2+
import { deployWithGraphProxy, upgradeGraphProxy } from '../proxy/GraphProxy'
33
import { deployImplementation } from '../proxy/implementation'
44

55
import ControllerModule from './Controller'

packages/horizon/scripts/migrate.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function main() {
2020
console.log('========== Running migration: step 1 ==========')
2121
const {
2222
GraphPaymentsProxy,
23-
PaymentsEscrowProxy
23+
PaymentsEscrowProxy,
2424
} = await ignition.deploy(MigrateModuleStep1, {
2525
displayUi: true,
2626
parameters: HorizonMigrateConfig,
@@ -30,8 +30,8 @@ async function main() {
3030
let patchedHorizonMigrateConfig = IgnitionHelper.patchConfig(HorizonMigrateConfig, {
3131
HorizonProxiesGovernor: {
3232
graphPaymentsAddress: GraphPaymentsProxy.target,
33-
paymentsEscrowAddress: PaymentsEscrowProxy.target
34-
}
33+
paymentsEscrowAddress: PaymentsEscrowProxy.target,
34+
},
3535
})
3636

3737
console.log('========== Running migration: step 2 ==========')
@@ -53,14 +53,14 @@ async function main() {
5353

5454
patchedHorizonMigrateConfig = IgnitionHelper.patchConfig(patchedHorizonMigrateConfig, {
5555
HorizonStakingGovernor: {
56-
horizonStakingImplementationAddress: deployment.HorizonStakingImplementation.target
56+
horizonStakingImplementationAddress: deployment.HorizonStakingImplementation.target,
5757
},
5858
L2CurationGovernor: {
59-
curationImplementationAddress: deployment.L2CurationImplementation.target
59+
curationImplementationAddress: deployment.L2CurationImplementation.target,
6060
},
6161
RewardsManagerGovernor: {
62-
rewardsManagerImplementationAddress: deployment.RewardsManagerImplementation.target
63-
}
62+
rewardsManagerImplementationAddress: deployment.RewardsManagerImplementation.target,
63+
},
6464
})
6565

6666
console.log('========== Running migration: step 4 ==========')

packages/horizon/types/hardhat-graph-protocol.d.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/subgraph-service/hardhat.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { hardhatBaseConfig } from 'hardhat-graph-protocol/sdk'
2+
import { HardhatUserConfig } from 'hardhat/config'
23

34
// Hardhat plugins
45
import '@nomicfoundation/hardhat-foundry'
56
import '@nomicfoundation/hardhat-toolbox'
67
import '@nomicfoundation/hardhat-ignition-ethers'
78
import 'hardhat-storage-layout'
89
import 'hardhat-contract-sizer'
10+
import 'hardhat-secure-accounts'
911
import 'solidity-docgen'
1012

13+
// Skip importing hardhat-graph-protocol when building the project, it has circular dependency
1114
if (process.env.BUILD_RUN !== 'true') {
1215
require('hardhat-graph-protocol')
1316
}
1417

15-
const config = {
18+
const config: HardhatUserConfig = {
1619
...hardhatBaseConfig,
1720
graph: {
1821
deployments: {

0 commit comments

Comments
 (0)