From 30dc5813443d597233d7be3461d95bbc16ba6f7c Mon Sep 17 00:00:00 2001 From: Raul Date: Wed, 6 Dec 2023 21:44:08 -0800 Subject: [PATCH] deployment script with licensing module and sepolia --- .env.example | 5 +- deployment-11155111.json | 28 +- script/foundry/deployment/Main.s.sol | 633 ++++++++++++++------------- 3 files changed, 353 insertions(+), 313 deletions(-) diff --git a/.env.example b/.env.example index 937a45e2..9d0eb4f7 100644 --- a/.env.example +++ b/.env.example @@ -12,4 +12,7 @@ SEPOLIA_PRIVATEKEY = 12341234123412341234123412341234 SEPOLIA_ADMIN_ADDRESS = 0x12341234123412341234123412341234 # ETHSCAN -ETHERSCAN_API_KEY = ETHERSCANAPIKEYETHERSCANAPIKEY \ No newline at end of file +ETHERSCAN_API_KEY = ETHERSCANAPIKEYETHERSCANAPIKEY + +# PROTOCOL LICENSE URL +PIPL_URL=https://url-to-license-file.pdf \ No newline at end of file diff --git a/deployment-11155111.json b/deployment-11155111.json index b7401025..8b7ded08 100644 --- a/deployment-11155111.json +++ b/deployment-11155111.json @@ -1,18 +1,18 @@ { "main": { - "AccessControlSingleton-Impl": "0xFb7d3D62673bE0c6A8809E823F18F6E84cF1f762", - "AccessControlSingleton-Proxy": "0x8f855374D45278Ce6651eA46cef5B610ac8fB6Ce", - "IPAssetRegistry": "0x309C205347E3826472643f9B7EbD8A50D64CCd9e", - "IPOrgController-Impl": "0x70d1B84390c9F70eCE87511f4fD14a194E1d06E2", - "IPOrgController-Proxy": "0xd778680fD9fa788A2fd6465087e6841814eE57CC", - "LicenseRegistry": "0x630d6672D6C15952852ca2Ff0A355d19f259400B", - "LicensingModule": "0xD692DE739fe1C1AAA31c3D0847Dc17976Afc05ff", - "MockERC721": "0x878fD0241993142cEd3e19Aa982809e07a7115d1", - "ModuleRegistry": "0x8209442D02FB517Bdb9099E8Ade3968762F8545A", - "RegistrationModule": "0x948f67E1C4F75Bc89C5fb42147d96356fb4B359f", - "RelationshipModule": "0x4231c45C32B53Ba61D8d04aD05255CCBF3E5DBD2", - "StoryProtocol": "0xD0060D8e88DD841FD32A01B18a9C7e84A1C7d6d4", - "TermsRepository": "0x4BfE248b3fdb27fe2a77fF8C871c6DdA63208A6C", - "TokenGatedHook": "0xA26Ba8224Fb6173063f63388685F80708A6f4d96" + "AccessControlSingleton-Impl": "0x6ad773E8fD28c3482e5d525e7e2F08e259806cdB", + "AccessControlSingleton-Proxy": "0xC20eb1d0a562cD906d2280de74DFcb4cbc159A04", + "IPAssetRegistry": "0x44eE13d12105A43c459908DD7B9c869556F19BE3", + "IPOrgController-Impl": "0x1F8de754eC04200945d5cC56a0e7648231818d8e", + "IPOrgController-Proxy": "0x578BF2322855975106743Af3b8ae5Df81304B86c", + "LicenseRegistry": "0x961D653c12a38c51C0368C452307D91561157452", + "LicensingFrameworkRepo": "0x4e57d5627094aBFaE2DEe6237Db57b05CF3F2aB3", + "LicensingModule": "0x12b148fA981881F1e259f46731D1c211919c21a9", + "MockERC721": "0xAc9A12183cFa4b3e4459b0cC724A88Ed9c64BaAf", + "ModuleRegistry": "0xb0417817C3c9cc37bC6b498bec2E1ca9ce8E144E", + "RegistrationModule": "0x46Ad4a5CAD9eE043974F4711D66934Ff5aa180b0", + "RelationshipModule": "0x8D0CFc1Accd92fBB417A9acCED55c2C1446942C8", + "StoryProtocol": "0x297DE9426121239e42f38b386481958E6ABFA17f", + "TokenGatedHook": "0x2372F5Cba08D58E3c11057f7751e41dea5338F26" } } \ No newline at end of file diff --git a/script/foundry/deployment/Main.s.sol b/script/foundry/deployment/Main.s.sol index 107dee6c..6aeeae4d 100644 --- a/script/foundry/deployment/Main.s.sol +++ b/script/foundry/deployment/Main.s.sol @@ -1,298 +1,335 @@ -// // SPDX-License-Identifier: MIT -// pragma solidity ^0.8.18; - -// import "forge-std/Script.sol"; -// import "test/foundry/utils/ProxyHelper.sol"; -// import "script/foundry/utils/StringUtil.sol"; -// import "script/foundry/utils/BroadcastManager.s.sol"; -// import "script/foundry/utils/JsonDeploymentHandler.s.sol"; -// import "contracts/ip-org/IPOrg.sol"; -// import "contracts/ip-org/IPOrgController.sol"; -// import "contracts/access-control/AccessControlSingleton.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/LicensingModule.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"; -// import "contracts/modules/licensing/TermsRepository.sol"; -// import { Licensing } from "contracts/lib/modules/Licensing.sol"; -// import { TermCategories, TermIds } from "contracts/lib/modules/ProtocolLicensingTerms.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 licensingModule; -// address tokenGatedHook; -// address mockNFT; -// address termsRepository; - - -// 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"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new AccessControlSingleton()); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - - -// contractKey = "AccessControlSingleton-Proxy"; - -// 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; - -// /// MODULE_REGISTRY -// contractKey = "ModuleRegistry"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new ModuleRegistry(accessControl)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// moduleRegistry = newAddress; - -// /// IP_ASSET_REGISTRY -// contractKey = "IPAssetRegistry"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new IPAssetRegistry(moduleRegistry)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// ipAssetRegistry = newAddress; - -// /// LICENSE_REGISTRY -// contractKey = "LicenseRegistry"; - -// 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; - -// /// 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), -// ipOrgController: IPOrgController(ipOrgController) -// }), 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), -// ipOrgController: IPOrgController(ipOrgController) -// }), accessControl)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// relationshipModule = newAddress; - -// /// TERMS_REPOSITORY -// contractKey = "TermsRepository"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new TermsRepository(accessControl)); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// termsRepository = newAddress; - -// /// LICENSE_MODULE -// contractKey = "LicensingModule"; - -// console.log(string.concat("Deploying ", contractKey, "...")); -// newAddress = address(new LicensingModule(BaseModule.ModuleConstruction({ -// ipaRegistry: IPAssetRegistry(ipAssetRegistry), -// moduleRegistry: ModuleRegistry(moduleRegistry), -// licenseRegistry: LicenseRegistry(licenseRegistry), -// ipOrgController: IPOrgController(ipOrgController) -// }), termsRepository) ); -// _writeAddress(contractKey, newAddress); -// console.log(string.concat(contractKey, " deployed to:"), newAddress); - -// licensingModule = 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.LICENSING_MANAGER, admin); -// accessControlSingleton.grantRole(AccessControl.IPORG_CREATOR_ROLE, admin); -// accessControlSingleton.grantRole(AccessControl.MODULE_REGISTRAR_ROLE, admin); -// accessControlSingleton.grantRole(AccessControl.MODULE_EXECUTOR_ROLE, spg); -// accessControlSingleton.grantRole(AccessControl.MODULE_EXECUTOR_ROLE, ipOrgController); - -// // 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(licensingModule)); -// string[] memory ipAssetTypes = new string[](2); -// ipAssetTypes[0] = "STORY"; -// ipAssetTypes[1] = "CHARACTER"; -// address ipOrg = StoryProtocol(spg).registerIpOrg(admin, "Sample IP Org", "SIPO", ipAssetTypes); - -// // 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); - -// // CONFIG LICENSING MODULE -// Licensing.CommercialStatus comStatus = Licensing.CommercialStatus.Both; -// TermsRepository(termsRepository).addCategory(TermCategories.SHARE_ALIKE); -// Licensing.LicensingTerm memory term = _getTerm(TermIds.NFT_SHARE_ALIKE, comStatus); -// TermsRepository(termsRepository).addTerm(TermCategories.SHARE_ALIKE, TermIds.NFT_SHARE_ALIKE, term); - -// TermsRepository(termsRepository).addCategory(TermCategories.LICENSOR); -// term = _getTerm(TermIds.LICENSOR_APPROVAL, comStatus); -// TermsRepository(termsRepository).addTerm(TermCategories.LICENSOR, TermIds.LICENSOR_APPROVAL, term); - -// TermsRepository(termsRepository).addCategory(TermCategories.CATEGORIZATION); -// term = _getTerm(TermIds.FORMAT_CATEGORY, comStatus); -// TermsRepository(termsRepository).addTerm(TermCategories.CATEGORIZATION, TermIds.FORMAT_CATEGORY, term); - -// TermsRepository(termsRepository).addCategory(TermCategories.ACTIVATION); -// term = _getTerm(TermIds.LICENSOR_IPORG_OR_PARENT, comStatus); -// TermsRepository(termsRepository).addTerm(TermCategories.ACTIVATION, TermIds.LICENSOR_IPORG_OR_PARENT, term); - - -// _writeDeployment(); -// _endBroadcast(); -// } - -// function _getTerm( -// string memory termId, -// Licensing.CommercialStatus comStatus_ -// ) internal pure returns (Licensing.LicensingTerm memory) { -// return Licensing.LicensingTerm({ -// comStatus: comStatus_, -// url: string(abi.encodePacked("https://", termId,".com")), -// hash: "qwertyu", -// algorithm: "sha256", -// hook: IHook(address(0)) -// }); -// } -// } +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +import "forge-std/Script.sol"; +import "test/foundry/utils/ProxyHelper.sol"; +import "script/foundry/utils/StringUtil.sol"; +import "script/foundry/utils/BroadcastManager.s.sol"; +import "script/foundry/utils/JsonDeploymentHandler.s.sol"; +import "contracts/ip-org/IPOrg.sol"; +import "contracts/ip-org/IPOrgController.sol"; +import "contracts/access-control/AccessControlSingleton.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/relationships/RelationshipModule.sol"; +import "contracts/lib/modules/ModuleRegistryKeys.sol"; +import "contracts/modules/licensing/LicensingModule.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"; +import "contracts/modules/licensing/LicenseRegistry.sol"; +import "contracts/modules/licensing/LicensingFrameworkRepo.sol"; +import "contracts/modules/licensing/LicensingModule.sol"; +import "contracts/lib/modules/Licensing.sol"; +import "contracts/lib/modules/PIPLicensingTerms.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 licensingModule; + address tokenGatedHook; + address mockNFT; + address licensingFrameworkRepo; + + constructor() JsonDeploymentHandler("main") {} + + /// @dev To use, run the following command (e.g. for Sepolia): + /// forge script script/foundry/deployment/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"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new AccessControlSingleton()); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + contractKey = "AccessControlSingleton-Proxy"; + + 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; + + /// LICENSING_FRAMEWORK_REPO + contractKey = "LicensingFrameworkRepo"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new LicensingFrameworkRepo(accessControl)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + licensingFrameworkRepo = newAddress; + + /// MODULE_REGISTRY + contractKey = "ModuleRegistry"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new ModuleRegistry(accessControl)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + moduleRegistry = newAddress; + + /// IP_ASSET_REGISTRY + contractKey = "IPAssetRegistry"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address(new IPAssetRegistry(moduleRegistry)); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + ipAssetRegistry = newAddress; + + /// LICENSE_REGISTRY + contractKey = "LicenseRegistry"; + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address( + new LicenseRegistry( + ipAssetRegistry, + moduleRegistry, + licensingFrameworkRepo + ) + ); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + licenseRegistry = newAddress; + + /// 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), + ipOrgController: IPOrgController(ipOrgController) + }), + 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), + ipOrgController: IPOrgController(ipOrgController) + }), + accessControl + ) + ); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + relationshipModule = newAddress; + + /// LICENSE_MODULE + contractKey = "LicensingModule"; + + console.log(string.concat("Deploying ", contractKey, "...")); + newAddress = address( + new LicensingModule( + BaseModule.ModuleConstruction({ + ipaRegistry: IPAssetRegistry(ipAssetRegistry), + moduleRegistry: ModuleRegistry(moduleRegistry), + licenseRegistry: LicenseRegistry(licenseRegistry), + ipOrgController: IPOrgController(ipOrgController) + }), + licensingFrameworkRepo, + admin + ) + ); + _writeAddress(contractKey, newAddress); + console.log(string.concat(contractKey, " deployed to:"), newAddress); + + licensingModule = 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.LICENSING_MANAGER, + admin + ); + accessControlSingleton.grantRole( + AccessControl.IPORG_CREATOR_ROLE, + admin + ); + accessControlSingleton.grantRole( + AccessControl.MODULE_REGISTRAR_ROLE, + admin + ); + accessControlSingleton.grantRole( + AccessControl.MODULE_EXECUTOR_ROLE, + spg + ); + accessControlSingleton.grantRole( + AccessControl.MODULE_EXECUTOR_ROLE, + ipOrgController + ); + + // 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(licensingModule) + ); + string[] memory ipAssetTypes = new string[](2); + ipAssetTypes[0] = "STORY"; + ipAssetTypes[1] = "CHARACTER"; + address ipOrg = StoryProtocol(spg).registerIpOrg( + admin, + "Sample IP Org", + "SIPO", + ipAssetTypes + ); + + // 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 + ); + + // CONFIG LICENSING MODULE + Licensing.ParamDefinition[] memory paramDefs = PIPLicensingTerms._getParamDefs(); + Licensing.SetFramework memory framework = Licensing.SetFramework({ + id: PIPLicensingTerms.FRAMEWORK_ID, + textUrl: vm.envString("PIPL_URL"), + paramDefs: paramDefs + }); + LicensingFrameworkRepo(licensingFrameworkRepo).addFramework(framework); + + _writeDeployment(); + _endBroadcast(); + } +}