-
Notifications
You must be signed in to change notification settings - Fork 568
XLS-0068: Sponsored Fees and Reserves #3199
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
Open
achowdhry-ripple
wants to merge
11
commits into
main
Choose a base branch
from
sponsored-fees
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8143935
init draft
achowdhry-ripple 3fa4bd8
codec changes
achowdhry-ripple 0c3762e
regen definitions
achowdhry-ripple 52ba681
rpc and granular
achowdhry-ripple 059588d
add base entry Sponsor field
achowdhry-ripple 525cd7a
unit testts
achowdhry-ripple ef25f63
update history.md
achowdhry-ripple 032902b
lint fix
achowdhry-ripple 2ffef8c
lint
achowdhry-ripple 50621a7
lint
achowdhry-ripple 469702c
lint
achowdhry-ripple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
packages/ripple-binary-codec/test/granularPermissions.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import { XrplDefinitions } from '../src' | ||
| import normalDefinitionsJson from '../src/enums/definitions.json' | ||
|
|
||
| describe('Granular Permissions', function () { | ||
| describe('SponsorFee and SponsorReserve permissions', function () { | ||
| it('should have SponsorFee defined with value 65549', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
| expect(definitions.granularPermissions.SponsorFee).toBe(65549) | ||
| }) | ||
|
|
||
| it('should have SponsorReserve defined with value 65550', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
| expect(definitions.granularPermissions.SponsorReserve).toBe(65550) | ||
| }) | ||
|
|
||
| it('should have all expected granular permissions defined', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
|
|
||
| // Verify all granular permissions are present | ||
| const expectedPermissions = { | ||
| TrustlineAuthorize: 65537, | ||
| TrustlineFreeze: 65538, | ||
| TrustlineUnfreeze: 65539, | ||
| AccountDomainSet: 65540, | ||
| AccountEmailHashSet: 65541, | ||
| AccountMessageKeySet: 65542, | ||
| AccountTransferRateSet: 65543, | ||
| AccountTickSizeSet: 65544, | ||
| PaymentMint: 65545, | ||
| PaymentBurn: 65546, | ||
| MPTokenIssuanceLock: 65547, | ||
| MPTokenIssuanceUnlock: 65548, | ||
| SponsorFee: 65549, | ||
| SponsorReserve: 65550, | ||
| } | ||
|
|
||
| expect(definitions.granularPermissions).toEqual(expectedPermissions) | ||
| }) | ||
|
|
||
| it('should have granular permissions with values greater than UINT16_MAX (65536)', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
| const UINT16_MAX = 65536 | ||
|
|
||
| // All granular permissions should have values > 65536 | ||
| Object.entries(definitions.granularPermissions).forEach( | ||
| ([_name, value]) => { | ||
| expect(value).toBeGreaterThan(UINT16_MAX) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| it('should have SponsorFee and SponsorReserve as the highest permission values', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
|
|
||
| const allValues = Object.values(definitions.granularPermissions) | ||
| const maxValue = Math.max(...allValues) | ||
|
|
||
| // SponsorReserve should be the highest value | ||
| expect(definitions.granularPermissions.SponsorReserve).toBe(maxValue) | ||
| // SponsorFee should be second highest | ||
| expect(definitions.granularPermissions.SponsorFee).toBe(maxValue - 1) | ||
| }) | ||
| }) | ||
|
|
||
| /** | ||
| * Edge cases and boundary conditions for granular permissions. | ||
| * Per XLS-0068 Sections 13-14, granular permissions are values > UINT16_MAX (65536). | ||
| */ | ||
| describe('Edge cases and boundary conditions', function () { | ||
| it('should have exactly 14 granular permissions defined', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
| const permissionCount = Object.keys( | ||
| definitions.granularPermissions, | ||
| ).length | ||
|
|
||
| expect(permissionCount).toBe(14) | ||
| }) | ||
|
|
||
| it('should have no granular permissions with value <= UINT16_MAX', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
| const UINT16_MAX = 65536 | ||
|
|
||
| Object.entries(definitions.granularPermissions).forEach( | ||
| ([_name, value]) => { | ||
| expect(value).toBeGreaterThan(UINT16_MAX) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| it('should have granular permissions starting at 65537 (UINT16_MAX + 1)', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
| const UINT16_MAX_PLUS_ONE = 65537 | ||
|
|
||
| const allValues = Object.values(definitions.granularPermissions) | ||
| const minValue = Math.min(...allValues) | ||
|
|
||
| expect(minValue).toBe(UINT16_MAX_PLUS_ONE) | ||
| }) | ||
|
|
||
| it('should have SponsorFee value exactly one less than SponsorReserve', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
|
|
||
| const sponsorFee = definitions.granularPermissions.SponsorFee | ||
| const sponsorReserve = definitions.granularPermissions.SponsorReserve | ||
|
|
||
| expect(sponsorReserve - sponsorFee).toBe(1) | ||
| }) | ||
|
|
||
| it('should have unique values for all granular permissions', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
|
|
||
| const allValues = Object.values(definitions.granularPermissions) | ||
| const uniqueValues = new Set(allValues) | ||
|
|
||
| expect(uniqueValues.size).toBe(allValues.length) | ||
| }) | ||
|
|
||
| it('should have consecutive values for all granular permissions', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
|
|
||
| const allValues = Object.values(definitions.granularPermissions).sort( | ||
| (a, b) => a - b, | ||
| ) | ||
|
|
||
| for (let i = 1; i < allValues.length; i++) { | ||
| expect(allValues[i] - allValues[i - 1]).toBe(1) | ||
| } | ||
| }) | ||
|
|
||
| it('should not allow undefined permission names to be accessed', function () { | ||
| const definitions = new XrplDefinitions(normalDefinitionsJson) | ||
|
|
||
| // Accessing an undefined permission should return undefined | ||
| expect( | ||
| definitions.granularPermissions['NonExistentPermission'], | ||
| ).toBeUndefined() | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: XRPLF/xrpl.js
Length of output: 400
🌐 Web query:
rippled transaction type codes SponsorshipSet SponsorshipTransfer💡 Result:
In XRPL’s
rippled(mainnet/mainline) there are no TransactionType entries namedSponsorshipSetorSponsorshipTransfer, so there are no corresponding UInt16 “transaction type codes” for them in the canonicalTxTypeenum / transaction-type identifiers list. The publishedTxTypeidentifiers cover types likettPAYMENT,ttACCOUNT_SET,ttTRUST_SET, etc., but not those sponsorship names. [1]If you’re trying to get the numeric transaction type code (UInt16) for any TransactionType name on a given network/build, the authoritative way is to query the server’s definitions and read the
TRANSACTION_TYPESmap (string → UInt16). [2]server_definitionsresult.TRANSACTION_TYPES.SponsorshipSetandresult.TRANSACTION_TYPES.SponsorshipTransferRelated note: in proposed “sponsorship” designs for XRPL, sponsorship is described as behavior attached to an existing
Paymentvia a flag (e.g.,tfSponsor), not as newSponsorshipSet/SponsorshipTransfertransaction types. [3]Sources
[1] rippled
TxType(transaction type identifiers / enum list) https://thejohnfreeman.github.io/rippled/namespaceripple.html[2] XRPL Binary Format docs (definitions file +
TRANSACTION_TYPES+server_definitions) https://xrpl.org/docs/references/protocol/binary-format[3] XRPL Standards discussion (sponsorship via
ttPAYMENT+tfSponsor) XRPLF/XRPL-Standards#56Remove
SponsorshipSetandSponsorshipTransferfrom TRANSACTION_TYPES—they do not exist in rippled.These transaction types are not defined in rippled's
TxTypeenum. Sponsorship in XRPL is implemented via a flag (tfSponsor) onPaymenttransactions, not as separate transaction types. Including codes 85 and 86 for non-existent types creates incorrect serialization mapping and will cause deserialization failures against actual rippled nodes.🤖 Prompt for AI Agents