Skip to content

Commit

Permalink
rename mintingLicenseSpec to mintingLicenseConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will committed Apr 5, 2024
1 parent 6938794 commit 7c844b9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 51 deletions.
30 changes: 15 additions & 15 deletions contracts/interfaces/registries/ILicenseRegistryV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ interface ILicenseRegistryV2 {
/// @notice Emitted when a new currency token is registered.
event CurrencyTokenRegistered(address indexed token);

/// @notice Emitted when a minting license specification is set.
event MintingLicenseSpecSet(
/// @notice Emitted when a minting license configuration is set.
event MintingLicenseConfigSet(
address indexed ipId,
address indexed licenseTemplate,
uint256 indexed licenseTermsId,
Licensing.MintingLicenseSpec mintingLicenseSpec
Licensing.MintingLicenseConfig mintingLicenseConfig
);

/// @notice Emitted when a minting license specification is set for all licenses of an IP.
event MintingLicenseSpecSetForAll(address indexed ipId, Licensing.MintingLicenseSpec mintingLicenseSpec);
/// @notice Emitted when a minting license configuration is set for all licenses of an IP.
event MintingLicenseConfigSetForAll(address indexed ipId, Licensing.MintingLicenseConfig mintingLicenseConfig);

/// @notice Emitted when an expiration time is set for an IP.
event ExpireTimeSet(address indexed ipId, uint256 expireTime);
Expand Down Expand Up @@ -85,7 +85,7 @@ interface ILicenseRegistryV2 {
address licenseTemplate,
uint256 licenseTermsId,
bool isMintedByIpOwner
) external view returns (Licensing.MintingLicenseSpec memory);
) external view returns (Licensing.MintingLicenseConfig memory);

/// @notice Attaches license terms to an IP.
/// @param ipId The address of the IP to which the license terms are attached.
Expand All @@ -112,25 +112,25 @@ interface ILicenseRegistryV2 {
/// @notice Gets the count of attached license terms of an IP.
function getAttachedLicenseTermsCount(address ipId) external view returns (uint256);

/// @notice Retrieves the minting license specification for a given IP, license template, and license terms ID.
function getMintingLicenseSpec(
/// @notice Retrieves the minting license configuration for a given IP, license template, and license terms ID.
function getMintingLicenseConfig(
address ipId,
address licenseTemplate,
uint256 licenseTermsId
) external view returns (Licensing.MintingLicenseSpec memory);
) external view returns (Licensing.MintingLicenseConfig memory);

/// @notice Sets the minting license specification for a given IP, license template, and license terms ID.
function setMintingLicenseSpec(
/// @notice Sets the minting license configuration for a given IP, license template, and license terms ID.
function setMintingLicenseConfig(
address ipId,
address licenseTemplate,
uint256 licenseTermsId,
Licensing.MintingLicenseSpec calldata mintingLicenseSpec
Licensing.MintingLicenseConfig calldata mintingLicenseConfig
) external;

/// @notice Sets the minting license specification for all licenser terms of given IP.
function setMintingLicenseSpecForAll(
/// @notice Sets the minting license configuration for all licenser terms of given IP.
function setMintingLicenseConfigForAll(
address ipId,
Licensing.MintingLicenseSpec calldata mintingLicenseSpec
Licensing.MintingLicenseConfig calldata mintingLicenseConfig
) external;

/// @notice Sets the expiration time for an IP.
Expand Down
4 changes: 3 additions & 1 deletion contracts/lib/Licensing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ library Licensing {
/// @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
// TODO: the struct will not be used in mainnet. will remove.
struct Policy {
bool isLicenseTransferable;
address policyFramework;
Expand All @@ -28,14 +29,15 @@ library Licensing {
/// license is burnt for linking
/// @param licensorIpId Id of the IP this license is for
/// @param transferable Whether or not the license is transferable
// TODO: the struct will not be used in mainnet. will remove.
struct License {
uint256 policyId;
address licensorIpId;
bool transferable;
// TODO: support for transfer hooks
}

struct MintingLicenseSpec {
struct MintingLicenseConfig {
bool isSet;
uint256 mintingFee;
address mintingFeeModule;
Expand Down
14 changes: 7 additions & 7 deletions contracts/modules/licensing/LicensingModuleV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ contract LicensingModuleV2 is

_verifyIpNotDisputed(originalIpId);

Licensing.MintingLicenseSpec memory mlc = LICENSE_REGISTRY.verifyMintLicenseToken(
Licensing.MintingLicenseConfig memory mlc = LICENSE_REGISTRY.verifyMintLicenseToken(
originalIpId,
licenseTemplate,
licenseTermsId,
Expand Down Expand Up @@ -276,7 +276,7 @@ contract LicensingModuleV2 is

for (uint256 i = 0; i < originalIpIds.length; i++) {
uint256 lcId = licenseTermsIds[i];
Licensing.MintingLicenseSpec memory mlc = LICENSE_REGISTRY.getMintingLicenseSpec(
Licensing.MintingLicenseConfig memory mlc = LICENSE_REGISTRY.getMintingLicenseConfig(
originalIpIds[i],
licenseTemplate,
lcId
Expand Down Expand Up @@ -310,7 +310,7 @@ contract LicensingModuleV2 is
uint256 licenseTermsId,
uint256 amount,
bytes calldata royaltyContext,
Licensing.MintingLicenseSpec memory mlc
Licensing.MintingLicenseConfig memory mlc
) private returns (address royaltyPolicy, bytes memory royaltyData) {
ILicenseTemplate lct = ILicenseTemplate(licenseTemplate);
uint256 mintingFee = 0;
Expand All @@ -328,17 +328,17 @@ contract LicensingModuleV2 is
}

function _getTotalMintingFee(
Licensing.MintingLicenseSpec memory mintingLicenseSpec,
Licensing.MintingLicenseConfig memory mintingLicenseConfig,
address licensorIpId,
address licenseTemplate,
uint256 licenseTermsId,
uint256 mintingFeeSetByLicenseTerms,
uint256 amount
) private view returns (uint256) {
if (!mintingLicenseSpec.isSet) return mintingFeeSetByLicenseTerms * amount;
if (mintingLicenseSpec.mintingFeeModule == address(0)) return mintingLicenseSpec.mintingFee * amount;
if (!mintingLicenseConfig.isSet) return mintingFeeSetByLicenseTerms * amount;
if (mintingLicenseConfig.mintingFeeModule == address(0)) return mintingLicenseConfig.mintingFee * amount;
return
IMintingFeeModule(mintingLicenseSpec.mintingFeeModule).getTotalMintingFee(
IMintingFeeModule(mintingLicenseConfig.mintingFeeModule).getTotalMintingFee(
licensorIpId,
licenseTemplate,
licenseTermsId,
Expand Down
56 changes: 28 additions & 28 deletions contracts/registries/LicenseRegistryV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ contract LicenseRegistryV2 is ILicenseRegistryV2, GovernableUpgradeable, UUPSUpg
mapping(address ipId => EnumerableSet.UintSet licenseTermsIds) attachedLicenseTerms;
mapping(address ipId => address licenseTemplate) licenseTemplates;
mapping(address ipId => uint256) expireTimes;
mapping(bytes32 ipLicenseHash => Licensing.MintingLicenseSpec mintingLicenseSpec) mintingLicenseSpecs;
mapping(address ipId => Licensing.MintingLicenseSpec mintingLicenseSpec) mintingLicenseSpecsForAll;
mapping(bytes32 ipLicenseHash => Licensing.MintingLicenseConfig mintingLicenseConfig) mintingLicenseConfigs;
mapping(address ipId => Licensing.MintingLicenseConfig mintingLicenseConfig) mintingLicenseConfigsForAll;
}

// TODO: update the storage location
Expand Down Expand Up @@ -118,40 +118,40 @@ contract LicenseRegistryV2 is ILicenseRegistryV2, GovernableUpgradeable, UUPSUpg
_setExpireTime(ipId, expireTime);
}

function setMintingLicenseSpec(
function setMintingLicenseConfig(
address ipId,
address licenseTemplate,
uint256 licenseTermsId,
Licensing.MintingLicenseSpec calldata mintingLicenseSpec
Licensing.MintingLicenseConfig calldata mintingLicenseConfig
) external onlyLicensingModule {
LicenseRegistryStorage storage $ = _getLicenseRegistryStorage();
if (!$.registeredLicenseTemplates[licenseTemplate]) {
revert Errors.LicenseRegistry__UnregisteredLicenseTemplate(licenseTemplate);
}
$.mintingLicenseSpecs[_getHash(ipId, licenseTemplate, licenseTermsId)] = Licensing.MintingLicenseSpec({
$.mintingLicenseConfigs[_getHash(ipId, licenseTemplate, licenseTermsId)] = Licensing.MintingLicenseConfig({
isSet: true,
mintingFee: mintingLicenseSpec.mintingFee,
mintingFeeModule: mintingLicenseSpec.mintingFeeModule,
receiverCheckModule: mintingLicenseSpec.receiverCheckModule,
receiverCheckData: mintingLicenseSpec.receiverCheckData
mintingFee: mintingLicenseConfig.mintingFee,
mintingFeeModule: mintingLicenseConfig.mintingFeeModule,
receiverCheckModule: mintingLicenseConfig.receiverCheckModule,
receiverCheckData: mintingLicenseConfig.receiverCheckData
});

emit MintingLicenseSpecSet(ipId, licenseTemplate, licenseTermsId, mintingLicenseSpec);
emit MintingLicenseConfigSet(ipId, licenseTemplate, licenseTermsId, mintingLicenseConfig);
}

function setMintingLicenseSpecForAll(
function setMintingLicenseConfigForAll(
address ipId,
Licensing.MintingLicenseSpec calldata mintingLicenseSpec
Licensing.MintingLicenseConfig calldata mintingLicenseConfig
) external onlyLicensingModule {
LicenseRegistryStorage storage $ = _getLicenseRegistryStorage();
$.mintingLicenseSpecsForAll[ipId] = Licensing.MintingLicenseSpec({
$.mintingLicenseConfigsForAll[ipId] = Licensing.MintingLicenseConfig({
isSet: true,
mintingFee: mintingLicenseSpec.mintingFee,
mintingFeeModule: mintingLicenseSpec.mintingFeeModule,
receiverCheckModule: mintingLicenseSpec.receiverCheckModule,
receiverCheckData: mintingLicenseSpec.receiverCheckData
mintingFee: mintingLicenseConfig.mintingFee,
mintingFeeModule: mintingLicenseConfig.mintingFeeModule,
receiverCheckModule: mintingLicenseConfig.receiverCheckModule,
receiverCheckData: mintingLicenseConfig.receiverCheckData
});
emit MintingLicenseSpecSetForAll(ipId, mintingLicenseSpec);
emit MintingLicenseConfigSetForAll(ipId, mintingLicenseConfig);
}

function attachLicenseTermsToIp(
Expand Down Expand Up @@ -228,7 +228,7 @@ contract LicenseRegistryV2 is ILicenseRegistryV2, GovernableUpgradeable, UUPSUpg
address licenseTemplate,
uint256 licenseTermsId,
bool isMintedByIpOwner
) external view returns (Licensing.MintingLicenseSpec memory) {
) external view returns (Licensing.MintingLicenseConfig memory) {
LicenseRegistryStorage storage $ = _getLicenseRegistryStorage();
if ($.expireTimes[originalIpId] < block.timestamp) {
revert Errors.LicenseRegistry__OriginalIpExpired(originalIpId);
Expand All @@ -240,7 +240,7 @@ contract LicenseRegistryV2 is ILicenseRegistryV2, GovernableUpgradeable, UUPSUpg
} else if (!_hasIpAttachedLicenseTerms(originalIpId, licenseTemplate, licenseTermsId)) {
revert Errors.LicenseRegistry__OriginalIpHasNoLicenseTerms(originalIpId, licenseTermsId);
}
return _getMintingLicenseSpec(originalIpId, licenseTemplate, licenseTermsId);
return _getMintingLicenseConfig(originalIpId, licenseTemplate, licenseTermsId);
}

function isRegisteredLicenseTemplate(address licenseTemplate) external view returns (bool) {
Expand Down Expand Up @@ -291,12 +291,12 @@ contract LicenseRegistryV2 is ILicenseRegistryV2, GovernableUpgradeable, UUPSUpg
return _getLicenseRegistryStorage().attachedLicenseTerms[ipId].length();
}

function getMintingLicenseSpec(
function getMintingLicenseConfig(
address ipId,
address licenseTemplate,
uint256 licenseTermsId
) external view returns (Licensing.MintingLicenseSpec memory) {
return _getMintingLicenseSpec(ipId, licenseTemplate, licenseTermsId);
) external view returns (Licensing.MintingLicenseConfig memory) {
return _getMintingLicenseConfig(ipId, licenseTemplate, licenseTermsId);
}

/// @notice Returns the canonical protocol-wide LicensingModule
Expand Down Expand Up @@ -327,19 +327,19 @@ contract LicenseRegistryV2 is ILicenseRegistryV2, GovernableUpgradeable, UUPSUpg
return _getLicenseRegistryStorage().originalIps[derivativeIpId].length() > 0;
}

function _getMintingLicenseSpec(
function _getMintingLicenseConfig(
address ipId,
address licenseTemplate,
uint256 licenseTermsId
) internal view returns (Licensing.MintingLicenseSpec memory) {
) internal view returns (Licensing.MintingLicenseConfig memory) {
LicenseRegistryStorage storage $ = _getLicenseRegistryStorage();
if (!$.registeredLicenseTemplates[licenseTemplate]) {
revert Errors.LicenseRegistry__UnregisteredLicenseTemplate(licenseTemplate);
}
if ($.mintingLicenseSpecs[_getHash(ipId, licenseTemplate, licenseTermsId)].isSet) {
return $.mintingLicenseSpecs[_getHash(ipId, licenseTemplate, licenseTermsId)];
if ($.mintingLicenseConfigs[_getHash(ipId, licenseTemplate, licenseTermsId)].isSet) {
return $.mintingLicenseConfigs[_getHash(ipId, licenseTemplate, licenseTermsId)];
}
return $.mintingLicenseSpecsForAll[ipId];
return $.mintingLicenseConfigsForAll[ipId];
}

function _getHash(address ipId, address licenseTemplate, uint256 licenseTermsId) internal pure returns (bytes32) {
Expand Down

0 comments on commit 7c844b9

Please sign in to comment.