Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
style: lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubpark committed Feb 17, 2024
1 parent 757bf9b commit f8572d9
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 56 deletions.
12 changes: 9 additions & 3 deletions contracts/modules/licensing/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ contract LicensingModule is AccessControlled, ILicensingModule, BaseModule, Reen
}
}

// If the policy has a royalty policy, we need to call the royalty module to process the minting.
// If the policy has a royalty policy, we need to call the royalty module to process the minting.
// Otherwise, it's non commercial and we can skip the call.
// NOTE: We must call `payLicenseMintingFee` after calling `onLicenseMinting` because minting licenses on
// NOTE: We must call `payLicenseMintingFee` after calling `onLicenseMinting` because minting licenses on
// root IPs (licensors) might mean the licensors don't have royalty policy initialized, so we initialize it
// (deploy the split clone contract) via `onLicenseMinting`. Then, pay the minting fee to the licensor's split
// clone contract address.
Expand All @@ -214,7 +214,13 @@ contract LicensingModule is AccessControlled, ILicensingModule, BaseModule, Reen

// If there's a minting fee, sender must pay it
if (pol.mintingFee > 0) {
ROYALTY_MODULE.payLicenseMintingFee(licensorIpId, msg.sender, pol.royaltyPolicy, pol.mintingFeeToken, pol.mintingFee);
ROYALTY_MODULE.payLicenseMintingFee(
licensorIpId,
msg.sender,
pol.royaltyPolicy,
pol.mintingFeeToken,
pol.mintingFee
);
}
}

Expand Down
8 changes: 6 additions & 2 deletions contracts/modules/licensing/PILPolicyFrameworkManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.s
// contracts
import { IHookModule } from "../../interfaces/modules/base/IHookModule.sol";
import { ILicensingModule } from "../../interfaces/modules/licensing/ILicensingModule.sol";
import { IRoyaltyModule } from "../../interfaces/modules/royalty/IRoyaltyModule.sol";
import { Licensing } from "../../lib/Licensing.sol";
import { Errors } from "../../lib/Errors.sol";
import { PILFrameworkErrors } from "../../lib/PILFrameworkErrors.sol";
Expand Down Expand Up @@ -354,7 +353,12 @@ contract PILPolicyFrameworkManager is
/// @param policy The policy to verify
/// @param royaltyPolicy The address of the royalty policy
// solhint-disable-next-line code-complexity
function _verifyComercialUse(PILPolicy calldata policy, address royaltyPolicy, uint256 mintingFee, address mintingFeeToken) internal view {
function _verifyComercialUse(
UMLPolicy calldata policy,
address royaltyPolicy,
uint256 mintingFee,
address mintingFeeToken
) internal view {
if (!policy.commercialUse) {
if (policy.commercialAttribution) {
revert PILFrameworkErrors.PILPolicyFrameworkManager__CommercialDisabled_CantAddAttribution();
Expand Down
1 change: 0 additions & 1 deletion contracts/modules/royalty-module/RoyaltyModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,4 @@ contract RoyaltyModule is IRoyaltyModule, Governable, ReentrancyGuard, BaseModul
function supportsInterface(bytes4 interfaceId) public view virtual override(BaseModule, IERC165) returns (bool) {
return interfaceId == type(IRoyaltyModule).interfaceId || super.supportsInterface(interfaceId);
}

}
6 changes: 3 additions & 3 deletions test/foundry/integration/big-bang/SingleNftCollection.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract BigBang_Integration_SingleNftCollection is BaseIntegration {
vm.startPrank(u.carl);
mockNFT.mintId(u.carl, 5);
ipAcct[5] = registerIpAccount(mockNFT, 5, u.carl);

/*//////////////////////////////////////////////////////////////
ADD POLICIES TO IP ACCOUNTS
///////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -349,7 +349,7 @@ contract BigBang_Integration_SingleNftCollection is BaseIntegration {
metadata,
u.carl, // caller
abi.encode(params)
);
);
}
}
}
}
6 changes: 2 additions & 4 deletions test/foundry/mocks/module/MockRoyaltyModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@ contract MockRoyaltyModule is BaseModule, IRoyaltyModule {
address payerRoyaltyPolicy = royaltyPolicies[_payerIpId];
// IRoyaltyPolicy(payerRoyaltyPolicy).onRoyaltyPayment(msg.sender, _receiverIpId, _token, _amount);
}

function payLicenseMintingFee(address receiverIpId, address payerAddress, address token, uint256 amount) external {

}
function payLicenseMintingFee(address receiverIpId, address payerAddress, address token, uint256 amount) external {}

function payLicenseMintingFee(
address receiverIpId,
address payerAddress,
address licenseRoyaltyPolicy,
address token,
uint256 amount
) external{}
) external {}

function supportsInterface(bytes4 interfaceId) public view virtual override(BaseModule, IERC165) returns (bool) {
return interfaceId == type(IRoyaltyModule).interfaceId || super.supportsInterface(interfaceId);
Expand Down
95 changes: 54 additions & 41 deletions test/foundry/modules/licensing/LicensingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ contract LicensingModuleTest is BaseTest {
}

function _createPolicyFrameworkData() internal view returns (Licensing.Policy memory) {
return Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: address(mockRoyaltyPolicyLAP),
royaltyData: "",
mintingFee: 0,
mintingFeeToken: address(0)
});
return
Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: address(mockRoyaltyPolicyLAP),
royaltyData: "",
mintingFee: 0,
mintingFeeToken: address(0)
});
}

function test_LicensingModule_registerPFM() public {
Expand Down Expand Up @@ -157,47 +158,59 @@ contract LicensingModuleTest is BaseTest {

vm.expectRevert(Errors.LicensingModule__RegisterPolicyFrameworkMismatch.selector);
vm.prank(address(anotherMockPFM));
uint256 policyId = licensingModule.registerPolicy(Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: address(mockRoyaltyPolicyLAP),
royaltyData: "",
mintingFee: 0,
mintingFeeToken: address(0)
}));
uint256 policyId = licensingModule.registerPolicy(
Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: address(mockRoyaltyPolicyLAP),
royaltyData: "",
mintingFee: 0,
mintingFeeToken: address(0)
})
);
}

function test_LicensingModule_registerPolicy_revert_royaltyPolicyNotWhitelisted() public withPolicyFrameworkManager {
function test_LicensingModule_registerPolicy_revert_royaltyPolicyNotWhitelisted()
public
withPolicyFrameworkManager
{
address nonWhitelistedRoyaltyPolicy = address(0x11beef22cc);

vm.expectRevert(Errors.LicensingModule__RoyaltyPolicyNotWhitelisted.selector);
vm.prank(address(mockPFM));
uint256 policyId = licensingModule.registerPolicy(Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: nonWhitelistedRoyaltyPolicy,
royaltyData: "",
mintingFee: 0,
mintingFeeToken: address(0)
}));
uint256 policyId = licensingModule.registerPolicy(
Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: nonWhitelistedRoyaltyPolicy,
royaltyData: "",
mintingFee: 0,
mintingFeeToken: address(0)
})
);
}

function test_LicensingModule_registerPolicy_revert_mintingFeeTokenNotWhitelisted() public withPolicyFrameworkManager {
function test_LicensingModule_registerPolicy_revert_mintingFeeTokenNotWhitelisted()
public
withPolicyFrameworkManager
{
address nonWhitelistedRoyaltyToken = address(0x11beef22cc);

vm.expectRevert(Errors.LicensingModule__MintingFeeTokenNotWhitelisted.selector);
vm.prank(address(mockPFM));
uint256 policyId = licensingModule.registerPolicy(Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: address(mockRoyaltyPolicyLAP),
royaltyData: "",
mintingFee: 1 ether,
mintingFeeToken: nonWhitelistedRoyaltyToken
}));
uint256 policyId = licensingModule.registerPolicy(
Licensing.Policy({
isLicenseTransferable: true,
policyFramework: address(mockPFM),
frameworkData: _createMockPolicy(),
royaltyPolicy: address(mockRoyaltyPolicyLAP),
royaltyData: "",
mintingFee: 1 ether,
mintingFeeToken: nonWhitelistedRoyaltyToken
})
);
}

function test_LicensingModule_registerPolicy() public withPolicyFrameworkManager {
Expand Down Expand Up @@ -552,7 +565,7 @@ contract LicensingModuleTest is BaseTest {
function test_LicensingModule_singleTransfer_revert_verifyFalse() public {
licensingModule.registerPolicyFrameworkManager(address(mockPFM));
vm.prank(address(mockPFM));

Licensing.Policy memory pol = _createPolicyFrameworkData();
pol.isLicenseTransferable = false;
uint256 policyId = licensingModule.registerPolicy(pol);
Expand Down Expand Up @@ -616,4 +629,4 @@ contract LicensingModuleTest is BaseTest {
function onERC721Received(address, address, uint256, bytes memory) public pure returns (bytes4) {
return this.onERC721Received.selector;
}
}
}
2 changes: 1 addition & 1 deletion test/foundry/modules/licensing/UMLPolicyFramework.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,4 @@ contract PILPolicyFrameworkTest is BaseTest {
function onERC721Received(address, address, uint256, bytes memory) public pure returns (bytes4) {
return this.onERC721Received.selector;
}
}
}
2 changes: 1 addition & 1 deletion test/foundry/utils/LicensingHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ contract LicensingHelper {
LICENSING_MODULE.registerPolicyFrameworkManager(address(_pfm));
pfm["pil"] = address(_pfm);
}
}
}

0 comments on commit f8572d9

Please sign in to comment.