Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/eslint-plugin-import…
Browse files Browse the repository at this point in the history
…-2.31.0
  • Loading branch information
anissa-ripple authored Nov 4, 2024
2 parents 5c202a0 + 496f774 commit f717369
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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

### Fixed
* `TransactionStream` model supports APIv2
* `TransactionStream` model includes `close_time_iso` field
* `Ledger` model includes `close_time_iso` field

## 4.0.0 (2024-07-15)

### BREAKING CHANGES
Expand Down
5 changes: 3 additions & 2 deletions packages/xrpl/src/client/partialPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { decode } from 'ripple-binary-codec'
import type {
TransactionEntryResponse,
TransactionStream,
TransactionV1Stream,
TxResponse,
} from '..'
import type { Amount, APIVersion, DEFAULT_API_VERSION } from '../models/common'
Expand Down Expand Up @@ -159,10 +160,10 @@ export function handlePartialPayment<
* @param log - The method used for logging by the connection (to report the partial payment).
*/
export function handleStreamPartialPayment(
stream: TransactionStream,
stream: TransactionStream | TransactionV1Stream,
log: (id: string, message: string) => void,
): void {
if (isPartialPayment(stream.transaction, stream.meta)) {
if (isPartialPayment(stream.tx_json ?? stream.transaction, stream.meta)) {
const warnings = stream.warnings ?? []

const warning = {
Expand Down
5 changes: 5 additions & 0 deletions packages/xrpl/src/models/ledger/Ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ interface BaseLedger {
* by which the close_time could be rounded.
*/
close_time_resolution: number
/**
* The approximate time this ledger was closed, in date time string format.
* Always uses the UTC time zone.
*/
close_time_iso: string
/** Whether or not this ledger has been closed. */
closed: boolean
/**
Expand Down
2 changes: 2 additions & 0 deletions packages/xrpl/src/models/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ import {
SubscribeRequest,
SubscribeResponse,
TransactionStream,
TransactionV1Stream,
ValidationStream,
} from './subscribe'
import {
Expand Down Expand Up @@ -583,6 +584,7 @@ export {
LedgerStreamResponse,
ValidationStream,
TransactionStream,
TransactionV1Stream,
PathFindStream,
PeerStatusStream,
OrderBookStream,
Expand Down
37 changes: 34 additions & 3 deletions packages/xrpl/src/models/methods/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import type {
Path,
StreamType,
ResponseOnlyTxInfo,
APIVersion,
DEFAULT_API_VERSION,
RIPPLED_API_V1,
RIPPLED_API_V2,
} from '../common'
import { Offer } from '../ledger'
import { OfferCreate, Transaction } from '../transactions'
Expand Down Expand Up @@ -262,9 +266,16 @@ export interface ValidationStream extends BaseStream {
*
* @category Streams
*/
export interface TransactionStream extends BaseStream {
interface TransactionStreamBase<
Version extends APIVersion = typeof DEFAULT_API_VERSION,
> extends BaseStream {
status: string
type: 'transaction'
/**
* The approximate time this ledger was closed, in date time string format.
* Always uses the UTC time zone.
*/
close_time_iso: string
/** String Transaction result code. */
engine_result: string
/** Numeric transaction response code, if applicable. */
Expand All @@ -285,8 +296,14 @@ export interface TransactionStream extends BaseStream {
* in detail.
*/
meta?: TransactionMetadata
/** The definition of the transaction in JSON format. */
transaction: Transaction & ResponseOnlyTxInfo
/** JSON object defining the transaction. */
tx_json?: Version extends typeof RIPPLED_API_V2
? Transaction & ResponseOnlyTxInfo
: never
/** JSON object defining the transaction in rippled API v1. */
transaction?: Version extends typeof RIPPLED_API_V1
? Transaction & ResponseOnlyTxInfo
: never
/**
* If true, this transaction is included in a validated ledger and its
* outcome is final. Responses from the transaction stream should always be
Expand All @@ -296,6 +313,20 @@ export interface TransactionStream extends BaseStream {
warnings?: Array<{ id: number; message: string }>
}

/**
* Expected response from an {@link AccountTxRequest}.
*
* @category Streams
*/
export type TransactionStream = TransactionStreamBase

/**
* Expected response from an {@link AccountTxRequest} with `api_version` set to 1.
*
* @category Streams
*/
export type TransactionV1Stream = TransactionStreamBase<typeof RIPPLED_API_V1>

/**
* The admin-only `peer_status` stream reports a large amount of information on
* the activities of other rippled servers to which this server is connected, in
Expand Down
1 change: 1 addition & 0 deletions packages/xrpl/test/fixtures/requests/hashLedger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"close_flags": 0,
"ledger_index": "15202439",
"close_time_human": "2015-Aug-12 01:01:10.000000000 UTC",
"close_time_iso": "2015-08-12T01:01.10Z",
"close_time_resolution": 10,
"closed": true,
"hash": "F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349",
Expand Down

0 comments on commit f717369

Please sign in to comment.