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

feat: add support for XLS-40d + add script to auto-generate models from rippled code #2491

Merged
merged 33 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ff17552
move createValidateTests
mvadari Sep 28, 2023
c3afe4e
fix isString location
mvadari Sep 28, 2023
28cb659
write generateModels script
mvadari Sep 28, 2023
2a6a3d4
edit transaction.ts too
mvadari Sep 28, 2023
f16faa4
update binary codec
mvadari Sep 28, 2023
8a160e7
fix more model gen issues
mvadari Sep 28, 2023
a9b97e3
generate DID models
mvadari Sep 28, 2023
d5d9f30
better error handling and fix bugs
mvadari Sep 28, 2023
433a095
[WIP] cleanup
mvadari Oct 3, 2023
2020d0b
Merge branch 'main' into did
mvadari Oct 16, 2023
085d6cd
[WIP] more
mvadari Oct 18, 2023
306521b
Merge branch 'main' into did
mvadari Oct 23, 2023
a0a2738
Update definitions.json
mvadari Oct 23, 2023
4a9badc
fix test
mvadari Oct 23, 2023
8d62c6c
fix XChainModifyBridge
mvadari Oct 23, 2023
915d588
build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.51.0 to…
dependabot[bot] Oct 23, 2023
f129354
more cleanup
mvadari Oct 23, 2023
962ea67
fix rename
mvadari Oct 23, 2023
1e875bb
Merge branch 'main' into did
mvadari Oct 23, 2023
b48db6f
clean up
mvadari Oct 23, 2023
6aaaa60
update changelog
mvadari Oct 23, 2023
b5b1e14
Merge branch 'main' into did
mvadari Oct 24, 2023
b921ada
update docker version
mvadari Oct 24, 2023
8598831
add integration tests
mvadari Oct 24, 2023
65667a9
fix tests
mvadari Oct 24, 2023
5ea2a87
Merge branch 'main' into did
mvadari Oct 24, 2023
050795f
Merge branch 'main' into did
mvadari Oct 25, 2023
1d97c10
Merge branch 'main' into did
mvadari Oct 26, 2023
4869e67
Update definitions.json
mvadari Nov 8, 2023
765a99a
Merge branch 'main' into did
mvadari Nov 8, 2023
f100d78
Update definitions.json
mvadari Nov 9, 2023
97b536c
Merge branch 'main' into did
mvadari Nov 14, 2023
0d32f82
respond to comments
mvadari Nov 15, 2023
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: 2 additions & 1 deletion .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,6 @@ AMM
Clawback
fixReducedOffersV1
fixNFTokenRemint
# 2.0.0-b1 Amendments
# 2.0.0 Amendments
XChainBridge
DID
4 changes: 3 additions & 1 deletion packages/ripple-binary-codec/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# ripple-binary-codec Release History

## Unreleased
### Added
- Support for the DID amendment (XLS-40).

## 1.10.0 (2023-09-27)
### Added
- Support for the XChainBridge amendment.
- Support for the XChainBridge amendment (XLS-38).

## 1.9.0 (2023-08-24)

Expand Down
47 changes: 36 additions & 11 deletions packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"NFTokenPage": 80,
"NFTokenOffer": 55,
"AMM": 121,
"DID": 73,
"Any": -3,
"Child": -2,
"Nickname": 110,
Expand Down Expand Up @@ -140,40 +141,40 @@
[
"LedgerEntry",
{
"nth": 1,
"nth": 257,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did these fields change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing discrepancies between the server_definitions RPC and the xrpl-codec-gen script. Tests all pass because these fields aren't used for signing, they only exist for rippled technical reasons.

"isVLEncoded": false,
"isSerialized": false,
"isSigningField": true,
"isSigningField": false,
"type": "LedgerEntry"
}
],
[
"Transaction",
{
"nth": 1,
"nth": 257,
"isVLEncoded": false,
"isSerialized": false,
"isSigningField": true,
"isSigningField": false,
"type": "Transaction"
}
],
[
"Validation",
{
"nth": 1,
"nth": 257,
"isVLEncoded": false,
"isSerialized": false,
"isSigningField": true,
"isSigningField": false,
"type": "Validation"
}
],
[
"Metadata",
{
"nth": 1,
"nth": 257,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"isSerialized": false,
"isSigningField": false,
"type": "Metadata"
}
],
Expand Down Expand Up @@ -1897,6 +1898,26 @@
"type": "Blob"
}
],
[
"DIDDocument",
{
"nth": 26,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Blob"
}
],
[
"Data",
{
"nth": 27,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Blob"
}
],
[
"Account",
{
Expand Down Expand Up @@ -2681,6 +2702,7 @@
"temXCHAIN_BRIDGE_NONDOOR_OWNER": -257,
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256,
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255,
"temEMPTY_DID": -254,

"tefFAILURE": -199,
"tefALREADY": -198,
Expand Down Expand Up @@ -2759,7 +2781,7 @@
"tecKILLED": 150,
"tecHAS_OBLIGATIONS": 151,
"tecTOO_SOON": 152,
"tecHOOK_ERROR": 153,
"tecHOOK_REJECTED": 153,
"tecMAX_SEQUENCE_REACHED": 154,
"tecNO_SUITABLE_NFTOKEN_PAGE": 155,
"tecNFTOKEN_BUY_SELL_MISMATCH": 156,
Expand Down Expand Up @@ -2792,7 +2814,8 @@
"tecXCHAIN_PAYMENT_FAILED": 183,
"tecXCHAIN_SELF_COMMIT": 184,
"tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 185,
"tecXCHAIN_CREATE_ACCOUNT_DISABLED": 186
"tecXCHAIN_CREATE_ACCOUNT_DISABLED": 186,
"tecEMPTY_DID": 187
},
"TRANSACTION_TYPES": {
"Invalid": -1,
Expand Down Expand Up @@ -2839,6 +2862,8 @@
"XChainAddAccountCreateAttestation": 46,
"XChainModifyBridge": 47,
"XChainCreateBridge": 48,
"DIDSet": 49,
"DIDDelete": 50,
"EnableAmendment": 100,
"SetFee": 101,
"UNLModify": 102
Expand Down
27 changes: 27 additions & 0 deletions packages/ripple-binary-codec/test/fixtures/codec-fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -4841,6 +4841,33 @@
"SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8",
"TxnSignature": "BC2F6E76969E3747E9BDE183C97573B086212F09D5387460E6EE2F32953E85EAEB9618FBBEF077276E30E59D619FCF7C7BDCDDDD9EB94D7CE1DD5CE9246B2107"
}
},
{
"binary": "1200322280000000240000000468400000000000000A7321ED9861C4CB029C0DA737B823D7D3459A70F227958D5C0C111CC7CF947FC5A93347744071E28B12465A1B47162C22E121DF61089DCD9AAF5773704B76179E771666886C8AAD5A33A87E34CC381A7D924E3FE3645F0BF98D565DE42C81E1A7A7E7981802811401476926B590BA3245F63C829116A0A3AF7F382D",
"json": {
"Account": "rfmDuhDyLGgx94qiwf3YF8BUV5j6KSvE8",
"Fee": "10",
"Flags": 2147483648,
"Sequence": 4,
"SigningPubKey": "ED9861C4CB029C0DA737B823D7D3459A70F227958D5C0C111CC7CF947FC5A93347",
"TransactionType": "DIDDelete",
"TxnSignature": "71E28B12465A1B47162C22E121DF61089DCD9AAF5773704B76179E771666886C8AAD5A33A87E34CC381A7D924E3FE3645F0BF98D565DE42C81E1A7A7E7981802"
}
},
{
"binary": "1200312280000000240000000368400000000000000A7321ED9861C4CB029C0DA737B823D7D3459A70F227958D5C0C111CC7CF947FC5A933477440AACD31A04CAE14670FC483A1382F393AA96B49C84479B58067F049FBD772999325667A6AA2520A63756EE84F3657298815019DD56A1AECE796B08535C4009C08750B6469645F6578616D706C65701A03646F63701B06617474657374811401476926B590BA3245F63C829116A0A3AF7F382D",
"json": {
"Account": "rfmDuhDyLGgx94qiwf3YF8BUV5j6KSvE8",
"Data": "617474657374",
"DIDDocument": "646F63",
"Fee": "10",
"Flags": 2147483648,
"Sequence": 3,
"SigningPubKey": "ED9861C4CB029C0DA737B823D7D3459A70F227958D5C0C111CC7CF947FC5A93347",
"TransactionType": "DIDSet",
"TxnSignature": "AACD31A04CAE14670FC483A1382F393AA96B49C84479B58067F049FBD772999325667A6AA2520A63756EE84F3657298815019DD56A1AECE796B08535C4009C08",
"URI": "6469645F6578616D706C65"
}
}
],
"ledgerData": [{
Expand Down
2 changes: 2 additions & 0 deletions packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release.

## Unreleased
### Added
- Support for the DID amendment (XLS-40).

### Added
* Support for `server_definitions` RPC
Expand Down
1 change: 1 addition & 0 deletions packages/xrpl/src/models/ledger/LedgerEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type LedgerEntryFilter =
| 'bridge'
| 'check'
| 'deposit_preauth'
| 'did'
| 'directory'
| 'escrow'
| 'fee'
Expand Down
18 changes: 18 additions & 0 deletions packages/xrpl/src/models/transactions/DIDDelete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { BaseTransaction, validateBaseTransaction } from './common'

/**
* @category Transaction Models
*/
export interface DIDDelete extends BaseTransaction {
TransactionType: 'DIDDelete'
}

/**
* Verify the form and type of a DIDDelete at runtime.
*
* @param tx - A DIDDelete Transaction.
* @throws When the DIDDelete is malformed.
*/
export function validateDIDDelete(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
}
35 changes: 35 additions & 0 deletions packages/xrpl/src/models/transactions/DIDSet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
BaseTransaction,
isString,
validateBaseTransaction,
validateOptionalField,
} from './common'

/**
* @category Transaction Models
*/
export interface DIDSet extends BaseTransaction {
TransactionType: 'DIDSet'

Data?: string

DIDDocument?: string
mvadari marked this conversation as resolved.
Show resolved Hide resolved

URI?: string
}

/**
* Verify the form and type of a DIDSet at runtime.
*
* @param tx - A DIDSet Transaction.
* @throws When the DIDSet is malformed.
*/
export function validateDIDSet(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)

validateOptionalField(tx, 'Data', isString)

validateOptionalField(tx, 'DIDDocument', isString)

validateOptionalField(tx, 'URI', isString)
}
2 changes: 2 additions & 0 deletions packages/xrpl/src/models/transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export { CheckCancel } from './checkCancel'
export { CheckCash } from './checkCash'
export { CheckCreate } from './checkCreate'
export { Clawback } from './clawback'
export { DIDDelete } from './DIDDelete'
export { DIDSet } from './DIDSet'
export { DepositPreauth } from './depositPreauth'
export { EscrowCancel } from './escrowCancel'
export { EscrowCreate } from './escrowCreate'
Expand Down
52 changes: 32 additions & 20 deletions packages/xrpl/src/models/transactions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { CheckCreate, validateCheckCreate } from './checkCreate'
import { Clawback, validateClawback } from './clawback'
import { isIssuedCurrency } from './common'
import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
import { DIDDelete, validateDIDDelete } from './DIDDelete'
import { DIDSet, validateDIDSet } from './DIDSet'
import { EnableAmendment } from './enableAmendment'
import { EscrowCancel, validateEscrowCancel } from './escrowCancel'
import { EscrowCreate, validateEscrowCreate } from './escrowCreate'
Expand Down Expand Up @@ -91,18 +93,20 @@ import {
* @category Transaction Models
*/
export type Transaction =
| AccountDelete
| AccountSet
| AMMBid
| AMMCreate
| AMMDelete
| AMMDeposit
| AMMCreate
| AMMVote
| AMMWithdraw
| AccountDelete
| AccountSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Alphabetically AccountDelete and AccountSet should be before AMM...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same nit applies below with the case statement if we want to maintain alphabetical order)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was sorting with capitals before lowercase, which makes more sense to me, but if you disagree I'm happy to change that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't consider capitalization when scanning lists, so I'd prefer to ignore it when sorting alphabetically

| CheckCancel
| CheckCash
| CheckCreate
| Clawback
| DIDDelete
| DIDSet
| DepositPreauth
| EscrowCancel
| EscrowCreate
Expand All @@ -122,13 +126,13 @@ export type Transaction =
| SignerListSet
| TicketCreate
| TrustSet
| XChainAccountCreateCommit
| XChainAddAccountCreateAttestation
| XChainAddClaimAttestation
| XChainClaim
| XChainCommit
| XChainCreateBridge
| XChainCreateClaimID
| XChainAccountCreateCommit
| XChainModifyBridge

export type PseudoTransaction = EnableAmendment | SetFee | UNLModify
Expand Down Expand Up @@ -210,18 +214,14 @@ export function validate(transaction: Record<string, unknown>): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- okay here
setTransactionFlagsToNumber(tx as unknown as Transaction)
switch (tx.TransactionType) {
case 'AccountDelete':
validateAccountDelete(tx)
break

case 'AccountSet':
validateAccountSet(tx)
break

case 'AMMBid':
validateAMMBid(tx)
break

case 'AMMCreate':
validateAMMCreate(tx)
break

case 'AMMDelete':
validateAMMDelete(tx)
break
Expand All @@ -230,10 +230,6 @@ export function validate(transaction: Record<string, unknown>): void {
validateAMMDeposit(tx)
break

case 'AMMCreate':
validateAMMCreate(tx)
break

case 'AMMVote':
validateAMMVote(tx)
break
Expand All @@ -242,6 +238,14 @@ export function validate(transaction: Record<string, unknown>): void {
validateAMMWithdraw(tx)
break

case 'AccountDelete':
validateAccountDelete(tx)
break

case 'AccountSet':
validateAccountSet(tx)
break

case 'CheckCancel':
validateCheckCancel(tx)
break
Expand All @@ -258,6 +262,14 @@ export function validate(transaction: Record<string, unknown>): void {
validateClawback(tx)
break

case 'DIDDelete':
validateDIDDelete(tx)
break

case 'DIDSet':
validateDIDSet(tx)
break

case 'DepositPreauth':
validateDepositPreauth(tx)
break
Expand Down Expand Up @@ -334,6 +346,10 @@ export function validate(transaction: Record<string, unknown>): void {
validateTrustSet(tx)
break

case 'XChainAccountCreateCommit':
validateXChainAccountCreateCommit(tx)
break

case 'XChainAddAccountCreateAttestation':
validateXChainAddAccountCreateAttestation(tx)
break
Expand All @@ -358,10 +374,6 @@ export function validate(transaction: Record<string, unknown>): void {
validateXChainCreateClaimID(tx)
break

case 'XChainAccountCreateCommit':
validateXChainAccountCreateCommit(tx)
break

case 'XChainModifyBridge':
validateXChainModifyBridge(tx)
break
Expand Down
Loading