add XChainCreateClaimID tx

This commit is contained in:
Mayukha Vadari
2022-07-12 11:11:18 -04:00
parent caddad737c
commit 277725858d
3 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import { ValidationError } from '../../errors'
import { Amount, Bridge } from '../common'
import { BaseTransaction, validateBaseTransaction } from './common'
/**
*
* @category Transaction Models
*/
export interface XChainCreateClaimID extends BaseTransaction {
TransactionType: 'XChainCreateClaimID'
Bridge: Bridge
SignatureReward: Amount
OtherChainAccount: string
}
/**
* Verify the form and type of a XChainCreateClaimID at runtime.
*
* @param tx - A XChainCreateClaimID Transaction.
* @throws When the XChainCreateClaimID is malformed.
*/
export function validateXChainCreateClaimID(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (tx.Bridge == null) {
throw new ValidationError('XChainCreateClaimID: missing field Bridge')
}
if (tx.SignatureReward == null) {
throw new ValidationError(
'XChainCreateClaimID: missing field SignatureReward',
)
}
if (tx.OtherChainAccount == null) {
throw new ValidationError(
'XChainCreateClaimID: missing field OtherChainAccount',
)
}
}

View File

@@ -48,3 +48,4 @@ export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
export { XChainClaim } from './XChainClaim'
export { XChainCommit } from './XChainCommit'
export { XChainCreateBridge } from './XChainCreateBridge'
export { XChainCreateClaimID } from './XChainCreateClaimID'

View File

@@ -56,6 +56,10 @@ import {
XChainCreateBridge,
validateXChainCreateBridge,
} from './XChainCreateBridge'
import {
XChainCreateClaimID,
validateXChainCreateClaimID,
} from './XChainCreateClaimID'
/**
* @category Transaction Models
@@ -88,6 +92,7 @@ export type Transaction =
| XChainClaim
| XChainCommit
| XChainCreateBridge
| XChainCreateClaimID
/**
* @category Transaction Models
@@ -224,6 +229,10 @@ export function validate(transaction: Record<string, unknown>): void {
validateXChainCreateBridge(tx)
break
case 'XChainCreateClaimID':
validateXChainCreateClaimID(tx)
break
default:
throw new ValidationError(
`Invalid field TransactionType: ${tx.TransactionType}`,