Skip to content

Conversation

@khancode
Copy link
Contributor

@khancode khancode commented Jun 18, 2025

High Level Overview of Change

Adds conditional check for PermissionValue so custom definitions (based on previous v2.x versions) don't break.

Context of Change

Bithomp reported this issue.

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

Adds unit test to delete PermissionValue from defintions.json and verified it doesn't throw an error anymore.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

"""

Walkthrough

A conditional check was added to ensure the existence of the PermissionValue field before assigning its associatedType property. The changelog was updated to document this fix, which preserves compatibility with custom definitions based on previous versions. A test was added to verify encoding/decoding without the PermissionValue field.

Changes

Files/Groups Change Summary
packages/ripple-binary-codec/HISTORY.md Added an entry describing the fix for PermissionValue compatibility in the changelog.
packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts Added a conditional check for PermissionValue before assigning its associatedType property.
packages/ripple-binary-codec/test/definitions.test.ts Added a test verifying encoding and decoding works when PermissionValue field is removed.

Possibly related issues

Suggested labels

bug

Suggested reviewers

  • Patel-Raj11

Poem

A bunny hopped through fields of code,
Where PermissionValue once overflowed.
With a careful check, the bug was caught,
Compatibility—no longer fraught!
Now custom types can safely play,
Thanks to the patch merged in today.
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: '@es-joy/[email protected]',
npm warn EBADENGINE required: { node: '^14 || ^16 || ^17 || ^18 || ^19' },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: '[email protected]',
npm warn EBADENGINE required: { node: '^14 || ^16 || ^17 || ^18 || ^19' },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-18T19_26_02_995Z-debug-0.log


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2f53699 and cd8f47f.

📒 Files selected for processing (3)
  • packages/ripple-binary-codec/HISTORY.md (1 hunks)
  • packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts (1 hunks)
  • packages/ripple-binary-codec/test/definitions.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/ripple-binary-codec/HISTORY.md
  • packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts
  • packages/ripple-binary-codec/test/definitions.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: generate-documentation (22.x)
  • GitHub Check: browser (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: unit (22.x)
  • GitHub Check: build-and-lint (22.x)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: integration (20.x)
  • GitHub Check: integration (22.x)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@Patel-Raj11
Copy link
Collaborator

Can we add a test here that removes PermissionValue and makes sure that encode and decode of a transaction works fine?
https://github.com/XRPLF/xrpl.js/blob/ea649338e7962300a0d60f1e358f5f4e36e51d85/packages/ripple-binary-codec/test/definitions.test.ts

Copy link
Collaborator

@Patel-Raj11 Patel-Raj11 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@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)
packages/ripple-binary-codec/test/definitions.test.ts (1)

168-172: Consider adding a guard for edge case scenarios.

While the current implementation is correct, consider adding a guard to handle the edge case where PermissionValue might not exist in the original definitions.

  // Remove PermissionValue from definitions
  if (definitions.FIELDS) {
+   const originalPermissionValue = definitions.FIELDS.find(
+     (fieldTuple: [string, object]) => fieldTuple[0] === 'PermissionValue'
+   )
+   
    definitions.FIELDS = definitions.FIELDS.filter(
      (fieldTuple: [string, object]) => fieldTuple[0] !== 'PermissionValue',
    )
+   
+   // Only verify removal if PermissionValue was originally present
+   if (originalPermissionValue) {
+     const expectedFieldsLength = originalFieldsLength - 1
+     expect(definitions.FIELDS.length).toBe(expectedFieldsLength)
+   }
  }
-
- // Verify it was deleted
- const expectedFieldsLength = originalFieldsLength - 1
- expect(definitions.FIELDS.length).toBe(expectedFieldsLength)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3cbb2d7 and 2f53699.

📒 Files selected for processing (1)
  • packages/ripple-binary-codec/test/definitions.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: integration (22.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: browser (22.x)
  • GitHub Check: unit (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build-and-lint (22.x)
🔇 Additional comments (1)
packages/ripple-binary-codec/test/definitions.test.ts (1)

161-188: LGTM! Well-implemented test case addressing the PR requirements.

This test effectively validates the conditional check fix for PermissionValue definition that was mentioned in the PR objectives. The implementation follows the established patterns in the test file and properly addresses the concern raised by Patel-Raj11 about adding test coverage.

The test logic is sound:

  • Creates a proper deep copy of definitions
  • Correctly removes the PermissionValue field using array filtering
  • Verifies the removal was successful
  • Tests that encoding/decoding still works without errors

@khancode khancode force-pushed the permission-value-check branch from 2f53699 to cd8f47f Compare June 18, 2025 19:25
@khancode khancode merged commit 53c00e7 into main Jun 18, 2025
14 checks passed
@khancode khancode deleted the permission-value-check branch June 18, 2025 19:28
khancode added a commit that referenced this pull request Jun 21, 2025
* add conditional check for PermissionValue

* update HISTORY

* remove release date

* add unit test
khancode added a commit that referenced this pull request Jul 3, 2025
* update HISTORY files

* enable SAV amendment

* add VaultCreate tx and update autofill

* build(deps-dev): bump karma from 6.4.3 to 6.4.4 (#2753)

* build(deps): bump @scure/bip39 from 1.5.4 to 1.6.0 (#3004)

* Fix AccountRoot ledger object (#3010)

* fix AccountRoot ledger object

* update HISTORY.md

* fix import and lint errors

* request a validated ledger

* build(deps-dev): bump react from 19.0.0 to 19.1.0 (#2968)

* upgrade ws dependency (#2940)

Co-authored-by: achowdhry-ripple <[email protected]>

* build(deps-dev): bump webpack from 5.98.0 to 5.99.9 (#3015)

Bumps [webpack](https://github.com/webpack/webpack) from 5.98.0 to 5.99.9.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.98.0...v5.99.9)

---
updated-dependencies:
- dependency-name: webpack
  dependency-version: 5.99.9
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: achowdhry-ripple <[email protected]>
Co-authored-by: Omar Khan <[email protected]>

* add Vault ledger entry and base integ test

* add rippled serialized type Number. update models & tests to support it

* fix: add conditional check for `PermissionValue` definition (#3018)

* add conditional check for PermissionValue

* update HISTORY

* remove release date

* add unit test

* ripple-binary-codec 2.4.1 patch release (#3019)

* update HISTORY

* update package.json files

* update package-lock.json

* test: Separate faucet tests from local integration tests (#2985)

* refactor(tests): separate faucet tests from local integration tests

* feat: add Faucet test workflow and documentation

* fix: Add missing test:faucet script

* fix: execute tests one time

Co-authored-by: Raj Patel <[email protected]>

* fix: remove docker steps from faucet test workflow

* docs: update faucet tests section in CONTRIBUTING.md

* fix: remove comment from contributing.md

Co-authored-by: Raj Patel <[email protected]>

* fix: remove test:all from root package

Co-authored-by: Raj Patel <[email protected]>

* Update CONTRIBUTING.md

---------

Co-authored-by: Raj Patel <[email protected]>

* update number test

* debug

* set alias Number to SerializedNumber in coreTypes

* update fee in VaultCreate integ test

* up the fee

* up more

* debug fee

* update fee with comment

* add vault_info RPC with integ test

* remove unused var in test

* use vault_id

* update vaultInfo test

* add owner and seq params to vault_info request

* add DomainID to vault_info response

* add XRPLNumber type and VaultSet tx

* rename SerializedNumber to XRPLNumber

* add VaultSet to integ test

* refactor DEFAULT_VAULT_WITHDRAWAL_POLICY location

* fix import bug

* add VaultDeposit tx

* add VaultDeposit to integ test

* add VaultWithdraw tx

* add VaultWithdraw to integ test

* add VaultClawback tx

* add VaultClawback to integ test

* use 2 wallets for integ test

* comment out VaultClawback tx in integ test

* use IOU in integ test

* add ClawbackAmount type and VaultClawback to integ test

* add VaultDelete tx

* remove isBigInt

* add VaultDelete to integ test

* rename to STNumber

* comment out Amount in VaultClawback integ test

* Revert "comment out Amount in VaultClawback integ test"

This reverts commit 416c1e1.

* comment out WithdrawalPolicy in VaultCreate integ test

* refactor WithdrawalPolicy

* cleanup

* cleanup vars

* update HISTORY

* rename var to VAULT_DATA_MAX_BYTE_LENGTH

* use STNumber class in static function

* add VaultCreate to codec-fixtures

* refactor unit tests

* update HISTORY

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Patel <[email protected]>
Co-authored-by: Chenna Keshava B S <[email protected]>
Co-authored-by: achowdhry-ripple <[email protected]>
Co-authored-by: Achal Jhawar <[email protected]>
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.

breaking change in the latest implementation of ripple-binary-codec 2.4.0

4 participants