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

Fix Derivative Registration, IP Graph & Solady's ERC6551 Integration, and Update Protocol Packages #30

Merged
merged 7 commits into from
Aug 18, 2024

Conversation

sebsadface
Copy link
Member

@sebsadface sebsadface commented Aug 18, 2024

Description

This PR introduces several updates and integrations to SPG, including:

  • Fixes integration issues with IP Graph contracts in SPG tests.
  • Resolves derivative registration failures due to license token ownership restrictions.
  • Integrates Solday's ERC6551 implementation into SPG tests.
  • Allows SPG NFT mint functions to be overridden.
  • Updates protocol packages.
  • Updates scripts to reflect the latest changes in SPG.

Test

Updated existing tests to align with core protocol changes.

Related Issue

This PR closes:

Summary by CodeRabbit

  • New Features
    • Enhanced contract functionality with new error handling for ownership issues.
    • Introduction of a new contract, MockIPGraph, for managing intellectual property relationships.
  • Improvements
    • Updated mint functions in SPGNFT to allow more extensibility.
    • Improved token handling in the StoryProtocolGateway contract with stricter ownership checks.
  • Dependency Updates
    • Added a new package dependency related to ERC-6551 functionality.
  • Bug Fixes
    • Adjusted logic in tests to accommodate new parameters for permission settings.

Copy link

coderabbitai bot commented Aug 18, 2024

Walkthrough

This update enhances the SPGNFT and StoryProtocolGateway contracts by implementing more extensible designs and improving token handling functionality. Key changes include the introduction of virtual mint functions, improved ownership checks for license tokens, and the addition of a new mock IP Graph contract to facilitate testing and relationship management between intellectual properties.

Changes

Files Change Summary
contracts/SPGNFT.sol Added virtual keyword to mint function signatures for extensibility.
contracts/StoryProtocolGateway.sol Added ERC721Holder interface and replaced _transferLicenseTokens with _collectLicenseTokens for improved ownership checks; modified function access.
contracts/lib/Errors.sol Introduced new error SPG__CallerAndNotTokenOwner for ownership-related issues.
package.json Added erc6551 as a new dependency.
script/UpgradeSPG.s.sol Enhanced constructor to accept licenseRegistryAddr and royaltyModuleAddr.
script/UpgradeSPGNFT.s.sol Changed create3SaltSeed constant from 15 to 12.
test/mocks/MockIPGraph.sol Introduced MockIPGraph contract with functions for managing IP relationships and royalties.
test/utils/BaseTest.t.sol Integrated MockIPGraph into BaseTest for enhanced testing capabilities.

Assessment against linked issues

Objective Addressed Explanation
Failure in registering derivatives with license tokens due to ownership restrictions (#26)

Possibly related issues

🐇 In the fields we hop and play,
With NFT minting bright and gay.
Tokens safe, and licenses clear,
A new IP Graph brings us cheer!
So let’s all dance, both far and near! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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 Configuration 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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 887ee6f and 19cb206.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (10)
  • contracts/SPGNFT.sol (2 hunks)
  • contracts/StoryProtocolGateway.sol (11 hunks)
  • contracts/lib/Errors.sol (1 hunks)
  • package.json (1 hunks)
  • remappings.txt (1 hunks)
  • script/UpgradeSPG.s.sol (1 hunks)
  • script/UpgradeSPGNFT.s.sol (1 hunks)
  • test/StoryProtocolGateway.t.sol (8 hunks)
  • test/mocks/MockIPGraph.sol (1 hunks)
  • test/utils/BaseTest.t.sol (3 hunks)
Additional context used
LanguageTool
remappings.txt

[misspelling] ~4-~4: Hoewel het woord correct kan zijn, is er een grote kans dat het een typefout is van “noden”. Zo niet, dan is het waarschijnlijk een ouderwetse uitdrukking.
Context: ...ory-protocol/create3-deployer/ @solady/=node_modules/solady/ ds-test/=lib/forge-std/...

(MACHTE)

Additional comments not posted (35)
remappings.txt (1)

4-4: LGTM!

The addition of the @solady remapping is correct and aligns with the project's structure.

Tools
LanguageTool

[misspelling] ~4-~4: Hoewel het woord correct kan zijn, is er een grote kans dat het een typefout is van “noden”. Zo niet, dan is het waarschijnlijk een ouderwetse uitdrukking.
Context: ...ory-protocol/create3-deployer/ @solady/=node_modules/solady/ ds-test/=lib/forge-std/...

(MACHTE)

contracts/lib/Errors.sol (1)

16-17: LGTM!

The new error SPG__CallerAndNotTokenOwner is well-defined and enhances error reporting for unauthorized token access.

package.json (1)

44-44: LGTM!

The addition of the erc6551 dependency is appropriate for supporting ERC-6551 functionalities.

script/UpgradeSPGNFT.s.sol (1)

23-23: Verify the change to create3SaltSeed.

Changing create3SaltSeed from 15 to 12 may impact contract deployment. Verify that this change aligns with the intended deployment strategy.

script/UpgradeSPG.s.sol (1)

59-60: Verify constructor parameter updates.

Ensure all constructor calls to UpgradeSPG are updated to include licenseRegistryAddr and royaltyModuleAddr.

test/mocks/MockIPGraph.sol (10)

15-19: LGTM!

The addParentIp function correctly adds parent IPs to the mapping.


20-22: LGTM!

The hasParentIp function efficiently checks for the existence of a parent IP.


23-25: LGTM!

The getParentIps function correctly returns all parent IPs using values.


26-28: LGTM!

The getParentIpsCount function correctly returns the count of parent IPs.


29-45: LGTM!

The hasAncestorIp function correctly implements a breadth-first search to check for ancestor IPs.


47-61: LGTM!

The getAncestorIpsCount function correctly counts ancestor IPs using a breadth-first search.


69-71: LGTM!

The setRoyalty function correctly updates the royalty percentage for IPs.


72-89: LGTM!

The getRoyalty function correctly calculates total royalties by traversing the IP graph.


91-106: LGTM!

The getRoyaltyStack function correctly calculates the total royalty stack for an IP ID.


114-119: LGTM!

The _toBytes32 and _toAddress functions correctly handle type conversions.

contracts/SPGNFT.sol (7)

Line range hint 47-73: LGTM!

The initialize function correctly sets up the contract and checks for zero addresses.


120-122: LGTM!

The addition of the virtual keyword to the mint function is appropriate for extensibility.


133-135: LGTM!

The addition of the virtual keyword to the mintBySPG function is appropriate for extensibility.


Line range hint 139-141: LGTM!

The withdrawToken function correctly handles token transfers using IERC20.transfer.


Line range hint 145-147: LGTM!

The supportsInterface function correctly checks for supported interfaces.


Line range hint 151-166: LGTM!

The _mintToken function correctly handles NFT minting and metadata setting.


Line range hint 183-186: LGTM!

The _getSPGNFTStorage function correctly accesses the storage struct using inline assembly.

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

28-28: LGTM!

The import statement for MockIPGraph is necessary for testing purposes.


75-75: LGTM!

The use of vm.etch to deploy MockIPGraph ensures the mock contract's bytecode is available for testing.


59-59: LGTM! But verify the address usage.

The initialization of MockIPGraph with a specific address is appropriate for testing.

Ensure that the address 0x1A does not conflict with other tests.

Verification successful

Address 0x1A Usage Verified

The address 0x1A is used in the initialization of MockIPGraph and in a related context involving vm.etch. There are no other conflicting uses of this address in the Solidity files.

  • The address 0x1A is used in:
    • Initialization of MockIPGraph.
    • vm.etch with MockIPGraph.

No conflicts were found with other tests or usages.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the address `0x1A` is not used elsewhere in tests.

# Test: Search for the address usage. Expect: Only occurrences related to `MockIPGraph`.
rg --type solidity '0x1A'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify that the address `0x1A` is not used elsewhere in Solidity tests.

# Find all Solidity files and search for the address usage.
fd --extension sol --exec rg '0x1A' {}

Length of output: 159

test/StoryProtocolGateway.t.sol (7)

Line range hint 514-560: LGTM!

The _getSetPermissionSignatureForSPG function correctly uses state instead of nonce for permission setting.


Line range hint 137-153: LGTM!

The test_SPG_registerIp test case correctly reflects the new logic with the state parameter.


178-183: LGTM!

The test_SPG_registerPILTermsAndAttach test case correctly reflects the new logic with the state parameter.


257-271: LGTM!

The test_SPG_registerIpAndAttachPILTerms test case correctly reflects the new logic with the state parameter.


439-452: LGTM!

The test_SPG_registerIpAndMakeDerivativeWithLicenseTokens test case correctly reflects the new logic with the state parameter.


Line range hint 572-612: LGTM!

The _mintAndRegisterIpAndMakeDerivativeBaseTest function correctly handles the logic for minting and registering derivatives.


Line range hint 618-658: LGTM!

The _registerIpAndMakeDerivativeBaseTest function correctly handles the logic for registering IPs and making derivatives.

contracts/StoryProtocolGateway.sol (3)

6-6: LGTM!

The addition of the ERC721Holder interface allows the contract to safely receive ERC721 tokens.


482-495: LGTM!

The _collectLicenseTokens function enhances security by ensuring only the owner can transfer license tokens.


Line range hint 509-539: LGTM!

Changing function visibility from private to internal allows for greater extensibility.

Also applies to: 565-597

test/mocks/MockIPGraph.sol Show resolved Hide resolved
test/mocks/MockIPGraph.sol Show resolved Hide resolved
Copy link

@kingster-will kingster-will left a comment

Choose a reason for hiding this comment

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

LGTM.

@sebsadface sebsadface merged commit f3348ea into storyprotocol:main Aug 18, 2024
3 checks passed
@sebsadface sebsadface deleted the issue-26-27-28 branch August 28, 2024 03:29
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