mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-28 16:15:49 +00:00
add XChainClaim tx
This commit is contained in:
@@ -124,3 +124,10 @@ export interface NFTOffer {
|
|||||||
destination?: string
|
destination?: string
|
||||||
expiration?: number
|
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 { SignerListSet } from './signerListSet'
|
||||||
export { TicketCreate } from './ticketCreate'
|
export { TicketCreate } from './ticketCreate'
|
||||||
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
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 { SignerListSet, validateSignerListSet } from './signerListSet'
|
||||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||||
import { TrustSet, validateTrustSet } from './trustSet'
|
import { TrustSet, validateTrustSet } from './trustSet'
|
||||||
|
import { XChainClaim, validateXChainClaim } from './XChainClaim'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
@@ -79,6 +80,7 @@ export type Transaction =
|
|||||||
| SignerListSet
|
| SignerListSet
|
||||||
| TicketCreate
|
| TicketCreate
|
||||||
| TrustSet
|
| TrustSet
|
||||||
|
| XChainClaim
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
@@ -203,6 +205,10 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateTrustSet(tx)
|
validateTrustSet(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'XChainClaim':
|
||||||
|
validateXChainClaim(tx)
|
||||||
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user