-
Notifications
You must be signed in to change notification settings - Fork 56
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
improve(hardhat): Autogenerate network config #833
base: master
Are you sure you want to change the base?
Conversation
Network config can be derived from the common network definitions that already exist upstream in the constants repository. This saves time when adding new chains and reduces duplication.
hardhat.config.ts
Outdated
const name = network.name.replace(" ", "").toLowerCase(); | ||
const hubChainId = Object.values(MAINNET_CHAIN_IDs).includes(chainId) ? CHAIN_IDs.MAINNET : CHAIN_IDs.SEPOLIA; | ||
const chainDef = { | ||
url: network.publicRPC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nb. depends on this PR: across-protocol/constants#88
accounts: { mnemonic }, | ||
companionNetworks: { l1: "mainnet" }, | ||
}, | ||
...networks, // autogenerated | ||
}, | ||
gasReporter: { enabled: process.env.REPORT_GAS !== undefined, currency: "USD" }, | ||
etherscan: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be interested to see if we can autogenerate some of this config as well.
hardhat.config.ts
Outdated
.filter((chainId) => PUBLIC_NETWORKS[chainId] !== undefined) | ||
.map((chainId) => { | ||
const network = PUBLIC_NETWORKS[chainId]; | ||
const name = network.name.replace(" ", "").toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nb. might need to add some special handling for the -sepolia
chains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 61f2d29 I reverted to using the chainId as the network key, rather than a symbolic name. The problem with symbolic names is that we have no consistent naming scheme for the various networks. Chain IDs are at least universally consistent and don't impose decisions like whether to hyphenate spaces or not.
Network config can be derived from the common network definitions that already exist upstream in the constants repository. This saves time when adding new chains and reduces duplication.