Skip to content

Commit

Permalink
Merge branch 'storyprotocol:main' into fix-transfer-vault
Browse files Browse the repository at this point in the history
  • Loading branch information
Spablob authored Dec 3, 2024
2 parents 50a2ac0 + 5f5f3e1 commit 43f224f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
6 changes: 3 additions & 3 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ library Errors {
/// @notice Provided license template does not match the IP's current license template.
error LicenseRegistry__UnmatchedLicenseTemplate(address ipId, address licenseTemplate, address newLicenseTemplate);

/// @notice Provided license template and terms ID is a duplicate.
error LicenseRegistry__DuplicateLicense(address ipId, address licenseTemplate, uint256 licenseTermsId);

/// @notice Zero address provided for License Template.
error LicenseRegistry__ZeroLicenseTemplate();

Expand Down Expand Up @@ -283,6 +280,9 @@ library Errors {
/// @notice The IP has no attached the same license terms of Group IPA.
error LicenseRegistry__IpHasNoGroupLicenseTerms(address groupId, address licenseTemplate, uint256 licenseTermsId);

/// @notice The IP has already linked to the same parent IP.
error LicenseRegistry__DuplicateParentIp(address ipId, address parentIpId);

/// @notice When Set LicenseConfig the license template cannot be Zero address if royalty percentage is not Zero.
error LicensingModule__LicenseTemplateCannotBeZeroAddressToOverrideRoyaltyPercent();

Expand Down
8 changes: 4 additions & 4 deletions contracts/registries/LicenseRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ contract LicenseRegistry is ILicenseRegistry, AccessManagedUpgradeable, UUPSUpgr
isUsingLicenseToken
);
$.childIps[parentIpIds[i]].add(childIpId);
// determine if duplicate license terms
// determine if duplicate parent IP
bool isNewParent = $.parentIps[childIpId].add(parentIpIds[i]);
bool isNewTerms = $.attachedLicenseTerms[childIpId].add(licenseTermsIds[i]);
if (!isNewParent && !isNewTerms) {
revert Errors.LicenseRegistry__DuplicateLicense(parentIpIds[i], licenseTemplate, licenseTermsIds[i]);
if (!isNewParent) {
revert Errors.LicenseRegistry__DuplicateParentIp(childIpId, parentIpIds[i]);
}
$.attachedLicenseTerms[childIpId].add(licenseTermsIds[i]);
// link child IP to parent IP with license terms
$.parentLicenseTerms[childIpId][parentIpIds[i]] = licenseTermsIds[i];
}
Expand Down
7 changes: 1 addition & 6 deletions test/foundry/integration/flows/royalty/Royalty.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ contract Flows_Integration_Disputes is BaseIntegration {
ipAcct[2] = registerIpAccount(address(mockNFT), 2, u.bob);

vm.expectRevert(
abi.encodeWithSelector(
Errors.LicenseRegistry__DuplicateLicense.selector,
ipAcct[1],
address(pilTemplate),
commRemixTermsId
)
abi.encodeWithSelector(Errors.LicenseRegistry__DuplicateParentIp.selector, ipAcct[2], ipAcct[1])
);
licensingModule.registerDerivativeWithLicenseTokens(ipAcct[2], licenseIds, "", 100e6);

Expand Down
18 changes: 10 additions & 8 deletions test/foundry/registries/LicenseRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,15 @@ contract LicenseRegistryTest is BaseTest {
});
}

function test_LicenseRegistry_registerDerivativeIp_revert_DuplicateLicense() public {
function test_LicenseRegistry_registerDerivativeIp_revert_DuplicateParents() public {
uint256 socialRemixTermsId = pilTemplate.registerLicenseTerms(PILFlavors.nonCommercialSocialRemixing());
uint256 commRemixTermsId = pilTemplate.registerLicenseTerms(
PILFlavors.commercialRemix(0, 10, address(royaltyPolicyLAP), address(erc20))
);

vm.prank(ipOwner[1]);
licensingModule.attachLicenseTerms(ipAcct[1], address(pilTemplate), commRemixTermsId);

vm.prank(ipOwner[1]);
vm.expectRevert(
abi.encodeWithSelector(
Expand All @@ -427,14 +434,9 @@ contract LicenseRegistryTest is BaseTest {
parentIpIds[1] = ipAcct[1];
uint256[] memory licenseTermsIds = new uint256[](2);
licenseTermsIds[0] = socialRemixTermsId;
licenseTermsIds[1] = socialRemixTermsId;
licenseTermsIds[1] = commRemixTermsId;
vm.expectRevert(
abi.encodeWithSelector(
Errors.LicenseRegistry__DuplicateLicense.selector,
ipAcct[1],
address(pilTemplate),
socialRemixTermsId
)
abi.encodeWithSelector(Errors.LicenseRegistry__DuplicateParentIp.selector, ipAcct[2], ipAcct[1])
);
vm.prank(address(licensingModule));
licenseRegistry.registerDerivativeIp({
Expand Down

0 comments on commit 43f224f

Please sign in to comment.