Skip to content

fix: ignition modules to output correct name of contracts #1107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/hardhat-graph-protocol/src/sdk/address-book.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs'

import { AssertionError } from 'assert'
import { assertObject } from './utils/assertion'

import { ContractList, loadContract } from './lib/contract'
Expand Down
55 changes: 11 additions & 44 deletions packages/hardhat-graph-protocol/src/sdk/hardhat.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,29 @@ export const etherscanUserConfig: Partial<EtherscanConfig> = {
...(vars.has('ARBISCAN_API_KEY') && {
arbitrumSepolia: vars.get('ARBISCAN_API_KEY'),
}),
...(vars.has('TENDERLY_API_KEY') && {
virtualArbitrumSepolia: vars.get('TENDERLY_API_KEY'),
virtualArbitrumOne: vars.get('TENDERLY_API_KEY'),
}),
},
customChains: [
...(vars.has('VIRTUAL_ARBITRUM_SEPOLIA_RPC')
? [{
network: 'virtualArbitrumSepolia',
chainId: 421615,
urls: {
apiURL: `${vars.get('VIRTUAL_ARBITRUM_SEPOLIA_RPC')}/verify/etherscan`,
browserURL: vars.get('VIRTUAL_ARBITRUM_SEPOLIA_RPC') || 'https://sepolia.arbiscan.io/',
},
}]
: []),
...(vars.has('VIRTUAL_ARBITRUM_ONE_RPC')
? [{
network: 'virtualArbitrumOne',
chainId: 42162,
urls: {
apiURL: `${vars.get('VIRTUAL_ARBITRUM_ONE_RPC')}/verify/etherscan`,
browserURL: vars.get('VIRTUAL_ARBITRUM_ONE_RPC') || 'https://arbiscan.io/',
},
}]
: []),
],
}

// In general:
// - hardhat is used for unit tests
// - localhost is used for local development on a hardhat network or fork
// - virtualArbitrumSepolia is for Tenderly Virtual Testnet
export const networksUserConfig: NetworksUserConfig & Record<string, { secureAccounts?: SecureAccountsOptions }> = {
type BaseNetworksUserConfig = NetworksUserConfig &
Record<string, { secureAccounts?: SecureAccountsOptions }>
export const networksUserConfig: BaseNetworksUserConfig = {
hardhat: {
chainId: 31337,
accounts: getHardhatAccounts(),
deployments: {
horizon: require.resolve('@graphprotocol/horizon/addresses-local.json'),
},
},
localhost: {
chainId: 31337,
url: 'http://localhost:8545',
accounts: getTestnetAccounts(),
deployments: {
horizon: require.resolve('@graphprotocol/horizon/addresses-local.json'),
},
},
arbitrumOne: {
chainId: 42161,
Expand All @@ -103,27 +84,13 @@ export const networksUserConfig: NetworksUserConfig & Record<string, { secureAcc
enabled: true,
},
},
...(vars.has('VIRTUAL_ARBITRUM_SEPOLIA_RPC') && {
virtualArbitrumSepolia: {
chainId: 421615,
url: vars.get('VIRTUAL_ARBITRUM_SEPOLIA_RPC'),
accounts: getTestnetAccounts(),
},
}),
...(vars.has('VIRTUAL_ARBITRUM_ONE_RPC') && {
virtualArbitrumOne: {
chainId: 42162,
url: vars.get('VIRTUAL_ARBITRUM_ONE_RPC'),
accounts: getTestnetAccounts(),
},
}),
}

type HardhatBaseConfig = HardhatUserConfig &
type BaseHardhatConfig = HardhatUserConfig &
{ etherscan: Partial<EtherscanConfig> } &
{ graph: GraphRuntimeEnvironmentOptions } &
{ secureAccounts: SecureAccountsOptions }
export const hardhatBaseConfig: HardhatBaseConfig = {
export const hardhatBaseConfig: BaseHardhatConfig = {
solidity: solidityUserConfig,
paths: projectPathsUserConfig,
secureAccounts: {
Expand Down
12 changes: 1 addition & 11 deletions packages/horizon/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { hardhatBaseConfig } from 'hardhat-graph-protocol/sdk'
import { HardhatUserConfig } from 'hardhat/config'

// Hardhat plugins
import '@nomicfoundation/hardhat-foundry'
import '@nomicfoundation/hardhat-toolbox'
import '@nomicfoundation/hardhat-ignition-ethers'
import '@tenderly/hardhat-tenderly'
import 'hardhat-storage-layout'
import 'hardhat-contract-sizer'
import 'hardhat-secure-accounts'
Expand All @@ -15,12 +13,4 @@ if (process.env.BUILD_RUN !== 'true') {
require('hardhat-graph-protocol')
}

const config: HardhatUserConfig = {
...hardhatBaseConfig,
tenderly: {
project: 'graph-network',
username: 'graphprotocol',
},
}

export default config
export default hardhatBaseConfig
8 changes: 4 additions & 4 deletions packages/horizon/ignition/modules/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default buildModule('GraphHorizon_Deploy', (m) => {
Controller,
EpochManager,
GraphProxyAdmin,
GraphTokenGateway,
GraphToken,
L2GraphTokenGateway,
L2GraphToken,
RewardsManager,
L2Curation,
} = m.useModule(GraphPeripheryModule)
Expand All @@ -35,8 +35,8 @@ export default buildModule('GraphHorizon_Deploy', (m) => {
L2Curation,
EpochManager,
GraphProxyAdmin,
GraphTokenGateway,
GraphToken,
L2GraphTokenGateway,
L2GraphToken,
RewardsManager,
HorizonStaking,
GraphPayments,
Expand Down
8 changes: 4 additions & 4 deletions packages/horizon/ignition/modules/migrate/migrate-3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default buildModule('GraphHorizon_Migrate_3', (m) => {
Controller,
GraphProxyAdmin,
EpochManager,
GraphToken,
GraphTokenGateway,
L2GraphToken,
L2GraphTokenGateway,
} = m.useModule(MigratePeripheryModule)

const {
Expand All @@ -37,7 +37,7 @@ export default buildModule('GraphHorizon_Migrate_3', (m) => {
Controller,
GraphProxyAdmin,
EpochManager,
GraphToken,
GraphTokenGateway,
L2GraphToken,
L2GraphTokenGateway,
}
})
22 changes: 11 additions & 11 deletions packages/horizon/ignition/modules/periphery/GraphToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ import GraphTokenArtifact from '@graphprotocol/contracts/build/contracts/contrac
export default buildModule('L2GraphToken', (m) => {
const { GraphProxyAdmin } = m.useModule(GraphProxyAdminModule)
const { RewardsManager } = m.useModule(RewardsManagerModule)
const { GraphTokenGateway } = m.useModule(GraphTokenGatewayModule)
const { L2GraphTokenGateway } = m.useModule(GraphTokenGatewayModule)

const deployer = m.getAccount(0)
const governor = m.getAccount(1)
const initialSupply = m.getParameter('initialSupply')

const GraphToken = deployWithGraphProxy(m, GraphProxyAdmin, {
const L2GraphToken = deployWithGraphProxy(m, GraphProxyAdmin, {
name: 'L2GraphToken',
artifact: GraphTokenArtifact,
initArgs: [deployer],
})

const mintCall = m.call(GraphToken, 'mint', [deployer, initialSupply])
const renounceMinterCall = m.call(GraphToken, 'renounceMinter', [])
const addMinterRewardsManagerCall = m.call(GraphToken, 'addMinter', [RewardsManager], { id: 'addMinterRewardsManager' })
const addMinterGatewayCall = m.call(GraphToken, 'addMinter', [GraphTokenGateway], { id: 'addMinterGateway' })
const mintCall = m.call(L2GraphToken, 'mint', [deployer, initialSupply])
const renounceMinterCall = m.call(L2GraphToken, 'renounceMinter', [])
const addMinterRewardsManagerCall = m.call(L2GraphToken, 'addMinter', [RewardsManager], { id: 'addMinterRewardsManager' })
const addMinterGatewayCall = m.call(L2GraphToken, 'addMinter', [L2GraphTokenGateway], { id: 'addMinterGateway' })

// No further calls are needed so we can transfer ownership now
const transferOwnershipCall = m.call(GraphToken, 'transferOwnership', [governor], { after: [mintCall, renounceMinterCall, addMinterRewardsManagerCall, addMinterGatewayCall] })
m.call(GraphToken, 'acceptOwnership', [], { from: governor, after: [transferOwnershipCall] })
const transferOwnershipCall = m.call(L2GraphToken, 'transferOwnership', [governor], { after: [mintCall, renounceMinterCall, addMinterRewardsManagerCall, addMinterGatewayCall] })
m.call(L2GraphToken, 'acceptOwnership', [], { from: governor, after: [transferOwnershipCall] })

return { GraphToken }
return { L2GraphToken }
})

export const MigrateGraphTokenModule = buildModule('L2GraphToken', (m) => {
const graphTokenAddress = m.getParameter('graphTokenAddress')

const GraphToken = m.contractAt('L2GraphToken', GraphTokenArtifact, graphTokenAddress)
const L2GraphToken = m.contractAt('L2GraphToken', GraphTokenArtifact, graphTokenAddress)

return { GraphToken }
return { L2GraphToken }
})
10 changes: 5 additions & 5 deletions packages/horizon/ignition/modules/periphery/GraphTokenGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ export default buildModule('L2GraphTokenGateway', (m) => {

const pauseGuardian = m.getParameter('pauseGuardian')

const GraphTokenGateway = deployWithGraphProxy(m, GraphProxyAdmin, {
const L2GraphTokenGateway = deployWithGraphProxy(m, GraphProxyAdmin, {
name: 'L2GraphTokenGateway',
artifact: GraphTokenGatewayArtifact,
initArgs: [Controller],
})
m.call(GraphTokenGateway, 'setPauseGuardian', [pauseGuardian])
m.call(L2GraphTokenGateway, 'setPauseGuardian', [pauseGuardian])

return { GraphTokenGateway }
return { L2GraphTokenGateway }
})

export const MigrateGraphTokenGatewayModule = buildModule('L2GraphTokenGateway', (m) => {
const graphTokenGatewayAddress = m.getParameter('graphTokenGatewayAddress')

const GraphTokenGateway = m.contractAt('L2GraphTokenGateway', GraphTokenGatewayArtifact, graphTokenGatewayAddress)
const L2GraphTokenGateway = m.contractAt('L2GraphTokenGateway', GraphTokenGatewayArtifact, graphTokenGatewayAddress)

return { GraphTokenGateway }
return { L2GraphTokenGateway }
})
20 changes: 10 additions & 10 deletions packages/horizon/ignition/modules/periphery/periphery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export default buildModule('GraphHorizon_Periphery', (m) => {
const { EpochManager } = m.useModule(EpochManagerModule)
const { L2Curation } = m.useModule(CurationModule)
const { RewardsManager } = m.useModule(RewardsManagerModule)
const { GraphTokenGateway } = m.useModule(GraphTokenGatewayModule)
const { GraphToken } = m.useModule(GraphTokenModule)
const { L2GraphTokenGateway } = m.useModule(GraphTokenGatewayModule)
const { L2GraphToken } = m.useModule(GraphTokenModule)

m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('EpochManager')), EpochManager], { id: 'setContractProxy_EpochManager' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('RewardsManager')), RewardsManager], { id: 'setContractProxy_RewardsManager' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphToken')), GraphToken], { id: 'setContractProxy_GraphToken' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphTokenGateway')), GraphTokenGateway], { id: 'setContractProxy_GraphTokenGateway' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphToken')), L2GraphToken], { id: 'setContractProxy_GraphToken' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphTokenGateway')), L2GraphTokenGateway], { id: 'setContractProxy_GraphTokenGateway' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('GraphProxyAdmin')), GraphProxyAdmin], { id: 'setContractProxy_GraphProxyAdmin' })
m.call(Controller, 'setContractProxy', [ethers.keccak256(ethers.toUtf8Bytes('Curation')), L2Curation], { id: 'setContractProxy_L2Curation' })

Expand All @@ -32,8 +32,8 @@ export default buildModule('GraphHorizon_Periphery', (m) => {
EpochManager,
L2Curation,
GraphProxyAdmin,
GraphToken,
GraphTokenGateway,
L2GraphToken,
L2GraphTokenGateway,
RewardsManager,
}
})
Expand All @@ -44,8 +44,8 @@ export const MigratePeripheryModule = buildModule('GraphHorizon_Periphery', (m)
const { Controller } = m.useModule(MigrateControllerDeployerModule)
const { GraphProxyAdmin } = m.useModule(MigrateGraphProxyAdminModule)
const { EpochManager } = m.useModule(MigrateEpochManagerModule)
const { GraphToken } = m.useModule(MigrateGraphTokenModule)
const { GraphTokenGateway } = m.useModule(MigrateGraphTokenGatewayModule)
const { L2GraphToken } = m.useModule(MigrateGraphTokenModule)
const { L2GraphTokenGateway } = m.useModule(MigrateGraphTokenGatewayModule)

// Load these contracts so they are available in the address book

Expand All @@ -55,8 +55,8 @@ export const MigratePeripheryModule = buildModule('GraphHorizon_Periphery', (m)
L2Curation,
L2CurationImplementation,
GraphProxyAdmin,
GraphToken,
GraphTokenGateway,
L2GraphToken,
L2GraphTokenGateway,
RewardsManager,
RewardsManagerImplementation,
}
Expand Down
2 changes: 0 additions & 2 deletions packages/horizon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"@nomicfoundation/ignition-core": "^0.15.9",
"@openzeppelin/contracts": "^5.0.2",
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@tenderly/api-client": "^1.1.0",
"@tenderly/hardhat-tenderly": "^2.5.2",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
Expand Down
Loading
Loading