mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 12:45:50 +00:00
fix: resolve OfferCancel merge issues (#1546)
* fix: resolve OfferCancel git issues
This commit is contained in:
committed by
Mayukha Vadari
parent
72f34d9388
commit
fef5f858fd
@@ -1,6 +1,7 @@
|
|||||||
export * from './transaction'
|
export * from './transaction'
|
||||||
export * from './offerCreate'
|
export * from './offerCreate'
|
||||||
export * from './accountSet'
|
export * from './accountSet'
|
||||||
|
export * from './offerCancel'
|
||||||
export * from './checkCreate'
|
export * from './checkCreate'
|
||||||
export * from './checkCash'
|
export * from './checkCash'
|
||||||
export * from './checkCancel'
|
export * from './checkCancel'
|
||||||
|
|||||||
24
src/models/transactions/offerCancel.ts
Normal file
24
src/models/transactions/offerCancel.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { ValidationError } from "../../common/errors"
|
||||||
|
import { BaseTransaction, verifyBaseTransaction } from "./common"
|
||||||
|
|
||||||
|
export interface OfferCancel extends BaseTransaction {
|
||||||
|
TransactionType: "OfferCancel"
|
||||||
|
OfferSequence: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an OfferCancel at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An OfferCancel Transaction
|
||||||
|
* @returns - Void.
|
||||||
|
* @throws - When the OfferCancel is Malformed.
|
||||||
|
*/
|
||||||
|
export function verifyOfferCancel(tx: OfferCancel): void {
|
||||||
|
verifyBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.OfferSequence === undefined)
|
||||||
|
throw new ValidationError("OfferCancel: missing field OfferSequence")
|
||||||
|
|
||||||
|
if (typeof tx.OfferSequence !== 'number')
|
||||||
|
throw new ValidationError("OfferCancel: OfferSequence must be a number")
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import Metadata from "../common/metadata";
|
import Metadata from "../common/metadata"
|
||||||
import { OfferCreate } from "./offerCreate";
|
import { OfferCreate } from "./offerCreate"
|
||||||
import { CheckCash } from "./checkCash";
|
import { OfferCancel } from "./offerCancel"
|
||||||
import { CheckCancel } from "./checkCancel";
|
import { CheckCash } from "./checkCash"
|
||||||
import { CheckCreate } from "./checkCreate";
|
import { CheckCancel } from "./checkCancel"
|
||||||
import { SignerListSet } from "./signerListSet";
|
import { CheckCreate } from "./checkCreate"
|
||||||
|
import { SignerListSet } from "./signerListSet"
|
||||||
import { AccountSet } from "./accountSet";
|
import { AccountSet } from "./accountSet";
|
||||||
|
|
||||||
export type Transaction =
|
export type Transaction =
|
||||||
@@ -16,6 +17,7 @@ export type Transaction =
|
|||||||
// | EscrowCancel
|
// | EscrowCancel
|
||||||
// | EscrowCreate
|
// | EscrowCreate
|
||||||
// | EscrowFinish
|
// | EscrowFinish
|
||||||
|
| OfferCancel
|
||||||
// | OfferCancel
|
// | OfferCancel
|
||||||
| OfferCreate
|
| OfferCreate
|
||||||
// | PaymentTransaction
|
// | PaymentTransaction
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { assert } from 'chai'
|
|||||||
*
|
*
|
||||||
* Providing runtime verification testing for each specific transaction type
|
* Providing runtime verification testing for each specific transaction type
|
||||||
*/
|
*/
|
||||||
describe('Transaction Verification', function () {
|
describe('CheckCancel Transaction Verification', function () {
|
||||||
|
|
||||||
it (`verifies valid CheckCancel`, () => {
|
it (`verifies valid CheckCancel`, () => {
|
||||||
const validCheckCancel = {
|
const validCheckCancel = {
|
||||||
|
|||||||
53
test/models/offerCancel.ts
Normal file
53
test/models/offerCancel.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { ValidationError } from 'xrpl-local/common/errors'
|
||||||
|
import { verifyOfferCancel } from './../../src/models/transactions/offerCancel'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OfferCancel Transaction Verification Testing
|
||||||
|
*
|
||||||
|
* Providing runtime verification testing for each specific transaction type
|
||||||
|
*/
|
||||||
|
describe('OfferCancel Transaction Verification', function () {
|
||||||
|
let offer
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
offer = {
|
||||||
|
Account: "rnKiczmiQkZFiDES8THYyLA2pQohC5C6EF",
|
||||||
|
Fee: "10",
|
||||||
|
LastLedgerSequence: 65477334,
|
||||||
|
OfferSequence: 60797528,
|
||||||
|
Sequence: 60797535,
|
||||||
|
SigningPubKey: "0361BFD43D1EEA54B77CC152887312949EBF052997FBFFCDAF6F2653164B55B21...",
|
||||||
|
TransactionType: "OfferCancel",
|
||||||
|
TxnSignature: "30450221008C43BDCFC68B4793857CA47DF454C07E5B45D3F80E8E6785CAB9292...",
|
||||||
|
date: "2021-08-06T21:04:11Z"
|
||||||
|
} as any
|
||||||
|
})
|
||||||
|
|
||||||
|
it (`verifies valid OfferCancel`, () => {
|
||||||
|
assert.doesNotThrow(() => verifyOfferCancel(offer))
|
||||||
|
})
|
||||||
|
|
||||||
|
it (`verifies valid OfferCancel with flags`, () => {
|
||||||
|
offer.Flags = 2147483648
|
||||||
|
assert.doesNotThrow(() => verifyOfferCancel(offer))
|
||||||
|
})
|
||||||
|
|
||||||
|
it (`throws w/ OfferSequence must be a number`, () => {
|
||||||
|
offer.OfferSequence = '99'
|
||||||
|
assert.throws(
|
||||||
|
() => verifyOfferCancel(offer),
|
||||||
|
ValidationError,
|
||||||
|
"OfferCancel: OfferSequence must be a number"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it (`throws w/ missing OfferSequence`, () => {
|
||||||
|
delete offer.OfferSequence
|
||||||
|
assert.throws(
|
||||||
|
() => verifyOfferCancel(offer),
|
||||||
|
ValidationError,
|
||||||
|
"OfferCancel: missing field OfferSequence"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user