Skip to content

Commit 776a7e6

Browse files
authored
Merge branch 'main' into model-test-cleanup
2 parents 4d199e1 + 6aaf4d6 commit 776a7e6

File tree

19 files changed

+559
-4
lines changed

19 files changed

+559
-4
lines changed

.ci-config/rippled.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ fixReducedOffersV2
184184
DeepFreeze
185185
DynamicNFT
186186
PermissionedDomains
187+
PermissionDelegation
187188

188189
# This section can be used to simulate various FeeSettings scenarios for rippled node in standalone mode
189190
[voting]

packages/ripple-binary-codec/HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Added
6+
* Support for `Account Permissions` and `Account Permission Delegation` (XLS-74d, XLS-75d)
7+
58
### Fixed
69
* add `MPTCurrency` support in `Issue` (rippled internal type)
710
* Throw an error during serialization if a field is unknown, rather than silently throwing it away.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export const TYPE_WIDTH = 2
2-
export const LEDGER_ENTRY_WIDTH = 2
3-
export const TRANSACTION_TYPE_WIDTH = 2
4-
export const TRANSACTION_RESULT_WIDTH = 1
1+
export const TYPE_WIDTH = 2 // UInt16
2+
export const LEDGER_ENTRY_WIDTH = 2 // UInt16
3+
export const TRANSACTION_TYPE_WIDTH = 2 // UInt16
4+
export const TRANSACTION_RESULT_WIDTH = 1 // UInt8
5+
export const DELEGATABLE_PERMISSIONS_WIDTH = 4 // UInt32

packages/ripple-binary-codec/src/enums/definitions.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,16 @@
670670
"type": "UInt32"
671671
}
672672
],
673+
[
674+
"PermissionValue",
675+
{
676+
"isSerialized": true,
677+
"isSigningField": true,
678+
"isVLEncoded": false,
679+
"nth": 52,
680+
"type": "UInt32"
681+
}
682+
],
673683
[
674684
"IndexNext",
675685
{
@@ -1950,6 +1960,16 @@
19501960
"type": "AccountID"
19511961
}
19521962
],
1963+
[
1964+
"Delegate",
1965+
{
1966+
"isSerialized": true,
1967+
"isSigningField": true,
1968+
"isVLEncoded": true,
1969+
"nth": 12,
1970+
"type": "AccountID"
1971+
}
1972+
],
19531973
[
19541974
"HookAccount",
19551975
{
@@ -2170,6 +2190,16 @@
21702190
"type": "STObject"
21712191
}
21722192
],
2193+
[
2194+
"Permission",
2195+
{
2196+
"isSerialized": true,
2197+
"isSigningField": true,
2198+
"isVLEncoded": false,
2199+
"nth": 15,
2200+
"type": "STObject"
2201+
}
2202+
],
21732203
[
21742204
"Signer",
21752205
{
@@ -2560,6 +2590,16 @@
25602590
"type": "STArray"
25612591
}
25622592
],
2593+
[
2594+
"Permissions",
2595+
{
2596+
"isSerialized": true,
2597+
"isSigningField": true,
2598+
"isVLEncoded": false,
2599+
"nth": 29,
2600+
"type": "STArray"
2601+
}
2602+
],
25632603
[
25642604
"CloseResolution",
25652605
{
@@ -2879,6 +2919,7 @@
28792919
"Check": 67,
28802920
"Credential": 129,
28812921
"DID": 73,
2922+
"Delegate": 131,
28822923
"DepositPreauth": 112,
28832924
"DirectoryNode": 100,
28842925
"Escrow": 117,
@@ -3107,6 +3148,7 @@
31073148
"CredentialDelete": 60,
31083149
"DIDDelete": 50,
31093150
"DIDSet": 49,
3151+
"DelegateSet": 64,
31103152
"DepositPreauth": 19,
31113153
"EnableAmendment": 100,
31123154
"EscrowCancel": 4,

packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
LEDGER_ENTRY_WIDTH,
77
TRANSACTION_TYPE_WIDTH,
88
TRANSACTION_RESULT_WIDTH,
9+
DELEGATABLE_PERMISSIONS_WIDTH,
910
} from './constants'
1011

1112
interface DefinitionsData {
@@ -35,6 +36,10 @@ class XrplDefinitionsBase {
3536
transactionNames: string[]
3637
// Maps serializable types to their TypeScript class implementation
3738
dataTypes: Record<string, typeof SerializedType>
39+
// Maps granular permissions names to their corresponding integer ids
40+
granularPermissions: Record<string, number>
41+
// Defined delegatable permissions
42+
delegatablePermissions: BytesLookup
3843

3944
/**
4045
* Present rippled types in a typed and updatable format.
@@ -75,6 +80,36 @@ class XrplDefinitionsBase {
7580

7681
this.dataTypes = {} // Filled in via associateTypes
7782
this.associateTypes(types)
83+
84+
this.granularPermissions = {
85+
TrustlineAuthorize: 65537,
86+
TrustlineFreeze: 65538,
87+
TrustlineUnfreeze: 65539,
88+
AccountDomainSet: 65540,
89+
AccountEmailHashSet: 65541,
90+
AccountMessageKeySet: 65542,
91+
AccountTransferRateSet: 65543,
92+
AccountTickSizeSet: 65544,
93+
PaymentMint: 65545,
94+
PaymentBurn: 65546,
95+
MPTokenIssuanceLock: 65547,
96+
MPTokenIssuanceUnlock: 65548,
97+
}
98+
99+
const incrementedTransactionTypes = Object.fromEntries(
100+
Object.entries(enums.TRANSACTION_TYPES).map(([key, value]) => [
101+
key,
102+
value + 1,
103+
]),
104+
)
105+
const combinedPermissions = {
106+
...this.granularPermissions,
107+
...incrementedTransactionTypes,
108+
}
109+
this.delegatablePermissions = new BytesLookup(
110+
combinedPermissions,
111+
DELEGATABLE_PERMISSIONS_WIDTH,
112+
)
78113
}
79114

80115
/**
@@ -94,6 +129,7 @@ class XrplDefinitionsBase {
94129
this.field['TransactionType'].associatedType = this.transactionType
95130
this.field['TransactionResult'].associatedType = this.transactionResult
96131
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType
132+
this.field['PermissionValue'].associatedType = this.delegatablePermissions
97133
}
98134

99135
public getAssociatedTypes(): Record<string, typeof SerializedType> {

packages/ripple-binary-codec/test/fixtures/codec-fixtures.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4891,6 +4891,32 @@
48914891
"AssetClass": "63757272656E6379"
48924892
}
48934893
},
4894+
{
4895+
"binary": "120040210000F7E0228000000024000009186840000000000000C87321ED510865F867CDFCB944D435812ACF23D231E5C14534B146BCE46A2F794D198B777440D05A89D0B489DEC1CECBE0D33BA656C929CDCCC75D4D41B282B378544975B87A70C3E42147D980D1F6E2E4DC6316C99D7E2D4F6335F147C71C0DAA0D6516150D8114DB9157872FA63FAF7432CD300911A43B981B85A28514EBA79C385B47C50D52445DF2676EEC0231F732CEF01DEF203400000001E1EF203400010004E1F1",
4896+
"json": {
4897+
"TransactionType": "DelegateSet",
4898+
"Account": "rMryaYXZMchTWBovAzEsMzid9FUwmrmcH7",
4899+
"Authorize": "r4Vp2qvKR59guHDn4Yzw9owTzDVnt6TJZA",
4900+
"Fee": "200",
4901+
"Flags": 2147483648,
4902+
"NetworkID": 63456,
4903+
"Permissions": [
4904+
{
4905+
"Permission": {
4906+
"PermissionValue": "Payment"
4907+
}
4908+
},
4909+
{
4910+
"Permission": {
4911+
"PermissionValue": "AccountDomainSet"
4912+
}
4913+
}
4914+
],
4915+
"Sequence": 2328,
4916+
"SigningPubKey": "ED510865F867CDFCB944D435812ACF23D231E5C14534B146BCE46A2F794D198B77",
4917+
"TxnSignature": "D05A89D0B489DEC1CECBE0D33BA656C929CDCCC75D4D41B282B378544975B87A70C3E42147D980D1F6E2E4DC6316C99D7E2D4F6335F147C71C0DAA0D6516150D"
4918+
}
4919+
},
48944920
{
48954921
"binary": "1200342033000004D2811401476926B590BA3245F63C829116A0A3AF7F382D",
48964922
"json": {

packages/xrpl/HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
66

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

1011
### Fixed
1112
* `OracleSet` transaction accepts hexadecimal string values for `AssetPrice` field
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Permission } from '../transactions'
2+
3+
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
4+
5+
/**
6+
* This object represents a set of permissions that an account has delegated to another account.
7+
*
8+
* @category Ledger Entries
9+
*/
10+
export default interface Delegate extends BaseLedgerEntry, HasPreviousTxnID {
11+
LedgerEntryType: 'Delegate'
12+
13+
/**
14+
* The account that wants to authorize another account.
15+
*/
16+
Account: string
17+
18+
/**
19+
* The authorized account.
20+
*/
21+
Authorize: string
22+
23+
/**
24+
* The transaction permissions that the account has access to.
25+
*/
26+
Permissions: Permission[]
27+
28+
/**
29+
* A hint indicating which page of the sender's owner directory links to this object,
30+
* in case the directory consists of multiple pages.
31+
*/
32+
OwnerNode: string
33+
34+
/**
35+
* A bit-map of boolean flags. No flags are defined for the Delegate object
36+
* type, so this value is always 0.
37+
*/
38+
Flags: 0
39+
}

packages/xrpl/src/models/ledger/LedgerEntry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AMM from './AMM'
44
import Bridge from './Bridge'
55
import Check from './Check'
66
import Credential from './Credential'
7+
import Delegate from './Delegate'
78
import DepositPreauth from './DepositPreauth'
89
import DirectoryNode from './DirectoryNode'
910
import Escrow from './Escrow'
@@ -27,6 +28,7 @@ type LedgerEntry =
2728
| Bridge
2829
| Check
2930
| Credential
31+
| Delegate
3032
| DepositPreauth
3133
| DirectoryNode
3234
| Escrow
@@ -50,6 +52,7 @@ type LedgerEntryFilter =
5052
| 'bridge'
5153
| 'check'
5254
| 'credential'
55+
| 'delegate'
5356
| 'deposit_preauth'
5457
| 'did'
5558
| 'directory'

packages/xrpl/src/models/ledger/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import AMM, { VoteSlot } from './AMM'
77
import Bridge from './Bridge'
88
import Check from './Check'
99
import Credential from './Credential'
10+
import Delegate from './Delegate'
1011
import DepositPreauth from './DepositPreauth'
1112
import DID from './DID'
1213
import DirectoryNode from './DirectoryNode'
@@ -43,6 +44,7 @@ export {
4344
Bridge,
4445
Check,
4546
Credential,
47+
Delegate,
4648
DepositPreauth,
4749
DirectoryNode,
4850
DID,

0 commit comments

Comments
 (0)