Skip to content
Draft
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
1 change: 1 addition & 0 deletions packages/xrpl/src/models/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface Memo {
}

export type StreamType =
| 'book_changes'
Comment on lines 56 to +57
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

LGTM: 'book_changes' stream type has been added correctly.

The addition of 'book_changes' to the StreamType union type looks good. This change expands the available stream types that can be used with the XRPL library.

Consider adding appropriate documentation to explain what the 'book_changes' stream represents and how it should be used by consumers of the library.


🏁 Script executed:

#!/bin/bash
# Check if there are any references to 'book_changes' in the documentation or other files
echo "Searching for documentation or usage examples of 'book_changes' stream type..."
rg --type md --type ts 'book_changes' -A 2 -B 2

Length of output: 499


🏁 Script executed:

#!/bin/bash
# List markdown documentation files at top-level and in docs/ directory
fd -t f -e md -d 2

Length of output: 115


Add documentation for the new book_changes stream type

I didn’t find any references to book_changes in your markdown docs (e.g. README.md, MIGRATION.md, etc.), so please add a note about what the book_changes stream represents and how consumers should use it. For example:

• In README.md (under “Streams” or “Websocket Subscriptions”), list book_changes alongside the existing stream types with a brief description.
• In MIGRATION.md (if you document breaking changes or new features), mention that book_changes was introduced in this release and point to any relevant examples.

| 'consensus'
| 'ledger'
| 'manifests'
Expand Down
81 changes: 81 additions & 0 deletions packages/xrpl/src/models/methods/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,87 @@ interface BaseStream {
type: string
}

/**
* The book_changes stream sends bookChanges messages whenever a new ledger
* is validated. This message contains a summary of all changes to order books
* in the decentralized exchange that occurred in that ledger.
*
* @category Streams
*/
export interface BookChangesStream extends BaseStream {
type: 'bookChanges'
/** The ledger index of the ledger with these changes. */
ledger_index: number
/** The identifying hash of the ledger with these changes. */
ledger_hash: string
/**
* The official close time of the ledger with these changes,
* in seconds since the Ripple Epoch.
*/
ledger_time: number
/**
* List of Book Update Objects, containing one entry for each order book
* that was updated in this ledger version. The array is empty if no
* order books were updated.
*/
changes: BookUpdateObject[]
}

/**
* A Book Update Object represents the changes to a single order book
* in a single ledger version.
*
* @category Streams
*/
export interface BookUpdateObject {
/**
* An identifier for the first of the two currencies in the order book.
* For XRP, this is the string "XRP_drops". For tokens, this is formatted as
* the address of the issuer in base58, followed by a forward-slash ("/"),
* followed by the Currency Code for the token, which can be a 3-character
* standard code or a 20-character hexadecimal code.
*/
currency_a: string
/**
* An identifier for the second of two currencies in the order book.
* This is in the same format as currency_a, except currency_b can never be XRP.
*/
currency_b: string
/**
* The total amount, or volume, of the first currency (that is, currency_a)
* that moved as a result of trades through this order book in this ledger.
*/
volume_a: string
/**
* The volume of the second currency (that is, currency_b) that moved
* as a result of trades through this order book in this ledger.
*/
volume_b: string
/**
* The highest exchange rate among all offers matched in this ledger,
* as a ratio of the first currency to the second currency.
* (In other words, currency_a : currency_b.)
*/
high: string
/**
* The lowest exchange rate among all offers matched in this ledger,
* as a ratio of the first currency to the second currency.
*/
low: string
/**
* The exchange rate at the top of this order book before processing
* the transactions in this ledger, as a ratio of the first currency
* to the second currency.
*/
open: string
/**
* The exchange rate at the top of this order book after processing
* the transactions in this ledger, as a ratio of the first currency
* to the second currency.
*/
close: string
}

/**
* The `ledger` stream only sends `ledgerClosed` messages when the consensus
* process declares a new validated ledger. The message identifies the ledger
Expand Down
Loading