Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(licensing): enable multi-license attachment #128

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions contracts/interfaces/workflows/IGroupingWorkflows.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ interface IGroupingWorkflows {
/// @param spgNftContract The address of the SPGNFT collection.
/// @param groupId The ID of the group IP to add the newly registered IP.
/// @param recipient The address of the recipient of the minted NFT.
/// @param licenseTemplate The address of the license template to be attached to the new IP.
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new IP.
/// @param licenseInfo The information of the license terms that will be attached to the new IP.
/// @param ipMetadata OPTIONAL. The desired metadata for the newly minted NFT and registered IP.
/// @param sigAddToGroup Signature data for addIp to the group IP via the Grouping Module.
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
Expand All @@ -23,8 +22,7 @@ interface IGroupingWorkflows {
address spgNftContract,
address groupId,
address recipient,
address licenseTemplate,
uint256 licenseTermsId,
WorkflowStructs.LicenseInfo[] calldata licenseInfo,
WorkflowStructs.IPMetadata calldata ipMetadata,
WorkflowStructs.SignatureData calldata sigAddToGroup,
bool allowDuplicates
Expand All @@ -35,49 +33,45 @@ interface IGroupingWorkflows {
/// @param nftContract The address of the NFT collection.
/// @param tokenId The ID of the NFT.
/// @param groupId The ID of the group IP to add the newly registered IP.
/// @param licenseTemplate The address of the license template to be attached to the new IP.
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new IP.
/// @param licenseInfo The information of the license terms that will be attached to the new IP.
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata).
/// @param sigAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
/// @param sigsAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
/// The i th signature data is for attaching the i th license terms registered
/// in the i th license template to the IP.
/// @param sigAddToGroup Signature data for addIp to the group IP via the Grouping Module.
/// @return ipId The ID of the newly registered IP.
function registerIpAndAttachLicenseAndAddToGroup(
address nftContract,
uint256 tokenId,
address groupId,
address licenseTemplate,
uint256 licenseTermsId,
WorkflowStructs.LicenseInfo[] calldata licenseInfo,
WorkflowStructs.IPMetadata calldata ipMetadata,
WorkflowStructs.SignatureData calldata sigMetadata,
WorkflowStructs.SignatureData calldata sigAttach,
WorkflowStructs.SignatureData[] calldata sigsAttach,
WorkflowStructs.SignatureData calldata sigAddToGroup
) external returns (address ipId);

/// @notice Register a group IP with a group reward pool and attach license terms to the group IP
/// @param groupPool The address of the group reward pool.
/// @param licenseTemplate The address of the license template to be attached to the new group IP.
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
/// @param licenseInfo The information of the license terms that will be attached to the new group IP.
/// @return groupId The ID of the newly registered group IP.
function registerGroupAndAttachLicense(
address groupPool,
address licenseTemplate,
uint256 licenseTermsId
WorkflowStructs.LicenseInfo calldata licenseInfo
) external returns (address groupId);

/// @notice Register a group IP with a group reward pool, attach license terms to the group IP,
/// and add individual IPs to the group IP.
/// @dev ipIds must be have the same license terms as the group IP.
/// @param groupPool The address of the group reward pool.
/// @param ipIds The IDs of the IPs to add to the newly registered group IP.
/// @param licenseTemplate The address of the license template to be attached to the new group IP.
/// @param licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
/// @param licenseInfo The information of the license terms that will be attached to the new group IP.
/// @return groupId The ID of the newly registered group IP.
function registerGroupAndAttachLicenseAndAddIps(
address groupPool,
address[] calldata ipIds,
address licenseTemplate,
uint256 licenseTermsId
WorkflowStructs.LicenseInfo calldata licenseInfo
) external returns (address groupId);

/// @notice Collect royalties for the entire group and distribute the rewards to each member IP's royalty vault
Expand Down
32 changes: 17 additions & 15 deletions contracts/interfaces/workflows/ILicenseAttachmentWorkflows.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ interface ILicenseAttachmentWorkflows {
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
/// @return ipId The ID of the newly registered IP.
/// @return tokenId The ID of the newly minted NFT.
/// @return licenseTermsId The ID of the newly registered PIL terms.
/// @return licenseTermsIds The IDs of the newly registered PIL terms.
function mintAndRegisterIpAndAttachPILTerms(
address spgNftContract,
address recipient,
WorkflowStructs.IPMetadata calldata ipMetadata,
PILTerms calldata terms,
PILTerms[] calldata terms,
bool allowDuplicates
) external returns (address ipId, uint256 tokenId, uint256 licenseTermsId);
) external returns (address ipId, uint256 tokenId, uint256[] memory licenseTermsIds);

/// @notice Mint an NFT from a SPGNFT collection, register as an IP, attach provided IP metadata,
/// and attach the provided license terms to the newly registered IP.
/// @dev Requires caller to have the minter role or the SPG NFT to allow public minting.
/// @param spgNftContract The address of the SPGNFT collection.
/// @param recipient The address of the recipient of the newly minted NFT.
/// @param ipMetadata OPTIONAL. The desired metadata for the newly minted NFT and registered IP.
/// @param licenseTemplate The address of the license template used of the license terms to be attached.
/// @param licenseTermsId The ID of the license terms to attach. Must be a valid ID that exists
/// in the specified license template.
/// @param licenseTemplates The addresses of the license templates used of the license terms to be attached.
/// @param licenseTermsIds The IDs of the license terms to attach. The i th license terms ID must be a valid license
/// terms that was registered in the i th license template.
/// @param allowDuplicates Set to true to allow minting an NFT with a duplicate metadata hash.
/// @return ipId The ID of the newly registered IP.
/// @return tokenId The ID of the newly minted NFT.
function mintAndRegisterIpAndAttachLicenseTerms(
address spgNftContract,
address recipient,
WorkflowStructs.IPMetadata calldata ipMetadata,
address licenseTemplate,
uint256 licenseTermsId,
address[] calldata licenseTemplates,
uint256[] calldata licenseTermsIds,
bool allowDuplicates
) external returns (address ipId, uint256 tokenId);

Expand All @@ -55,19 +55,21 @@ interface ILicenseAttachmentWorkflows {
/// @param nftContract The address of the NFT collection.
/// @param tokenId The ID of the NFT.
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
/// @param licenseTemplate The address of the license template used of the license terms to be attached.
/// @param licenseTermsId The ID of the license terms to attach. Must be a valid ID that exists
/// in the specified license template.
/// @param licenseTemplates The addresses of the license templates used of the license terms to be attached.
/// @param licenseTermsIds The IDs of the license terms to attach. The i th license terms ID must be a valid license
/// terms that was registered in the i th license template.
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module.
/// @param sigAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
/// @param sigsAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
/// The i th signature data is for attaching the i th license terms registered in the i th license template
/// to the IP.
/// @return ipId The ID of the newly registered IP.
function registerIpAndAttachLicenseTerms(
address nftContract,
uint256 tokenId,
WorkflowStructs.IPMetadata calldata ipMetadata,
address licenseTemplate,
uint256 licenseTermsId,
address[] calldata licenseTemplates,
uint256[] calldata licenseTermsIds,
WorkflowStructs.SignatureData calldata sigMetadata,
WorkflowStructs.SignatureData calldata sigAttach
WorkflowStructs.SignatureData[] calldata sigsAttach
) external returns (address ipId);
}
31 changes: 8 additions & 23 deletions contracts/lib/LicensingHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ library LicensingHelper {
/// @param pilTemplate The address of the PIL License Template.
/// @param licensingModule The address of the Licensing Module.
/// @param terms The PIL terms to be registered.
/// @return licenseTermsId The ID of the registered PIL terms.
/// @return licenseTermsIds The IDs of the registered PIL terms.
function registerPILTermsAndAttach(
address ipId,
address pilTemplate,
address licensingModule,
PILTerms memory terms
) internal returns (uint256 licenseTermsId) {
licenseTermsId = IPILicenseTemplate(pilTemplate).registerLicenseTerms(terms);
attachLicenseTerms(ipId, licensingModule, pilTemplate, licenseTermsId);
PILTerms[] memory terms
) internal returns (uint256[] memory licenseTermsIds) {
licenseTermsIds = new uint256[](terms.length);
for (uint256 i = 0; i < terms.length; i++) {
licenseTermsIds[i] = IPILicenseTemplate(pilTemplate).registerLicenseTerms(terms[i]);
attachLicenseTerms(ipId, licensingModule, pilTemplate, licenseTermsIds[i]);
}
}

/// @dev Attaches license terms to the given IP.
Expand All @@ -50,24 +53,6 @@ library LicensingHelper {
}
}

/// @dev Registers PIL License Terms and attaches them to the given IP on behalf of the owner with a signature.
/// @param ipId The ID of the IP to which the license terms will be attached.
/// @param pilTemplate The address of the PIL License Template.
/// @param licensingModule The address of the Licensing Module.
/// @param terms The PIL terms to be registered.
/// @param sigAttach Signature data for attachLicenseTerms to the IP via the Licensing Module.
/// @return licenseTermsId The ID of the registered PIL terms.
function registerPILTermsAndAttachWithSig(
address ipId,
address pilTemplate,
address licensingModule,
PILTerms calldata terms,
WorkflowStructs.SignatureData memory sigAttach
) internal returns (uint256 licenseTermsId) {
licenseTermsId = IPILicenseTemplate(pilTemplate).registerLicenseTerms(terms);
attachLicenseTermsWithSig(ipId, licensingModule, pilTemplate, licenseTermsId, sigAttach);
}

/// @dev Attaches license terms to the given IP on behalf of the owner with a signature.
/// @param ipId The ID of the IP to which the license terms will be attached.
/// @param licensingModule The address of the Licensing Module.
Expand Down
8 changes: 8 additions & 0 deletions contracts/lib/WorkflowStructs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ library WorkflowStructs {
bytes royaltyContext;
uint256 maxMintingFee;
}

/// @notice Struct for license terms information.
/// @param licenseTemplate The address of the license template.
/// @param licenseTermsId The ID of the license terms which was registered in the license template.
struct LicenseInfo {
address licenseTemplate;
uint256 licenseTermsId;
}
}
Loading