xrpl.js icon indicating copy to clipboard operation
xrpl.js copied to clipboard

MPT

Open shawnxie999 opened this issue 1 year ago • 4 comments

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

shawnxie999 avatar Mar 14 '24 15:03 shawnxie999

@coderabbit full review

justinr1234 avatar Sep 19 '24 16:09 justinr1234

@coderabbitai full review

justinr1234 avatar Sep 19 '24 16:09 justinr1234

Actions performed

Full review triggered.

coderabbitai[bot] avatar Sep 19 '24 16:09 coderabbitai[bot]

Walkthrough

The changes in this pull request involve extensive updates to the Ripple binary codec and XRPL packages. Key modifications include the introduction of new types and interfaces for multi-party tokens (MPTs), enhanced handling of amounts, and the addition of new transaction models related to MPT operations. The updates also include renaming existing types, expanding validation logic, and enhancing serialization/deserialization processes. Additionally, numerous test cases have been added or updated to ensure comprehensive coverage of the new functionalities.

Changes

File Path Change Summary
packages/ripple-binary-codec/src/types/amount.ts Updated Amount class for IOUs and MPTs, added AmountObjectMPT interface, and new validation methods.
packages/ripple-binary-codec/src/types/hash-192.ts Introduced Hash192 class with properties and constructor.
packages/ripple-binary-codec/src/types/index.ts Added Hash192 to core types for serialization/deserialization.
packages/ripple-binary-codec/src/types/serialized-type.ts Updated toJSON method signature for flexibility.
packages/ripple-binary-codec/src/types/st-object.ts Updated STObject class to handle UInt64 types.
packages/ripple-binary-codec/src/types/uint-64.ts Enhanced UInt64 class for base 10 string support.
packages/ripple-binary-codec/test/amount.test.ts Expanded test suite for Amount class with new cases.
packages/ripple-binary-codec/test/binary-parser.test.ts Updated binary parser tests with new assertions.
packages/ripple-binary-codec/test/fixtures/data-driven-tests.json Added new test cases for Amount type edge cases.
packages/ripple-binary-codec/test/hash.test.ts Introduced test suite for Hash192.
packages/ripple-binary-codec/test/uint.test.ts Updated tests for new MPT issuance entities.
packages/xrpl/HISTORY.md Updated history file with new utility functions and breaking changes.
packages/xrpl/src/client/partialPayment.ts Enhanced handling of amounts in partial payments.
packages/xrpl/src/models/common/index.ts Introduced MPTAmount interface.
packages/xrpl/src/models/ledger/LedgerEntry.ts Added new string literals to LedgerEntryFilter.
packages/xrpl/src/models/ledger/MPToken.ts Introduced MPToken interface for ledger entries.
packages/xrpl/src/models/ledger/MPTokenIssuance.ts Introduced MPTokenIssuance interface for token issuance.
packages/xrpl/src/models/ledger/index.ts Added imports for MPTokenIssuance and MPToken.
packages/xrpl/src/models/methods/ledgerEntry.ts Updated LedgerEntryRequest interface with new properties for MPToken operations.
packages/xrpl/src/models/transactions/MPTokenAuthorize.ts Introduced MPTokenAuthorize transaction model.
packages/xrpl/src/models/transactions/MPTokenIssuanceCreate.ts Introduced MPTokenIssuanceCreate transaction model.
packages/xrpl/src/models/transactions/MPTokenIssuanceDestroy.ts Introduced MPTokenIssuanceDestroy transaction model.
packages/xrpl/src/models/transactions/MPTokenIssuanceSet.ts Introduced MPTokenIssuanceSet transaction model.
packages/xrpl/src/models/transactions/clawback.ts Updated Clawback transaction model for MPT support.
packages/xrpl/src/models/transactions/metadata.ts Updated metadata.ts to include MPTAmount type.
packages/xrpl/src/models/transactions/payment.ts Updated Payment transaction model to support MPTAmount.
packages/xrpl/src/models/transactions/transaction.ts Added new transaction types for MP tokens.
packages/xrpl/src/models/utils/flags.ts Updated flags.ts with new transaction flags for MPToken operations.
packages/xrpl/test/integration/transactions/clawback.test.ts Added new test cases for MPToken functionality.
packages/xrpl/test/integration/transactions/mptokenAuthorize.test.ts Introduced integration tests for MPTokenAuthorize.
packages/xrpl/test/integration/transactions/mptokenIssuanceCreate.test.ts Introduced integration tests for MPTokenIssuanceCreate.
packages/xrpl/test/integration/transactions/mptokenIssuanceDestroy.test.ts Introduced integration tests for MPTokenIssuanceDestroy.
packages/xrpl/test/integration/transactions/mptokenIssuanceSet.test.ts Introduced integration tests for MPTokenIssuanceSet.
packages/xrpl/test/integration/transactions/payment.test.ts Added new test case for validating MPT payments.
packages/xrpl/test/models/MPTokenAuthorize.test.ts Introduced unit tests for MPTokenAuthorize verification.
packages/xrpl/test/models/MPTokenIssuanceCreate.test.ts Introduced unit tests for MPTokenIssuanceCreate verification.
packages/xrpl/test/models/MPTokenIssuanceSet.test.ts Introduced unit tests for MPTokenIssuanceSet verification.
packages/xrpl/test/models/clawback.test.ts Added new test cases for validating clawback transactions involving MPTs.

Possibly related PRs

  • #2765: The changes in the paths.ts file enhance the functionality of pathfinding tests related to issued currencies, which may connect to the broader context of handling amounts, including IOUs and MPTs, as seen in the main PR.
  • #2777: The updates in the HISTORY.md file reflect changes related to transaction handling, including the introduction of new transaction types and enhancements that may relate to the handling of amounts, particularly in the context of MPTs.
  • #2824: The modification of the TRANSACTION_TYPES.Payment value in the binary codec test relates to the handling of payment transactions, which could be relevant to the changes made in the main PR regarding the Amount class and its handling of different types.

Suggested reviewers

  • achowdhry-ripple
  • justinr1234

Poem

In the meadow where changes bloom,
New tokens dance, dispelling gloom.
With amounts that leap and twirl,
MPTs frolic, flags unfurl.
A hop, a skip, through code we play,
Celebrating updates, hip-hip-hooray! 🐇✨


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. (Experiment)
  • @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.

coderabbitai[bot] avatar Sep 19 '24 16:09 coderabbitai[bot]

Quick note: you can refer to the Verified Credentials PR to see the CI docker changes needed to get the integration tests to run. Once you switch to 2.3.0+, there is an entrypoint issue that requires a manual override in the script, so you will have to make the changes here too

achowdhry-ripple avatar Dec 05 '24 17:12 achowdhry-ripple

Seeing the integration tests failing now, will need to be resolved. Looks like they are running now so the docker part is good. Might still need to use a different version of the docker image, there are a lot after rc1 and I suspect the temDisabled response has to do with it

achowdhry-ripple avatar Dec 06 '24 17:12 achowdhry-ripple

nit: I also agree with the typos raised by coderabbit, should be quick fixes

achowdhry-ripple avatar Dec 06 '24 17:12 achowdhry-ripple

@achowdhry-ripple fixed comments from coderabbits that are relevant. previously the integration test failed with temDISABLED because the rippled cfg didn't include the MPT amendment.

shawnxie999 avatar Dec 06 '24 20:12 shawnxie999

MPToken is an asset with a balance, don't we need to change to getBalanceChanges(packages/xrpl/src/utils/getBalanceChanges.ts)?

tequdev avatar Dec 11 '24 09:12 tequdev

MPToken is an asset with a balance, don't we need to change to getBalanceChanges(packages/xrpl/src/utils/getBalanceChanges.ts)?

Good catch! Yes, we can support this later separately.

shawnxie999 avatar Dec 11 '24 17:12 shawnxie999

MPToken is an asset with a balance, don't we need to change to getBalanceChanges(packages/xrpl/src/utils/getBalanceChanges.ts)?

Also agree, this is a good catch. If its not too much overhead would say it should go out with this, otherwise we should update the JSDoc to say this does not include MPTs for now

achowdhry-ripple avatar Dec 11 '24 18:12 achowdhry-ripple

@achowdhry-ripple i would prefer doing it separately, may not be necessary to hold off merging the main change for a sub-component

shawnxie999 avatar Dec 11 '24 21:12 shawnxie999

@achowdhry-ripple i would prefer doing it separately, may not be necessary to hold off merging the main change for a sub-component

In that case, could you raise a github issue here so we can track it?

achowdhry-ripple avatar Dec 11 '24 22:12 achowdhry-ripple