From 0edd7f08c2a28e91a82adb7da6243b3d5313fe33 Mon Sep 17 00:00:00 2001 From: Leeren Date: Tue, 21 Nov 2023 15:59:48 -0500 Subject: [PATCH] Fixes IP asset types (#179) --- contracts/ip-org/IPOrgController.sol | 20 ++++++++-------- test/foundry/IPOrgTest.t.sol | 34 +++++++++++++++++++++++----- test/foundry/utils/BaseTest.sol | 3 ++- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/contracts/ip-org/IPOrgController.sol b/contracts/ip-org/IPOrgController.sol index 738faa3e..2de3545a 100644 --- a/contracts/ip-org/IPOrgController.sol +++ b/contracts/ip-org/IPOrgController.sol @@ -176,16 +176,16 @@ contract IPOrgController is pendingOwner: address(0) }); - // bytes memory encodedParams = abi.encode( - // Registration.SET_IP_ORG_ASSET_TYPES, - // abi.encode(ipAssetTypes_) - // ); - // ModuleRegistry(MODULE_REGISTRY).configure( - // IIPOrg(ipOrg_), - // address(this), - // ModuleRegistryKeys.REGISTRATION_MODULE, - // encodedParams - // ); + bytes memory encodedParams = abi.encode( + Registration.SET_IP_ORG_ASSET_TYPES, + abi.encode(ipAssetTypes_) + ); + ModuleRegistry(MODULE_REGISTRY).configure( + IIPOrg(ipOrg_), + address(this), + ModuleRegistryKeys.REGISTRATION_MODULE, + encodedParams + ); emit IPOrgRegistered( msg.sender, diff --git a/test/foundry/IPOrgTest.t.sol b/test/foundry/IPOrgTest.t.sol index 2efb652b..595dd9de 100644 --- a/test/foundry/IPOrgTest.t.sol +++ b/test/foundry/IPOrgTest.t.sol @@ -7,12 +7,16 @@ import { IPOrgController } from "contracts/ip-org/IPOrgController.sol"; import { ModuleRegistry } from "contracts/modules/ModuleRegistry.sol"; import { IPOrgParams } from "contracts/lib/IPOrgParams.sol"; import { AccessControl } from "contracts/lib/AccessControl.sol"; +import { LicenseRegistry } from "contracts/modules/licensing/LicenseRegistry.sol"; import { AccessControlSingleton } from "contracts/access-control/AccessControlSingleton.sol"; import { IPAssetRegistry } from "contracts/IPAssetRegistry.sol"; import { AccessControlHelper } from "./utils/AccessControlHelper.sol"; import { MockCollectNFT } from "./mocks/MockCollectNFT.sol"; import { MockCollectModule } from "./mocks/MockCollectModule.sol"; import { MockIPOrgController } from "./mocks/MockIPOrgController.sol"; +import { BaseModule } from "contracts/modules/base/BaseModule.sol"; +import { RegistrationModule } from "contracts/modules/registration/RegistrationModule.sol"; +import { ModuleRegistryKeys } from "contracts/lib/modules/ModuleRegistryKeys.sol"; import 'test/foundry/utils/ProxyHelper.sol'; import "forge-std/Test.sol"; @@ -24,8 +28,11 @@ contract IPOrgTest is Test, ProxyHelper, AccessControlHelper { event BeaconUpgraded(address indexed beacon); event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); + RegistrationModule public registrationModule; + LicenseRegistry public licenseRegistry; IPAssetRegistry public registry; IPOrgController public ipOrgController; + ModuleRegistry public moduleRegistry; IPOrg public ipOrg; uint256 internal ipOrgOwnerPk = 0xa11ce; @@ -35,18 +42,33 @@ contract IPOrgTest is Test, ProxyHelper, AccessControlHelper { _setupAccessControl(); _grantRole(vm, AccessControl.IPORG_CREATOR_ROLE, ipOrgOwner); - address moduleRegistry = address(new ModuleRegistry(address(accessControl))); - registry = new IPAssetRegistry(moduleRegistry); - - address implementation = address(new IPOrgController(moduleRegistry)); + moduleRegistry = new ModuleRegistry(address(accessControl)); + registry = new IPAssetRegistry(address(moduleRegistry)); + address ipOrgControllerImpl = address(new IPOrgController(address(moduleRegistry))); ipOrgController = IPOrgController( _deployUUPSProxy( - implementation, + ipOrgControllerImpl, abi.encodeWithSelector( - bytes4(keccak256(bytes("initialize(address)"))), address(accessControl) + bytes4(keccak256(bytes("initialize(address)"))), + address(accessControl) ) ) ); + _grantRole(vm, AccessControl.MODULE_EXECUTOR_ROLE, address(address(ipOrgController))); + + licenseRegistry = new LicenseRegistry(address(registry), address(moduleRegistry)); + registrationModule = new RegistrationModule( + BaseModule.ModuleConstruction({ + ipaRegistry: registry, + moduleRegistry: moduleRegistry, + licenseRegistry: licenseRegistry, + ipOrgController: ipOrgController + }), + address(accessControl) + ); + _grantRole(vm, AccessControl.MODULE_REGISTRAR_ROLE, address(this)); + moduleRegistry.registerProtocolModule(ModuleRegistryKeys.REGISTRATION_MODULE, registrationModule); + } function test_ipOrgController_registerIpOrg() public { diff --git a/test/foundry/utils/BaseTest.sol b/test/foundry/utils/BaseTest.sol index 8e9e845e..6cf67db1 100644 --- a/test/foundry/utils/BaseTest.sol +++ b/test/foundry/utils/BaseTest.sol @@ -132,7 +132,8 @@ contract BaseTest is BaseTestUtils, ProxyHelper, AccessControlHelper { ); vm.startPrank(ipAssetOrgOwner); - string[] memory ipAssetTypes = new string[](0); + string[] memory ipAssetTypes = new string[](1); + ipAssetTypes[0] = "CHARACTER"; ipOrg = IPOrg(spg.registerIpOrg( ipAssetOrgOwner, ipAssetOrgParams.name,