Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/ripple-binary-codec/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

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

## 2.4.0 (2025-6-09)

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ class XrplDefinitionsBase {
this.field['TransactionType'].associatedType = this.transactionType
this.field['TransactionResult'].associatedType = this.transactionResult
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType
this.field['PermissionValue'].associatedType = this.delegatablePermissions
if (this.field['PermissionValue']) {
this.field['PermissionValue'].associatedType = this.delegatablePermissions
}
}

public getAssociatedTypes(): Record<string, typeof SerializedType> {
Expand Down
29 changes: 29 additions & 0 deletions packages/ripple-binary-codec/test/definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,33 @@ describe('encode and decode using new types as a parameter', function () {
const decoded = decode(encoded, newDefs)
expect(decoded).toEqual(tx)
})

it('removing PermissionValue does not break encoding/decoding', function () {
// Make a deep copy of definitions
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))

const originalFieldsLength = definitions.FIELDS.length

// Remove PermissionValue from definitions
if (definitions.FIELDS) {
definitions.FIELDS = definitions.FIELDS.filter(
(fieldTuple: [string, object]) => fieldTuple[0] !== 'PermissionValue',
)
}

// Verify it was deleted
const expectedFieldsLength = originalFieldsLength - 1
expect(definitions.FIELDS.length).toBe(expectedFieldsLength)

// Create new custom definitions
const customDefs = new XrplDefinitions(definitions)

const tx = { ...txJson }

// It should encode and decode normally, even with PermissionValue missing
const encoded = encode(tx, customDefs)
const decoded = decode(encoded, customDefs)

expect(decoded).toEqual(tx)
})
})
Loading