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

feat: add DeploymentConfig for network specifc deployments #5

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

0x-r4bbit
Copy link
Collaborator

Description

To allow deployment to different chains but using the same deployment scripts, this commit introduces a basic DeploymentConfig which can be extended as necessary in each project.

There's a few things that should be considered:

  • activeNetworkConfig will be initialized via the constructor, at which point it is know what block.chainid is
  • To add new configuration settings, extend NetworkConfig
  • To add a new config for a different chain, extend the if/else block in the constructor so that it creates a NetworkConfig for the chain in question

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran forge snapshot?
  • Ran pnpm lint?
  • Ran forge test?

Copy link

@rymnc rymnc left a comment

Choose a reason for hiding this comment

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

LGTM in general, couple queries

script/DeploymentConfig.s.sol Outdated Show resolved Hide resolved
script/Deploy.s.sol Outdated Show resolved Hide resolved
To allow deployment to different chains but using the same deployment
scripts, this commit introduces a basic `DeploymentConfig` which can be
extended as necessary in each project.

There's a few things that should be considered:

- `activeNetworkConfig` will be initialized via the constructor, at
  which point it is know what `block.chainid` is
- To add new configuration settings, extend `NetworkConfig`
- To add a new config for a different chain, extend the `if/else` block
  in the constructor so that it creates a `NetworkConfig` for the chain
  in question
@0x-r4bbit
Copy link
Collaborator Author

@rymnc take another look :D

Copy link

@rymnc rymnc left a comment

Choose a reason for hiding this comment

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

LGTM


contract Deploy is BaseScript {
function run() public broadcast returns (Foo foo) {
function run() public returns (Foo foo, DeploymentConfig deploymentConfig) {
Copy link

Choose a reason for hiding this comment

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

nice, last question - what does the broadcast keyword specify?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

broadcast is a modifier that wraps the function in vm.startBroadcast() and vm.stopBroadcast().

Anything that happens inside these are tx that are broadcast to the network.
We don't want the instantiation of DeploymentConfig() to happen onchain, we only need it to access our configuration values.

That's why I'm removing the broadcast from the main deploy script's run() function. This gives us control over which action should indeed be broadcast.

Copy link

Choose a reason for hiding this comment

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

nice, okay!

@0x-r4bbit 0x-r4bbit merged commit 013c9b7 into main Sep 7, 2023
3 checks passed
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.

2 participants