Skip to content

Commit

Permalink
require IP has vault to be added to group
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will committed Dec 12, 2024
1 parent d2281f5 commit 2d311fe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions contracts/modules/grouping/GroupingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions test/foundry/modules/grouping/GroupingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2d311fe

Please sign in to comment.