mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
add XChainModifyBridge model
This commit is contained in:
38
packages/xrpl/src/models/transactions/XChainModifyBridge.ts
Normal file
38
packages/xrpl/src/models/transactions/XChainModifyBridge.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount, XChainBridge } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
export interface XChainModifyBridge extends BaseTransaction {
|
||||
TransactionType: 'XChainModifyBridge'
|
||||
|
||||
XChainBridge: XChainBridge
|
||||
|
||||
SignatureReward: Amount
|
||||
|
||||
MinAccountCreateAmount?: Amount
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the form and type of a XChainModifyBridge at runtime.
|
||||
*
|
||||
* @param tx - A XChainModifyBridge Transaction.
|
||||
* @throws When the XChainModifyBridge is malformed.
|
||||
*/
|
||||
export function validateXChainModifyBridge(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.XChainBridge == null) {
|
||||
throw new ValidationError('XChainModifyBridge: missing field XChainBridge')
|
||||
}
|
||||
|
||||
if (tx.SignatureReward == null) {
|
||||
throw new ValidationError(
|
||||
'XChainModifyBridge: missing field SignatureReward',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -51,3 +51,4 @@ export { XChainCommit } from './XChainCommit'
|
||||
export { XChainCreateBridge } from './XChainCreateBridge'
|
||||
export { XChainCreateClaimID } from './XChainCreateClaimID'
|
||||
export { SidechainXChainAccountCreate } from './sidechainXChainAccountCreate'
|
||||
export { XChainModifyBridge } from './XChainModifyBridge'
|
||||
|
||||
@@ -68,6 +68,10 @@ import {
|
||||
XChainCreateClaimID,
|
||||
validateXChainCreateClaimID,
|
||||
} from './XChainCreateClaimID'
|
||||
import {
|
||||
XChainModifyBridge,
|
||||
validateXChainModifyBridge,
|
||||
} from './XChainModifyBridge'
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -103,6 +107,7 @@ export type Transaction =
|
||||
| XChainCreateBridge
|
||||
| XChainCreateClaimID
|
||||
| SidechainXChainAccountCreate
|
||||
| XChainModifyBridge
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -251,6 +256,10 @@ export function validate(transaction: Record<string, unknown>): void {
|
||||
validateSidechainXChainAccountCreate(tx)
|
||||
break
|
||||
|
||||
case 'XChainModifyBridge':
|
||||
validateXChainModifyBridge(tx)
|
||||
break
|
||||
|
||||
default:
|
||||
throw new ValidationError(
|
||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||
|
||||
Reference in New Issue
Block a user