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 1 commit 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

};

// zkSync is a special snowflake.
if ([CHAIN_IDs.ZK_SYNC, CHAIN_IDs.ZK_SYNC_SEPOLIA].includes(chainId)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would need to add Lens to this list. zkSync tooling is really annoying :\

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.

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