refactor: define typescript types for OfferCancel Transaction Model (#1512)

* define typescript types for OfferCancel Transaction Model
This commit is contained in:
Mukul Jangid
2021-08-18 10:11:27 -04:00
committed by Mayukha Vadari
parent 1cc23c6ba9
commit b2d03363a6
6 changed files with 91 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
export * from './transaction'
export * from './offerCreate'
export * from './offerCancel'
export * from './checkCreate'
export * from './checkCash'
export * from './checkCancel'

View 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: invalid OfferSequence")
}

View File

@@ -1,13 +1,17 @@
import Metadata from "../common/metadata";
import { OfferCreate } from "./offerCreate";
import { CheckCash } from "./checkCash";
import { CheckCancel } from "./checkCancel";
import { CheckCreate } from "./checkCreate";
import { SignerListSet } from "./signerListSet";
import Metadata from "../common/metadata"
import { OfferCreate } from "./offerCreate"
import { OfferCancel } from "./offerCancel"
import { CheckCash } from "./checkCash"
import { CheckCancel } from "./checkCancel"
import { CheckCreate } from "./checkCreate"
import { SignerListSet } from "./signerListSet"
export type Transaction =
// AccountSet
// | AccountDelete
// | CheckCancel
// | CheckCash
// | CheckCreate
CheckCancel
| CheckCash
| CheckCreate
@@ -15,6 +19,7 @@ export type Transaction =
// | EscrowCancel
// | EscrowCreate
// | EscrowFinish
| OfferCancel
// | OfferCancel
| OfferCreate
// | PaymentTransaction