From 4de4963ecc125e4cffaab1dce00937983e78c157 Mon Sep 17 00:00:00 2001 From: Raul Date: Fri, 14 Jun 2024 01:54:14 -0300 Subject: [PATCH] check licensor IP is registered --- contracts/lib/Errors.sol | 3 +++ .../modules/licensing/LicensingModule.sol | 4 +++- .../modules/licensing/LicensingModule.t.sol | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/contracts/lib/Errors.sol b/contracts/lib/Errors.sol index b3ad06b93..14c62f162 100644 --- a/contracts/lib/Errors.sol +++ b/contracts/lib/Errors.sol @@ -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(); diff --git a/contracts/modules/licensing/LicensingModule.sol b/contracts/modules/licensing/LicensingModule.sol index bb5000fad..e7d5b882a 100644 --- a/contracts/modules/licensing/LicensingModule.sol +++ b/contracts/modules/licensing/LicensingModule.sol @@ -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, diff --git a/test/foundry/modules/licensing/LicensingModule.t.sol b/test/foundry/modules/licensing/LicensingModule.t.sol index b68792bde..a86e31849 100644 --- a/test/foundry/modules/licensing/LicensingModule.t.sol +++ b/test/foundry/modules/licensing/LicensingModule.t.sol @@ -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);