Skip to content

Commit

Permalink
add XChainModifyBridge model
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Aug 3, 2022
1 parent afccda3 commit 3982787
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/xrpl/src/models/transactions/XChainModifyBridge.ts
Original file line number Diff line number Diff line change
@@ -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',
)
}
}
1 change: 1 addition & 0 deletions packages/xrpl/src/models/transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ export { XChainCommit } from './XChainCommit'
export { XChainCreateBridge } from './XChainCreateBridge'
export { XChainCreateClaimID } from './XChainCreateClaimID'
export { SidechainXChainAccountCreate } from './sidechainXChainAccountCreate'
export { XChainModifyBridge } from './XChainModifyBridge'
9 changes: 9 additions & 0 deletions packages/xrpl/src/models/transactions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ import {
XChainCreateClaimID,
validateXChainCreateClaimID,
} from './XChainCreateClaimID'
import {
XChainModifyBridge,
validateXChainModifyBridge,
} from './XChainModifyBridge'

/**
* @category Transaction Models
Expand Down Expand Up @@ -103,6 +107,7 @@ export type Transaction =
| XChainCreateBridge
| XChainCreateClaimID
| SidechainXChainAccountCreate
| XChainModifyBridge

/**
* @category Transaction Models
Expand Down Expand Up @@ -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}`,
Expand Down

0 comments on commit 3982787

Please sign in to comment.