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

support DynamicNFT #2726

Merged
merged 11 commits into from
Feb 3, 2025
Merged

support DynamicNFT #2726

merged 11 commits into from
Feb 3, 2025

Conversation

yinyiqian1
Copy link
Collaborator

@yinyiqian1 yinyiqian1 commented Jul 4, 2024

support DynamicNFT XRPLF/rippled#5048

High Level Overview of Change

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update HISTORY.md?

  • Yes
  • [] No, this change does not impact library users

Test Plan

@yinyiqian1 yinyiqian1 marked this pull request as draft July 4, 2024 18:28
@yinyiqian1 yinyiqian1 marked this pull request as ready for review July 4, 2024 18:43
@mvadari
Copy link
Collaborator

mvadari commented Jul 5, 2024

FYI the general policy with this repo and xrpl-py is that amendment PRs aren't merged until the corresponding rippled PR is merged (though of course development can happen before).

Copy link
Collaborator

@shawnxie999 shawnxie999 left a comment

Choose a reason for hiding this comment

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

Left a nit, but looks good! (should not be merged till rippled changes are merged)

@mvadari mvadari changed the title support DynamicNFT [DO NOT MERGE] support DynamicNFT Jul 10, 2024
@justinr1234
Copy link
Collaborator

@CodeRabbit full review

@justinr1234
Copy link
Collaborator

@coderabbitai full review

Copy link

coderabbitai bot commented Sep 19, 2024

Actions performed

Full review triggered.

Copy link

coderabbitai bot commented Sep 19, 2024

Walkthrough

This pull request introduces enhancements to the XRPL library's non-fungible token (NFT) capabilities. Key changes include the addition of a new NFTokenModify transaction type, the introduction of the tfMutable flag for NFTokenMint, and the implementation of corresponding validation and testing mechanisms. These modifications expand the functionality of NFT management by enabling URI modifications and providing a structured approach to NFT-related transactions.

Changes

File Change Summary
packages/ripple-binary-codec/HISTORY.md Added version 2.1.0 entry with NFTokenModify transaction and tfMutable flag
packages/ripple-binary-codec/src/enums/definitions.json Added new transaction type NFTokenModify with value 61
packages/xrpl/HISTORY.md Added NFTokenModify transaction and tfMutable flag for NFTokenMint
packages/xrpl/src/models/transactions/NFTokenMint.ts Added tfMutable flag to NFTokenMintFlags and updated related interfaces
packages/xrpl/src/models/transactions/NFTokenModify.ts Created new interface and validation function for NFTokenModify transaction
packages/xrpl/src/models/transactions/index.ts Added exports for NFTokenModify and validateNFTokenModify
packages/xrpl/src/models/transactions/transaction.ts Updated SubmittableTransaction type and validation logic for NFTokenModify
packages/xrpl/test/integration/transactions/nftokenModify.test.ts Added integration test suite for NFTokenModify functionality
packages/xrpl/test/models/NFTokenModify.test.ts Added unit tests for validation logic of NFTokenModify transaction
.ci-config/rippled.cfg Added DynamicNFT feature to configuration; cleaned up comments
.github/workflows/nodejs.yml Updated RIPPLED_DOCKER_IMAGE from rippleci/rippled:2.3.0-rc1 to rippleci/rippled:develop

Possibly related PRs

  • 4.1.0 release #2851: The changes in this PR include the addition of the NFTokenModify transaction and the tfMutable flag in the xrpl package, which directly relates to the new transaction type and flag added in the main PR for the ripple-binary-codec package.
  • add more mpt flag validations #2856: Although this PR focuses on MPT flag validations, it is related to the broader context of transaction flags and their validation, which is relevant to the changes made in the main PR regarding transaction types and flags.

Suggested reviewers

  • mvadari
  • achowdhry-ripple

Poem

🐰 A Rabbit's Ode to NFT Delight 🎨
Mutable tokens, a magical sight,
Modify URIs with newfound might!
NFTs dancing, flags unfurled,
A codec's magic in our digital world!
Hop, hop, hooray for change so bright! 🚀


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@yinyiqian1 yinyiqian1 changed the title [DO NOT MERGE] support DynamicNFT support DynamicNFT Jan 24, 2025
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

🧹 Nitpick comments (4)
packages/xrpl/test/models/NFTokenModify.test.ts (1)

14-25: Consider adding more coverage for invalid URIs.

The current test suite validates a correct NFTokenModify scenario and missing NFTokenID. However, additional tests for an invalid or empty URI would further strengthen coverage. For instance, verifying that a non-hex or empty string URI correctly triggers a validation error.

packages/xrpl/src/models/transactions/NFTokenModify.ts (1)

60-62: Document a recommended approach for removing a URI.

It may be helpful to clarify in the docstring that if a user wants to remove or clear a previously set URI, they should set URI to undefined or omit it instead of passing an empty string, since an empty string triggers a validation error.

packages/xrpl/test/integration/transactions/nftokenModify.test.ts (1)

3-4: Resolve ESLint import/extensions rule.

According to static analysis hints, adding file extensions to imports under ../../../dist/npm and ../../../dist/npm/src may be required. Consider applying a configuration or including .js in these imports to resolve lint errors.

Here's an example of how to fix it:

-import { NFTokenModify } from '../../../dist/npm'
-import { NFTokenMintFlags } from '../../../dist/npm/src'
+import { NFTokenModify } from '../../../dist/npm/index.js'
+import { NFTokenMintFlags } from '../../../dist/npm/src/index.js'
🧰 Tools
🪛 eslint

[error] 3-3: Missing file extension for "../../../dist/npm"

(import/extensions)


[error] 4-4: Missing file extension for "../../../dist/npm/src"

(import/extensions)

packages/xrpl/src/models/transactions/NFTokenMint.ts (1)

41-44: Validate bitmask usage for new flag.

Adding tfMutable = 0x00000010 seems correct following the prior flag 0x00000008. Ensure that there is no overlap with any other existing flags in the codebase.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92eb809 and f655224.

📒 Files selected for processing (9)
  • packages/ripple-binary-codec/HISTORY.md (1 hunks)
  • packages/ripple-binary-codec/src/enums/definitions.json (1 hunks)
  • packages/xrpl/HISTORY.md (1 hunks)
  • packages/xrpl/src/models/transactions/NFTokenMint.ts (2 hunks)
  • packages/xrpl/src/models/transactions/NFTokenModify.ts (1 hunks)
  • packages/xrpl/src/models/transactions/index.ts (1 hunks)
  • packages/xrpl/src/models/transactions/transaction.ts (3 hunks)
  • packages/xrpl/test/integration/transactions/nftokenModify.test.ts (1 hunks)
  • packages/xrpl/test/models/NFTokenModify.test.ts (1 hunks)
🧰 Additional context used
🪛 eslint
packages/xrpl/test/integration/transactions/nftokenModify.test.ts

[error] 3-3: Missing file extension for "../../../dist/npm"

(import/extensions)


[error] 4-4: Missing file extension for "../../../dist/npm/src"

(import/extensions)

🔇 Additional comments (10)
packages/xrpl/test/models/NFTokenModify.test.ts (1)

27-40: Good negative test coverage.

This test correctly verifies that an NFTokenModify transaction missing the NFTokenID field raises a ValidationError. This ensures robust handling of incomplete inputs.

packages/xrpl/src/models/transactions/index.ts (1)

55-55: Export statement looks good.

Exporting NFTokenModify and validateNFTokenModify here ensures they are conveniently available. The ordering is consistent and no immediate issues are observed.

packages/xrpl/test/integration/transactions/nftokenModify.test.ts (1)

34-103: Excellent integration test for NFTokenModify.

The flow of minting an NFT with the tfMutable flag, then modifying its URI, and finally verifying the updated URI is comprehensive. The use of testTransaction and subsequent validation via account_nfts ensures end-to-end coverage.

packages/xrpl/src/models/transactions/NFTokenMint.ts (1)

58-58: Ensure parity between interface and flag.

The new tfMutable?: boolean property correctly corresponds to the tfMutable flag. No further changes needed.

packages/xrpl/src/models/transactions/transaction.ts (3)

124-124: Extend transaction coverage.

Adding NFTokenModify to the SubmittableTransaction union is consistent with the introduction of a new transaction type.


331-334: Validate newly introduced transaction.

Including a case 'NFTokenModify' to invoke validateNFTokenModify ensures the transaction is properly validated. This is a necessary and correct addition.


44-44: Confirm import presence.

The added import { NFTokenModify, validateNFTokenModify } looks good. Verify that the file NFTokenModify.ts exists and is being exported in the correct format.

✅ Verification successful

Import verification successful

The file NFTokenModify.ts exists and exports both NFTokenModify interface and validateNFTokenModify function in the correct format.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Confirm presence of NFTokenModify.ts and export statements
fd NFTokenModify.ts
rg -A 10 'export function validateNFTokenModify' 

Length of output: 1153


Script:

#!/bin/bash
# Check NFTokenModify export
ast-grep --pattern 'export interface NFTokenModify'
ast-grep --pattern 'export type NFTokenModify'

Length of output: 102


Script:

#!/bin/bash
# Check all exports in NFTokenModify.ts
rg "export" packages/xrpl/src/models/transactions/NFTokenModify.ts

Length of output: 198

packages/ripple-binary-codec/HISTORY.md (1)

9-9: Retain clarity of update history.

Documenting the newly added NFTokenModify transaction and tfMutable flag under version 2.1.0 is helpful for future reference. Good job keeping HISTORY.md current.

packages/ripple-binary-codec/src/enums/definitions.json (1)

2977-2977: Add consistent tooling note.

The addition of "NFTokenModify": 53 is correct for the new transaction type. However, note that previous feedback suggests using the xrpl-codec-gen script for these changes. Please confirm this step was followed or consider generating the definitions to maintain consistency.

packages/xrpl/HISTORY.md (1)

9-9: LGTM! Changes align with DynamicNFT support.

The addition of NFTokenModify transaction and tfMutable flag in NFTokenMint is properly documented and consistent with the PR objectives of supporting Dynamic Non-Fungible Tokens (DynamicNFT).

@xVet
Copy link

xVet commented Jan 25, 2025

Thank you for this :)

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

🧹 Nitpick comments (1)
.ci-config/rippled.cfg (1)

191-191: Add version grouping comment for better maintainability.

To maintain consistency with other amendments, consider adding a version group comment above the DynamicNFT amendment. This helps track which rippled version introduced this feature.

 fixReducedOffersV2
+# X.X.X Amendments
 DynamicNFT
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e59412 and 7e3c155.

📒 Files selected for processing (2)
  • .ci-config/rippled.cfg (1 hunks)
  • .github/workflows/nodejs.yml (1 hunks)
🔇 Additional comments (3)
.ci-config/rippled.cfg (1)

191-191: Verify the amendment status in rippled.

Since this amendment corresponds to rippled PR #5048, we should verify its status before enabling it.

Let's check the rippled PR status:

✅ Verification successful

The DynamicNFT amendment is properly merged in rippled.

The amendment corresponds to PR #5048 which is now merged, confirming it's safe to enable this feature.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the status of the DynamicNFT amendment PR in rippled

gh pr view 5048 --repo XRPLF/rippled --json state,title,url

Length of output: 160

.github/workflows/nodejs.yml (2)

Line range hint 15-236: LGTM! The workflow configuration follows CI/CD best practices.

The job configurations demonstrate good practices:

  • Comprehensive test matrix across Node.js versions
  • Efficient caching strategy
  • Proper cleanup handling
  • Reasonable timeout limits

7-7: Verify the stability implications of using the develop tag.

Switching from a specific version (2.3.0-rc1) to develop tag could introduce instability in the CI pipeline as the image content can change unexpectedly. While this might be necessary for testing the new DynamicNFT features, consider:

  1. Adding a comment explaining why the develop tag is required
  2. Creating a tracking issue to revert back to a stable version once the DynamicNFT features are released

Run this script to check the current state of the develop branch and available tags:

✅ Verification successful

Using the develop tag is appropriate but requires monitoring

The verification shows that the Docker image is actively maintained and synchronized with the rippled develop branch. While using a specific version is generally preferred for stability, using the develop tag is acceptable in this context as:

  1. The Docker image is regularly updated to match the develop branch
  2. Testing new features like DynamicNFT may require the latest changes

Consider adding a comment in the workflow file explaining this dependency on the develop branch.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the rippled Docker image tags and compare with the rippled repository state

# Get available Docker tags
echo "Available Docker tags:"
curl -s https://registry.hub.docker.com/v2/repositories/rippleci/rippled/tags | jq -r '.results[].name'

# Check the rippled repository state
echo -e "\nRippled repository state:"
gh api repos/XRPLF/rippled/branches/develop --jq '.commit.sha, .commit.commit.message'

Length of output: 776

@yinyiqian1 yinyiqian1 requested review from mvadari and xVet January 27, 2025 21:31
@@ -11,6 +11,7 @@

### Added
* Support for the Price Oracles amendment (XLS-47).
* Add `NFTokenModify` transaction and add `tfMutable` flag in `NFTokenMint`
Copy link
Collaborator

@achowdhry-ripple achowdhry-ripple Jan 30, 2025

Choose a reason for hiding this comment

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

nit: can follow the format on line 13 and indicate XLS-46 instead of adding the specifics here

@@ -17,6 +17,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
* New `MPTAmount` type support for `Payment` and `Clawback` transactions
* `parseTransactionFlags` as a utility function in the xrpl package to streamline transactions flags-to-map conversion
* Support for XLS-70d (Credentials)
* Add `NFTokenModify` transaction and add `tfMutable` flag in `NFTokenMint`
Copy link
Collaborator

Choose a reason for hiding this comment

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

same nit here to reference xls-46 here instead of the specifics

* convert this field to the proper encoding.
*
* This field must not be an empty string. Omit it from the transaction or
* set to `undefined` value if you do not use it.
Copy link
Collaborator

@achowdhry-ripple achowdhry-ripple Jan 30, 2025

Choose a reason for hiding this comment

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

could this comment reference setting to null for clarity

Comment on lines +53 to +57
const mutableTx: TxRequest = {
command: 'tx',
transaction: hashSignedTx(response.result.tx_blob),
}
const mutableTxResponse = await testContext.client.request(mutableTx)
Copy link
Collaborator

@achowdhry-ripple achowdhry-ripple Jan 30, 2025

Choose a reason for hiding this comment

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

how come we need a separate tx request here? could we get the nft id from the mint response

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mint response won't provide nftoken id. we have to query it through another request

() => validate(invalid),
ValidationError,
'NFTokenModify: missing field NFTokenID',
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you add test cases for invalid hex format and empty string check here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a separate PR to add the test and resolve comments: #2892

Copy link
Collaborator

@achowdhry-ripple achowdhry-ripple left a comment

Choose a reason for hiding this comment

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

Overall LGTM, few minor comments

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.

6 participants