mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 03:35:49 +00:00
add XChainClaim tx
This commit is contained in:
@@ -124,3 +124,10 @@ export interface NFTOffer {
|
||||
destination?: string
|
||||
expiration?: number
|
||||
}
|
||||
|
||||
export interface Bridge {
|
||||
src_chain_door: string
|
||||
src_chain_issue: 'XRP' | IssuedCurrency
|
||||
dst_chain_door: string
|
||||
dst_chain_issue: 'XRP' | IssuedCurrency
|
||||
}
|
||||
|
||||
46
packages/xrpl/src/models/transactions/XChainClaim.ts
Normal file
46
packages/xrpl/src/models/transactions/XChainClaim.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount, Bridge } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
export interface XChainClaim extends BaseTransaction {
|
||||
TransactionType: 'XChainClaim'
|
||||
|
||||
Bridge: Bridge
|
||||
|
||||
XChainClaimID: number | string
|
||||
|
||||
Destination: string
|
||||
|
||||
Amount: Amount
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the form and type of a XChainClaim at runtime.
|
||||
*
|
||||
* @param tx - A XChainClaim Transaction.
|
||||
* @throws When the XChainClaim is malformed.
|
||||
*/
|
||||
export function validateXChainClaim(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.Bridge == null) {
|
||||
throw new ValidationError('XChainClaim: missing field Bridge')
|
||||
}
|
||||
|
||||
if (tx.XChainClaimID == null) {
|
||||
throw new ValidationError('XChainClaim: missing field XChainClaimID')
|
||||
}
|
||||
|
||||
if (tx.Destination == null) {
|
||||
throw new ValidationError('XChainClaim: missing field Destination')
|
||||
}
|
||||
|
||||
if (tx.Amount == null) {
|
||||
throw new ValidationError('XChainClaim: missing field Amount')
|
||||
}
|
||||
}
|
||||
@@ -45,3 +45,4 @@ export { SetRegularKey } from './setRegularKey'
|
||||
export { SignerListSet } from './signerListSet'
|
||||
export { TicketCreate } from './ticketCreate'
|
||||
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
||||
export { XChainClaim } from './XChainClaim'
|
||||
|
||||
@@ -50,6 +50,7 @@ import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
|
||||
import { SignerListSet, validateSignerListSet } from './signerListSet'
|
||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||
import { TrustSet, validateTrustSet } from './trustSet'
|
||||
import { XChainClaim, validateXChainClaim } from './XChainClaim'
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -79,6 +80,7 @@ export type Transaction =
|
||||
| SignerListSet
|
||||
| TicketCreate
|
||||
| TrustSet
|
||||
| XChainClaim
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -203,6 +205,10 @@ export function validate(transaction: Record<string, unknown>): void {
|
||||
validateTrustSet(tx)
|
||||
break
|
||||
|
||||
case 'XChainClaim':
|
||||
validateXChainClaim(tx)
|
||||
break
|
||||
|
||||
default:
|
||||
throw new ValidationError(
|
||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||
|
||||
Reference in New Issue
Block a user