mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 21:15:47 +00:00
fix: resolve TransactionStream and Ledger model issues (#2779)
* update TransactionStream model * fix everywhere else * add close_time_iso * add close_time_iso to TransactionStream * update HISTORY * fix tests * fix import * Update packages/xrpl/src/client/partialPayment.ts
This commit is contained in:
@@ -7,6 +7,11 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
|
|||||||
### Added
|
### Added
|
||||||
* parseTransactionFlags as a utility function in the xrpl package to streamline transactions flags-to-map conversion
|
* 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)
|
## 4.0.0 (2024-07-15)
|
||||||
|
|
||||||
### BREAKING CHANGES
|
### BREAKING CHANGES
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { decode } from 'ripple-binary-codec'
|
|||||||
import type {
|
import type {
|
||||||
TransactionEntryResponse,
|
TransactionEntryResponse,
|
||||||
TransactionStream,
|
TransactionStream,
|
||||||
|
TransactionV1Stream,
|
||||||
TxResponse,
|
TxResponse,
|
||||||
} from '..'
|
} from '..'
|
||||||
import type { Amount, APIVersion, DEFAULT_API_VERSION } from '../models/common'
|
import type { Amount, APIVersion, DEFAULT_API_VERSION } from '../models/common'
|
||||||
@@ -159,10 +160,10 @@ export function handlePartialPayment<
|
|||||||
* @param log - The method used for logging by the connection (to report the partial payment).
|
* @param log - The method used for logging by the connection (to report the partial payment).
|
||||||
*/
|
*/
|
||||||
export function handleStreamPartialPayment(
|
export function handleStreamPartialPayment(
|
||||||
stream: TransactionStream,
|
stream: TransactionStream | TransactionV1Stream,
|
||||||
log: (id: string, message: string) => void,
|
log: (id: string, message: string) => void,
|
||||||
): void {
|
): void {
|
||||||
if (isPartialPayment(stream.transaction, stream.meta)) {
|
if (isPartialPayment(stream.tx_json ?? stream.transaction, stream.meta)) {
|
||||||
const warnings = stream.warnings ?? []
|
const warnings = stream.warnings ?? []
|
||||||
|
|
||||||
const warning = {
|
const warning = {
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ interface BaseLedger {
|
|||||||
* by which the close_time could be rounded.
|
* by which the close_time could be rounded.
|
||||||
*/
|
*/
|
||||||
close_time_resolution: number
|
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. */
|
/** Whether or not this ledger has been closed. */
|
||||||
closed: boolean
|
closed: boolean
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ import {
|
|||||||
SubscribeRequest,
|
SubscribeRequest,
|
||||||
SubscribeResponse,
|
SubscribeResponse,
|
||||||
TransactionStream,
|
TransactionStream,
|
||||||
|
TransactionV1Stream,
|
||||||
ValidationStream,
|
ValidationStream,
|
||||||
} from './subscribe'
|
} from './subscribe'
|
||||||
import {
|
import {
|
||||||
@@ -583,6 +584,7 @@ export {
|
|||||||
LedgerStreamResponse,
|
LedgerStreamResponse,
|
||||||
ValidationStream,
|
ValidationStream,
|
||||||
TransactionStream,
|
TransactionStream,
|
||||||
|
TransactionV1Stream,
|
||||||
PathFindStream,
|
PathFindStream,
|
||||||
PeerStatusStream,
|
PeerStatusStream,
|
||||||
OrderBookStream,
|
OrderBookStream,
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import type {
|
|||||||
Path,
|
Path,
|
||||||
StreamType,
|
StreamType,
|
||||||
ResponseOnlyTxInfo,
|
ResponseOnlyTxInfo,
|
||||||
|
APIVersion,
|
||||||
|
DEFAULT_API_VERSION,
|
||||||
|
RIPPLED_API_V1,
|
||||||
|
RIPPLED_API_V2,
|
||||||
} from '../common'
|
} from '../common'
|
||||||
import { Offer } from '../ledger'
|
import { Offer } from '../ledger'
|
||||||
import { OfferCreate, Transaction } from '../transactions'
|
import { OfferCreate, Transaction } from '../transactions'
|
||||||
@@ -262,9 +266,16 @@ export interface ValidationStream extends BaseStream {
|
|||||||
*
|
*
|
||||||
* @category Streams
|
* @category Streams
|
||||||
*/
|
*/
|
||||||
export interface TransactionStream extends BaseStream {
|
interface TransactionStreamBase<
|
||||||
|
Version extends APIVersion = typeof DEFAULT_API_VERSION,
|
||||||
|
> extends BaseStream {
|
||||||
status: string
|
status: string
|
||||||
type: 'transaction'
|
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. */
|
/** String Transaction result code. */
|
||||||
engine_result: string
|
engine_result: string
|
||||||
/** Numeric transaction response code, if applicable. */
|
/** Numeric transaction response code, if applicable. */
|
||||||
@@ -285,8 +296,14 @@ export interface TransactionStream extends BaseStream {
|
|||||||
* in detail.
|
* in detail.
|
||||||
*/
|
*/
|
||||||
meta?: TransactionMetadata
|
meta?: TransactionMetadata
|
||||||
/** The definition of the transaction in JSON format. */
|
/** JSON object defining the transaction. */
|
||||||
transaction: Transaction & ResponseOnlyTxInfo
|
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
|
* If true, this transaction is included in a validated ledger and its
|
||||||
* outcome is final. Responses from the transaction stream should always be
|
* outcome is final. Responses from the transaction stream should always be
|
||||||
@@ -296,6 +313,20 @@ export interface TransactionStream extends BaseStream {
|
|||||||
warnings?: Array<{ id: number; message: string }>
|
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 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
|
* the activities of other rippled servers to which this server is connected, in
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"close_flags": 0,
|
"close_flags": 0,
|
||||||
"ledger_index": "15202439",
|
"ledger_index": "15202439",
|
||||||
"close_time_human": "2015-Aug-12 01:01:10.000000000 UTC",
|
"close_time_human": "2015-Aug-12 01:01:10.000000000 UTC",
|
||||||
|
"close_time_iso": "2015-08-12T01:01.10Z",
|
||||||
"close_time_resolution": 10,
|
"close_time_resolution": 10,
|
||||||
"closed": true,
|
"closed": true,
|
||||||
"hash": "F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349",
|
"hash": "F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349",
|
||||||
|
|||||||
Reference in New Issue
Block a user