This commit is contained in:
Mayukha Vadari
2022-07-31 16:55:38 +02:00
parent dab0667b2f
commit c4dd6fba84
2 changed files with 14 additions and 4 deletions

View File

@@ -66,19 +66,28 @@ export function validateXChainAddAttestation(
): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
if (tx.XChainAttestationBatch == null) {
throw new ValidationError(
'XChainAddAttestation: missing field XChainBridge',
'XChainAddAttestation: missing field XChainAttestationBatch',
)
}
if (tx.XChainClaimAttestationBatch == null) {
if (typeof tx.XChainAttestationBatch !== 'object') {
throw new ValidationError(
'XChainAddAttestation: XChainAttestationBatch must be an object',
)
}
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- known to be this */
const attestationBatch = tx.XChainAttestationBatch as Record<string, unknown>
if (attestationBatch.XChainClaimAttestationBatch == null) {
throw new ValidationError(
'XChainAddAttestation: missing field XChainClaimAttestationBatch',
)
}
if (tx.XChainCreateAccountAttestationBatch == null) {
if (attestationBatch.XChainCreateAccountAttestationBatch == null) {
throw new ValidationError(
'XChainAddAttestation: missing field XChainCreateAccountAttestationBatch',
)

View File

@@ -249,6 +249,7 @@ export function validate(transaction: Record<string, unknown>): void {
case 'SidechainXChainAccountCreate':
validateSidechainXChainAccountCreate(tx)
break
default:
throw new ValidationError(