Skip to content

Commit

Permalink
Support Consistent Address Deployment Across Networks (storyprotocol#132
Browse files Browse the repository at this point in the history
)

* forge install: create3-deployer
* Deployed with pre-deployed Create3Deployer
* Fix OZ upgrade check warning
* Deploy contracts to unified/same addresses across all chains
  • Loading branch information
kingster-will authored Apr 23, 2024
1 parent f559e0b commit 972c201
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions contracts/LicenseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions contracts/access/AccessController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions contracts/modules/licensing/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions contracts/registries/LicenseRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/create3-deployer
Submodule create3-deployer added at a044ab
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"@openzeppelin/contracts": "5.0.2",
"@openzeppelin/contracts-upgradeable": "5.0.2",
"@openzeppelin/contracts-upgradeable-v4": "npm:@openzeppelin/[email protected]",
"erc6551": "^0.3.1",
"solady": "^0.0.191"
"erc6551": "^0.3.1"
}
}
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/
@create3-deployer/=lib/create3-deployer
13 changes: 12 additions & 1 deletion script/foundry/deployment/Main.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
}
Loading

0 comments on commit 972c201

Please sign in to comment.