From 972c20154a32b10b37703c297d4f9c76860ded9f Mon Sep 17 00:00:00 2001 From: Kingter <83567446+kingster-will@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:35:33 -0700 Subject: [PATCH] Support Consistent Address Deployment Across Networks (#132) * forge install: create3-deployer * Deployed with pre-deployed Create3Deployer * Fix OZ upgrade check warning * Deploy contracts to unified/same addresses across all chains --- .gitmodules | 3 + contracts/LicenseToken.sol | 2 + contracts/access/AccessController.sol | 2 + .../modules/licensing/LicensingModule.sol | 2 + contracts/registries/LicenseRegistry.sol | 2 + lib/create3-deployer | 1 + package.json | 3 +- remappings.txt | 2 +- script/foundry/deployment/Main.s.sol | 13 +- script/foundry/utils/DeployHelper.sol | 142 ++++++++++++++++-- .../mocks/module/MockAccessControllerV2.sol | 1 + test/foundry/utils/BaseTest.t.sol | 14 +- test/foundry/utils/Create3Deployer.sol | 14 -- test/foundry/utils/TestProxyHelper.sol | 11 +- yarn.lock | 5 - 15 files changed, 177 insertions(+), 40 deletions(-) create mode 160000 lib/create3-deployer delete mode 100644 test/foundry/utils/Create3Deployer.sol diff --git a/.gitmodules b/.gitmodules index 9e88c822..9b90486a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/openzeppelin-foundry-upgrades"] path = lib/openzeppelin-foundry-upgrades url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades +[submodule "lib/create3-deployer"] + path = lib/create3-deployer + url = https://github.com/storyprotocol/create3-deployer diff --git a/contracts/LicenseToken.sol b/contracts/LicenseToken.sol index b01b619a..f4973bc1 100644 --- a/contracts/LicenseToken.sol +++ b/contracts/LicenseToken.sol @@ -19,7 +19,9 @@ import { ILicenseTemplate } from "./interfaces/modules/licensing/ILicenseTemplat contract LicenseToken is ILicenseToken, ERC721EnumerableUpgradeable, AccessManagedUpgradeable, UUPSUpgradeable { using Strings for *; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable ILicensingModule public immutable LICENSING_MODULE; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IDisputeModule public immutable DISPUTE_MODULE; /// @notice Emitted for metadata updates, per EIP-4906 diff --git a/contracts/access/AccessController.sol b/contracts/access/AccessController.sol index 2224853b..a54cad95 100644 --- a/contracts/access/AccessController.sol +++ b/contracts/access/AccessController.sol @@ -32,7 +32,9 @@ import { Errors } from "../lib/Errors.sol"; contract AccessController is IAccessController, ProtocolPausableUpgradeable, UUPSUpgradeable { using IPAccountChecker for IIPAccountRegistry; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IIPAccountRegistry public immutable IP_ACCOUNT_REGISTRY; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IModuleRegistry public immutable MODULE_REGISTRY; /// @dev The storage struct of AccessController. diff --git a/contracts/modules/licensing/LicensingModule.sol b/contracts/modules/licensing/LicensingModule.sol index 6815b53d..bb5000fa 100644 --- a/contracts/modules/licensing/LicensingModule.sol +++ b/contracts/modules/licensing/LicensingModule.sol @@ -67,6 +67,8 @@ contract LicensingModule is /// @custom:oz-upgrades-unsafe-allow state-variable-immutable ILicenseToken public immutable LICENSE_NFT; + /// @notice Returns the protocol-wide ModuleRegistry + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IModuleRegistry public immutable MODULE_REGISTRY; // keccak256(abi.encode(uint256(keccak256("story-protocol.LicensingModule")) - 1)) & ~bytes32(uint256(0xff)); diff --git a/contracts/registries/LicenseRegistry.sol b/contracts/registries/LicenseRegistry.sol index e8f74046..b6637513 100644 --- a/contracts/registries/LicenseRegistry.sol +++ b/contracts/registries/LicenseRegistry.sol @@ -28,7 +28,9 @@ contract LicenseRegistry is ILicenseRegistry, AccessManagedUpgradeable, UUPSUpgr using EnumerableSet for EnumerableSet.AddressSet; using IPAccountStorageOps for IIPAccount; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable ILicensingModule public immutable LICENSING_MODULE; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable IDisputeModule public immutable DISPUTE_MODULE; /// @dev Storage of the LicenseRegistry diff --git a/lib/create3-deployer b/lib/create3-deployer new file mode 160000 index 00000000..a044ab56 --- /dev/null +++ b/lib/create3-deployer @@ -0,0 +1 @@ +Subproject commit a044ab56d8a80f30d1ce835cd50cafb9a647188f diff --git a/package.json b/package.json index 92675f6b..8dc1b78e 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,6 @@ "@openzeppelin/contracts": "5.0.2", "@openzeppelin/contracts-upgradeable": "5.0.2", "@openzeppelin/contracts-upgradeable-v4": "npm:@openzeppelin/contracts-upgradeable@4.9.6", - "erc6551": "^0.3.1", - "solady": "^0.0.191" + "erc6551": "^0.3.1" } } diff --git a/remappings.txt b/remappings.txt index 2359244d..c7c20eb8 100644 --- a/remappings.txt +++ b/remappings.txt @@ -2,4 +2,4 @@ ds-test/=node_modules/ds-test/src/ forge-std/=node_modules/forge-std/src/ @openzeppelin/=node_modules/@openzeppelin/ @openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades -@solady/=node_modules/solady/ \ No newline at end of file +@create3-deployer/=lib/create3-deployer \ No newline at end of file diff --git a/script/foundry/deployment/Main.s.sol b/script/foundry/deployment/Main.s.sol index 8c8f6a88..baae62e6 100644 --- a/script/foundry/deployment/Main.s.sol +++ b/script/foundry/deployment/Main.s.sol @@ -9,6 +9,8 @@ import { DeployHelper } from "../utils/DeployHelper.sol"; contract Main is DeployHelper { address internal ERC6551_REGISTRY = 0x000000006551c19487814612e58FE06813775758; + address internal CREATE3_DEPLOYER = 0x384a891dFDE8180b054f04D66379f16B7a678Ad6; + uint256 internal CREATE3_DEFAULT_SEED = 0; // For arbitration policy uint256 internal constant ARBITRATION_PRICE = 1000 * 10 ** 6; // 1000 USDC // For royalty policy @@ -17,6 +19,7 @@ contract Main is DeployHelper { constructor() DeployHelper( ERC6551_REGISTRY, + CREATE3_DEPLOYER, address(0), // replaced with USDC in DeployHelper.sol ARBITRATION_PRICE, MAX_ROYALTY_APPROVAL @@ -27,12 +30,20 @@ contract Main is DeployHelper { /// forge script script/foundry/deployment/Main.s.sol:Main --rpc-url $RPC_URL --broadcast --verify -vvvv function run() public virtual override { + _run(CREATE3_DEFAULT_SEED); + } + + function run(uint256 seed) public { + _run(seed); + } + + function _run(uint256 seed) internal { // deploy all contracts via DeployHelper super.run( + seed, // create3 seed true, // runStorageLayoutCheck true // writeDeployments ); _writeDeployment(); // write deployment json to deployments/deployment-{chainId}.json - _endBroadcast(); // BroadcastManager.s.sol } } diff --git a/script/foundry/utils/DeployHelper.sol b/script/foundry/utils/DeployHelper.sol index e1d12dff..1aebeac6 100644 --- a/script/foundry/utils/DeployHelper.sol +++ b/script/foundry/utils/DeployHelper.sol @@ -52,7 +52,7 @@ import { JsonDeploymentHandler } from "./JsonDeploymentHandler.s.sol"; // test import { TestProxyHelper } from "test/foundry/utils/TestProxyHelper.sol"; -import { Create3Deployer } from "test/foundry/utils/Create3Deployer.sol"; +import { ICreate3Deployer } from "@create3-deployer/contracts/ICreate3Deployer.sol"; contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, StorageLayoutChecker { using StringUtil for uint256; @@ -64,6 +64,9 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag error RoleConfigError(string message); ERC6551Registry internal immutable erc6551Registry; + ICreate3Deployer internal immutable create3Deployer; + // seed for CREATE3 salt + uint256 internal create3SaltSeed; IPAccountImpl internal ipAccountImpl; // Registry @@ -110,11 +113,13 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag constructor( address erc6551Registry_, + address create3Deployer_, address erc20_, uint256 arbitrationPrice_, uint256 maxRoyaltyApproval_ ) JsonDeploymentHandler("main") { erc6551Registry = ERC6551Registry(erc6551Registry_); + create3Deployer = ICreate3Deployer(create3Deployer_); erc20 = ERC20(erc20_); ARBITRATION_PRICE = arbitrationPrice_; MAX_ROYALTY_APPROVAL = maxRoyaltyApproval_; @@ -129,7 +134,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(bool runStorageLayoutCheck, bool writeDeploys_) public virtual { + function run(uint256 create3SaltSeed_, bool runStorageLayoutCheck, bool writeDeploys_) public virtual { + create3SaltSeed = create3SaltSeed_; writeDeploys = writeDeploys_; // This will run OZ storage layout check for all contracts. Requires --ffi flag. @@ -165,15 +171,32 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag require(address(erc20) != address(0), "Deploy: Asset Not Set"); string memory contractKey; // Core Protocol Contracts - contractKey = "ProtocolAccessManager"; _predeploy(contractKey); - protocolAccessManager = new AccessManager(deployer); + protocolAccessManager = AccessManager( + create3Deployer.deploy( + _getSalt(type(AccessManager).name), + abi.encodePacked(type(AccessManager).creationCode, abi.encode(deployer)) + ) + ); + require( + _getDeployedAddress(type(AccessManager).name) == address(protocolAccessManager), + "Deploy: Protocol Access Manager Address Mismatch" + ); _postdeploy(contractKey, address(protocolAccessManager)); contractKey = "ProtocolPauseAdmin"; _predeploy(contractKey); - protocolPauser = new ProtocolPauseAdmin(address(protocolAccessManager)); + protocolPauser = ProtocolPauseAdmin( + create3Deployer.deploy( + _getSalt(type(ProtocolPauseAdmin).name), + abi.encodePacked(type(ProtocolPauseAdmin).creationCode, abi.encode(address(protocolAccessManager))) + ) + ); + require( + _getDeployedAddress(type(ProtocolPauseAdmin).name) == address(protocolPauser), + "Deploy: Protocol Pause Admin Address Mismatch" + ); _postdeploy(contractKey, address(protocolPauser)); contractKey = "ModuleRegistry"; @@ -181,10 +204,17 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag address impl = address(new ModuleRegistry()); moduleRegistry = ModuleRegistry( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(ModuleRegistry).name), impl, abi.encodeCall(ModuleRegistry.initialize, address(protocolAccessManager)) ) ); + require( + _getDeployedAddress(type(ModuleRegistry).name) == address(moduleRegistry), + "Deploy: Module Registry Address Mismatch" + ); + require(_loadProxyImpl(address(moduleRegistry)) == impl, "ModuleRegistry Proxy Implementation Mismatch"); impl = address(0); // Make sure we don't deploy wrong impl _postdeploy(contractKey, address(moduleRegistry)); @@ -193,10 +223,17 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag impl = address(new IPAssetRegistry(address(erc6551Registry), _getDeployedAddress(type(IPAccountImpl).name))); ipAssetRegistry = IPAssetRegistry( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(IPAssetRegistry).name), impl, abi.encodeCall(IPAssetRegistry.initialize, address(protocolAccessManager)) ) ); + require( + _getDeployedAddress(type(IPAssetRegistry).name) == address(ipAssetRegistry), + "Deploy: IP Asset Registry Address Mismatch" + ); + require(_loadProxyImpl(address(ipAssetRegistry)) == impl, "IPAssetRegistry Proxy Implementation Mismatch"); impl = address(0); // Make sure we don't deploy wrong impl _postdeploy(contractKey, address(ipAssetRegistry)); @@ -207,10 +244,17 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag impl = address(new AccessController(address(ipAssetRegistry), address(moduleRegistry))); accessController = AccessController( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(AccessController).name), impl, abi.encodeCall(AccessController.initialize, address(protocolAccessManager)) ) ); + require( + _getDeployedAddress(type(AccessController).name) == address(accessController), + "Deploy: Access Controller Address Mismatch" + ); + require(_loadProxyImpl(address(accessController)) == impl, "AccessController Proxy Implementation Mismatch"); impl = address(0); // Make sure we don't deploy wrong impl _postdeploy(contractKey, address(accessController)); @@ -224,6 +268,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ); licenseRegistry = LicenseRegistry( TestProxyHelper.deployUUPSProxy( + create3Deployer, _getSalt(type(LicenseRegistry).name), impl, abi.encodeCall(LicenseRegistry.initialize, (address(protocolAccessManager))) @@ -249,7 +294,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ); _predeploy(contractKey); ipAccountImpl = IPAccountImpl( - payable(Create3Deployer.deploy(_getSalt(type(IPAccountImpl).name), ipAccountImplCode)) + payable(create3Deployer.deploy(_getSalt(type(IPAccountImpl).name), ipAccountImplCode)) ); _postdeploy(contractKey, address(ipAccountImpl)); require( @@ -264,6 +309,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ); disputeModule = DisputeModule( TestProxyHelper.deployUUPSProxy( + create3Deployer, _getSalt(type(DisputeModule).name), impl, abi.encodeCall(DisputeModule.initialize, address(protocolAccessManager)) @@ -288,10 +334,17 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ); royaltyModule = RoyaltyModule( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(RoyaltyModule).name), impl, abi.encodeCall(RoyaltyModule.initialize, address(protocolAccessManager)) ) ); + require( + _getDeployedAddress(type(RoyaltyModule).name) == address(royaltyModule), + "Deploy: Royalty Module Address Mismatch" + ); + require(_loadProxyImpl(address(royaltyModule)) == impl, "RoyaltyModule Proxy Implementation Mismatch"); impl = address(0); _postdeploy(contractKey, address(royaltyModule)); @@ -310,6 +363,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ); licensingModule = LicensingModule( TestProxyHelper.deployUUPSProxy( + create3Deployer, _getSalt(type(LicensingModule).name), impl, abi.encodeCall(LicensingModule.initialize, address(protocolAccessManager)) @@ -328,6 +382,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag impl = address(new LicenseToken(address(licensingModule), address(disputeModule))); licenseToken = LicenseToken( TestProxyHelper.deployUUPSProxy( + create3Deployer, _getSalt(type(LicenseToken).name), impl, abi.encodeCall( @@ -355,10 +410,20 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag impl = address(new ArbitrationPolicySP(address(disputeModule), address(erc20), ARBITRATION_PRICE)); arbitrationPolicySP = ArbitrationPolicySP( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(ArbitrationPolicySP).name), impl, abi.encodeCall(ArbitrationPolicySP.initialize, address(protocolAccessManager)) ) ); + require( + _getDeployedAddress(type(ArbitrationPolicySP).name) == address(arbitrationPolicySP), + "Deploy: Arbitration Policy Address Mismatch" + ); + require( + _loadProxyImpl(address(arbitrationPolicySP)) == impl, + "ArbitrationPolicySP Proxy Implementation Mismatch" + ); impl = address(0); _postdeploy("ArbitrationPolicySP", address(arbitrationPolicySP)); @@ -366,10 +431,17 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag impl = address(new RoyaltyPolicyLAP(address(royaltyModule), address(licensingModule))); royaltyPolicyLAP = RoyaltyPolicyLAP( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(RoyaltyPolicyLAP).name), impl, abi.encodeCall(RoyaltyPolicyLAP.initialize, address(protocolAccessManager)) ) ); + require( + _getDeployedAddress(type(RoyaltyPolicyLAP).name) == address(royaltyPolicyLAP), + "Deploy: Royalty Policy Address Mismatch" + ); + require(_loadProxyImpl(address(royaltyPolicyLAP)) == impl, "RoyaltyPolicyLAP Proxy Implementation Mismatch"); impl = address(0); _postdeploy("RoyaltyPolicyLAP", address(royaltyPolicyLAP)); @@ -384,6 +456,8 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ); pilTemplate = PILicenseTemplate( TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(PILicenseTemplate).name), impl, abi.encodeCall( PILicenseTemplate.initialize, @@ -395,28 +469,70 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag ) ) ); + require( + _getDeployedAddress(type(PILicenseTemplate).name) == address(pilTemplate), + "Deploy: PI License Template Address Mismatch" + ); + require(_loadProxyImpl(address(pilTemplate)) == impl, "PILicenseTemplate Proxy Implementation Mismatch"); impl = address(0); _postdeploy("PILicenseTemplate", address(pilTemplate)); _predeploy("IpRoyaltyVaultImpl"); - ipRoyaltyVaultImpl = new IpRoyaltyVault(address(royaltyPolicyLAP), address(disputeModule)); + ipRoyaltyVaultImpl = IpRoyaltyVault( + create3Deployer.deploy( + _getSalt(type(IpRoyaltyVault).name), + abi.encodePacked( + type(IpRoyaltyVault).creationCode, + abi.encode(address(royaltyPolicyLAP), address(disputeModule)) + ) + ) + ); _postdeploy("IpRoyaltyVaultImpl", address(ipRoyaltyVaultImpl)); _predeploy("IpRoyaltyVaultBeacon"); // Transfer Ownership to RoyaltyPolicyLAP later - ipRoyaltyVaultBeacon = new UpgradeableBeacon(address(ipRoyaltyVaultImpl), deployer); + ipRoyaltyVaultBeacon = UpgradeableBeacon( + create3Deployer.deploy( + _getSalt(type(UpgradeableBeacon).name), + abi.encodePacked(type(UpgradeableBeacon).creationCode, abi.encode(address(ipRoyaltyVaultImpl), deployer)) + ) + ); _postdeploy("IpRoyaltyVaultBeacon", address(ipRoyaltyVaultBeacon)); _predeploy("CoreMetadataModule"); - coreMetadataModule = new CoreMetadataModule(address(accessController), address(ipAssetRegistry)); + coreMetadataModule = CoreMetadataModule( + create3Deployer.deploy( + _getSalt(type(CoreMetadataModule).name), + abi.encodePacked( + type(CoreMetadataModule).creationCode, + abi.encode(address(accessController), address(ipAssetRegistry)) + ) + ) + ); _postdeploy("CoreMetadataModule", address(coreMetadataModule)); _predeploy("CoreMetadataViewModule"); - coreMetadataViewModule = new CoreMetadataViewModule(address(ipAssetRegistry), address(moduleRegistry)); + coreMetadataViewModule = CoreMetadataViewModule( + create3Deployer.deploy( + _getSalt(type(CoreMetadataViewModule).name), + abi.encodePacked( + type(CoreMetadataViewModule).creationCode, + abi.encode(address(ipAssetRegistry), address(moduleRegistry)) + ) + ) + ); _postdeploy("CoreMetadataViewModule", address(coreMetadataViewModule)); _predeploy("TokenWithdrawalModule"); - tokenWithdrawalModule = new TokenWithdrawalModule(address(accessController), address(ipAccountRegistry)); + tokenWithdrawalModule = TokenWithdrawalModule( + create3Deployer.deploy( + _getSalt(type(TokenWithdrawalModule).name), + abi.encodePacked( + type(TokenWithdrawalModule).creationCode, + abi.encode(address(accessController), address(ipAccountRegistry)) + ) + ) + ); _postdeploy("TokenWithdrawalModule", address(tokenWithdrawalModule)); } @@ -546,12 +662,12 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag /// @dev get the salt for the contract deployment with CREATE3 function _getSalt(string memory name) private view returns (bytes32 salt) { - salt = keccak256(abi.encode(name, block.number)); + salt = keccak256(abi.encode(name, create3SaltSeed)); } /// @dev Get the deterministic deployed address of a contract with CREATE3 function _getDeployedAddress(string memory name) private view returns (address) { - return Create3Deployer.getDeployed(_getSalt(name)); + return create3Deployer.getDeployed(_getSalt(name)); } /// @dev Load the implementation address from the proxy contract diff --git a/test/foundry/mocks/module/MockAccessControllerV2.sol b/test/foundry/mocks/module/MockAccessControllerV2.sol index d0be4f18..9457b42b 100644 --- a/test/foundry/mocks/module/MockAccessControllerV2.sol +++ b/test/foundry/mocks/module/MockAccessControllerV2.sol @@ -14,6 +14,7 @@ contract MockAccessControllerV2 is AccessController { bytes32 private constant AccessControllerV2StorageLocation = 0xf328f2cdee4ae4df23921504bfa43e3156fb4d18b23549ca0a43fd1e64947a00; + /// @custom:oz-upgrades-unsafe-allow constructor constructor( address ipAccountRegistry, address moduleRegistry diff --git a/test/foundry/utils/BaseTest.t.sol b/test/foundry/utils/BaseTest.t.sol index 7b8081c7..753508fd 100644 --- a/test/foundry/utils/BaseTest.t.sol +++ b/test/foundry/utils/BaseTest.t.sol @@ -5,6 +5,7 @@ pragma solidity 0.8.23; // external import { Test } from "forge-std/Test.sol"; import { ERC6551Registry } from "erc6551/ERC6551Registry.sol"; +import { Create3Deployer } from "@create3-deployer/contracts/Create3Deployer.sol"; // contract import { IPAccountRegistry } from "../../../contracts/registries/IPAccountRegistry.sol"; @@ -32,6 +33,8 @@ contract BaseTest is Test, DeployHelper, LicensingHelper { address internal dan; ERC6551Registry internal ERC6551_REGISTRY = new ERC6551Registry(); + Create3Deployer internal CREATE3_DEPLOYER = new Create3Deployer(); + uint256 internal CREATE3_DEFAULT_SEED = 0; IPAccountRegistry internal ipAccountRegistry; MockERC20 internal erc20 = new MockERC20(); @@ -46,7 +49,15 @@ contract BaseTest is Test, DeployHelper, LicensingHelper { uint256 internal constant ARBITRATION_PRICE = 1000 * 10 ** 6; // 1000 MockToken (6 decimals) uint256 internal constant MAX_ROYALTY_APPROVAL = 10000 ether; - constructor() DeployHelper(address(ERC6551_REGISTRY), address(erc20), ARBITRATION_PRICE, MAX_ROYALTY_APPROVAL) {} + constructor() + DeployHelper( + address(ERC6551_REGISTRY), + address(CREATE3_DEPLOYER), + address(erc20), + ARBITRATION_PRICE, + MAX_ROYALTY_APPROVAL + ) + {} /// @notice Sets up the base test contract. function setUp() public virtual { @@ -60,6 +71,7 @@ contract BaseTest is Test, DeployHelper, LicensingHelper { // deploy all contracts via DeployHelper super.run( + CREATE3_DEFAULT_SEED, false, // runStorageLayoutCheck false // writeDeploys ); diff --git a/test/foundry/utils/Create3Deployer.sol b/test/foundry/utils/Create3Deployer.sol deleted file mode 100644 index 84d2a72b..00000000 --- a/test/foundry/utils/Create3Deployer.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.23; - -import { CREATE3 } from "@solady/src/utils/CREATE3.sol"; - -library Create3Deployer { - function deploy(bytes32 salt, bytes calldata creationCode) external returns (address) { - return CREATE3.deploy(salt, creationCode, 0); - } - - function getDeployed(bytes32 salt) external view returns (address) { - return CREATE3.getDeployed(salt); - } -} diff --git a/test/foundry/utils/TestProxyHelper.sol b/test/foundry/utils/TestProxyHelper.sol index 65716c61..08ae6259 100644 --- a/test/foundry/utils/TestProxyHelper.sol +++ b/test/foundry/utils/TestProxyHelper.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; -import { Create3Deployer } from "./Create3Deployer.sol"; +import { ICreate3Deployer } from "@create3-deployer/contracts/ICreate3Deployer.sol"; library TestProxyHelper { /// Deploys a new UUPS proxy with the provided implementation and data @@ -13,7 +13,12 @@ library TestProxyHelper { return address(proxy); } - function deployUUPSProxy(bytes32 salt, address impl, bytes memory data) internal returns (address) { - return Create3Deployer.deploy(salt, abi.encodePacked(type(ERC1967Proxy).creationCode, abi.encode(impl, data))); + function deployUUPSProxy( + ICreate3Deployer create3Deployer, + bytes32 salt, + address impl, + bytes memory data + ) internal returns (address) { + return create3Deployer.deploy(salt, abi.encodePacked(type(ERC1967Proxy).creationCode, abi.encode(impl, data))); } } diff --git a/yarn.lock b/yarn.lock index d2cb7325..4d9271c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4936,11 +4936,6 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" -solady@^0.0.191: - version "0.0.191" - resolved "https://registry.yarnpkg.com/solady/-/solady-0.0.191.tgz#a4a285ddbcc0d5a8860128ffdd6ea1564b673199" - integrity sha512-wiab1exBWHT7tLv8m+MnIppa0cn1PBhYskdYqe9/WYgL5Tn2cph5uZVLgy3H3fXXrya68Y5K5oe17hvOyrU87Q== - solc@0.7.3: version "0.7.3" resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a"