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

Commit

Permalink
license related adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Spablob committed Feb 17, 2024
1 parent 0650769 commit 56a862b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
19 changes: 6 additions & 13 deletions contracts/interfaces/modules/licensing/ILicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ interface ILicensingModule is IModule {
address indexed policyFrameworkManager,
bytes frameworkData,
address royaltyPolicy,
bytes royaltyData
bytes royaltyData,
uint256 mintingFee,
address mintingFeeToken
);

/// @notice Emitted when a policy is added to an IP
Expand Down Expand Up @@ -73,18 +75,9 @@ interface ILicensingModule is IModule {
/// @param manager the address of the manager. Will be ERC165 checked for IPolicyFrameworkManager
function registerPolicyFrameworkManager(address manager) external;

/// @notice Registers a policy into the contract. MUST be called by a registered framework or it will revert.
/// The policy data and its integrity must be verified by the policy framework manager.
/// @param isLicenseTransferable True if the license is transferable
/// @param royaltyPolicy The address of the royalty policy
/// @param royaltyData The royalty policy specific encoded data
/// @param frameworkData The policy framework specific encoded data
function registerPolicy(
bool isLicenseTransferable,
address royaltyPolicy,
bytes memory royaltyData,
bytes memory frameworkData
) external returns (uint256 policyId);
/// @param pol The Licensing policy data. MUST have same policy framework as the caller address
/// @return policyId The id of the newly registered policy
function registerPolicy(Licensing.Policy memory pol) external returns (uint256 policyId);

/// @notice Adds a policy to the set of policies of an IP
/// @param ipId The id of the IP
Expand Down
4 changes: 4 additions & 0 deletions contracts/lib/Licensing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ library Licensing {
/// @param frameworkData Data to be used by the policy framework to verify minting and linking
/// @param royaltyPolicy address of the royalty policy to be used by the policy framework, if any
/// @param royaltyData Data to be used by the royalty policy (for example, encoding of the royalty percentage)
/// @param mintingFee Fee to be paid when minting a license
/// @param mintingFeeToken Token to be used to pay the minting fee
struct Policy {
bool isLicenseTransferable;
address policyFramework;
bytes frameworkData;
address royaltyPolicy;
bytes royaltyData;
uint256 mintingFee;
address mintingFeeToken;
}
/// @notice Data that define a License Agreement NFT
/// @param policyId Id of the policy this license is based on, which will be set in the derivative IP when the
Expand Down
46 changes: 25 additions & 21 deletions contracts/modules/licensing/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,36 @@ contract LicensingModule is AccessControlled, ILicensingModule, BaseModule, Reen

/// @notice Registers a policy into the contract. MUST be called by a registered framework or it will revert.
/// The policy data and its integrity must be verified by the policy framework manager.
/// @param isLicenseTransferable True if the license is transferable
/// @param royaltyPolicy The address of the royalty policy
/// @param royaltyData The royalty policy specific encoded data
/// @param frameworkData The policy framework specific encoded data
function registerPolicy(
bool isLicenseTransferable,
address royaltyPolicy,
bytes memory royaltyData,
bytes memory frameworkData
) external returns (uint256 policyId) {
/// @param pol The Licensing policy data. MUST have same policy framework as the caller address
/// @return policyId The id of the newly registered policy
function registerPolicy(Licensing.Policy memory pol) external returns (uint256 policyId) {
_verifyRegisteredFramework(address(msg.sender));
Licensing.Policy memory pol = Licensing.Policy({
isLicenseTransferable: isLicenseTransferable,
policyFramework: msg.sender,
frameworkData: frameworkData,
royaltyPolicy: royaltyPolicy,
royaltyData: royaltyData
});

if (pol.policyFramework != address(msg.sender)) {
revert Errors.LicensingModule__RegisterPolicyFrameworkMismatch();
}
if (pol.royaltyPolicy != address(0) && !ROYALTY_MODULE.isWhitelistedRoyaltyPolicy(pol.royaltyPolicy)) {
revert Errors.LicensingModule__RoyaltyPolicyNotWhitelisted();
}
if (pol.mintingFee > 0 && !ROYALTY_MODULE.isWhitelistedRoyaltyToken(pol.mintingFeeToken)) {
revert Errors.LicensingModule__MintingFeeTokenNotWhitelisted();
}
(uint256 polId, bool newPol) = DataUniqueness.addIdOrGetExisting(
abi.encode(pol),
_hashedPolicies,
_totalPolicies
);

if (newPol) {
_totalPolicies = polId;
_policies[polId] = pol;
emit PolicyRegistered(polId, msg.sender, frameworkData, royaltyPolicy, royaltyData);
emit PolicyRegistered(
polId,
pol.policyFramework,
pol.frameworkData,
pol.royaltyPolicy,
pol.royaltyData,
pol.mintingFee,
pol.mintingFeeToken
);
}
return polId;
}
Expand Down Expand Up @@ -204,7 +205,10 @@ 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
// Otherwise, it's non commercial and we can skip the call.
if (pol.royaltyPolicy != address(0)) {
ROYALTY_MODULE.onLicenseMinting(licensorIpId, pol.royaltyPolicy, pol.royaltyData, royaltyContext);
// 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);
}
}

// If a policy is set, then is only up to the policy params.
Expand Down

0 comments on commit 56a862b

Please sign in to comment.