Skip to content

Commit e153ef0

Browse files
committed
Revert "refactor(permission): enable direct function calls via executeWithSig (storyprotocol#121)"
This reverts commit a6fbf2c. Revert "feat(licensing): support custom license templates and decouple terms registration from attachment (storyprotocol#123)" This reverts commit 68f4a4a. Revert "feat(licensing): enable multi-license attachment (storyprotocol#128)" This reverts commit 027eed9.
1 parent 027eed9 commit e153ef0

33 files changed

+1628
-2152
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ function mintAndRegisterIpAndAttachPILTerms(
2424
address nftContract,
2525
address recipient,
2626
IPMetadata calldata ipMetadata,
27-
PILTerms calldata terms,
28-
bool allowDuplicates
27+
PILTerms calldata terms
2928
) external onlyCallerWithMinterRole(nftContract) returns (address ipId, uint256 tokenId, uint256 licenseTermsId)
3029
```
3130

contracts/interfaces/workflows/IDerivativeWorkflows.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ interface IDerivativeWorkflows {
2929
/// @param derivData The derivative data to be used for registerDerivative.
3030
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
3131
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module.
32-
/// @param sigMintingFee OPTIONAL. Signature data for approving license minting fee for the IP via the currency token.
3332
/// @param sigRegister Signature data for registerDerivative for the IP via the Licensing Module.
3433
/// @return ipId The ID of the newly registered IP.
3534
function registerIpAndMakeDerivative(
@@ -38,7 +37,6 @@ interface IDerivativeWorkflows {
3837
WorkflowStructs.MakeDerivative calldata derivData,
3938
WorkflowStructs.IPMetadata calldata ipMetadata,
4039
WorkflowStructs.SignatureData calldata sigMetadata,
41-
WorkflowStructs.SignatureData calldata sigMintingFee,
4240
WorkflowStructs.SignatureData calldata sigRegister
4341
) external returns (address ipId);
4442

@@ -48,6 +46,7 @@ interface IDerivativeWorkflows {
4846
/// @param spgNftContract The address of the SPGNFT collection.
4947
/// @param licenseTokenIds The IDs of the license tokens to be burned for linking the IP to parent IPs.
5048
/// @param royaltyContext The context for royalty module, should be empty for Royalty Policy LAP.
49+
/// @param maxRts The maximum number of royalty tokens that can be distributed to the external royalty policies.
5150
/// @param ipMetadata OPTIONAL. The desired metadata for the newly minted NFT and registered IP.
5251
/// @param recipient The address to receive the minted NFT.
5352
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
@@ -57,6 +56,7 @@ interface IDerivativeWorkflows {
5756
address spgNftContract,
5857
uint256[] calldata licenseTokenIds,
5958
bytes calldata royaltyContext,
59+
uint32 maxRts,
6060
WorkflowStructs.IPMetadata calldata ipMetadata,
6161
address recipient,
6262
bool allowDuplicates
@@ -68,6 +68,7 @@ interface IDerivativeWorkflows {
6868
/// @param tokenId The ID of the NFT.
6969
/// @param licenseTokenIds The IDs of the license tokens to be burned for linking the IP to parent IPs.
7070
/// @param royaltyContext The context for royalty module, should be empty for Royalty Policy LAP.
71+
/// @param maxRts The maximum number of royalty tokens that can be distributed to the external royalty policies.
7172
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
7273
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module.
7374
/// @param sigRegister Signature data for registerDerivativeWithLicenseTokens for the IP via the Licensing Module.
@@ -77,6 +78,7 @@ interface IDerivativeWorkflows {
7778
uint256 tokenId,
7879
uint256[] calldata licenseTokenIds,
7980
bytes calldata royaltyContext,
81+
uint32 maxRts,
8082
WorkflowStructs.IPMetadata calldata ipMetadata,
8183
WorkflowStructs.SignatureData calldata sigMetadata,
8284
WorkflowStructs.SignatureData calldata sigRegister

contracts/interfaces/workflows/IGroupingWorkflows.sol

+19-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ interface IGroupingWorkflows {
1212
/// @param spgNftContract The address of the SPGNFT collection.
1313
/// @param groupId The ID of the group IP to add the newly registered IP.
1414
/// @param recipient The address of the recipient of the minted NFT.
15-
/// @param licenseInfo The information of the license terms that will be attached to the new IP.
15+
/// @param licenseTemplate The address of the license template to be attached to the new IP.
16+
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new IP.
1617
/// @param ipMetadata OPTIONAL. The desired metadata for the newly minted NFT and registered IP.
1718
/// @param sigAddToGroup Signature data for addIp to the group IP via the Grouping Module.
1819
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
@@ -22,7 +23,8 @@ interface IGroupingWorkflows {
2223
address spgNftContract,
2324
address groupId,
2425
address recipient,
25-
WorkflowStructs.LicenseInfo[] calldata licenseInfo,
26+
address licenseTemplate,
27+
uint256 licenseTermsId,
2628
WorkflowStructs.IPMetadata calldata ipMetadata,
2729
WorkflowStructs.SignatureData calldata sigAddToGroup,
2830
bool allowDuplicates
@@ -33,45 +35,48 @@ interface IGroupingWorkflows {
3335
/// @param nftContract The address of the NFT collection.
3436
/// @param tokenId The ID of the NFT.
3537
/// @param groupId The ID of the group IP to add the newly registered IP.
36-
/// @param licenseInfo The information of the license terms that will be attached to the new IP.
38+
/// @param licenseTemplate The address of the license template to be attached to the new IP.
39+
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new IP.
3740
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
38-
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata).
39-
/// @param sigsAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
40-
/// The i th signature data is for attaching the i th license terms registered
41-
/// in the i th license template to the IP.
41+
/// @param sigMetadataAndAttach Signature data for setAll (metadata) and attachLicenseTerms to the IP
42+
/// via the Core Metadata Module and Licensing Module.
4243
/// @param sigAddToGroup Signature data for addIp to the group IP via the Grouping Module.
4344
/// @return ipId The ID of the newly registered IP.
4445
function registerIpAndAttachLicenseAndAddToGroup(
4546
address nftContract,
4647
uint256 tokenId,
4748
address groupId,
48-
WorkflowStructs.LicenseInfo[] calldata licenseInfo,
49+
address licenseTemplate,
50+
uint256 licenseTermsId,
4951
WorkflowStructs.IPMetadata calldata ipMetadata,
50-
WorkflowStructs.SignatureData calldata sigMetadata,
51-
WorkflowStructs.SignatureData[] calldata sigsAttach,
52+
WorkflowStructs.SignatureData calldata sigMetadataAndAttach,
5253
WorkflowStructs.SignatureData calldata sigAddToGroup
5354
) external returns (address ipId);
5455

5556
/// @notice Register a group IP with a group reward pool and attach license terms to the group IP
5657
/// @param groupPool The address of the group reward pool.
57-
/// @param licenseInfo The information of the license terms that will be attached to the new group IP.
58+
/// @param licenseTemplate The address of the license template to be attached to the new group IP.
59+
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
5860
/// @return groupId The ID of the newly registered group IP.
5961
function registerGroupAndAttachLicense(
6062
address groupPool,
61-
WorkflowStructs.LicenseInfo calldata licenseInfo
63+
address licenseTemplate,
64+
uint256 licenseTermsId
6265
) external returns (address groupId);
6366

6467
/// @notice Register a group IP with a group reward pool, attach license terms to the group IP,
6568
/// and add individual IPs to the group IP.
6669
/// @dev ipIds must be have the same license terms as the group IP.
6770
/// @param groupPool The address of the group reward pool.
6871
/// @param ipIds The IDs of the IPs to add to the newly registered group IP.
69-
/// @param licenseInfo The information of the license terms that will be attached to the new group IP.
72+
/// @param licenseTemplate The address of the license template to be attached to the new group IP.
73+
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
7074
/// @return groupId The ID of the newly registered group IP.
7175
function registerGroupAndAttachLicenseAndAddIps(
7276
address groupPool,
7377
address[] calldata ipIds,
74-
WorkflowStructs.LicenseInfo calldata licenseInfo
78+
address licenseTemplate,
79+
uint256 licenseTermsId
7580
) external returns (address groupId);
7681

7782
/// @notice Collect royalties for the entire group and distribute the rewards to each member IP's royalty vault

contracts/interfaces/workflows/ILicenseAttachmentWorkflows.sol

+28-42
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,54 @@ import { WorkflowStructs } from "../../lib/WorkflowStructs.sol";
88
/// @title License Attachment Workflows Interface
99
/// @notice Interface for IP license attachment workflows.
1010
interface ILicenseAttachmentWorkflows {
11-
/// @notice Mint an NFT from a SPGNFT collection, register it as an IP, attach provided IP metadata,
12-
/// register Programmable IPLicense Terms (if unregistered), and attach it to the newly registered IP.
11+
/// @notice Register Programmable IP License Terms (if unregistered) and attach it to IP.
12+
/// @param ipId The ID of the IP.
13+
/// @param terms The PIL terms to be registered.
14+
/// @param sigAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
15+
/// @return licenseTermsId The ID of the newly registered PIL terms.
16+
function registerPILTermsAndAttach(
17+
address ipId,
18+
PILTerms calldata terms,
19+
WorkflowStructs.SignatureData calldata sigAttach
20+
) external returns (uint256 licenseTermsId);
21+
22+
/// @notice Mint an NFT from a SPGNFT collection, register it with metadata as an IP,
23+
/// register Programmable IPLicense
24+
/// Terms (if unregistered), and attach it to the registered IP.
1325
/// @dev Requires caller to have the minter role or the SPG NFT to allow public minting.
1426
/// @param spgNftContract The address of the SPGNFT collection.
1527
/// @param recipient The address of the recipient of the minted NFT.
1628
/// @param ipMetadata OPTIONAL. The desired metadata for the newly minted NFT and registered IP.
17-
/// @param terms The PIL terms to be registered and attached to the newly registered IP.
29+
/// @param terms The PIL terms to be registered.
1830
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
1931
/// @return ipId The ID of the newly registered IP.
2032
/// @return tokenId The ID of the newly minted NFT.
21-
/// @return licenseTermsIds The IDs of the newly registered PIL terms.
33+
/// @return licenseTermsId The ID of the newly registered PIL terms.
2234
function mintAndRegisterIpAndAttachPILTerms(
2335
address spgNftContract,
2436
address recipient,
2537
WorkflowStructs.IPMetadata calldata ipMetadata,
26-
PILTerms[] calldata terms,
27-
bool allowDuplicates
28-
) external returns (address ipId, uint256 tokenId, uint256[] memory licenseTermsIds);
29-
30-
/// @notice Mint an NFT from a SPGNFT collection, register as an IP, attach provided IP metadata,
31-
/// and attach the provided license terms to the newly registered IP.
32-
/// @dev Requires caller to have the minter role or the SPG NFT to allow public minting.
33-
/// @param spgNftContract The address of the SPGNFT collection.
34-
/// @param recipient The address of the recipient of the newly minted NFT.
35-
/// @param ipMetadata OPTIONAL. The desired metadata for the newly minted NFT and registered IP.
36-
/// @param licenseTemplates The addresses of the license templates used of the license terms to be attached.
37-
/// @param licenseTermsIds The IDs of the license terms to attach. The i th license terms ID must be a valid license
38-
/// terms that was registered in the i th license template.
39-
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
40-
/// @return ipId The ID of the newly registered IP.
41-
/// @return tokenId The ID of the newly minted NFT.
42-
function mintAndRegisterIpAndAttachLicenseTerms(
43-
address spgNftContract,
44-
address recipient,
45-
WorkflowStructs.IPMetadata calldata ipMetadata,
46-
address[] calldata licenseTemplates,
47-
uint256[] calldata licenseTermsIds,
38+
PILTerms calldata terms,
4839
bool allowDuplicates
49-
) external returns (address ipId, uint256 tokenId);
40+
) external returns (address ipId, uint256 tokenId, uint256 licenseTermsId);
5041

51-
/// @notice Register a given NFT as an IP, attach provided IP metadata, and attach the provided license terms to the
52-
/// newly registered IP.
53-
/// @dev Since IP Account is created in this function, we need signatures to allow this contract to set metadata
54-
/// and attach PIL Terms to the newly created IP Account on behalf of the owner.
42+
/// @notice Register a given NFT as an IP and attach Programmable IP License Terms.
43+
/// @dev Because IP Account is created in this function, we need to set the permission via signature to allow this
44+
/// contract to attach PIL Terms to the newly created IP Account in the same function.
5545
/// @param nftContract The address of the NFT collection.
5646
/// @param tokenId The ID of the NFT.
5747
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
58-
/// @param licenseTemplates The addresses of the license templates used of the license terms to be attached.
59-
/// @param licenseTermsIds The IDs of the license terms to attach. The i th license terms ID must be a valid license
60-
/// terms that was registered in the i th license template.
48+
/// @param terms The PIL terms to be registered.
6149
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module.
62-
/// @param sigsAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
63-
/// The i th signature data is for attaching the i th license terms registered in the i th license template
64-
/// to the IP.
50+
/// @param sigAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
6551
/// @return ipId The ID of the newly registered IP.
66-
function registerIpAndAttachLicenseTerms(
52+
/// @return licenseTermsId The ID of the newly registered PIL terms.
53+
function registerIpAndAttachPILTerms(
6754
address nftContract,
6855
uint256 tokenId,
6956
WorkflowStructs.IPMetadata calldata ipMetadata,
70-
address[] calldata licenseTemplates,
71-
uint256[] calldata licenseTermsIds,
57+
PILTerms calldata terms,
7258
WorkflowStructs.SignatureData calldata sigMetadata,
73-
WorkflowStructs.SignatureData[] calldata sigsAttach
74-
) external returns (address ipId);
59+
WorkflowStructs.SignatureData calldata sigAttach
60+
) external returns (address ipId, uint256 licenseTermsId);
7561
}

contracts/lib/LicensingHelper.sol

+10-50
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,41 @@
22
pragma solidity 0.8.26;
33

44
import { Errors as CoreErrors } from "@storyprotocol/core/lib/Errors.sol";
5-
import { IIPAccount } from "@storyprotocol/core/interfaces/IIPAccount.sol";
65
import { ILicensingModule } from "@storyprotocol/core/interfaces/modules/licensing/ILicensingModule.sol";
76
import { IPILicenseTemplate, PILTerms } from "@storyprotocol/core/interfaces/modules/licensing/IPILicenseTemplate.sol";
87

9-
import { WorkflowStructs } from "../lib/WorkflowStructs.sol";
10-
118
/// @title Periphery Licensing Helper Library
129
/// @notice Library for all licensing related helper functions for Periphery contracts.
1310
library LicensingHelper {
1411
/// @dev Registers PIL License Terms and attaches them to the given IP.
1512
/// @param ipId The ID of the IP.
1613
/// @param pilTemplate The address of the PIL License Template.
1714
/// @param licensingModule The address of the Licensing Module.
15+
/// @param licenseRegistry The address of the License Registry.
1816
/// @param terms The PIL terms to be registered.
19-
/// @return licenseTermsIds The IDs of the registered PIL terms.
17+
/// @return licenseTermsId The ID of the registered PIL terms.
2018
function registerPILTermsAndAttach(
2119
address ipId,
2220
address pilTemplate,
2321
address licensingModule,
24-
PILTerms[] memory terms
25-
) internal returns (uint256[] memory licenseTermsIds) {
26-
licenseTermsIds = new uint256[](terms.length);
27-
for (uint256 i = 0; i < terms.length; i++) {
28-
licenseTermsIds[i] = IPILicenseTemplate(pilTemplate).registerLicenseTerms(terms[i]);
29-
attachLicenseTerms(ipId, licensingModule, pilTemplate, licenseTermsIds[i]);
30-
}
22+
address licenseRegistry,
23+
PILTerms calldata terms
24+
) internal returns (uint256 licenseTermsId) {
25+
licenseTermsId = IPILicenseTemplate(pilTemplate).registerLicenseTerms(terms);
26+
27+
attachLicenseTerms(ipId, licensingModule, licenseRegistry, pilTemplate, licenseTermsId);
3128
}
3229

3330
/// @dev Attaches license terms to the given IP.
3431
/// @param ipId The ID of the IP.
3532
/// @param licensingModule The address of the Licensing Module.
33+
/// @param licenseRegistry The address of the License Registry.
3634
/// @param licenseTemplate The address of the license template.
3735
/// @param licenseTermsId The ID of the license terms to be attached.
3836
function attachLicenseTerms(
3937
address ipId,
4038
address licensingModule,
39+
address licenseRegistry,
4140
address licenseTemplate,
4241
uint256 licenseTermsId
4342
) internal {
@@ -52,43 +51,4 @@ library LicensingHelper {
5251
}
5352
}
5453
}
55-
56-
/// @dev Attaches license terms to the given IP on behalf of the owner with a signature.
57-
/// @param ipId The ID of the IP to which the license terms will be attached.
58-
/// @param licensingModule The address of the Licensing Module.
59-
/// @param licenseTemplate The address of the license template.
60-
/// @param licenseTermsId The ID of the license terms to be attached.
61-
/// @param sigAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
62-
function attachLicenseTermsWithSig(
63-
address ipId,
64-
address licensingModule,
65-
address licenseTemplate,
66-
uint256 licenseTermsId,
67-
WorkflowStructs.SignatureData memory sigAttach
68-
) internal {
69-
try
70-
IIPAccount(payable(ipId)).executeWithSig({
71-
to: address(licensingModule),
72-
value: 0,
73-
data: abi.encodeWithSelector(
74-
ILicensingModule.attachLicenseTerms.selector,
75-
ipId,
76-
licenseTemplate,
77-
licenseTermsId
78-
),
79-
signer: sigAttach.signer,
80-
deadline: sigAttach.deadline,
81-
signature: sigAttach.signature
82-
})
83-
{
84-
return; // license terms are attached successfully
85-
} catch (bytes memory reason) {
86-
// if the error is not that the license terms are already attached, revert with the original error
87-
if (CoreErrors.LicenseRegistry__LicenseTermsAlreadyAttached.selector != bytes4(reason)) {
88-
assembly {
89-
revert(add(reason, 32), mload(reason))
90-
}
91-
}
92-
}
93-
}
9454
}

0 commit comments

Comments
 (0)