Validation Updates #52
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updated the validation logic for AssignDeposit and CreateVault actions in accordance with system prompt updates on the web app.
Summary
This PR does 2 things:
Adds validation support for
CreateVaultintentions, updates fee validation forAssignDepositintentions,CreateVaultintentions can now have empty arrays for inputs, outputs, and all fee fields, whileAssignDepositnow allows emptytotalFeearrays (previously required non-empty with zero amounts). Both action types have consistent validation patterns and return early after processing to skip unnecessary balance checks. These changes have been reflected in the system prompt as well.Fully extracts validator functions to
utils/validator.tsusing a factory pattern. per feedback in [WIP] Assign Deposit Handling #48All validation logic is now centralized in
validator.tswith contract dependencies injected via a factory function.Changes Made
AssignDeposit Validation Updates
validateAssignDepositStructure()(src/utils/validator.ts):totalFeevalidation to allow empty arrays; if not empty, all amounts must be'0'src/proposer.tsto reflect the newtotalFeeruleCreateVault Validation
validateCreateVaultStructure()function (src/utils/validator.ts):inputs,outputs, and all fee arrays must be emptyvalidateIntention()function (src/utils/validator.ts):CreateVaultactions using optional validation functionssrc/utils/validator.ts):validateIntentionInputsOptional(): Allows empty arrays for inputsvalidateIntentionOutputsOptional(): Allows empty arrays for outputshandleIntention()function (src/proposer.ts):validateCreateVaultStructure()before processing CreateVault intentionsValidator Extraction (Factory Pattern)
src/utils/validator.ts:VaultIdValidatorinterface for contract dependencycreateValidators()factory that returns configuredvalidateVaultIdOnChainandvalidateAssignDepositStructurefunctionssrc/proposer.ts:initializeWalletAndContract()to use factory pattern after contract initializationValidation Consistency
AssignDepositandCreateVaultfollow the same pattern:validateIntention()first