Skip to content

Commit fea444c

Browse files
authored
feat(grouping): add registerGroupAndAttachLicense function (#85)
* feat(grouping): add `registerGroupAndAttachLicense` * docs(grouping): add `registerGroupAndAttachLicense` * test(grouping): add `registerGroupAndAttachLicense` * Update yarn.lock
1 parent 53b1e87 commit fea444c

File tree

6 files changed

+83
-4
lines changed

6 files changed

+83
-4
lines changed

contracts/interfaces/workflows/IGroupingWorkflows.sol

+11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ interface IGroupingWorkflows {
5151
WorkflowStructs.SignatureData calldata sigAddToGroup
5252
) external returns (address ipId);
5353

54+
/// @notice Register a group IP with a group reward pool and attach license terms to the group IP
55+
/// @param groupPool The address of the group reward pool.
56+
/// @param licenseTemplate The address of the license template to be attached to the new group IP.
57+
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
58+
/// @return groupId The ID of the newly registered group IP.
59+
function registerGroupAndAttachLicense(
60+
address groupPool,
61+
address licenseTemplate,
62+
uint256 licenseTermsId
63+
) external returns (address groupId);
64+
5465
/// @notice Register a group IP with a group reward pool, attach license terms to the group IP,
5566
/// and add individual IPs to the group IP.
5667
/// @dev ipIds must be have the same license terms as the group IP.

contracts/workflows/GroupingWorkflows.sol

+24
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,30 @@ contract GroupingWorkflows is
220220
GROUPING_MODULE.addIp(groupId, ipIds);
221221
}
222222

223+
/// @notice Register a group IP with a group reward pool and attach license terms to the group IP
224+
/// @param groupPool The address of the group reward pool.
225+
/// @param licenseTemplate The address of the license template to be attached to the new group IP.
226+
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
227+
/// @return groupId The ID of the newly registered group IP.
228+
function registerGroupAndAttachLicense(
229+
address groupPool,
230+
address licenseTemplate,
231+
uint256 licenseTermsId
232+
) external returns (address groupId) {
233+
groupId = GROUPING_MODULE.registerGroup(groupPool);
234+
235+
// attach license terms to the group IP, do nothing if already attached
236+
LicensingHelper.attachLicenseTerms(
237+
groupId,
238+
address(LICENSING_MODULE),
239+
address(LICENSE_REGISTRY),
240+
licenseTemplate,
241+
licenseTermsId
242+
);
243+
244+
GROUP_NFT.safeTransferFrom(address(this), msg.sender, GROUP_NFT.totalSupply() - 1);
245+
}
246+
223247
/// @notice Register a group IP with a group reward pool, attach license terms to the group IP,
224248
/// and add individual IPs to the group IP.
225249
/// @dev ipIds must have the same PIL terms as the group IP.

docs/WORKFLOWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
- Mints a NFT → Registers it as an IP → Attaches the given license terms to the IP → Adds the IP to a group IP
3838
- `registerIpAndAttachLicenseAndAddToGroup`:
3939
- Registers an IP → Attaches the given license terms to the IP → Adds the IP to a group IP
40+
- `registerGroupAndAttachLicense`:
41+
- Registers a group IP → Attaches the given license terms to the group IP
4042
- `registerGroupAndAttachLicenseAndAddIps`:
4143
- Registers a group IP → Attaches the given license terms to the group IP → Adds existing IPs to the group IP
4244

test/integration/workflows/GroupingIntegration.t.sol

+20
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ contract GroupingIntegration is BaseIntegration {
3434
_setUpTest();
3535
_test_GroupingIntegration_mintAndRegisterIpAndAttachLicenseAndAddToGroup();
3636
_test_GroupingIntegration_registerIpAndAttachLicenseAndAddToGroup();
37+
_test_GroupingIntegration_registerGroupAndAttachLicense();
3738
_test_GroupingIntegration_registerGroupAndAttachLicenseAndAddIps();
3839
_test_GroupingIntegration_multicall_mintAndRegisterIpAndAttachLicenseAndAddToGroup();
3940
_test_GroupingIntegration_multicall_registerIpAndAttachLicenseAndAddToGroup();
@@ -147,6 +148,25 @@ contract GroupingIntegration is BaseIntegration {
147148
assertEq(licenseTermsId, testLicenseTermsId);
148149
}
149150

151+
function _test_GroupingIntegration_registerGroupAndAttachLicense()
152+
private
153+
logTest("test_GroupingIntegration_registerGroupAndAttachLicense")
154+
{
155+
address newGroupId = groupingWorkflows.registerGroupAndAttachLicense({
156+
groupPool: groupRewardPool,
157+
licenseTemplate: testLicenseTemplate,
158+
licenseTermsId: testLicenseTermsId
159+
});
160+
161+
// check the group IPA is registered
162+
assertTrue(IGroupIPAssetRegistry(ipAssetRegistryAddr).isRegisteredGroup(newGroupId));
163+
164+
// check the license terms is correctly attached to the group IPA
165+
(address licenseTemplate, uint256 licenseTermsId) = licenseRegistry.getAttachedLicenseTerms(newGroupId, 0);
166+
assertEq(licenseTemplate, testLicenseTemplate);
167+
assertEq(licenseTermsId, testLicenseTermsId);
168+
}
169+
150170
function _test_GroupingIntegration_registerGroupAndAttachLicenseAndAddIps()
151171
private
152172
logTest("test_GroupingIntegration_registerGroupAndAttachLicenseAndAddIps")

test/workflows/GroupingWorkflows.t.sol

+22
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,28 @@ contract GroupingWorkflowsTest is BaseTest {
173173
assertEq(licenseTermsId, testLicenseTermsId);
174174
}
175175

176+
// Register group IP → Attach license terms to group IPA
177+
function test_GroupingWorkflows_registerGroupAndAttachLicense() public {
178+
vm.startPrank(groupOwner);
179+
address newGroupId = groupingWorkflows.registerGroupAndAttachLicense({
180+
groupPool: address(mockRewardPool),
181+
licenseTemplate: address(pilTemplate),
182+
licenseTermsId: testLicenseTermsId
183+
});
184+
vm.stopPrank();
185+
186+
// check the group IPA is registered
187+
assertTrue(IGroupIPAssetRegistry(ipAssetRegistry).isRegisteredGroup(newGroupId));
188+
189+
// check the license terms is correctly attached to the group IPA
190+
(address licenseTemplate, uint256 licenseTermsId) = ILicenseRegistry(licenseRegistry).getAttachedLicenseTerms(
191+
newGroupId,
192+
0
193+
);
194+
assertEq(licenseTemplate, address(pilTemplate));
195+
assertEq(licenseTermsId, testLicenseTermsId);
196+
}
197+
176198
// Register group IP → Attach license terms to group IPA → Add existing IPs to the new group IPA
177199
function test_GroupingWorkflows_registerGroupAndAttachLicenseAndAddIps() public {
178200
vm.startPrank(groupOwner);

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@
441441

442442
"@story-protocol/protocol-core@github:storyprotocol/protocol-core-v1#main":
443443
version "1.1.0"
444-
resolved "https://codeload.github.com/storyprotocol/protocol-core-v1/tar.gz/0aed667579299c8a263a60236cb6d93f0ac8aa72"
444+
resolved "https://codeload.github.com/storyprotocol/protocol-core-v1/tar.gz/7834ac522e8b0e3f95adffe15815c4b9b0412377"
445445
dependencies:
446446
"@openzeppelin/contracts" "5.0.2"
447447
"@openzeppelin/contracts-upgradeable" "5.0.2"
@@ -495,9 +495,9 @@
495495
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==
496496

497497
"@types/node@*":
498-
version "22.7.3"
499-
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.3.tgz#7ddf1ddf13078692b4cfadb835852b2a718ee1ef"
500-
integrity sha512-qXKfhXXqGTyBskvWEzJZPUxSslAiLaB6JGP1ic/XTH9ctGgzdgYguuLP1C601aRTSDNlLb0jbKqXjZ48GNraSA==
498+
version "22.7.4"
499+
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc"
500+
integrity sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==
501501
dependencies:
502502
undici-types "~6.19.2"
503503

0 commit comments

Comments
 (0)