Skip to content
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

XLS80d PermissionedDomains #2834

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,15 @@ PriceOracle
fixEmptyDID
fixXChainRewardRounding
fixPreviousTxnID
fixAMMv1_1
Credentials
NFTokenMintOffer
fixNFTokenPageLinks
fixInnerObjTemplate2
fixEnforceNFTokenTrustline
fixReducedOffersV2
InvariantsV1_1
MPTokensV1
AMMv1_2
AMMClawback
PermissionedDomains
109 changes: 108 additions & 1 deletion packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"AMM": 121,
"DID": 73,
"Oracle": 128,
"Credential": 129,
"PermissionedDomain": 130,
"Any": -3,
"Child": -2,
"Nickname": 110,
Expand Down Expand Up @@ -1070,6 +1072,26 @@
"type": "UInt64"
}
],
[
"IssuerNode",
{
"nth": 27,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"SubjectNode",
{
"nth": 28,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"EmailHash",
{
Expand Down Expand Up @@ -1430,6 +1452,16 @@
"type": "Hash256"
}
],
[
"DomainID",
{
"nth": 34,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Hash256"
}
],
[
"Amount",
{
Expand Down Expand Up @@ -1980,6 +2012,16 @@
"type": "Blob"
}
],
[
"CredentialType",
{
"nth": 31,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Blob"
}
],
[
"Account",
{
Expand Down Expand Up @@ -2140,6 +2182,16 @@
"type": "AccountID"
}
],
[
"Subject",
{
"nth": 24,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"Indexes",
{
Expand Down Expand Up @@ -2180,6 +2232,16 @@
"type": "Vector256"
}
],
[
"CredentialIDs",
{
"nth": 5,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Vector256"
}
],
[
"Paths",
{
Expand Down Expand Up @@ -2550,6 +2612,16 @@
"type": "STObject"
}
],
[
"Credential",
{
"nth": 33,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"Signers",
{
Expand Down Expand Up @@ -2739,6 +2811,35 @@
"isSigningField": true,
"type": "STArray"
}
],
[
"AuthorizeCredentials",
{
"nth": 26,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"UnauthorizeCredentials",
{
"nth": 27,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"AcceptedCredentials", {
"nth": 28,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
]
],
"TRANSACTION_RESULTS": {
Expand Down Expand Up @@ -2923,7 +3024,8 @@
"tecINVALID_UPDATE_TIME": 188,
"tecTOKEN_PAIR_NOT_FOUND": 189,
"tecARRAY_EMPTY": 190,
"tecARRAY_TOO_LARGE": 191
"tecARRAY_TOO_LARGE": 191,
"tecBAD_CREDENTIALS": 193
},
"TRANSACTION_TYPES": {
"Invalid": -1,
Expand Down Expand Up @@ -2974,6 +3076,11 @@
"DIDDelete": 50,
"OracleSet": 51,
"OracleDelete": 52,
"CredentialCreate": 58,
"CredentialAccept": 59,
"CredentialDelete": 60,
"PermissionedDomainSet": 61,
"PermissionedDomainDelete": 62,
"EnableAmendment": 100,
"SetFee": 101,
"UNLModify": 102
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
* parseTransactionFlags as a utility function in the xrpl package to streamline transactions flags-to-map conversion
* Implementation of XLS-80d PermissionedDomain feature.

### Fixed
* `TransactionStream` model supports APIv2
Expand Down
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 @@ -12,6 +12,7 @@ import NegativeUNL from './NegativeUNL'
import Offer from './Offer'
import Oracle from './Oracle'
import PayChannel from './PayChannel'
import PermissionedDomain from './PermissionedDomain'
import RippleState from './RippleState'
import SignerList from './SignerList'
import Ticket from './Ticket'
Expand All @@ -33,6 +34,7 @@ type LedgerEntry =
| Offer
| Oracle
| PayChannel
| PermissionedDomain
| RippleState
| SignerList
| Ticket
Expand All @@ -56,6 +58,7 @@ type LedgerEntryFilter =
| 'offer'
| 'oracle'
| 'payment_channel'
| 'permissioned_domain'
| 'signer_list'
| 'state'
| 'ticket'
Expand Down
23 changes: 23 additions & 0 deletions packages/xrpl/src/models/ledger/PermissionedDomain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'

// Keshava TODO: After the merge of VerifiableCredentials feature, import this interface
export interface Credential {
Credential : {
Issuer: string
CredentialType: string
}
}

export default interface PermissionedDomain extends BaseLedgerEntry, HasPreviousTxnID {
LedgerEntryType: 'PermissionedDomain'

Owner: string

Flags: 0

OwnerNode: string

Sequence: number

AcceptedCredentials: Credential[]
}
3 changes: 3 additions & 0 deletions packages/xrpl/src/models/transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ export {
XChainModifyBridgeFlags,
XChainModifyBridgeFlagsInterface,
} from './XChainModifyBridge'

export {PermissionedDomainSet} from './permissionedDomainSet'
export {PermissionedDomainDelete} from './permissionedDomainDelete'
18 changes: 18 additions & 0 deletions packages/xrpl/src/models/transactions/permissionedDomainDelete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
BaseTransaction,
isString,
validateBaseTransaction,
validateRequiredField
} from './common'

export interface PermissionedDomainDelete extends BaseTransaction {
TransactionType: 'PermissionedDomainDelete'

DomainID: string
}

export function validatePermissionedDomainDelete(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)

validateRequiredField(tx, 'DomainID', isString)
}
49 changes: 49 additions & 0 deletions packages/xrpl/src/models/transactions/permissionedDomainSet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ValidationError } from '../../errors'

import {
BaseTransaction,
isString,
validateBaseTransaction,
validateOptionalField,
validateRequiredField,
} from './common'

import {Credential} from '../ledger/PermissionedDomain'

const ACCEPTED_CREDENTIALS_MAX_LENGTH = 10

export interface PermissionedDomainSet extends BaseTransaction {
TransactionType: 'PermissionedDomainSet'

DomainID?: string
AcceptedCredentials: Credential[]
}

// eslint-disable-next-line max-lines-per-function -- necessary to validate many fields
export function validatePermissionedDomainSet(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)

validateOptionalField(tx, 'DomainID', isString)

// eslint-disable-next-line max-lines-per-function -- necessary to validate many fields
validateRequiredField(tx, 'AcceptedCredentials', (value) => {
if (!Array.isArray(value)) {
throw new ValidationError('PermissionedDomainSet: AcceptedCredentials must be an array')
}

if (value.length > ACCEPTED_CREDENTIALS_MAX_LENGTH) {
throw new ValidationError(
`PermissionedDomainSet: AcceptedCredentials must have at most ${ACCEPTED_CREDENTIALS_MAX_LENGTH} Credential objects`,
)
}
else if (value.length == 0) {
throw new ValidationError(
`PermissionedDomainSet: AcceptedCredentials must have at least one Credential object`,
)
}

// Note: This implementation does not rigorously validate the inner-object format of AcceptedCredentials array because that would be a blatant repetition of the rippled cpp implementation.

return true
})
}
12 changes: 12 additions & 0 deletions packages/xrpl/src/models/transactions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import {
PaymentChannelFund,
validatePaymentChannelFund,
} from './paymentChannelFund'
import { PermissionedDomainDelete, validatePermissionedDomainDelete } from './permissionedDomainDelete'
import { PermissionedDomainSet, validatePermissionedDomainSet } from './permissionedDomainSet'
import { SetFee } from './setFee'
import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
import { SignerListSet, validateSignerListSet } from './signerListSet'
Expand Down Expand Up @@ -128,6 +130,8 @@ export type SubmittableTransaction =
| PaymentChannelClaim
| PaymentChannelCreate
| PaymentChannelFund
| PermissionedDomainSet
| PermissionedDomainDelete
| SetRegularKey
| SignerListSet
| TicketCreate
Expand Down Expand Up @@ -358,6 +362,14 @@ export function validate(transaction: Record<string, unknown>): void {
validatePaymentChannelFund(tx)
break

case 'PermissionedDomainSet':
validatePermissionedDomainSet(tx)
break

case 'PermissionedDomainDelete':
validatePermissionedDomainDelete(tx)
break

case 'SetRegularKey':
validateSetRegularKey(tx)
break
Expand Down
Loading
Loading