mirror of
				https://github.com/Xahau/xahau.js.git
				synced 2025-11-04 04:55:48 +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
 | 
			
		||||
* 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
 | 
			
		||||
 
 | 
			
		||||
@@ -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'
 | 
			
		||||
@@ -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 = {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
  /**
 | 
			
		||||
 
 | 
			
		||||
@@ -168,6 +168,7 @@ import {
 | 
			
		||||
  SubscribeRequest,
 | 
			
		||||
  SubscribeResponse,
 | 
			
		||||
  TransactionStream,
 | 
			
		||||
  TransactionV1Stream,
 | 
			
		||||
  ValidationStream,
 | 
			
		||||
} from './subscribe'
 | 
			
		||||
import {
 | 
			
		||||
@@ -583,6 +584,7 @@ export {
 | 
			
		||||
  LedgerStreamResponse,
 | 
			
		||||
  ValidationStream,
 | 
			
		||||
  TransactionStream,
 | 
			
		||||
  TransactionV1Stream,
 | 
			
		||||
  PathFindStream,
 | 
			
		||||
  PeerStatusStream,
 | 
			
		||||
  OrderBookStream,
 | 
			
		||||
 
 | 
			
		||||
@@ -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'
 | 
			
		||||
@@ -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. */
 | 
			
		||||
@@ -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
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user