Skip to content

Commit

Permalink
build: multi-chain deployment script (#748)
Browse files Browse the repository at this point in the history
* build: add deploy multi chains script

build: remove etherscan api keys in foundry.toml
feat: add deploy core 3 scripts
chore: improve .env.example file

* build: add arbitrum sepolia

chore: git ignore deployments dir

* chore: update wording in scripts

chore: remove forge fmt comment

* refactor: separate base env from deployment env

chore: improve multi-chain deployment script
refactor: rename env var MAX_SEGMENT_COUNT

* refactor: rename multi-chain script

* chore: fix arbitrum config key

* fix: use array to create deployment command

* chore: create an array for deployment command

* Powerful command line options for deployment script (#752)

* build: add script to generate deployment command

* feat: new command-line options for deploy-multi-chain command

* chore: continue for warnings and throw for errors

* perf: polish deployment script

---------

Co-authored-by: Paul Razvan Berg <[email protected]>

* refactor: hard code admin addresses

---------

Co-authored-by: andreivladbrg <[email protected]>
Co-authored-by: smol-ninja <[email protected]>
  • Loading branch information
3 people authored Jan 16, 2024
1 parent b001643 commit 7819a3b
Show file tree
Hide file tree
Showing 7 changed files with 539 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .env.deployment.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Used by the multi-chain deployment script

# General
export MAX_SEGMENT_COUNT="THE_MAX_SEGMENT_COUNT"
export MNEMONIC="YOUR_MNEMONIC"

# RPC URLs
export ARBITRUM_RPC_URL="YOUR_RPC_URL"
export ARBITRUM_SEPOLIA_RPC_URL="YOUR_RPC_URL"
export AVALANCHE_RPC_URL="YOUR_RPC_URL"
export BASE_RPC_URL="YOUR_RPC_URL"
export BSC_RPC_URL="YOUR_RPC_URL"
export GNOSIS_RPC_URL="YOUR_RPC_URL"
export MAINNET_RPC_URL="YOUR_RPC_URL"
export OPTIMISM_RPC_URL="YOUR_RPC_URL"
export POLYGON_RPC_URL="YOUR_RPC_URL"
export SCROLL_RPC_URL="YOUR_RPC_URL"
export SEPOLIA_RPC_URL="YOUR_RPC_URL"

# Etherscan API keys
export ARBISCAN_API_KEY="YOUR_API_KEY"
export BASESCAN_API_KEY="YOUR_API_KEY"
export BSCSCAN_API_KEY="YOUR_API_KEY"
export ETHERSCAN_API_KEY="YOUR_API_KEY"
export GNOSISSCAN_API_KEY="YOUR_API_KEY"
export OPTIMISTIC_API_KEY="YOUR_API_KEY"
export POLYGONSCAN_API_KEY="YOUR_API_KEY"
export SCROLLSCAN_API_KEY="YOUR_API_KEY"
export SNOWTRACE_API_KEY="YOUR_API_KEY"

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ artifacts
broadcast
cache
coverage
deployments
docs
node_modules
out
Expand All @@ -11,6 +12,7 @@ out-svg

# files
*.env
*.env.deployment
*.log
.DS_Store
.pnp.*
Expand Down
35 changes: 35 additions & 0 deletions script/DeployCore3.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.19 <0.9.0;

import { ISablierV2Comptroller } from "../src/interfaces/ISablierV2Comptroller.sol";
import { SablierV2NFTDescriptor } from "../src/SablierV2NFTDescriptor.sol";
import { SablierV2LockupDynamic } from "../src/SablierV2LockupDynamic.sol";
import { SablierV2LockupLinear } from "../src/SablierV2LockupLinear.sol";

import { BaseScript } from "./Base.s.sol";

/// @notice Deploys these contracts in the following order:
///
/// 1. {SablierV2NFTDescriptor}
/// 2. {SablierV2LockupDynamic}
/// 3. {SablierV2LockupLinear}
contract DeployCore3 is BaseScript {
function run(
address initialAdmin,
ISablierV2Comptroller comptroller,
uint256 maxSegmentCount
)
public
virtual
broadcast
returns (
SablierV2NFTDescriptor nftDescriptor,
SablierV2LockupDynamic lockupDynamic,
SablierV2LockupLinear lockupLinear
)
{
nftDescriptor = new SablierV2NFTDescriptor();
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupLinear = new SablierV2LockupLinear(initialAdmin, comptroller, nftDescriptor);
}
}
1 change: 0 additions & 1 deletion script/DeployDeterministicCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ contract DeployDeterministicCore is BaseScript {
bytes32 salt = bytes32(abi.encodePacked(create2Salt));
comptroller = new SablierV2Comptroller{ salt: salt }(initialAdmin);
nftDescriptor = new SablierV2NFTDescriptor{ salt: salt }();
// forgefmt: disable-next-line
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupLinear = new SablierV2LockupLinear{ salt: salt }(initialAdmin, comptroller, nftDescriptor);
Expand Down
1 change: 0 additions & 1 deletion script/DeployDeterministicCore2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ contract DeployDeterministicCore2 is BaseScript {
{
bytes32 salt = bytes32(abi.encodePacked(create2Salt));
comptroller = new SablierV2Comptroller{ salt: salt }(initialAdmin);
// forgefmt: disable-next-line
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupLinear = new SablierV2LockupLinear{ salt: salt }(initialAdmin, comptroller, nftDescriptor);
Expand Down
42 changes: 42 additions & 0 deletions script/DeployDeterministicCore3.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.19 <0.9.0;

import { ISablierV2Comptroller } from "../src/interfaces/ISablierV2Comptroller.sol";
import { SablierV2NFTDescriptor } from "../src/SablierV2NFTDescriptor.sol";
import { SablierV2LockupDynamic } from "../src/SablierV2LockupDynamic.sol";
import { SablierV2LockupLinear } from "../src/SablierV2LockupLinear.sol";

import { BaseScript } from "./Base.s.sol";

/// @notice Deploys these contracts at deterministic addresses across chains, in the following order:
///
/// 1. {SablierV2NFTDescriptor}
/// 2. {SablierV2LockupDynamic}
/// 3. {SablierV2LockupLinear}
///
/// @dev Reverts if any contract has already been deployed.
contract DeployDeterministicCore3 is BaseScript {
/// @dev The presence of the salt instructs Forge to deploy the contract via a deterministic CREATE2 factory.
/// https://github.com/Arachnid/deterministic-deployment-proxy
function run(
string memory create2Salt,
address initialAdmin,
ISablierV2Comptroller comptroller,
uint256 maxSegmentCount
)
public
virtual
broadcast
returns (
SablierV2NFTDescriptor nftDescriptor,
SablierV2LockupDynamic lockupDynamic,
SablierV2LockupLinear lockupLinear
)
{
bytes32 salt = bytes32(abi.encodePacked(create2Salt));
nftDescriptor = new SablierV2NFTDescriptor{ salt: salt }();
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupLinear = new SablierV2LockupLinear{ salt: salt }(initialAdmin, comptroller, nftDescriptor);
}
}
Loading

0 comments on commit 7819a3b

Please sign in to comment.