-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1094 from graphprotocol/tmigone/tooling-improvements
- Loading branch information
Showing
17 changed files
with
184 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/hardhat-graph-protocol/src/sdk/hardhat.base.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { vars } from 'hardhat/config' | ||
|
||
import type { HardhatUserConfig, NetworksUserConfig, ProjectPathsUserConfig, SolidityUserConfig } from 'hardhat/types' | ||
import type { EtherscanConfig } from '@nomicfoundation/hardhat-verify/types' | ||
|
||
// This next import ensures secure accounts config is correctly typed | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import type { SecureAccountsOptions } from 'hardhat-secure-accounts/src/type-extensions' | ||
|
||
// Environment variables | ||
const ARBISCAN_API_KEY = vars.get('ARBISCAN_API_KEY', undefined) | ||
|
||
// RPCs | ||
const VIRTUAL_ARBITRUM_SEPOLIA_RPC = vars.has('VIRTUAL_ARBITRUM_SEPOLIA_RPC') ? vars.get('VIRTUAL_ARBITRUM_SEPOLIA_RPC') : undefined | ||
const ARBITRUM_SEPOLIA_RPC = vars.get('ARBITRUM_SEPOLIA_RPC', 'https://sepolia-rollup.arbitrum.io/rpc') | ||
|
||
// Accounts | ||
const DEPLOYER_PRIVATE_KEY = vars.get('DEPLOYER_PRIVATE_KEY', undefined) | ||
const GOVERNOR_PRIVATE_KEY = vars.get('GOVERNOR_PRIVATE_KEY', undefined) | ||
const getTestnetAccounts = () => { | ||
const accounts: string[] = [] | ||
if (DEPLOYER_PRIVATE_KEY) accounts.push(DEPLOYER_PRIVATE_KEY) | ||
if (GOVERNOR_PRIVATE_KEY) accounts.push(GOVERNOR_PRIVATE_KEY) | ||
return accounts.length > 0 ? accounts : undefined | ||
} | ||
const getHardhatAccounts = () => { | ||
return { | ||
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect', | ||
} | ||
} | ||
|
||
export const solidityUserConfig: SolidityUserConfig = { | ||
version: '0.8.27', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 1, | ||
}, | ||
}, | ||
} | ||
|
||
export const projectPathsUserConfig: ProjectPathsUserConfig = { | ||
artifacts: './build/contracts', | ||
sources: './contracts', | ||
} | ||
|
||
export const etherscanUserConfig: Partial<EtherscanConfig> = { | ||
apiKey: { | ||
arbitrumSepolia: ARBISCAN_API_KEY, | ||
}, | ||
customChains: [ | ||
{ | ||
network: 'arbitrumSepolia', | ||
chainId: 421614, | ||
urls: { apiURL: 'https://api-sepolia.arbiscan.io/api', browserURL: 'https://sepolia.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 = { | ||
hardhat: { | ||
chainId: 31337, | ||
accounts: getHardhatAccounts(), | ||
}, | ||
localhost: { | ||
chainId: 31337, | ||
url: 'http://localhost:8545', | ||
accounts: getTestnetAccounts(), | ||
}, | ||
arbitrumSepolia: { | ||
chainId: 421614, | ||
url: ARBITRUM_SEPOLIA_RPC, | ||
secureAccounts: { | ||
enabled: true, | ||
}, | ||
}, | ||
...(VIRTUAL_ARBITRUM_SEPOLIA_RPC && { | ||
virtualArbitrumSepolia: { | ||
chainId: 421615, | ||
url: VIRTUAL_ARBITRUM_SEPOLIA_RPC, | ||
accounts: getTestnetAccounts(), | ||
}, | ||
}), | ||
} | ||
|
||
export const hardhatBaseConfig: HardhatUserConfig & { etherscan: Partial<EtherscanConfig> } = { | ||
solidity: solidityUserConfig, | ||
paths: projectPathsUserConfig, | ||
secureAccounts: { | ||
enabled: false, | ||
}, | ||
networks: networksUserConfig, | ||
graph: { | ||
deployments: { | ||
horizon: { | ||
addressBook: 'addresses.json', | ||
}, | ||
}, | ||
}, | ||
etherscan: etherscanUserConfig, | ||
} | ||
|
||
export default hardhatBaseConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { loadConfig, saveAddressBook } from './ignition/ignition' | ||
import { hardhatBaseConfig } from './hardhat.base.config' | ||
|
||
export const IgnitionHelper = { saveAddressBook, loadConfig } | ||
const IgnitionHelper = { saveAddressBook, loadConfig } | ||
export { hardhatBaseConfig, IgnitionHelper } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,15 @@ | ||
import { vars } from 'hardhat/config' | ||
|
||
import type { HardhatUserConfig } from 'hardhat/config' | ||
import { hardhatBaseConfig } from 'hardhat-graph-protocol/sdk' | ||
|
||
// 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' | ||
|
||
// Environment variables | ||
const ETHERSCAN_API_KEY = vars.get('ETHERSCAN_API_KEY', '') | ||
const ARBITRUM_VIRTUAL_TESTNET_URL = vars.get('ARBITRUM_VIRTUAL_TESTNET_URL', '') | ||
const DEPLOYER_PRIVATE_KEY = vars.get('DEPLOYER_PRIVATE_KEY') | ||
const GOVERNOR_PRIVATE_KEY = vars.get('GOVERNOR_PRIVATE_KEY') | ||
|
||
const getNetworkAccounts = () => { | ||
const accounts: string[] = [] | ||
if (vars.has('DEPLOYER_PRIVATE_KEY')) accounts.push(DEPLOYER_PRIVATE_KEY) | ||
if (vars.has('GOVERNOR_PRIVATE_KEY')) accounts.push(GOVERNOR_PRIVATE_KEY) | ||
return accounts.length > 0 ? accounts : undefined | ||
} | ||
|
||
if (process.env.BUILD_RUN !== 'true') { | ||
require('hardhat-graph-protocol') | ||
} | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: { | ||
version: '0.8.27', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 1, | ||
}, | ||
}, | ||
}, | ||
paths: { | ||
artifacts: './build/contracts', | ||
sources: './contracts', | ||
}, | ||
secureAccounts: { | ||
enabled: false, | ||
}, | ||
networks: { | ||
hardhat: { | ||
chainId: 31337, | ||
accounts: { | ||
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect', | ||
}, | ||
}, | ||
localhost: { | ||
chainId: 31337, | ||
url: 'http://localhost:8545', | ||
accounts: getNetworkAccounts(), | ||
}, | ||
arbitrumSepolia: { | ||
chainId: 421614, | ||
secureAccounts: { | ||
enabled: true, | ||
}, | ||
url: 'https://sepolia-rollup.arbitrum.io/rpc', | ||
}, | ||
arbitrumVirtualTestnet: { | ||
chainId: 421615, | ||
url: ARBITRUM_VIRTUAL_TESTNET_URL, | ||
accounts: getNetworkAccounts(), | ||
}, | ||
}, | ||
tenderly: { | ||
project: 'graph-network', | ||
username: 'graphprotocol', | ||
}, | ||
graph: { | ||
deployments: { | ||
horizon: { | ||
addressBook: 'addresses.json', | ||
}, | ||
}, | ||
}, | ||
etherscan: { | ||
apiKey: { | ||
arbitrumSepolia: ETHERSCAN_API_KEY, | ||
}, | ||
customChains: [ | ||
{ | ||
network: 'arbitrumSepolia', | ||
chainId: 421614, | ||
urls: { | ||
apiURL: 'https://api-sepolia.arbiscan.io/api', | ||
browserURL: 'https://sepolia.arbiscan.io/', | ||
}, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export default config | ||
export default hardhatBaseConfig |
3 changes: 1 addition & 2 deletions
3
...on/ignition/configs/horizon.hardhat.json5 → ...on/ignition/configs/horizon.default.json5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.