diff --git a/packages/xrpl/src/models/transactions/XChainAddAttestation.ts b/packages/xrpl/src/models/transactions/XChainAddAttestation.ts index 121c1e0e..dfbc8e14 100644 --- a/packages/xrpl/src/models/transactions/XChainAddAttestation.ts +++ b/packages/xrpl/src/models/transactions/XChainAddAttestation.ts @@ -32,8 +32,25 @@ export interface XChainAddAttestation extends BaseTransaction { } }> - // TODO: update this once it's been implemented in rippled - XChainCreateAccountAttestationBatch: Array> + XChainCreateAccountAttestationBatch: Array<{ + XChainClaimAttestationBatchElement: { + Account: string + + Amount: Amount + + AttestationRewardAccount: string + + Destination: string + + PublicKey: string + + Signature: string + + WasLockingChainSend: 0 | 1 + + XChainAccountCreateCount: string + } + }> } /** diff --git a/packages/xrpl/src/models/transactions/index.ts b/packages/xrpl/src/models/transactions/index.ts index 66741134..0327bdb8 100644 --- a/packages/xrpl/src/models/transactions/index.ts +++ b/packages/xrpl/src/models/transactions/index.ts @@ -50,3 +50,4 @@ export { XChainClaim } from './XChainClaim' export { XChainCommit } from './XChainCommit' export { XChainCreateBridge } from './XChainCreateBridge' export { XChainCreateClaimID } from './XChainCreateClaimID' +export { SidechainXChainAccountCreate } from './sidechainXChainAccountCreate' diff --git a/packages/xrpl/src/models/transactions/sidechainXChainAccountCreate.ts b/packages/xrpl/src/models/transactions/sidechainXChainAccountCreate.ts new file mode 100644 index 00000000..4043be34 --- /dev/null +++ b/packages/xrpl/src/models/transactions/sidechainXChainAccountCreate.ts @@ -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, +): 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', + ) + } +} diff --git a/packages/xrpl/src/models/transactions/transaction.ts b/packages/xrpl/src/models/transactions/transaction.ts index 06c84c11..ca6b4c2e 100644 --- a/packages/xrpl/src/models/transactions/transaction.ts +++ b/packages/xrpl/src/models/transactions/transaction.ts @@ -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): void { validateXChainCreateClaimID(tx) break + case 'SidechainXChainAccountCreate': + validateSidechainXChainAccountCreate(tx) + default: throw new ValidationError( `Invalid field TransactionType: ${tx.TransactionType}`,