From 2f252ace1476bbd8aa7dc299626bb67ef7a7dd7f Mon Sep 17 00:00:00 2001 From: Jackson Mills Date: Mon, 18 Apr 2022 15:50:37 -0700 Subject: [PATCH] Add tx info which is only available in requests (#1962) * Add Response Only info --- packages/xrpl/src/models/common/index.ts | 20 +++++++++++++++++++ packages/xrpl/src/models/methods/accountTx.ts | 4 ++-- .../xrpl/src/models/methods/norippleCheck.ts | 4 ++-- packages/xrpl/src/models/methods/subscribe.ts | 20 ++++++++----------- .../src/models/methods/transactionEntry.ts | 4 ++-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/packages/xrpl/src/models/common/index.ts b/packages/xrpl/src/models/common/index.ts index 03d34e97..650d9d36 100644 --- a/packages/xrpl/src/models/common/index.ts +++ b/packages/xrpl/src/models/common/index.ts @@ -66,6 +66,26 @@ export interface SignerEntry { } } +/** + * This information is added to Transactions in request responses, but is not part + * of the canonical Transaction information on ledger. These fields are denoted with + * lowercase letters to indicate this in the rippled responses. + */ +export interface ResponseOnlyTxInfo { + /** + * The date/time when this transaction was included in a validated ledger. + */ + date?: number + /** + * An identifying hash value unique to this transaction, as a hex string. + */ + hash?: string + /** + * The sequence number of the ledger that included this transaction. + */ + ledger_index?: number +} + /** * One offer that might be returned from either an {@link NFTBuyOffersRequest} * or an {@link NFTSellOffersRequest}. diff --git a/packages/xrpl/src/models/methods/accountTx.ts b/packages/xrpl/src/models/methods/accountTx.ts index 03ca4b55..a722902c 100644 --- a/packages/xrpl/src/models/methods/accountTx.ts +++ b/packages/xrpl/src/models/methods/accountTx.ts @@ -1,4 +1,4 @@ -import { LedgerIndex } from '../common' +import { LedgerIndex, ResponseOnlyTxInfo } from '../common' import { Transaction, TransactionMetadata } from '../transactions' import { BaseRequest, BaseResponse } from './baseMethod' @@ -62,7 +62,7 @@ interface AccountTransaction { */ meta: string | TransactionMetadata /** JSON object defining the transaction. */ - tx?: Transaction + tx?: Transaction & ResponseOnlyTxInfo /** Unique hashed String representing the transaction. */ tx_blob?: string /** diff --git a/packages/xrpl/src/models/methods/norippleCheck.ts b/packages/xrpl/src/models/methods/norippleCheck.ts index 91c4e770..73103326 100644 --- a/packages/xrpl/src/models/methods/norippleCheck.ts +++ b/packages/xrpl/src/models/methods/norippleCheck.ts @@ -1,4 +1,4 @@ -import { LedgerIndex } from '../common' +import { LedgerIndex, ResponseOnlyTxInfo } from '../common' import { Transaction } from '../transactions' import { BaseRequest, BaseResponse } from './baseMethod' @@ -77,6 +77,6 @@ export interface NoRippleCheckResponse extends BaseResponse { * the problems array, and each entry is intended to fix the problem * described at the same index into that array. */ - transactions: Transaction[] + transactions: Array } } diff --git a/packages/xrpl/src/models/methods/subscribe.ts b/packages/xrpl/src/models/methods/subscribe.ts index 1cb7f667..5f0ed891 100644 --- a/packages/xrpl/src/models/methods/subscribe.ts +++ b/packages/xrpl/src/models/methods/subscribe.ts @@ -1,4 +1,10 @@ -import type { Amount, Currency, Path, StreamType } from '../common' +import type { + Amount, + Currency, + Path, + StreamType, + ResponseOnlyTxInfo, +} from '../common' import { Offer } from '../ledger' import { OfferCreate, Transaction } from '../transactions' import { TransactionMetadata } from '../transactions/metadata' @@ -268,17 +274,7 @@ export interface TransactionStream extends BaseStream { */ meta?: TransactionMetadata /** The definition of the transaction in JSON format. */ - transaction: Transaction & { - /** - * This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC) - */ - date?: number - /** - * Every signed transaction has a unique "hash" that identifies it. - * The transaction hash can be used to look up its final status, which may serve as a "proof of payment" - */ - hash?: string - } + transaction: Transaction & ResponseOnlyTxInfo /** * If true, this transaction is included in a validated ledger and its * outcome is final. Responses from the transaction stream should always be diff --git a/packages/xrpl/src/models/methods/transactionEntry.ts b/packages/xrpl/src/models/methods/transactionEntry.ts index 535b3a9c..d0dbe3a6 100644 --- a/packages/xrpl/src/models/methods/transactionEntry.ts +++ b/packages/xrpl/src/models/methods/transactionEntry.ts @@ -1,4 +1,4 @@ -import { LedgerIndex } from '../common' +import { LedgerIndex, ResponseOnlyTxInfo } from '../common' import { Transaction, TransactionMetadata } from '../transactions' import { BaseRequest, BaseResponse } from './baseMethod' @@ -46,6 +46,6 @@ export interface TransactionEntryResponse extends BaseResponse { */ metadata: TransactionMetadata /** JSON representation of the Transaction object. */ - tx_json: Transaction + tx_json: Transaction & ResponseOnlyTxInfo } }