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

Public minting fee recipient control #16

Merged
merged 6 commits into from
Sep 2, 2024

Conversation

jdubpark
Copy link

@jdubpark jdubpark commented Jul 1, 2024

Description

This PR closes

  1. Add Public Minting of SPG NFT Collection Allow Public Minting of SPG NFT Collections #12
  2. Fee Recipient for SPG NFT mints Fee Recipient for SPG NFT mints #14
  3. Control Mint Status for SPG NFT collections Control Mint Status for SPG NFT collections #15

Tests

Tests have been modified to support the modified SPG and SPG NFT contracts and the protocol core v1.0.0. More unit and integration tests are needed for the new features added by 1, 2, and 3 above.

Summary by CodeRabbit

  • New Features

    • Added configurable minting fee recipients and minting control options for NFTs.
    • Introduced functions to manage minting status and permissions.
    • Updated createCollection to include minting configuration parameters.
  • Bug Fixes

    • Enhanced error handling for minting restrictions and permissions.
  • Chores

    • Updated package versions for dependencies.
    • Added new test cases to cover the new minting functionalities and error scenarios.
  • Tests

    • Updated test suites to incorporate new minting control parameters and fee recipient logic.

Copy link

coderabbitai bot commented Jul 1, 2024

Walkthrough

The updates focused on enhancing the minting functionality of the SPGNFT contract by adding controls for minting fees, recipient address, open minting, and public minting permissions. Corresponding changes were made to the StoryProtocolGateway and relevant interfaces to incorporate these enhancements. Testing infrastructure was also updated to reflect the new parameters and behaviors, ensuring robust verification of the modified minting features.

Changes

File(s) Change Summary
contracts/SPGNFT.sol Added fields for minting controls, updated initialize, new functions to manage minting status and fee recipient, and modified mint.
contracts/StoryProtocolGateway.sol Updated createCollection function with new minting parameters.
contracts/interfaces/ISPGNFT.sol, ...Gateway.sol Enhanced interfaces with new minting parameters and corresponding functions.
contracts/lib/Errors.sol Introduced new error types related to minting and fee recipient constraints.
package.json Updated package versions and added a new dependency.
test/SPGNFT.t.sol, ...Gateway.t.sol, ...BaseTest.t.sol Updated tests with new parameters and behaviors for minting features.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StoryProtocolGateway
    participant SPGNFT

    User ->> StoryProtocolGateway: createCollection(name, symbol, maxSupply, ...)
    StoryProtocolGateway ->> SPGNFT: initialize(owner, mintFeeRecipient, mintOpen, isPublicMinting, ...)
    
    User ->> SPGNFT: mint(to)
    SPGNFT ->> SPGNFT: Check mintOpen, publicMinting, and fee
    SPGNFT ->> User: Mint success or revert with error
Loading

Poem

In fields of code where bytes do roam,
Our minting journey finds new home.
With fees and rules, recipients fair,
NFTs crafted with utmost care.
A gateway opens to realms untold,
Where Story and protocol weave gold.
Mint, my friends, with hearts so bold!


Tip

Early access features: disabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b1439a9 and bb95282.

Files selected for processing (9)
  • contracts/SPGNFT.sol (7 hunks)
  • contracts/StoryProtocolGateway.sol (1 hunks)
  • contracts/interfaces/ISPGNFT.sol (2 hunks)
  • contracts/interfaces/IStoryProtocolGateway.sol (1 hunks)
  • contracts/lib/Errors.sol (1 hunks)
  • package.json (2 hunks)
  • test/SPGNFT.t.sol (3 hunks)
  • test/StoryProtocolGateway.t.sol (3 hunks)
  • test/utils/BaseTest.t.sol (6 hunks)
Files skipped from review due to trivial changes (1)
  • package.json
Additional comments not posted (22)
contracts/lib/Errors.sol (3)

26-26: New error type for minting denial is clear and specific.

The SPGNFT__MintingDenied error is well-named and clearly describes a scenario where minting is denied due to the public minting status being false and the caller lacking the minter role.


32-32: New error type for fee recipient verification is clear and specific.

The SPGNFT__CallerNotFeeRecipient error is appropriately named and clearly indicates that the caller is not the designated fee recipient, which is a crucial check for certain financial operations.


35-35: New error type for closed minting is clear and specific.

The SPGNFT__MintingClosed error is well-defined and accurately reflects a scenario where an attempt is made to mint while the minting status is closed.

contracts/interfaces/ISPGNFT.sol (4)

10-20: Initialization parameters are comprehensive and well-documented.

The added parameters in the initialize function (mintFeeRecipient, mintOpen, isPublicMinting) are crucial for the new functionalities introduced, allowing for better control over the minting process.


36-50: Getter methods for minting properties are correctly implemented.

The added getter methods (mintFee, mintFeeToken, mintFeeRecipient, mintOpen, publicMinting) provide necessary visibility into the minting settings of the collection, which aligns with the goals of enhancing control and transparency.


61-74: Setter methods for minting properties are correctly implemented and restricted.

The added setter methods (setMintFee, setMintFeeToken, setMintFeeRecipient, setMintOpen, setPublicMinting) are correctly restricted to appropriate roles, ensuring that only authorized users can change critical settings.


87-89: Withdraw function is correctly updated to handle specific tokens.

The update to the withdrawToken function to allow specifying the token is a necessary improvement for handling multiple token types, enhancing flexibility in financial operations.

test/SPGNFT.t.sol (4)

18-35: Setup function correctly initializes test variables and contract.

The setUp function is well-organized, setting up necessary test variables and correctly initializing the SPGNFT contract with the new parameters. This ensures that the contract is ready for testing with the intended settings.


51-65: Test for initialize function covers new parameters and roles.

The test_SPGNFT_initialize function effectively tests the initialization of another SPGNFT contract instance with the new parameters, ensuring that roles and minting settings are correctly applied.


80-96: Error handling tests for initialization parameters are comprehensive.

The tests test_SPGNFT_initialize_revert_zeroParams and test_SPGNFT_initialize_revert_zeroMaxSupply correctly anticipate and handle potential errors due to invalid parameters, ensuring robustness in contract initialization.


206-223: Test for withdrawToken function correctly simulates fee handling and token withdrawal.

The test_SPGNFT_withdrawToken function effectively simulates the process of setting a mint fee recipient, minting an NFT, and withdrawing tokens, ensuring that the token transfer logic works as expected under normal and edge cases.

contracts/SPGNFT.sol (5)

19-29: Storage structure for SPGNFT is well-defined and comprehensive.

The SPGNFTStorage struct is correctly updated to include new fields (mintFeeRecipient, mintOpen, publicMinting), which are essential for managing minting operations and fees. This structure is crucial for the new functionalities introduced.


58-72: Initialization function is robust and well-documented.

The initialize function in the SPGNFT contract is comprehensive, including checks for non-zero mint fees and zero max supply. It also correctly sets up roles and minting settings, ensuring the contract is initialized with the correct parameters and controls.


102-125: Getter methods for minting properties are implemented correctly.

The getter methods (mintFee, mintFeeToken, mintFeeRecipient, mintOpen, publicMinting) provide necessary visibility into the contract's minting settings, ensuring transparency and control over the minting process.


Line range hint 127-162: Setter methods for minting properties are secure and appropriately restricted.

The setter methods (setMintFee, setMintFeeToken, setMintFeeRecipient, setMintOpen, setPublicMinting) are correctly restricted to appropriate roles, ensuring that only authorized users can modify critical settings, which is crucial for maintaining integrity and security in minting operations.


183-186: Withdraw function is implemented correctly for handling token transfers.

The withdrawToken function is effectively designed to transfer tokens to the mint fee recipient, utilizing the correct checks and balances. This ensures that token withdrawals are handled securely and appropriately.

contracts/interfaces/IStoryProtocolGateway.sol (1)

49-64: Review of createCollection function signature changes:

The function signature for createCollection has been expanded to include new parameters such as mintFeeRecipient, owner, mintOpen, and isPublicMinting. These changes align with the PR objectives and summary, aiming to enhance control over minting fees, ownership, and permissions.

  • mintFeeRecipient allows specifying where minting fees should be sent.
  • owner designates the owner of the collection.
  • mintOpen and isPublicMinting control the minting status and public accessibility.

This expansion provides greater flexibility and control over the NFT collection creation process.

test/utils/BaseTest.t.sol (2)

Line range hint 122-147: Review of instantiation changes for AccessController and LicenseRegistry:

The instantiation of AccessController and LicenseRegistry has been modified to include additional setup steps. These changes are critical for ensuring that the test environment mirrors the production setup closely, allowing for accurate testing of the new features introduced in the PR.

  • The instantiation now includes additional checks to ensure that the deployed addresses match expected values, enhancing the robustness of the setup process.
  • The use of TestProxyHelper.deployUUPSProxy suggests that these components are intended to be upgradeable, aligning with best practices for contract flexibility.

Overall, these changes enhance the test setup's accuracy and robustness, ensuring that new features can be thoroughly tested.


Line range hint 230-312: Review of LicenseToken setup and subsequent configuration changes:

The setup for LicenseToken involves deploying a new proxy instance and setting various module interactions. This setup is crucial for testing the interactions between licensing and other modules within the system.

  • The configuration of LicenseToken with URLs and interactions with other modules like LicensingModule and DisputeModule is essential for ensuring that licensing operations are tested in an environment that closely resembles production.
  • The method calls to setAddresses and setLicensingModule on various contracts ensure that the system components are correctly interconnected, which is vital for end-to-end functionality testing.

These changes are well-aligned with the PR's goals of enhancing control and flexibility in the licensing operations of the protocol.

test/StoryProtocolGateway.t.sol (2)

Line range hint 29-61: Review of setup changes and new tests in StoryProtocolGatewayTest:

The setup for testing has been expanded to include new variables such as feeRecipient and modifications to the createCollection method to incorporate new parameters like mintFeeRecipient and isPublicMinting.

  • The addition of feeRecipient and its use in the createCollection call is crucial for testing the new minting fee recipient functionality.
  • The expanded parameters in createCollection allow for comprehensive testing of the collection creation process with all the new features like mint control and public minting status.

These changes ensure that the tests cover the new functionalities introduced in the PR, providing a robust framework for verifying the behavior of the updated contract.


72-76: Testing of minting parameters and control flags:

The tests now include assertions for minting-related parameters and control flags such as mintFee, mintFeeToken, mintFeeRecipient, mintOpen, and publicMinting.

  • Assertions for mintFee, mintFeeToken, and mintFeeRecipient ensure that the minting fee logic is functioning as expected.
  • Checks for mintOpen and publicMinting validate the control mechanisms over the minting process.

These tests are essential for ensuring that the minting process is correctly implemented with all the new control features, providing confidence in the system's functionality.

contracts/StoryProtocolGateway.sol (1)

119-147: Implementation of enhanced createCollection method in StoryProtocolGateway:

The createCollection method has been significantly expanded to include new parameters such as mintFeeRecipient, owner, mintOpen, and isPublicMinting. These additions are designed to provide enhanced control over the minting process and access to the collections.

  • The method now correctly initializes the NFT collection with all the new parameters, ensuring that the collection's setup is fully customizable.
  • The use of BeaconProxy for collection instantiation suggests a flexible, upgradeable approach to managing NFT collections.

This implementation aligns with the PR's objectives of enhancing minting functionality and control, ensuring that the gateway can manage NFT collections effectively with the new features.

Copy link
Member

@LeoHChen LeoHChen left a comment

Choose a reason for hiding this comment

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

LGTM, seems like we are adding more functions to the SPG NFT collection. Can we hook up with external minting engines?

@sebsadface sebsadface force-pushed the public-minting-fee-recipient-control branch from 902def1 to 32d1524 Compare September 2, 2024 19:38
@sebsadface sebsadface merged commit 8bc50a4 into main Sep 2, 2024
3 checks passed
@sebsadface sebsadface deleted the public-minting-fee-recipient-control branch September 12, 2024 01:15
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.

3 participants