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

Fix Licensing Minting Payment to Account for Mint Amount #129

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ contract LicensingModule is AccessControlled, ILicensingModule, BaseModule, Reen
msg.sender,
pol.royaltyPolicy,
pol.mintingFeeToken,
pol.mintingFee
pol.mintingFee * amount
jdubpark marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Expand Down
30 changes: 26 additions & 4 deletions test/foundry/integration/flows/royalty/Royalty.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

// contract
import { IRoyaltyModule } from "contracts/interfaces/modules/royalty/IRoyaltyModule.sol";
import { IRoyaltyPolicyLAP } from "contracts/interfaces/modules/royalty/policies/IRoyaltyPolicyLAP.sol";

// test
Expand All @@ -30,21 +31,29 @@ contract Flows_Integration_Disputes is BaseIntegration {
})
);

address internal royaltyPolicyAddr; // must be assigned AFTER super.setUp()
address internal mintingFeeToken; // must be assigned AFTER super.setUp()
uint32 internal defaultCommRevShare = 100;
uint256 internal mintingFee = 7 ether;

function setUp() public override {
super.setUp();

// Register PIL Framework
_deployLFM_PIL();

royaltyPolicyAddr = address(royaltyPolicyLAP);
mintingFeeToken = address(erc20);

// Register a License
_mapPILPolicySimple({
_mapPILPolicyCommercial({
name: "commercial-remix",
commercial: true,
derivatives: true,
reciprocal: true,
commercialRevShare: defaultCommRevShare
commercialRevShare: defaultCommRevShare,
royaltyPolicy: royaltyPolicyAddr,
mintingFeeToken: mintingFeeToken,
mintingFee: mintingFee
});
_registerPILPolicyFromMapping("commercial-remix");

Expand Down Expand Up @@ -74,11 +83,17 @@ contract Flows_Integration_Disputes is BaseIntegration {
ipAcct[2] = _getIpId(mockNFT, 2);
vm.label(ipAcct[2], "IPAccount2");

uint256 mintAmount = 3;
erc20.approve(address(royaltyPolicyAddr), mintAmount * mintingFee);

uint256[] memory licenseIds = new uint256[](1);

vm.expectEmit(address(royaltyModule));
emit IRoyaltyModule.LicenseMintingFeePaid(ipAcct[1], u.bob, address(erc20), mintAmount * mintingFee);
licenseIds[0] = licensingModule.mintLicense(
_getPilPolicyId("commercial-remix"),
ipAcct[1],
1,
mintAmount,
u.bob,
emptyRoyaltyPolicyLAPInitParams
);
Expand Down Expand Up @@ -116,8 +131,13 @@ contract Flows_Integration_Disputes is BaseIntegration {
ipAcct[3] = _getIpId(mockNFT, 3);
vm.label(ipAcct[3], "IPAccount3");

uint256 mintAmount = 1;
uint256[] memory licenseIds = new uint256[](2);

erc20.approve(address(royaltyPolicyAddr), 2 * mintAmount * mintingFee);

vm.expectEmit(address(royaltyModule));
emit IRoyaltyModule.LicenseMintingFeePaid(ipAcct[1], u.carl, address(erc20), mintAmount * mintingFee);
licenseIds[0] = licensingModule.mintLicense(
_getPilPolicyId("commercial-remix"),
ipAcct[1], // grandparent, root IP
Expand All @@ -137,6 +157,8 @@ contract Flows_Integration_Disputes is BaseIntegration {
params1.targetAncestors[0] = ipAcct[1];
params1.targetRoyaltyAmount[0] = defaultCommRevShare;

vm.expectEmit(address(royaltyModule));
emit IRoyaltyModule.LicenseMintingFeePaid(ipAcct[2], u.carl, address(erc20), mintAmount * mintingFee);
licenseIds[1] = licensingModule.mintLicense(
_getPilPolicyId("commercial-remix"),
ipAcct[2], // parent, is child IP of ipAcct[1]
Expand Down
38 changes: 35 additions & 3 deletions test/foundry/utils/LicensingHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ contract LicensingHelper {
string memory pName = string(abi.encodePacked("pil_", name));
policies[pName] = RegisterPILPolicyParams({
transferable: true,
// TODO: use mock or real based on condition
royaltyPolicy: commercial ? address(ROYALTY_POLICY_LAP) : address(0),
mintingFee: 0,
mintingFeeToken: address(0),
mintingFee: commercial ? 1 ether : 0,
mintingFeeToken: address(0), // TODO: set to a valid token if commercial
policy: PILPolicy({
attribution: true,
commercialUse: commercial,
Expand All @@ -143,6 +142,39 @@ contract LicensingHelper {
});
}

function _mapPILPolicyCommercial(
string memory name,
bool derivatives,
bool reciprocal,
uint32 commercialRevShare,
address royaltyPolicy,
uint256 mintingFee,
address mintingFeeToken
) internal {
string memory pName = string(abi.encodePacked("pil_", name));
policies[pName] = RegisterPILPolicyParams({
transferable: true,
royaltyPolicy: royaltyPolicy,
mintingFee: mintingFee,
mintingFeeToken: mintingFeeToken,
policy: PILPolicy({
attribution: true,
commercialUse: true,
commercialAttribution: false,
commercializerChecker: address(0),
commercializerCheckerData: "",
commercialRevShare: commercialRevShare,
derivativesAllowed: derivatives,
derivativesAttribution: false,
derivativesApproval: false,
derivativesReciprocal: reciprocal,
territories: emptyStringArray,
distributionChannels: emptyStringArray,
contentRestrictions: emptyStringArray
})
});
}

function _addPILPolicyFromMapping(string memory name, address pilFramework) internal returns (uint256) {
string memory pName = string(abi.encodePacked("pil_", name));
policyIds[pName] = PILPolicyFrameworkManager(pilFramework).registerPolicy(policies[pName]);
Expand Down
Loading