feat(xrpl): custom definitions support
High Level Overview of Change
In previous versions, custom definition support was added to the ripple-binary-codec methods but not the proxy ones in the xrpl package.
This PR adds support for Custom Definitions to the following xrpl methods:
utils.encodeutils.decodeutils.encodeForSigningWallet.signclient.submit()(@tequdev)client.submitAndWait(@tequdev)
Context of Change
When using custom definitions, you had to directly use the encode, decode, and encodeForSigning methods from ripple-binary-codec. Those features can now be used via the proxy methods in the xrpl package.
Custom definition support has also been added to the Wallet.sign method which wasn't the case before.
Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] 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?
- [x] Yes
- [ ] No, this change does not impact library users
Test Plan
Added 3 unit tests for:
Wallet.sign(single signature)Wallet.sign(multisignature)Wallet.sign(unknown transaction type)
Summary by CodeRabbit
Release Notes
-
New Features
- Enhanced API methods to accept optional parameters for custom transaction definitions, improving flexibility in transaction handling.
- Introduced new utility functions and improved existing methods to support custom definitions in transaction submissions and validations.
- Added support for custom definitions in the Wallet class, enhancing transaction signing capabilities.
- New JSON fixtures for testing custom transaction definitions have been added.
-
Bug Fixes
- Improved error handling for transaction validation and signing processes.
-
Documentation
- Updated README and release history to reflect new features and changes in method signatures.
-
Tests
- Added new test cases for signing transactions with custom definitions and handling invalid transaction types.
Hey there, did you also check https://github.com/XRPLF/xrpl.js/pull/2214
Hey there, did you also check #2214
#2214 is massively outdated and it'd take a ton of effort to update.
@elmurci
I have created a PR for client.submit() and client.submitAndWait() to support definitions as well.
If it looks good, please consider including it in this PR.
https://github.com/elmurci/xrpl.js/pull/1
@elmurci
I have created a PR for
client.submit()andclient.submitAndWait()to support definitions as well. If it looks good, please consider including it in this PR.
done, thanks @tequdev
@elmurci looks like something broke TS
@elmurci Here is a commit that fixes the current lint error. Please use it if necessary.
https://github.com/tequdev/xrpl.js/commit/4f93aa800c7c0f1152538cacb42b0ba943c568d2
@coderabbitai full review
Actions performed
Full review triggered.
[!WARNING]
Rate limit exceeded
@elmurci has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 51 seconds before requesting another review.
β How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.We recommend that you space out your commits to avoid hitting the rate limit.
π¦ How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.
π₯ Commits
Reviewing files that changed from the base of the PR and between 4731f60785a7145945a4afd2cdff876b04b23825 and 5db85fe6db1f44f97d80e1ee79979f0d867bb458.
π Files selected for processing (1)
packages/xrpl/HISTORY.md(2 hunks)
Walkthrough
This pull request introduces optional parameters to several methods in the ripple-binary-codec and xrpl libraries, specifically allowing for the inclusion of custom definitions during transaction encoding, decoding, and signing processes. Key methods have been updated to accept a new parameter, definitions, which enhances their flexibility. Additionally, new utility functions and modifications to existing methods improve the handling of transaction submissions and validations. The changes are reflected across various files, including enhancements to testing fixtures for custom transaction definitions.
Changes
| File Path | Change Summary |
|---|---|
| packages/ripple-binary-codec/README.md | Updated method signatures for decode, encode, encodeForSigning, and encodeForMultisigning to include definitions. Minor formatting adjustments made. |
| packages/xrpl/HISTORY.md | Added release notes for new utility functions, custom definitions support, and breaking changes in the xrpl.js library. |
| packages/xrpl/src/Wallet/index.ts | Updated sign and computeSignature methods to accept definitions. |
| packages/xrpl/src/client/index.ts | Introduced definitions property and getDefinitions() method; updated submit() and submitAndWait() methods to support custom definitions. |
| packages/xrpl/src/models/transactions/common.ts | Added validateTxAgainstCustomDefinitions function for custom validation of transaction types. |
| packages/xrpl/src/models/transactions/transaction.ts | Updated validate function to include optional customDefinitions parameter for flexible validation. |
| packages/xrpl/src/sugar/submit.ts | Modified submitRequest, isSigned, and getSignedTx functions to accept definitions. |
| packages/xrpl/src/utils/hashes/hashLedger.ts | Updated hashSignedTx function to accept definitions. |
| packages/xrpl/src/utils/index.ts | Updated encode, encodeForSigning, encodeForMultiSigning, and decode functions to accept definitions. |
| packages/xrpl/test/fixtures/requests/index.ts | Added import for signAsCustomDefinition and updated sign object. |
| packages/xrpl/test/fixtures/requests/signAsCustomDefinition.json | New JSON file for token swap transaction request. |
| packages/xrpl/test/fixtures/responses/index.ts | Added imports for signAsCustomDefinition and signCustomDefinition, updated sign object. |
| packages/xrpl/test/fixtures/responses/signAsCustomDefinition.json | New JSON file for signed transaction response. |
| packages/xrpl/test/fixtures/responses/signCustomDefinition.json | New JSON file for signed transaction response. |
| packages/xrpl/test/fixtures/rippled/index.ts | Added definitions object containing customDefinition. |
| packages/xrpl/test/wallet/index.test.ts | Enhanced wallet tests to include signing with custom definitions and validate error handling. |
Possibly related PRs
- #2851: The changes in this PR involve updates to the
ripple-binary-codecpackage, which is directly related to the main PR's modifications that introduce optional parameters in theripple-binary-codecAPI methods.
Suggested reviewers
- pdp2121
- achowdhry-ripple
- ckeshava
π° In the meadow where bunnies play,
Custom definitions brighten the day!
With transactions signed, oh what a sight,
Flexibility blooms, everything feels right.
Hop along, letβs encode and decode,
In the world of XRPL, our joy will explode! πΌ
Finishing Touches
- [ ] π Generate Docstrings
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?
πͺ§ 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
@elmurci Please let me know if I can re-review this PR.