Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Licensing Hook for Limiting Total License Tokens #99

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

kingster-will
Copy link

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

  • Set Total License Token Limit: IP owners can specify the maximum number of license tokens that can be minted for a given license template and terms.
  • Minting Fee Calculation: The hook calculates the minting fee based on the license template and terms.
  • Validation: The hook validates the total supply of license tokens before allowing new tokens to be minted, ensuring the limit is not exceeded.
  • Revert on Exceeding Limit: If the minting request exceeds the set limit, the transaction is reverted with a TotalLicenseTokenLimitExceeded error.

Changes

  • Added 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.
  • Added tests in 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

  1. Set Licensing Config: IP owners set the licensing configuration using the LicensingModule.
  2. Set Token Limit: IP owners set the total license token limit using the setTotalLicenseTokenLimit function.
  3. Mint License Tokens: The system checks the limit before minting new license tokens to ensure compliance.

Copy link
Member

@sebsadface sebsadface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments that can be addressed in a future PR. Overall LGTM :)

@sebsadface sebsadface merged commit 68bc52d into storyprotocol:main Oct 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants