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

Enforce Licensing Config to Only Increase Royalty Percentage #310

Merged
merged 2 commits into from
Nov 20, 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
2 changes: 1 addition & 1 deletion contracts/modules/licensing/PILicenseTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ contract PILicenseTemplate is
function canOverrideRoyaltyPercent(uint256 licenseTermsId, uint32 newRoyaltyPercent) external view returns (bool) {
if (licenseTermsId == 0 || newRoyaltyPercent == 0) return false;
PILTerms memory terms = _getPILicenseTemplateStorage().licenseTerms[licenseTermsId];
return terms.commercialUse;
return terms.commercialUse && newRoyaltyPercent >= terms.commercialRevShare;
}

/// @notice checks the contract whether supports the given interface.
Expand Down
33 changes: 33 additions & 0 deletions test/foundry/modules/licensing/LicensingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,39 @@ contract LicensingModuleTest is BaseTest {
licensingModule.setLicensingConfig(ipId1, address(pilTemplate), socialRemixTermsId, licensingConfig);
}

function test_LicensingModule_setLicensingConfig_revert_newRoyaltyPercentLessThanLicenseTerms() public {
uint256 commRemixTermsId = pilTemplate.registerLicenseTerms(
PILFlavors.commercialRemix({
mintingFee: 0,
commercialRevShare: 20_000_000,
royaltyPolicy: address(royaltyPolicyLRP),
currencyToken: address(erc20)
})
);
MockLicensingHook licensingHook = new MockLicensingHook();
vm.prank(admin);
moduleRegistry.registerModule("MockLicensingHook", address(licensingHook));
Licensing.LicensingConfig memory licensingConfig = Licensing.LicensingConfig({
isSet: true,
mintingFee: 100,
licensingHook: address(licensingHook),
hookData: abi.encode(address(0x123)),
commercialRevShare: 10_000_000,
disabled: false
});

vm.expectRevert(
abi.encodeWithSelector(
Errors.LicensingModule__CurrentLicenseNotAllowOverrideRoyaltyPercent.selector,
address(pilTemplate),
commRemixTermsId,
10_000_000
)
);
vm.prank(ipOwner1);
licensingModule.setLicensingConfig(ipId1, address(pilTemplate), commRemixTermsId, licensingConfig);
}

function test_LicensingModule_setLicensingConfig_revert_invalidLicensingHook() public {
uint256 socialRemixTermsId = pilTemplate.registerLicenseTerms(PILFlavors.nonCommercialSocialRemixing());
// unregistered the licensing hook
Expand Down