From 2360bbcf3c7cfdd4ddc6913d5157a6a986a3d8be Mon Sep 17 00:00:00 2001 From: Kingster Date: Wed, 15 Nov 2023 22:36:35 -0800 Subject: [PATCH] deploy stroy protocol contracts to Sepolia --- deployment-11155111.json | 17 + deployment-31337.json | 20 +- script/foundry/deployment/Main.s.sol | 400 +++++++++++--------- script/foundry/utils/BroadcastManager.s.sol | 4 + 4 files changed, 256 insertions(+), 185 deletions(-) create mode 100644 deployment-11155111.json diff --git a/deployment-11155111.json b/deployment-11155111.json new file mode 100644 index 00000000..4205ae4e --- /dev/null +++ b/deployment-11155111.json @@ -0,0 +1,17 @@ +{ + "main": { + "AccessControlSingleton-Impl": "0xF19bde1c961a88cBaaA506E9F9355c605997193A", + "AccessControlSingleton-Proxy": "0x517d920c9a3889f620c48965788C576f1504894F", + "IPAssetRegistry": "0x398DA4b4a45C43d8B9530A948B549323bEb8323e", + "IPOrgController-Impl": "0xDc73A45336444a498129970C8811e39D5fEc2bBf", + "IPOrgController-Proxy": "0x971836EE58DA68a38A2a567b4D313A6e5B9a7c72", + "LicenseCreatorModule": "0x75dD702C1d8325CaAd47b8698645B8C0C0417557", + "LicenseRegistry": "0x15eA336C219A33CFE4Ba53C816A4E0B267d19908", + "MockERC721": "0x4098d9f937F7537fB9147315E4845Fc2098AA00E", + "ModuleRegistry": "0x4600029b3b2426d627dFde7d57AbCFdC96aEC147", + "RegistrationModule": "0x1a880B69077A440BE6100343bA6e0D189cdBE9Ff", + "RelationshipModule": "0xEda86EB15dac456DDc5E432781Bb40B4e467920D", + "StoryProtocol": "0x65C37A300A6fbDB2bf0C1685813c89a059A41296", + "TokenGatedHook": "0x51e590be99756c6FC6A61B6F8B465fb62a7212be" + } +} \ No newline at end of file diff --git a/deployment-31337.json b/deployment-31337.json index f1c8cdb8..5ca09a7d 100644 --- a/deployment-31337.json +++ b/deployment-31337.json @@ -1,12 +1,18 @@ { "main": { - "AccessControlSingleton-Impl": "0x6E447CeC286dbaBe885fDbD9723DD63Cc2DE0Bd2", - "AccessControlSingleton-Proxy": "0xC06CBc0B7A136bda48865BE24228396Dea4094Ec", - "FranchiseRegistry-Impl": "0x446ce25bff9fe7049Aaf3339124F51F301e9c220", - "FranchiseRegistry-Proxy": "0x687E4e5a4471c259a8f56F1f06b0E5c5FEa808c8", - "IPAssetRegistryFactory": "0x7B4f9313d7a12aa902462860eeBD97ab2B68176F", - "ProtocolRelationshipModule-Impl": "0xa1833d78f09e2198774E612ca3d9879597ACc859", - "ProtocolRelationshipModule-Proxy": "0xd8562c2C2f7497D96C7Cf2f9E15392fe4c31c84f" + "AccessControlSingleton-Impl": "0x7B4f9313d7a12aa902462860eeBD97ab2B68176F", + "AccessControlSingleton-Proxy": "0x6E447CeC286dbaBe885fDbD9723DD63Cc2DE0Bd2", + "IPAssetRegistry": "0x446ce25bff9fe7049Aaf3339124F51F301e9c220", + "IPOrgController-Impl": "0xa1833d78f09e2198774E612ca3d9879597ACc859", + "IPOrgController-Proxy": "0xd8562c2C2f7497D96C7Cf2f9E15392fe4c31c84f", + "LicenseCreatorModule": "0x0e0C15Fe242628fce34A123A0317C97f1D3256c8", + "LicenseRegistry": "0x687E4e5a4471c259a8f56F1f06b0E5c5FEa808c8", + "MockERC721": "0xdCc500f52a509F65023696FE7B717c81F8a432d5", + "ModuleRegistry": "0xC06CBc0B7A136bda48865BE24228396Dea4094Ec", + "RegistrationModule": "0x869b721BbF176D0130d87E3aD2eEA02CEBB883eE", + "RelationshipModule": "0x812d70D430362c56E56F7Cfc73464FE2F1670ec9", + "StoryProtocol": "0xB61c296B51f542EeD7B76022c736488A571ac05b", + "TokenGatedHook": "0xb9162E7d63aDAC660f987755D45f55710EB5542a" }, "relationship-processors": { "DstOwnerRelationshipProcessor": "0x6E447CeC286dbaBe885fDbD9723DD63Cc2DE0Bd2", diff --git a/script/foundry/deployment/Main.s.sol b/script/foundry/deployment/Main.s.sol index 6ecaf1ec..3c1fcf57 100644 --- a/script/foundry/deployment/Main.s.sol +++ b/script/foundry/deployment/Main.s.sol @@ -17,196 +17,240 @@ import "contracts/modules/royalties/RoyaltyNFT.sol"; import "contracts/ip-accounts/IPAccountImpl.sol"; import "contracts/ip-accounts/IPAccountRegistry.sol"; import { AccessControl } from "contracts/lib/AccessControl.sol"; +import "contracts/modules/ModuleRegistry.sol"; +import "contracts/IPAssetRegistry.sol"; +import "contracts/modules/registration/RegistrationModule.sol"; +import "contracts/StoryProtocol.sol"; +import "contracts/modules/base/BaseModule.sol"; +import "contracts/modules/licensing/LicenseRegistry.sol"; +import "contracts/modules/relationships/RelationshipModule.sol"; +import "contracts/lib/modules/ModuleRegistryKeys.sol"; +import "contracts/modules/licensing/LicenseCreatorModule.sol"; +import "contracts/hooks/TokenGatedHook.sol"; +import "contracts/modules/base/HookRegistry.sol"; +import "contracts/interfaces/hooks/base/IHook.sol"; +import { TokenGated } from "contracts/lib/hooks/TokenGated.sol"; +import "test/foundry/mocks/MockERC721.sol"; + + contract Main is Script, BroadcastManager, JsonDeploymentHandler, ProxyHelper { + + using StringUtil for uint256; + using stdJson for string; + + address accessControl; + address ipOrgController; + address moduleRegistry; + address ipAssetRegistry; + address spg; + address licenseRegistry; + address registrationModule; + address relationshipModule; + address licenseCreatorModule; + address tokenGatedHook; + address mockNFT; + + string constant NON_COMMERCIAL_LICENSE_URI = "https://noncommercial.license"; + string constant COMMERCIAL_LICENSE_URI = "https://commercial.license"; + + constructor() JsonDeploymentHandler("main") { + } + + /// @dev To use, run the following command (e.g. for Sepolia): + /// forge script script/Main.s.sol:Main --rpc-url $SEPOLIA_RPC_URL --broadcast --verify -vvvv + + function run() public { + _beginBroadcast(); + string memory contractKey; + address newAddress; + + /// ACCESS CONTROL SINGLETON + contractKey = "AccessControlSingleton-Impl"; -// contract Main is Script, BroadcastManager, JsonDeploymentHandler, ProxyHelper { + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new AccessControlSingleton()); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + -// using StringUtil for uint256; -// using stdJson for string; + contractKey = "AccessControlSingleton-Proxy"; -// address accessControl; -// address franchise; + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = _deployUUPSProxy( + newAddress, + abi.encodeWithSelector( + bytes4(keccak256(bytes("initialize(address)"))), admin + ) + ); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); -// string constant NON_COMMERCIAL_LICENSE_URI = "https://noncommercial.license"; -// string constant COMMERCIAL_LICENSE_URI = "https://commercial.license"; + accessControl = newAddress; -// constructor() JsonDeploymentHandler("main") { -// } + /// MODULE_REGISTRY + contractKey = "ModuleRegistry"; -// /// @dev To use, run the following command (e.g. for Goerli): -// /// forge script script/Deploy.s.sol:Deploy --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv - -// function run() public { -// _beginBroadcast(); -// string memory contractKey; -// address newAddress; - -// /// ACCESS CONTROL SINGLETON -// contractKey = "AccessControlSingleton-Impl"; + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new ModuleRegistry(accessControl)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new AccessControlSingleton()); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - + moduleRegistry = newAddress; -// contractKey = "AccessControlSingleton-Proxy"; + /// IP_ASSET_REGISTRY + contractKey = "IPAssetRegistry"; -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = _deployUUPSProxy( -// newAddress, -// abi.encodeWithSelector( -// bytes4(keccak256(bytes("initialize(address)"))), admin -// ) -// ); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// accessControl = newAddress; - -// /// IP_ORG_FACTORY REGISTRY -// contractKey = "IPOrgController-Impl"; + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new IPAssetRegistry(moduleRegistry)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new IPOrgController()); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// contractKey = "IPOrgController-Proxy"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = _deployUUPSProxy( -// newAddress, -// abi.encodeWithSelector( -// bytes4(keccak256(bytes("initialize(address)"))), accessControl -// ) -// ); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// franchise = newAddress; - -// /// LICENSING MODULE -// contractKey = "LicensingModule-Impl"; - -// console.log(string.concat("Deploying ", contractKey, "...")); - -// newAddress = address(new LicensingModule(address(franchise))); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// contractKey = "LicensingModule-Proxy"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = _deployUUPSProxy( -// newAddress, -// abi.encodeWithSelector( -// bytes4(keccak256(bytes("initialize(address,string)"))), -// accessControl, NON_COMMERCIAL_LICENSE_URI -// ) -// ); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); -// address licensingModule = newAddress; - -// /// COLLECT MODULE -// contractKey = "CollectNFT"; -// console.log(string.concat("Deploying ", contractKey, "...")); - -// newAddress = address(new MockCollectNFT()); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// address defaultCollectNFTImpl = newAddress; - -// contractKey = "CollectModule-Impl"; -// console.log(string.concat("Deploying ", contractKey, "...")); - -// newAddress = address(new MockCollectModule(address(franchise), defaultCollectNFTImpl)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// contractKey = "CollectModule-Proxy"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = _deployUUPSProxy( -// newAddress, -// abi.encodeWithSelector( -// bytes4(keccak256(bytes("initialize(address)"))), address(accessControl) -// ) -// ); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); -// address collectModule = newAddress; - - -// /// IP ACCOUNT REGISTRY -// contractKey = "IPAccount-Impl"; -// console.log(string.concat("Deploying ", contractKey, "...")); - -// newAddress = address(new IPAccountImpl()); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// contractKey = "IPAccountRegistry"; -// console.log(string.concat("Deploying ", contractKey, "...")); - -// newAddress = address(new IPAccountRegistry(newAddress)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// address ipAccountRegistry = newAddress; - -// /// ROYALTY MODULE -// address SPLIT_MAIN = 0x2ed6c4B5dA6378c7897AC67Ba9e43102Feb694EE; -// contractKey = "RoyaltyNFT"; -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new RoyaltyNFT(SPLIT_MAIN)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// address royaltyNft = newAddress; - -// contractKey = "MutableRoyaltyProportionPolicy"; -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new MutableRoyaltyProportionPolicy(royaltyNft)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// contractKey = "RoyaltyDistributor"; -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new RoyaltyDistributor(ipAccountRegistry, royaltyNft)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// /// PROTOCOL RELATIONSHIP MODULE -// contractKey = "ProtocolRelationshipModule-Impl"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new ProtocolRelationshipModule(franchise)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - + ipAssetRegistry = newAddress; -// contractKey = "ProtocolRelationshipModule-Proxy"; + /// LICENSE_REGISTRY + contractKey = "LicenseRegistry"; -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = _deployUUPSProxy( -// newAddress, -// abi.encodeWithSelector( -// bytes4(keccak256(bytes("initialize(address)"))), accessControl -// ) -// ); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new LicenseRegistry(ipAssetRegistry, moduleRegistry)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + licenseRegistry = newAddress; -// /// GRANT ROLEs -// AccessControlSingleton accessControlSingleton = AccessControlSingleton(accessControl); -// accessControlSingleton.grantRole(AccessControl.UPGRADER_ROLE, admin); -// accessControlSingleton.grantRole(AccessControl.RELATIONSHIP_MANAGER_ROLE, admin); - -// _writeDeployment(); -// _endBroadcast(); -// } + /// IP_ORG_FACTORY REGISTRY + contractKey = "IPOrgController-Impl"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new IPOrgController(moduleRegistry)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + contractKey = "IPOrgController-Proxy"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = _deployUUPSProxy( + newAddress, + abi.encodeWithSelector( + bytes4(keccak256(bytes("initialize(address)"))), accessControl + ) + ); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + ipOrgController = newAddress; + + /// SPG + contractKey = "StoryProtocol"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new StoryProtocol(IIPOrgController(ipOrgController), ModuleRegistry(moduleRegistry))); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + spg = newAddress; + + + /// REGISTRATION_MODULE + contractKey = "RegistrationModule"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new RegistrationModule(BaseModule.ModuleConstruction({ + ipaRegistry: IPAssetRegistry(ipAssetRegistry), + moduleRegistry: ModuleRegistry(moduleRegistry), + licenseRegistry: LicenseRegistry(licenseRegistry) + }), accessControl)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + registrationModule = newAddress; + + + /// RELATIONSHIP_MODULE + contractKey = "RelationshipModule"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new RelationshipModule(BaseModule.ModuleConstruction({ + ipaRegistry: IPAssetRegistry(ipAssetRegistry), + moduleRegistry: ModuleRegistry(moduleRegistry), + licenseRegistry: LicenseRegistry(licenseRegistry) + }), accessControl)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + relationshipModule = newAddress; + + + /// LICENSE_MODULE + contractKey = "LicenseCreatorModule"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new LicenseCreatorModule(BaseModule.ModuleConstruction({ + ipaRegistry: IPAssetRegistry(ipAssetRegistry), + moduleRegistry: ModuleRegistry(moduleRegistry), + licenseRegistry: LicenseRegistry(licenseRegistry) + }))); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + licenseCreatorModule = newAddress; + + + /// TOKEN_GATED_HOOK + contractKey = "TokenGatedHook"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new TokenGatedHook(accessControl)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + tokenGatedHook = newAddress; + + /// MOCK_ERC_721 + contractKey = "MockERC721"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new MockERC721()); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + mockNFT = newAddress; + + + ///////////////////////////////////////////////////////////////////////////////////////////////////// + // CONFIGURATION // + ///////////////////////////////////////////////////////////////////////////////////////////////////// + + /// GRANT ROLEs + AccessControlSingleton accessControlSingleton = AccessControlSingleton(accessControl); + accessControlSingleton.grantRole(AccessControl.UPGRADER_ROLE, admin); + accessControlSingleton.grantRole(AccessControl.RELATIONSHIP_MANAGER_ROLE, admin); + accessControlSingleton.grantRole(AccessControl.LICENSING_MANAGER_ROLE, admin); + accessControlSingleton.grantRole(AccessControl.IPORG_CREATOR_ROLE, admin); + accessControlSingleton.grantRole(AccessControl.MODULE_REGISTRAR_ROLE, admin); + accessControlSingleton.grantRole(AccessControl.MODULE_EXECUTOR_ROLE, spg); + + // REGISTER MODULES + ModuleRegistry(moduleRegistry).registerProtocolModule( + ModuleRegistryKeys.REGISTRATION_MODULE, BaseModule(registrationModule)); + ModuleRegistry(moduleRegistry).registerProtocolModule( + ModuleRegistryKeys.RELATIONSHIP_MODULE, BaseModule(relationshipModule)); + ModuleRegistry(moduleRegistry).registerProtocolModule( + ModuleRegistryKeys.LICENSING_MODULE, BaseModule(licenseCreatorModule)); + + address ipOrg = StoryProtocol(spg).registerIpOrg(admin, "Sample IP Org", "SIPO"); + + // REGISTER TOKEN_GATED_HOOK + address[] memory hooks = new address[](1); + hooks[0] = tokenGatedHook; + + TokenGated.Config memory tokenGatedConfig = TokenGated.Config({ + tokenAddress: mockNFT + }); + bytes[] memory hooksConfig = new bytes[](1); + hooksConfig[0] = abi.encode(tokenGatedConfig); + RegistrationModule(registrationModule).registerHooks(HookRegistry.HookType.PreAction, IIPOrg(ipOrg), hooks, hooksConfig); + + _writeDeployment(); + _endBroadcast(); + } -// } + } diff --git a/script/foundry/utils/BroadcastManager.s.sol b/script/foundry/utils/BroadcastManager.s.sol index 3abff0c5..e54f18ac 100644 --- a/script/foundry/utils/BroadcastManager.s.sol +++ b/script/foundry/utils/BroadcastManager.s.sol @@ -19,6 +19,10 @@ contract BroadcastManager is Script { deployerPrivateKey = vm.envUint("GOERLI_PRIVATEKEY"); admin = vm.envAddress("GOERLI_ADMIN_ADDRESS"); vm.startBroadcast(deployerPrivateKey); + } else if (block.chainid == 11155111) { + deployerPrivateKey = vm.envUint("SEPOLIA_PRIVATEKEY"); + admin = vm.envAddress("SEPOLIA_ADMIN_ADDRESS"); + vm.startBroadcast(deployerPrivateKey); } else { vm.startPrank(admin); }