Skip to content

Commit

Permalink
check licensor IP is registered
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramarti committed Jun 14, 2024
1 parent b2b1e82 commit 4de4963
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ library Errors {
/// @notice Mint amount is zero.
error LicensingModule__MintAmountZero();

/// @notice minting a license for non-registered IP.
error LicensingModule__LicensorIpNotRegistered();

/// @notice IP is dispute tagged.
error LicensingModule__DisputedIpId();

Expand Down
4 changes: 3 additions & 1 deletion contracts/modules/licensing/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ contract LicensingModule is
if (receiver == address(0)) {
revert Errors.LicensingModule__ReceiverZeroAddress();
}

if (!IP_ACCOUNT_REGISTRY.isIpAccount(licensorIpId)) {
revert Errors.LicensingModule__LicensorIpNotRegistered();
}
_verifyIpNotDisputed(licensorIpId);
Licensing.LicensingConfig memory lsc = LICENSE_REGISTRY.verifyMintLicenseToken(
licensorIpId,
Expand Down
19 changes: 19 additions & 0 deletions test/foundry/modules/licensing/LicensingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,25 @@ contract LicensingModuleTest is BaseTest {
assertEq(licenseToken.balanceOf(ipOwner2), 1);
}

function test_LicensingModule_mintLicenseTokens_revert_licensorIpNotRegistered() public {
uint256 termsId = pilTemplate.registerLicenseTerms(PILFlavors.defaultValuesLicenseTerms());
vm.prank(ipOwner1);
licensingModule.attachLicenseTerms(ipId1, address(pilTemplate), termsId);

vm.expectRevert(
abi.encodeWithSelector(Errors.LicensingModule__LicensorIpNotRegistered.selector)
);
uint256 lcTokenId = licensingModule.mintLicenseTokens({
licensorIpId: address(0x123),
licenseTemplate: address(pilTemplate),
licenseTermsId: termsId,
amount: 1,
receiver: address(0x777),
royaltyContext: ""
});
}


function test_LicensingModule_mintLicenseTokens_revert_invalidInputs() public {
uint256 termsId = pilTemplate.registerLicenseTerms(PILFlavors.defaultValuesLicenseTerms());
vm.prank(ipOwner1);
Expand Down

0 comments on commit 4de4963

Please sign in to comment.