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

Update PILicenseTemplate for Compatibility Checks of derivativesReciprocal #157

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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ILicenseTemplate } from "../../../interfaces/modules/licensing/ILicense
struct PILTerms {
bool transferable;
address royaltyPolicy;
uint256 mintingFee;
uint256 defaultMintingFee;
kingster-will marked this conversation as resolved.
Show resolved Hide resolved
uint256 expiration;
bool commercialUse;
bool commercialAttribution;
Expand Down
8 changes: 4 additions & 4 deletions contracts/lib/PILFlavors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ library PILFlavors {
PILTerms({
transferable: true,
royaltyPolicy: address(0),
mintingFee: 0,
defaultMintingFee: 0,
kingster-will marked this conversation as resolved.
Show resolved Hide resolved
expiration: 0,
commercialUse: false,
commercialAttribution: false,
Expand All @@ -126,7 +126,7 @@ library PILFlavors {
PILTerms({
transferable: true,
royaltyPolicy: address(0),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 0,
commercialUse: false,
commercialAttribution: false,
Expand Down Expand Up @@ -154,7 +154,7 @@ library PILFlavors {
PILTerms({
transferable: true,
royaltyPolicy: royaltyPolicy,
mintingFee: mintingFee,
defaultMintingFee: mintingFee,
expiration: 0,
commercialUse: true,
commercialAttribution: true,
Expand Down Expand Up @@ -183,7 +183,7 @@ library PILFlavors {
PILTerms({
transferable: true,
royaltyPolicy: royaltyPolicy,
mintingFee: mintingFee,
defaultMintingFee: mintingFee,
expiration: 0,
commercialUse: true,
commercialAttribution: true,
Expand Down
3 changes: 2 additions & 1 deletion contracts/modules/licensing/PILicenseTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ contract PILicenseTemplate is
uint256 licenseTermsId
) external view returns (address royaltyPolicy, bytes memory royaltyData, uint256 mintingFee, address currency) {
PILTerms memory terms = _getPILicenseTemplateStorage().licenseTerms[licenseTermsId];
return (terms.royaltyPolicy, abi.encode(terms.commercialRevShare), terms.mintingFee, terms.currency);
return (terms.royaltyPolicy, abi.encode(terms.commercialRevShare), terms.defaultMintingFee, terms.currency);
}

/// @notice Checks if a license terms is transferable.
Expand Down Expand Up @@ -463,6 +463,7 @@ contract PILicenseTemplate is
for (uint256 i = 1; i < licenseTermsIds.length; i++) {
if ($.licenseTerms[licenseTermsIds[i]].commercialUse != commercial) return false;
if ($.licenseTerms[licenseTermsIds[i]].derivativesReciprocal != derivativesReciprocal) return false;
if (derivativesReciprocal && licenseTermsIds[0] != licenseTermsIds[i]) return false;
jdubpark marked this conversation as resolved.
Show resolved Hide resolved
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/LicenseToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract LicenseTokenTest is BaseTest {
PILTerms({
transferable: false,
royaltyPolicy: address(0),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 0,
commercialUse: false,
commercialAttribution: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract BigBang_Integration_SingleNftCollection is BaseIntegration {
PILTerms({
transferable: true,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: mintingFee,
defaultMintingFee: mintingFee,
expiration: 0,
commercialUse: true,
commercialAttribution: false,
Expand Down
33 changes: 11 additions & 22 deletions test/foundry/modules/licensing/LicensingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ contract LicensingModuleTest is BaseTest {
PILTerms memory terms = PILTerms({
transferable: true,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 10 days,
commercialUse: true,
commercialAttribution: true,
Expand Down Expand Up @@ -419,7 +419,7 @@ contract LicensingModuleTest is BaseTest {
PILTerms memory terms = PILTerms({
transferable: true,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 10 days,
commercialUse: true,
commercialAttribution: true,
Expand Down Expand Up @@ -734,20 +734,19 @@ contract LicensingModuleTest is BaseTest {
}

function test_LicensingModule_registerDerivativeWithLicenseTokens_revert_ParentExpired() public {
uint256 termsId = pilTemplate.registerLicenseTerms(PILFlavors.nonCommercialSocialRemixing());
PILTerms memory expiredTerms = PILFlavors.nonCommercialSocialRemixing();
expiredTerms.expiration = 10 days;
uint256 expiredTermsId = pilTemplate.registerLicenseTerms(expiredTerms);

vm.prank(ipOwner1);
licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId);
licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), expiredTermsId);
vm.prank(ipOwner2);
licensingModule.attachLicenseTerms(ipId2, address(pilTemplate), expiredTermsId);

uint256 lcTokenId1 = licensingModule.mintLicenseTokens({
licensorIpId: ipId1,
licenseTemplate: address(pilTemplate),
licenseTermsId: termsId,
licenseTermsId: expiredTermsId,
amount: 1,
receiver: ipOwner3,
royaltyContext: ""
Expand All @@ -763,7 +762,7 @@ contract LicensingModuleTest is BaseTest {
});

assertEq(licenseToken.ownerOf(lcTokenId1), ipOwner3);
assertEq(licenseToken.getLicenseTermsId(lcTokenId1), termsId);
assertEq(licenseToken.getLicenseTermsId(lcTokenId1), expiredTermsId);
assertEq(licenseToken.getLicenseTemplate(lcTokenId1), address(pilTemplate));
assertEq(licenseToken.getLicensorIpId(lcTokenId1), ipId1);

Expand All @@ -782,9 +781,8 @@ contract LicensingModuleTest is BaseTest {
vm.prank(ipOwner3);
licensingModule.registerDerivativeWithLicenseTokens(ipId3, licenseTokens, "");

assertEq(licenseRegistry.hasIpAttachedLicenseTerms(ipId3, address(pilTemplate), termsId), true);
assertEq(licenseRegistry.hasIpAttachedLicenseTerms(ipId3, address(pilTemplate), expiredTermsId), true);
assertEq(licenseRegistry.getAttachedLicenseTermsCount(ipId3), 2);
assertEq(licenseRegistry.getAttachedLicenseTermsCount(ipId3), 1);
assertEq(licenseRegistry.isDerivativeIp(ipId3), true);
assertEq(licenseRegistry.hasDerivativeIps(ipId3), false);
assertEq(licenseRegistry.getDerivativeIpCount(ipId3), 0);
Expand All @@ -805,24 +803,15 @@ contract LicensingModuleTest is BaseTest {

(address licenseTemplate, uint256 licenseTermsId) = licenseRegistry.getAttachedLicenseTerms(ipId3, 0);
assertEq(licenseTemplate, address(pilTemplate));
assertEq(licenseTermsId, termsId);
(address anotherLicenseTemplate, uint256 anotherLicenseTermsId) = licenseRegistry.getAttachedLicenseTerms(
ipId3,
1
);
assertEq(anotherLicenseTemplate, address(pilTemplate));
assertEq(anotherLicenseTermsId, expiredTermsId);
uint256[] memory licenseTerms = new uint256[](2);
licenseTerms[0] = termsId;
licenseTerms[1] = expiredTermsId;
assertEq(licenseTermsId, expiredTermsId);

assertEq(licenseRegistry.getExpireTime(ipId3), block.timestamp + 10 days, "IPA has unexpected expiration time");
vm.warp(5 days);

uint256 lcTokenId3 = licensingModule.mintLicenseTokens({
licensorIpId: ipId3,
licenseTemplate: address(pilTemplate),
licenseTermsId: termsId,
licenseTermsId: expiredTermsId,
amount: 1,
receiver: ipOwner5,
royaltyContext: ""
Expand Down Expand Up @@ -972,7 +961,7 @@ contract LicensingModuleTest is BaseTest {
PILTerms memory terms = PILTerms({
transferable: true,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 0,
commercialUse: true,
commercialAttribution: true,
Expand Down Expand Up @@ -1021,7 +1010,7 @@ contract LicensingModuleTest is BaseTest {
PILTerms memory terms = PILTerms({
transferable: true,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 0,
commercialUse: true,
commercialAttribution: true,
Expand Down Expand Up @@ -1068,7 +1057,7 @@ contract LicensingModuleTest is BaseTest {
PILTerms memory terms = PILTerms({
transferable: true,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 0,
commercialUse: true,
commercialAttribution: true,
Expand Down
18 changes: 17 additions & 1 deletion test/foundry/modules/licensing/PILicenseTemplate.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ contract PILicenseTemplateTest is BaseTest {
})
);
PILTerms memory terms = pilTemplate.getLicenseTerms(commUseTermsId);
assertEq(terms.mintingFee, 100);
assertEq(terms.defaultMintingFee, 100);
assertEq(terms.currency, address(erc20));
assertEq(terms.royaltyPolicy, address(royaltyPolicyLAP));
}
Expand Down Expand Up @@ -418,6 +418,22 @@ contract PILicenseTemplateTest is BaseTest {
licenseTermsIds[0] = socialRemixTermsId;
licenseTermsIds[1] = socialRemixTermsId;
assertTrue(pilTemplate.verifyCompatibleLicenses(licenseTermsIds));

uint256 anotherCommRemixTermsId = pilTemplate.registerLicenseTerms(
PILFlavors.commercialRemix({
mintingFee: 200,
commercialRevShare: 20,
royaltyPolicy: address(royaltyPolicyLAP),
currencyToken: address(erc20)
})
);
licenseTermsIds[0] = commRemixTermsId;
licenseTermsIds[1] = anotherCommRemixTermsId;
assertFalse(pilTemplate.verifyCompatibleLicenses(licenseTermsIds));

licenseTermsIds[0] = commRemixTermsId;
licenseTermsIds[1] = commRemixTermsId;
assertTrue(pilTemplate.verifyCompatibleLicenses(licenseTermsIds));
}

// test verifyRegisterDerivativeForAllParents
Expand Down
4 changes: 2 additions & 2 deletions test/foundry/utils/LicensingHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ contract LicensingHelper {
PILTerms({
transferable: transferable,
royaltyPolicy: address(royaltyPolicyLAP),
mintingFee: 1 ether,
defaultMintingFee: 1 ether,
kingster-will marked this conversation as resolved.
Show resolved Hide resolved
expiration: 0,
commercialUse: true,
commercialAttribution: false,
Expand All @@ -112,7 +112,7 @@ contract LicensingHelper {
PILTerms({
transferable: transferable,
royaltyPolicy: address(0),
mintingFee: 0,
defaultMintingFee: 0,
expiration: 0,
commercialUse: false,
commercialAttribution: false,
Expand Down
Loading