mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-06-03 16:56:41 +00:00
add/update models
This commit is contained in:
@@ -32,8 +32,25 @@ export interface XChainAddAttestation extends BaseTransaction {
|
||||
}
|
||||
}>
|
||||
|
||||
// TODO: update this once it's been implemented in rippled
|
||||
XChainCreateAccountAttestationBatch: Array<Record<string, never>>
|
||||
XChainCreateAccountAttestationBatch: Array<{
|
||||
XChainClaimAttestationBatchElement: {
|
||||
Account: string
|
||||
|
||||
Amount: Amount
|
||||
|
||||
AttestationRewardAccount: string
|
||||
|
||||
Destination: string
|
||||
|
||||
PublicKey: string
|
||||
|
||||
Signature: string
|
||||
|
||||
WasLockingChainSend: 0 | 1
|
||||
|
||||
XChainAccountCreateCount: string
|
||||
}
|
||||
}>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,3 +50,4 @@ export { XChainClaim } from './XChainClaim'
|
||||
export { XChainCommit } from './XChainCommit'
|
||||
export { XChainCreateBridge } from './XChainCreateBridge'
|
||||
export { XChainCreateClaimID } from './XChainCreateClaimID'
|
||||
export { SidechainXChainAccountCreate } from './sidechainXChainAccountCreate'
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount, XChainBridge } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
export interface SidechainXChainAccountCreate extends BaseTransaction {
|
||||
TransactionType: 'SidechainXChainAccountCreate'
|
||||
|
||||
XChainBridge: XChainBridge
|
||||
|
||||
SignatureReward: number | string
|
||||
|
||||
Destination: string
|
||||
|
||||
Amount: Amount
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the form and type of a SidechainXChainAccountCreate at runtime.
|
||||
*
|
||||
* @param tx - A SidechainXChainAccountCreate Transaction.
|
||||
* @throws When the SidechainXChainAccountCreate is malformed.
|
||||
*/
|
||||
export function validateSidechainXChainAccountCreate(
|
||||
tx: Record<string, unknown>,
|
||||
): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.XChainBridge == null) {
|
||||
throw new ValidationError(
|
||||
'SidechainXChainAccountCreate: missing field XChainBridge',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.SignatureReward == null) {
|
||||
throw new ValidationError(
|
||||
'SidechainXChainAccountCreate: missing field SignatureReward',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.Destination == null) {
|
||||
throw new ValidationError(
|
||||
'SidechainXChainAccountCreate: missing field Destination',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.Amount == null) {
|
||||
throw new ValidationError(
|
||||
'SidechainXChainAccountCreate: missing field Amount',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,10 @@ import {
|
||||
validatePaymentChannelFund,
|
||||
} from './paymentChannelFund'
|
||||
import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
|
||||
import {
|
||||
SidechainXChainAccountCreate,
|
||||
validateSidechainXChainAccountCreate,
|
||||
} from './sidechainXChainAccountCreate'
|
||||
import { SignerListSet, validateSignerListSet } from './signerListSet'
|
||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||
import { TrustSet, validateTrustSet } from './trustSet'
|
||||
@@ -98,6 +102,7 @@ export type Transaction =
|
||||
| XChainCommit
|
||||
| XChainCreateBridge
|
||||
| XChainCreateClaimID
|
||||
| SidechainXChainAccountCreate
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -242,6 +247,9 @@ export function validate(transaction: Record<string, unknown>): void {
|
||||
validateXChainCreateClaimID(tx)
|
||||
break
|
||||
|
||||
case 'SidechainXChainAccountCreate':
|
||||
validateSidechainXChainAccountCreate(tx)
|
||||
|
||||
default:
|
||||
throw new ValidationError(
|
||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||
|
||||
Reference in New Issue
Block a user