diff --git a/packages/xrpl/src/models/transactions/escrowCancel.ts b/packages/xrpl/src/models/transactions/escrowCancel.ts index 91863913..b51649a4 100644 --- a/packages/xrpl/src/models/transactions/escrowCancel.ts +++ b/packages/xrpl/src/models/transactions/escrowCancel.ts @@ -15,7 +15,12 @@ export interface EscrowCancel extends BaseTransaction { * Transaction sequence (or Ticket number) of EscrowCreate transaction that. * created the escrow to cancel. */ - OfferSequence: number + OfferSequence?: number + /** + * The ID of the Escrow ledger object to cancel as a 64-character hexadecimal + * string. + */ + EscrowID?: string } /** @@ -35,11 +40,17 @@ export function validateEscrowCancel(tx: Record): void { throw new ValidationError('EscrowCancel: Owner must be a string') } - if (tx.OfferSequence === undefined) { - throw new ValidationError('EscrowCancel: missing OfferSequence') + if (tx.OfferSequence === undefined && tx.EscrowID === undefined) { + throw new ValidationError( + 'EscrowCancel: must include OfferSequence or EscrowID', + ) } - if (typeof tx.OfferSequence !== 'number') { - throw new ValidationError('EscrowCancel: OfferSequence must be a number') + if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') { + throw new ValidationError('EscrowCancel: invalid OfferSequence') + } + + if (tx.EscrowID !== undefined && typeof tx.EscrowID !== 'string') { + throw new ValidationError('EscrowCancel: invalid EscrowID') } } diff --git a/packages/xrpl/src/models/transactions/offerCancel.ts b/packages/xrpl/src/models/transactions/offerCancel.ts index 4989d188..aba388ed 100644 --- a/packages/xrpl/src/models/transactions/offerCancel.ts +++ b/packages/xrpl/src/models/transactions/offerCancel.ts @@ -15,7 +15,12 @@ export interface OfferCancel extends BaseTransaction { * created by that transaction. It is not considered an error if the offer. * specified does not exist. */ - OfferSequence: number + OfferSequence?: number + /** + * The ID of the Escrow ledger object to cancel as a 64-character hexadecimal + * string. + */ + OfferID?: string } /** @@ -27,11 +32,17 @@ export interface OfferCancel extends BaseTransaction { export function validateOfferCancel(tx: Record): void { validateBaseTransaction(tx) - if (tx.OfferSequence === undefined) { - throw new ValidationError('OfferCancel: missing field OfferSequence') + if (tx.OfferSequence === undefined && tx.OfferID === undefined) { + throw new ValidationError( + 'OfferCancel: must include OfferSequence or OfferID', + ) } - if (typeof tx.OfferSequence !== 'number') { - throw new ValidationError('OfferCancel: OfferSequence must be a number') + if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') { + throw new ValidationError('OfferCancel: invalid OfferSequence') + } + + if (tx.OfferID !== undefined && typeof tx.OfferID !== 'string') { + throw new ValidationError('OfferCancel: invalid OfferID') } } diff --git a/packages/xrpl/src/models/transactions/offerCreate.ts b/packages/xrpl/src/models/transactions/offerCreate.ts index 07f9d341..e8bad100 100644 --- a/packages/xrpl/src/models/transactions/offerCreate.ts +++ b/packages/xrpl/src/models/transactions/offerCreate.ts @@ -103,6 +103,11 @@ export interface OfferCreate extends BaseTransaction { Expiration?: number /** An offer to delete first, specified in the same way as OfferCancel. */ OfferSequence?: number + /** + * The ID of the Offer ledger object to cancel as a 64-character hexadecimal + * string. + */ + OfferID?: string /** The amount and type of currency being provided by the offer creator. */ TakerGets: Amount /** The amount and type of currency being requested by the offer creator. */ @@ -141,4 +146,8 @@ export function validateOfferCreate(tx: Record): void { if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') { throw new ValidationError('OfferCreate: invalid OfferSequence') } + + if (tx.OfferID !== undefined && typeof tx.OfferID !== 'string') { + throw new ValidationError('OfferCreate: invalid OfferID') + } }