mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
add XChainCreateBridge tx
This commit is contained in:
@@ -31,7 +31,7 @@ export function validateXChainCommit(tx: Record<string, unknown>): void {
|
||||
}
|
||||
|
||||
if (tx.XChainCommitID == null) {
|
||||
throw new ValidationError('XChainCommit: missing field XChainCommitID')
|
||||
throw new ValidationError('XChainCommit: missing field XChainClaimID')
|
||||
}
|
||||
|
||||
if (tx.Amount == null) {
|
||||
|
||||
38
packages/xrpl/src/models/transactions/XChainCreateBridge.ts
Normal file
38
packages/xrpl/src/models/transactions/XChainCreateBridge.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount, Bridge } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
export interface XChainCreateBridge extends BaseTransaction {
|
||||
TransactionType: 'XChainCreateBridge'
|
||||
|
||||
Bridge: Bridge
|
||||
|
||||
SignatureReward: Amount
|
||||
|
||||
MinAccountCreateAmount?: Amount
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the form and type of a XChainCreateBridge at runtime.
|
||||
*
|
||||
* @param tx - A XChainCreateBridge Transaction.
|
||||
* @throws When the XChainCreateBridge is malformed.
|
||||
*/
|
||||
export function validateXChainCreateBridge(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.Bridge == null) {
|
||||
throw new ValidationError('XChainCreateBridge: missing field Bridge')
|
||||
}
|
||||
|
||||
if (tx.SignatureReward == null) {
|
||||
throw new ValidationError(
|
||||
'XChainCreateBridge: missing field SignatureReward',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -47,3 +47,4 @@ export { TicketCreate } from './ticketCreate'
|
||||
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
||||
export { XChainClaim } from './XChainClaim'
|
||||
export { XChainCommit } from './XChainCommit'
|
||||
export { XChainCreateBridge } from './XChainCreateBridge'
|
||||
|
||||
@@ -52,6 +52,10 @@ import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||
import { TrustSet, validateTrustSet } from './trustSet'
|
||||
import { XChainClaim, validateXChainClaim } from './XChainClaim'
|
||||
import { XChainCommit, validateXChainCommit } from './XChainCommit'
|
||||
import {
|
||||
XChainCreateBridge,
|
||||
validateXChainCreateBridge,
|
||||
} from './XChainCreateBridge'
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -83,6 +87,7 @@ export type Transaction =
|
||||
| TrustSet
|
||||
| XChainClaim
|
||||
| XChainCommit
|
||||
| XChainCreateBridge
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -215,6 +220,10 @@ export function validate(transaction: Record<string, unknown>): void {
|
||||
validateXChainCommit(tx)
|
||||
break
|
||||
|
||||
case 'XChainCreateBridge':
|
||||
validateXChainCreateBridge(tx)
|
||||
break
|
||||
|
||||
default:
|
||||
throw new ValidationError(
|
||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||
|
||||
Reference in New Issue
Block a user