mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
fix: pseudo-transactions for ledger and tx (#2515)
* Add pseudo transactions as types returned by `tx` and `ledger` * Make` LedgerEntryResponse` generic to allow custom ledger entries * Update UNLModify to extend BaseTransaction * Create type `PseudoTransaction` Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
This commit is contained in:
@@ -6,6 +6,10 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
|
||||
|
||||
### Fixed
|
||||
- Allow flag maps when submitting `NFTokenMint` and `NFTokenCreateOffer` transactions like others with flags
|
||||
- Add pseudo transaction types to `tx` and `ledger` methods responses.
|
||||
|
||||
### Updated
|
||||
- Make `LedgerEntryResponse` a generic so it can be used like `LedgerEntryResponse<Escrow>`
|
||||
|
||||
## 2.12.0 (2023-09-27)
|
||||
### Added
|
||||
|
||||
@@ -10,7 +10,11 @@ import type {
|
||||
TxResponse,
|
||||
} from '..'
|
||||
import type { Amount } from '../models/common'
|
||||
import { PaymentFlags, Transaction } from '../models/transactions'
|
||||
import {
|
||||
PaymentFlags,
|
||||
PseudoTransaction,
|
||||
Transaction,
|
||||
} from '../models/transactions'
|
||||
import type { TransactionMetadata } from '../models/transactions/metadata'
|
||||
import { isFlagEnabled } from '../models/utils'
|
||||
|
||||
@@ -36,7 +40,7 @@ function amountsEqual(amt1: Amount, amt2: Amount): boolean {
|
||||
}
|
||||
|
||||
function isPartialPayment(
|
||||
tx?: Transaction,
|
||||
tx?: Transaction | PseudoTransaction,
|
||||
metadata?: TransactionMetadata | string,
|
||||
): boolean {
|
||||
if (tx == null || metadata == null || tx.TransactionType !== 'Payment') {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Transaction, TransactionMetadata } from '../transactions'
|
||||
import { PseudoTransaction } from '../transactions/transaction'
|
||||
|
||||
import LedgerEntry from './LedgerEntry'
|
||||
|
||||
@@ -61,5 +62,7 @@ export default interface Ledger {
|
||||
* either JSON or binary depending on whether the request specified binary
|
||||
* as true.
|
||||
*/
|
||||
transactions?: Array<Transaction & { metaData?: TransactionMetadata }>
|
||||
transactions?: Array<
|
||||
(Transaction | PseudoTransaction) & { metaData?: TransactionMetadata }
|
||||
>
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
|
||||
*
|
||||
* @category Responses
|
||||
*/
|
||||
export interface LedgerEntryResponse extends BaseResponse {
|
||||
export interface LedgerEntryResponse<T = LedgerEntry> extends BaseResponse {
|
||||
result: {
|
||||
/** The unique ID of this ledger object. */
|
||||
index: string
|
||||
@@ -194,7 +194,7 @@ export interface LedgerEntryResponse extends BaseResponse {
|
||||
* Object containing the data of this ledger object, according to the
|
||||
* ledger format.
|
||||
*/
|
||||
node?: LedgerEntry
|
||||
node?: T
|
||||
/** The binary representation of the ledger object, as hexadecimal. */
|
||||
node_binary?: string
|
||||
validated?: boolean
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Transaction, TransactionMetadata } from '../transactions'
|
||||
import { BaseTransaction } from '../transactions/common'
|
||||
import { PseudoTransaction } from '../transactions/transaction'
|
||||
|
||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
|
||||
@@ -39,8 +40,9 @@ export interface TxRequest extends BaseRequest {
|
||||
*
|
||||
* @category Responses
|
||||
*/
|
||||
export interface TxResponse<T extends BaseTransaction = Transaction>
|
||||
extends BaseResponse {
|
||||
export interface TxResponse<
|
||||
T extends BaseTransaction = Transaction | PseudoTransaction,
|
||||
> extends BaseResponse {
|
||||
result: {
|
||||
/** The SHA-512 hash of the transaction. */
|
||||
hash: string
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { BaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
* Mark a change to the Negative UNL.
|
||||
*
|
||||
* @category Pseudo Transaction Models
|
||||
*/
|
||||
export interface UNLModify {
|
||||
export interface UNLModify extends BaseTransaction {
|
||||
TransactionType: 'UNLModify'
|
||||
/**
|
||||
* The ledger index where this pseudo-transaction appears.
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
export { BaseTransaction } from './common'
|
||||
export { validate, TransactionAndMetadata, Transaction } from './transaction'
|
||||
export {
|
||||
validate,
|
||||
PseudoTransaction,
|
||||
TransactionAndMetadata,
|
||||
Transaction,
|
||||
} from './transaction'
|
||||
export * from './metadata'
|
||||
export {
|
||||
AccountSetAsfFlags,
|
||||
|
||||
@@ -20,6 +20,7 @@ import { CheckCreate, validateCheckCreate } from './checkCreate'
|
||||
import { Clawback, validateClawback } from './clawback'
|
||||
import { isIssuedCurrency } from './common'
|
||||
import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
|
||||
import { EnableAmendment } from './enableAmendment'
|
||||
import { EscrowCancel, validateEscrowCancel } from './escrowCancel'
|
||||
import { EscrowCreate, validateEscrowCreate } from './escrowCreate'
|
||||
import { EscrowFinish, validateEscrowFinish } from './escrowFinish'
|
||||
@@ -53,10 +54,12 @@ import {
|
||||
PaymentChannelFund,
|
||||
validatePaymentChannelFund,
|
||||
} from './paymentChannelFund'
|
||||
import { SetFee } from './setFee'
|
||||
import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
|
||||
import { SignerListSet, validateSignerListSet } from './signerListSet'
|
||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||
import { TrustSet, validateTrustSet } from './trustSet'
|
||||
import { UNLModify } from './UNLModify'
|
||||
import {
|
||||
XChainAccountCreateCommit,
|
||||
validateXChainAccountCreateCommit,
|
||||
@@ -128,6 +131,8 @@ export type Transaction =
|
||||
| XChainAccountCreateCommit
|
||||
| XChainModifyBridge
|
||||
|
||||
export type PseudoTransaction = EnableAmendment | SetFee | UNLModify
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ValidationError, XrplError } from '../../errors'
|
||||
import type { Ledger } from '../../models/ledger'
|
||||
import { LedgerEntry } from '../../models/ledger'
|
||||
import { Transaction, TransactionMetadata } from '../../models/transactions'
|
||||
import { PseudoTransaction } from '../../models/transactions/transaction'
|
||||
|
||||
import HashPrefix from './HashPrefix'
|
||||
import sha512Half from './sha512Half'
|
||||
@@ -124,7 +125,9 @@ export function hashLedgerHeader(ledgerHeader: Ledger): string {
|
||||
* @category Utilities
|
||||
*/
|
||||
export function hashTxTree(
|
||||
transactions: Array<Transaction & { metaData?: TransactionMetadata }>,
|
||||
transactions: Array<
|
||||
(Transaction | PseudoTransaction) & { metaData?: TransactionMetadata }
|
||||
>,
|
||||
): string {
|
||||
const shamap = new SHAMap()
|
||||
for (const txJSON of transactions) {
|
||||
|
||||
Reference in New Issue
Block a user