diff --git a/contracts/lib/Errors.sol b/contracts/lib/Errors.sol index 3ab13311..4fd95d59 100644 --- a/contracts/lib/Errors.sol +++ b/contracts/lib/Errors.sol @@ -139,6 +139,9 @@ library Errors { /// @notice The group reward pool is not whitelisted. error GroupingModule__GroupRewardPoolNotWhitelisted(address groupId, address groupRewardPool); + /// @notice To add an IP to group, require the IP royalty vault has been created. + error GroupingModule__IpRoyaltyVaultNotCreated(address ipId); + //////////////////////////////////////////////////////////////////////////// // IP Asset Registry // //////////////////////////////////////////////////////////////////////////// diff --git a/contracts/modules/grouping/GroupingModule.sol b/contracts/modules/grouping/GroupingModule.sol index 172e7e6b..8dc22e27 100644 --- a/contracts/modules/grouping/GroupingModule.sol +++ b/contracts/modules/grouping/GroupingModule.sol @@ -181,6 +181,9 @@ contract GroupingModule is if (DISPUTE_MODULE.isIpTagged(ipIds[i])) { revert Errors.GroupingModule__CannotAddDisputedIpToGroup(ipIds[i]); } + if (ROYALTY_MODULE.ipRoyaltyVaults(ipIds[i]) == address(0)) { + revert Errors.GroupingModule__IpRoyaltyVaultNotCreated(ipIds[i]); + } Licensing.LicensingConfig memory lc = LICENSE_REGISTRY.verifyGroupAddIp( groupIpId, diff --git a/test/foundry/modules/grouping/GroupingModule.t.sol b/test/foundry/modules/grouping/GroupingModule.t.sol index 605b696f..59142be8 100644 --- a/test/foundry/modules/grouping/GroupingModule.t.sol +++ b/test/foundry/modules/grouping/GroupingModule.t.sol @@ -158,6 +158,9 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { licensingModule.setLicensingConfig(ipId2, address(pilTemplate), termsId, licensingConfig); vm.stopPrank(); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); + licensingModule.mintLicenseTokens(ipId2, address(pilTemplate), termsId, 1, address(this), "", 0); + vm.startPrank(alice); licensingModule.attachLicenseTerms(groupId, address(pilTemplate), termsId); licensingConfig.expectGroupRewardPool = address(0); @@ -200,10 +203,12 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { vm.startPrank(ipOwner1); licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); vm.startPrank(ipOwner2); licensingModule.attachLicenseTerms(ipId2, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId2, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId2, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); licensingConfig.expectGroupRewardPool = address(0); @@ -538,6 +543,7 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { vm.startPrank(ipOwner1); licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); vm.stopPrank(); @@ -587,6 +593,7 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { vm.startPrank(ipOwner1); licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); address[] memory ipIds = new address[](1); @@ -636,6 +643,7 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { vm.startPrank(ipOwner1); licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); address[] memory ipIds = new address[](1); @@ -673,11 +681,13 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { vm.startPrank(ipOwner1); licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); vm.startPrank(ipOwner2); licensingModule.attachLicenseTerms(ipId2, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId2, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId2, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); licensingConfig.expectGroupRewardPool = address(0); @@ -788,6 +798,7 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { }); vm.prank(ipOwner1); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); licensingConfig.expectGroupRewardPool = address(0); vm.startPrank(alice); @@ -929,10 +940,12 @@ contract GroupingModuleTest is BaseTest, ERC721Holder { vm.startPrank(ipOwner1); licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId1, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId1, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); vm.startPrank(ipOwner2); licensingModule.attachLicenseTerms(ipId2, address(pilTemplate), termsId); licensingModule.setLicensingConfig(ipId2, address(pilTemplate), termsId, licensingConfig); + licensingModule.mintLicenseTokens(ipId2, address(pilTemplate), termsId, 1, address(this), "", 0); vm.stopPrank(); licensingConfig.expectGroupRewardPool = address(0);