Introduce Licensing Hook for Limiting Total License Tokens #99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new Licensing Hook,
TotalLicenseTokenLimitHook
, which allows IP owners to set a limit on the total number of license tokens that can be minted from specific license terms of an IP. This feature ensures that the minting of license tokens is controlled and adheres to the predefined limits set by the IP owner.Key Features
TotalLicenseTokenLimitExceeded
error.Changes
TotalLicenseTokenLimitHook
contract with the following key functions:beforeRegisterDerivative
: Checks the total token limit before registering a derivative.calculateMintingFee
: Calculates the minting fee for license tokens.getTotalLicenseTokenLimit
: Retrieves the total license token limit for a specific license._checkTotalTokenLimit
: Internal function to check if the total token limit is exceeded._calculateFee
: Internal function to calculate the minting fee.TotalLicenseTokenLimitHookTest
to ensure the functionality works as expected:test_TotalLicenseTokenLimitHook_setLimit
: Tests setting and enforcing the total license token limit.test_TotalLicenseTokenLimitHook_revert_nonIpOwner_setLimit
: Tests that only the IP owner can set the limit.Usage
LicensingModule
.setTotalLicenseTokenLimit
function.