mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-08-23 16:40:52 +00:00
add validate for new txs
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user