Skip to content

Commit

Permalink
Allow Specifying CREATE3 Deployer in Protocol Deployment Script (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will authored Nov 28, 2024
1 parent 8cc0211 commit de2858b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
12 changes: 8 additions & 4 deletions script/foundry/deployment/Main.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ contract Main is DeployHelper {
constructor()
DeployHelper(
ERC6551_REGISTRY,
CREATE3_DEPLOYER,
address(0), // replaced with USDC in DeployHelper.sol
ARBITRATION_PRICE,
MAX_ROYALTY_APPROVAL,
Expand All @@ -35,16 +34,21 @@ contract Main is DeployHelper {
/// forge script script/foundry/deployment/Main.s.sol:Main --rpc-url $RPC_URL --broadcast --verify -vvvv

function run() public virtual {
_run(CREATE3_DEFAULT_SEED);
_run(CREATE3_DEPLOYER, CREATE3_DEFAULT_SEED);
}

function run(uint256 seed) public {
_run(seed);
_run(CREATE3_DEPLOYER, seed);
}

function _run(uint256 seed) internal {
function run(address create3Deployer, uint256 seed) public {
_run(create3Deployer, seed);
}

function _run(address create3Deployer, uint256 seed) internal {
// deploy all contracts via DeployHelper
super.run(
create3Deployer,
seed, // create3 seed
false, // runStorageLayoutCheck
true, // writeDeployments,
Expand Down
7 changes: 3 additions & 4 deletions script/foundry/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
error RoleConfigError(string message);

ERC6551Registry internal immutable erc6551Registry;
ICreate3Deployer internal immutable create3Deployer;
ICreate3Deployer internal create3Deployer;
// seed for CREATE3 salt
uint256 internal create3SaltSeed;
IPAccountImpl internal ipAccountImpl;
Expand Down Expand Up @@ -132,15 +132,13 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag

constructor(
address erc6551Registry_,
address create3Deployer_,
address erc20_,
uint256 arbitrationPrice_,
uint256 maxRoyaltyApproval_,
address treasury_,
address ipGraphACL_
) JsonDeploymentHandler("main") {
erc6551Registry = ERC6551Registry(erc6551Registry_);
create3Deployer = ICreate3Deployer(create3Deployer_);
erc20 = ERC20(erc20_);
MAX_ROYALTY_APPROVAL = maxRoyaltyApproval_;
TREASURY_ADDRESS = treasury_;
Expand All @@ -162,7 +160,8 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
/// @dev To use, run the following command (e.g. for Sepolia):
/// forge script script/foundry/deployment/Main.s.sol:Main --rpc-url $RPC_URL --broadcast --verify -vvvv

function run(uint256 create3SaltSeed_, bool runStorageLayoutCheck, bool writeDeploys_, string memory version_) public virtual {
function run(address create3Deployer_, uint256 create3SaltSeed_, bool runStorageLayoutCheck, bool writeDeploys_, string memory version_) public virtual {
create3Deployer = ICreate3Deployer(create3Deployer_);
create3SaltSeed = create3SaltSeed_;
writeDeploys = writeDeploys_;
version = version_;
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/utils/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ contract BaseTest is Test, DeployHelper, LicensingHelper {
constructor()
DeployHelper(
address(ERC6551_REGISTRY),
address(CREATE3_DEPLOYER),
address(erc20),
ARBITRATION_PRICE,
MAX_ROYALTY_APPROVAL,
Expand All @@ -83,6 +82,7 @@ contract BaseTest is Test, DeployHelper, LicensingHelper {

// deploy all contracts via DeployHelper
super.run(
address(CREATE3_DEPLOYER),
CREATE3_DEFAULT_SEED,
false, // runStorageLayoutCheck
false, // writeDeploys
Expand Down

0 comments on commit de2858b

Please sign in to comment.