mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
add XChainCommit tx
This commit is contained in:
40
packages/xrpl/src/models/transactions/XChainCommit.ts
Normal file
40
packages/xrpl/src/models/transactions/XChainCommit.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount, Bridge } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
export interface XChainCommit extends BaseTransaction {
|
||||
TransactionType: 'XChainCommit'
|
||||
|
||||
Bridge: Bridge
|
||||
|
||||
XChainClaimID: number | string
|
||||
|
||||
Amount: Amount
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the form and type of a XChainCommit at runtime.
|
||||
*
|
||||
* @param tx - A XChainCommit Transaction.
|
||||
* @throws When the XChainCommit is malformed.
|
||||
*/
|
||||
export function validateXChainCommit(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.Bridge == null) {
|
||||
throw new ValidationError('XChainCommit: missing field Bridge')
|
||||
}
|
||||
|
||||
if (tx.XChainCommitID == null) {
|
||||
throw new ValidationError('XChainCommit: missing field XChainCommitID')
|
||||
}
|
||||
|
||||
if (tx.Amount == null) {
|
||||
throw new ValidationError('XChainCommit: missing field Amount')
|
||||
}
|
||||
}
|
||||
@@ -46,3 +46,4 @@ export { SignerListSet } from './signerListSet'
|
||||
export { TicketCreate } from './ticketCreate'
|
||||
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
||||
export { XChainClaim } from './XChainClaim'
|
||||
export { XChainCommit } from './XChainCommit'
|
||||
|
||||
@@ -51,6 +51,7 @@ import { SignerListSet, validateSignerListSet } from './signerListSet'
|
||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||
import { TrustSet, validateTrustSet } from './trustSet'
|
||||
import { XChainClaim, validateXChainClaim } from './XChainClaim'
|
||||
import { XChainCommit, validateXChainCommit } from './XChainCommit'
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -81,6 +82,7 @@ export type Transaction =
|
||||
| TicketCreate
|
||||
| TrustSet
|
||||
| XChainClaim
|
||||
| XChainCommit
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -209,6 +211,10 @@ export function validate(transaction: Record<string, unknown>): void {
|
||||
validateXChainClaim(tx)
|
||||
break
|
||||
|
||||
case 'XChainCommit':
|
||||
validateXChainCommit(tx)
|
||||
break
|
||||
|
||||
default:
|
||||
throw new ValidationError(
|
||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||
|
||||
Reference in New Issue
Block a user