From 82d0d12d8187caabaddcbf72a63ecede1ee36a87 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 7 Feb 2023 15:25:04 -0500 Subject: [PATCH] add validate for new txs --- .../XChainAddAccountCreateAttestation.ts | 54 ++++++++++++++++++ .../transactions/XChainAddClaimAttestation.ts | 56 ++++++++++++++++++- 2 files changed, 109 insertions(+), 1 deletion(-) diff --git a/packages/xrpl/src/models/transactions/XChainAddAccountCreateAttestation.ts b/packages/xrpl/src/models/transactions/XChainAddAccountCreateAttestation.ts index 207eaafa..99cee911 100644 --- a/packages/xrpl/src/models/transactions/XChainAddAccountCreateAttestation.ts +++ b/packages/xrpl/src/models/transactions/XChainAddAccountCreateAttestation.ts @@ -42,6 +42,60 @@ export function validateXChainAddAccountCreateAttestation( ): void { validateBaseTransaction(tx) + if (tx.Amount == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.Amount', + ) + } + + if (tx.AttestationRewardAccount == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.AttestationRewardAccount', + ) + } + + if (tx.Destination == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.Destination', + ) + } + + if (tx.OtherChainSource == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.OtherChainSource', + ) + } + + if (tx.PublicKey == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.PublicKey', + ) + } + + if (tx.Signature == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.Signature', + ) + } + + if (tx.SignatureReward == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.SignatureReward', + ) + } + + if (tx.WasLockingChainSend == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.WasLockingChainSend', + ) + } + + if (tx.XChainAccountCreateCount == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.XChainAccountCreateCount', + ) + } + if (tx.XChainBridge == null) { throw new ValidationError( 'XChainAddAccountCreateAttestation: missing field tx.XChainBridge', diff --git a/packages/xrpl/src/models/transactions/XChainAddClaimAttestation.ts b/packages/xrpl/src/models/transactions/XChainAddClaimAttestation.ts index b2e2deb3..f59222fc 100644 --- a/packages/xrpl/src/models/transactions/XChainAddClaimAttestation.ts +++ b/packages/xrpl/src/models/transactions/XChainAddClaimAttestation.ts @@ -40,9 +40,63 @@ export function validateXChainAddClaimAttestation( ): void { validateBaseTransaction(tx) + if (tx.Amount == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.Amount', + ) + } + + if (tx.AttestationRewardAccount == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.AttestationRewardAccount', + ) + } + + if (tx.Destination != null && typeof tx.Destination !== 'string') { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: invalid field tx.Destination', + ) + } + + if (tx.OtherChainSource == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.OtherChainSource', + ) + } + + if (tx.PublicKey == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.PublicKey', + ) + } + + if (tx.Signature == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.Signature', + ) + } + + if (tx.WasLockingChainSend == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.WasLockingChainSend', + ) + } + + if (tx.XChainAccountCreateCount == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.XChainAccountCreateCount', + ) + } + if (tx.XChainBridge == null) { throw new ValidationError( - 'XChainAddClaimAttestation: missing field tx.XChainBridge', + 'XChainAddAccountCreateAttestation: missing field tx.XChainBridge', + ) + } + + if (tx.XChainClaimID == null) { + throw new ValidationError( + 'XChainAddAccountCreateAttestation: missing field tx.XChainClaimID', ) } }