Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
6028c5e
enable PermissionDelegation in rippled.cfg
khancode May 8, 2025
349ca16
update HISTORY
khancode May 8, 2025
5bcf9ae
add Delegate to BaseTransaction
khancode May 8, 2025
7090b5e
update definitions
khancode May 9, 2025
1f09c81
add DelegateSet tx
khancode May 9, 2025
0b139a2
fix lint error
khancode May 9, 2025
1486f79
add Delegate ledger entry
khancode May 9, 2025
f5c4c30
add initial integ test
khancode May 9, 2025
e272712
clean up test
khancode May 9, 2025
84c6183
catch error in test
khancode May 9, 2025
1385305
debug test
khancode May 9, 2025
bf2c13c
debug again
khancode May 9, 2025
dd40b5b
add missing disable lint desc
khancode May 9, 2025
2a737b6
debug 3x
khancode May 9, 2025
e5c6e8b
remove debug lines
khancode May 9, 2025
0d467d0
add base case to integ test
khancode May 9, 2025
9370c3e
update base case
khancode May 9, 2025
4fa69e0
fix Permissions array type
khancode May 10, 2025
0e9b50e
add log
khancode May 10, 2025
de5e896
another log
khancode May 10, 2025
610c5dc
more logs
khancode May 12, 2025
f5b8e18
logs
khancode May 12, 2025
480e744
logs
khancode May 12, 2025
985bbf6
logs
khancode May 12, 2025
d7e77f7
debug test
khancode May 12, 2025
cb633fa
more logs
khancode May 12, 2025
53730c4
progress
khancode May 12, 2025
085883e
update STObject.toJSON
khancode May 12, 2025
6f6f1d9
remove empty array check
khancode May 12, 2025
5c5ace3
add granularPermissions to XrplDefinitionsBase
khancode May 12, 2025
358f3f0
fix conditional
khancode May 12, 2025
59f7ce0
add conditional in toJSON
khancode May 12, 2025
1ca4359
parse as hex
khancode May 12, 2025
1c30b61
remove logs
khancode May 12, 2025
e16175e
debug tx not found error
khancode May 12, 2025
b917e5a
include -1
khancode May 12, 2025
7838bfd
uncomment line in integ test
khancode May 12, 2025
0c20d16
debug tx not found
khancode May 12, 2025
32a33dd
update integ test
khancode May 12, 2025
6336f58
add log
khancode May 12, 2025
2173298
add missing .toJSON
khancode May 12, 2025
8609aa6
fix increment/decrement to only apply to non-granular permissions
khancode May 12, 2025
7ab6ab6
test delegate ledger entry
khancode May 12, 2025
57d6c59
fix ledger entry request
khancode May 12, 2025
3920c2f
add codec-fixture
khancode May 12, 2025
f4c461d
refactor binary-codec parsing
khancode May 13, 2025
8419546
cleanup
khancode May 13, 2025
1aaa2f0
add non-delegatable transaction check
khancode May 13, 2025
fc0a0ac
update HISTORY
khancode May 13, 2025
41c9f8a
refactor permissionsSet
khancode May 13, 2025
d94402e
cleanup
khancode May 13, 2025
f9dc69e
cleanup
khancode May 13, 2025
5f2d0f1
use Permission interface in Delegate
khancode May 13, 2025
55287b0
use testContext.wallet
khancode May 13, 2025
e82f4af
refactor Permissions array check
khancode May 13, 2025
8d7262a
include non-delegatable transaction in error message
khancode May 13, 2025
1d1a52d
revert st-object.ts, do PermissionValue serialization using associate…
khancode May 14, 2025
ffdba86
add debug logs
khancode May 14, 2025
65de459
verify DelegateSet tx submit works in integ test
khancode May 14, 2025
e0757a1
comment another test
khancode May 14, 2025
631e5f5
resolve lint error
khancode May 14, 2025
272601c
change ordinal width to 4
khancode May 14, 2025
7a1584f
add comments to width vars
khancode May 15, 2025
90f50c6
verify ledger data in integ test
khancode May 15, 2025
50679d3
add missing comment
khancode May 20, 2025
6e91c7e
remove ledger_data check
khancode May 20, 2025
5cc9427
remove unused imports
khancode May 20, 2025
d4af57d
test error
khancode May 20, 2025
760ac8b
refactor testTransaction to accept expected errCode
khancode May 20, 2025
e1e5706
improve errCode param check
khancode May 20, 2025
2f1f6a2
try another errCode check
khancode May 20, 2025
faea446
Merge branch 'main' into permission-delegation
khancode May 20, 2025
a192433
refactor test
khancode May 20, 2025
e85825b
Revert "refactor test"
khancode May 20, 2025
1d80561
remove redundant no permission check
khancode May 20, 2025
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
1 change: 1 addition & 0 deletions .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ fixReducedOffersV2
DeepFreeze
DynamicNFT
PermissionedDomains
PermissionDelegation

# This section can be used to simulate various FeeSettings scenarios for rippled node in standalone mode
[voting]
Expand Down
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

### Added
* Support for `Account Permissions` and `Account Permission Delegation` (XLS-74d, XLS-75d)

### Fixed
* add `MPTCurrency` support in `Issue` (rippled internal type)
* Throw an error during serialization if a field is unknown, rather than silently throwing it away.
Expand Down
9 changes: 5 additions & 4 deletions packages/ripple-binary-codec/src/enums/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const TYPE_WIDTH = 2
export const LEDGER_ENTRY_WIDTH = 2
export const TRANSACTION_TYPE_WIDTH = 2
export const TRANSACTION_RESULT_WIDTH = 1
export const TYPE_WIDTH = 2 // UInt16
export const LEDGER_ENTRY_WIDTH = 2 // UInt16
export const TRANSACTION_TYPE_WIDTH = 2 // UInt16
export const TRANSACTION_RESULT_WIDTH = 1 // UInt8
export const DELEGATABLE_PERMISSIONS_WIDTH = 4 // UInt32
42 changes: 42 additions & 0 deletions packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,16 @@
"type": "UInt32"
}
],
[
"PermissionValue",
{
"isSerialized": true,
"isSigningField": true,
"isVLEncoded": false,
"nth": 52,
"type": "UInt32"
}
],
[
"IndexNext",
{
Expand Down Expand Up @@ -1950,6 +1960,16 @@
"type": "AccountID"
}
],
[
"Delegate",
{
"isSerialized": true,
"isSigningField": true,
"isVLEncoded": true,
"nth": 12,
"type": "AccountID"
}
],
[
"HookAccount",
{
Expand Down Expand Up @@ -2170,6 +2190,16 @@
"type": "STObject"
}
],
[
"Permission",
{
"isSerialized": true,
"isSigningField": true,
"isVLEncoded": false,
"nth": 15,
"type": "STObject"
}
],
[
"Signer",
{
Expand Down Expand Up @@ -2560,6 +2590,16 @@
"type": "STArray"
}
],
[
"Permissions",
{
"isSerialized": true,
"isSigningField": true,
"isVLEncoded": false,
"nth": 29,
"type": "STArray"
}
],
[
"CloseResolution",
{
Expand Down Expand Up @@ -2879,6 +2919,7 @@
"Check": 67,
"Credential": 129,
"DID": 73,
"Delegate": 131,
"DepositPreauth": 112,
"DirectoryNode": 100,
"Escrow": 117,
Expand Down Expand Up @@ -3107,6 +3148,7 @@
"CredentialDelete": 60,
"DIDDelete": 50,
"DIDSet": 49,
"DelegateSet": 64,
"DepositPreauth": 19,
"EnableAmendment": 100,
"EscrowCancel": 4,
Expand Down
36 changes: 36 additions & 0 deletions packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
LEDGER_ENTRY_WIDTH,
TRANSACTION_TYPE_WIDTH,
TRANSACTION_RESULT_WIDTH,
DELEGATABLE_PERMISSIONS_WIDTH,
} from './constants'

interface DefinitionsData {
Expand Down Expand Up @@ -35,6 +36,10 @@ class XrplDefinitionsBase {
transactionNames: string[]
// Maps serializable types to their TypeScript class implementation
dataTypes: Record<string, typeof SerializedType>
// Maps granular permissions names to their corresponding integer ids
granularPermissions: Record<string, number>
// Defined delegatable permissions
delegatablePermissions: BytesLookup

/**
* Present rippled types in a typed and updatable format.
Expand Down Expand Up @@ -75,6 +80,36 @@ class XrplDefinitionsBase {

this.dataTypes = {} // Filled in via associateTypes
this.associateTypes(types)

this.granularPermissions = {
TrustlineAuthorize: 65537,
TrustlineFreeze: 65538,
TrustlineUnfreeze: 65539,
AccountDomainSet: 65540,
AccountEmailHashSet: 65541,
AccountMessageKeySet: 65542,
AccountTransferRateSet: 65543,
AccountTickSizeSet: 65544,
PaymentMint: 65545,
PaymentBurn: 65546,
MPTokenIssuanceLock: 65547,
MPTokenIssuanceUnlock: 65548,
}

const incrementedTransactionTypes = Object.fromEntries(
Object.entries(enums.TRANSACTION_TYPES).map(([key, value]) => [
key,
value + 1,
]),
)
const combinedPermissions = {
...this.granularPermissions,
...incrementedTransactionTypes,
}
this.delegatablePermissions = new BytesLookup(
combinedPermissions,
DELEGATABLE_PERMISSIONS_WIDTH,
)
}

/**
Expand All @@ -94,6 +129,7 @@ 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
}

public getAssociatedTypes(): Record<string, typeof SerializedType> {
Expand Down
26 changes: 26 additions & 0 deletions packages/ripple-binary-codec/test/fixtures/codec-fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -4891,6 +4891,32 @@
"AssetClass": "63757272656E6379"
}
},
{
"binary": "120040210000F7E0228000000024000009186840000000000000C87321ED510865F867CDFCB944D435812ACF23D231E5C14534B146BCE46A2F794D198B777440D05A89D0B489DEC1CECBE0D33BA656C929CDCCC75D4D41B282B378544975B87A70C3E42147D980D1F6E2E4DC6316C99D7E2D4F6335F147C71C0DAA0D6516150D8114DB9157872FA63FAF7432CD300911A43B981B85A28514EBA79C385B47C50D52445DF2676EEC0231F732CEF01DEF203400000001E1EF203400010004E1F1",
"json": {
"TransactionType": "DelegateSet",
"Account": "rMryaYXZMchTWBovAzEsMzid9FUwmrmcH7",
"Authorize": "r4Vp2qvKR59guHDn4Yzw9owTzDVnt6TJZA",
"Fee": "200",
"Flags": 2147483648,
"NetworkID": 63456,
"Permissions": [
{
"Permission": {
"PermissionValue": "Payment"
}
},
{
"Permission": {
"PermissionValue": "AccountDomainSet"
}
}
],
"Sequence": 2328,
"SigningPubKey": "ED510865F867CDFCB944D435812ACF23D231E5C14534B146BCE46A2F794D198B77",
"TxnSignature": "D05A89D0B489DEC1CECBE0D33BA656C929CDCCC75D4D41B282B378544975B87A70C3E42147D980D1F6E2E4DC6316C99D7E2D4F6335F147C71C0DAA0D6516150D"
}
},
{
"binary": "1200342033000004D2811401476926B590BA3245F63C829116A0A3AF7F382D",
"json": {
Expand Down
1 change: 1 addition & 0 deletions packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr

### Added
* Support for `NFTokenMintOffer` (XLS-52)
* Support for `Account Permissions` and `Account Permission Delegation` (XLS-74d, XLS-75d)

### Fixed
* `OracleSet` transaction accepts hexadecimal string values for `AssetPrice` field
Expand Down
39 changes: 39 additions & 0 deletions packages/xrpl/src/models/ledger/Delegate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Permission } from '../transactions'

import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'

/**
* This object represents a set of permissions that an account has delegated to another account.
*
* @category Ledger Entries
*/
export default interface Delegate extends BaseLedgerEntry, HasPreviousTxnID {
LedgerEntryType: 'Delegate'

/**
* The account that wants to authorize another account.
*/
Account: string

/**
* The authorized account.
*/
Authorize: string

/**
* The transaction permissions that the account has access to.
*/
Permissions: Permission[]

/**
* A hint indicating which page of the sender's owner directory links to this object,
* in case the directory consists of multiple pages.
*/
OwnerNode: string

/**
* A bit-map of boolean flags. No flags are defined for the Delegate object
* type, so this value is always 0.
*/
Flags: 0
}
3 changes: 3 additions & 0 deletions packages/xrpl/src/models/ledger/LedgerEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AMM from './AMM'
import Bridge from './Bridge'
import Check from './Check'
import Credential from './Credential'
import Delegate from './Delegate'
import DepositPreauth from './DepositPreauth'
import DirectoryNode from './DirectoryNode'
import Escrow from './Escrow'
Expand All @@ -27,6 +28,7 @@ type LedgerEntry =
| Bridge
| Check
| Credential
| Delegate
| DepositPreauth
| DirectoryNode
| Escrow
Expand All @@ -50,6 +52,7 @@ type LedgerEntryFilter =
| 'bridge'
| 'check'
| 'credential'
| 'delegate'
| 'deposit_preauth'
| 'did'
| 'directory'
Expand Down
2 changes: 2 additions & 0 deletions packages/xrpl/src/models/ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import AMM, { VoteSlot } from './AMM'
import Bridge from './Bridge'
import Check from './Check'
import Credential from './Credential'
import Delegate from './Delegate'
import DepositPreauth from './DepositPreauth'
import DID from './DID'
import DirectoryNode from './DirectoryNode'
Expand Down Expand Up @@ -43,6 +44,7 @@ export {
Bridge,
Check,
Credential,
Delegate,
DepositPreauth,
DirectoryNode,
DID,
Expand Down
5 changes: 5 additions & 0 deletions packages/xrpl/src/models/methods/ledgerEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
xchain_owned_create_account_claim_id: string | number
}
| string

delegate?: {
account: string
authorize: string
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/xrpl/src/models/transactions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ export interface BaseTransaction {
* The network id of the transaction.
*/
NetworkID?: number
/**
* The delegate account that is sending the transaction.
*/
Delegate?: Account
}

/**
Expand All @@ -347,6 +351,7 @@ export interface BaseTransaction {
* @param common - An interface w/ common transaction fields.
* @throws When the common param is malformed.
*/
// eslint-disable-next-line max-statements -- lines required for validation
export function validateBaseTransaction(common: Record<string, unknown>): void {
if (common.TransactionType === undefined) {
throw new ValidationError('BaseTransaction: missing field TransactionType')
Expand Down Expand Up @@ -395,6 +400,15 @@ export function validateBaseTransaction(common: Record<string, unknown>): void {
validateOptionalField(common, 'TxnSignature', isString)

validateOptionalField(common, 'NetworkID', isNumber)

validateOptionalField(common, 'Delegate', isAccount)

const delegate = common.Delegate
if (delegate != null && delegate === common.Account) {
throw new ValidationError(
'BaseTransaction: Account and Delegate addresses cannot be the same',
)
}
}

/**
Expand Down
Loading
Loading