Skip to content
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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented Jan 3, 2025

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.

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.
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,
Copy link
Contributor Author

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

hardhat.config.ts Outdated Show resolved Hide resolved
accounts: { mnemonic },
companionNetworks: { l1: "mainnet" },
},
...networks, // autogenerated
},
gasReporter: { enabled: process.env.REPORT_GAS !== undefined, currency: "USD" },
etherscan: {
Copy link
Contributor Author

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.

.filter((chainId) => PUBLIC_NETWORKS[chainId] !== undefined)
.map((chainId) => {
const network = PUBLIC_NETWORKS[chainId];
const name = network.name.replace(" ", "").toLowerCase();
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant