Skip to content

feat(issue-116): add shared validation helpers#135

Merged
Ibinola merged 1 commit intoLead-Studios:mainfrom
mxllv:feat/issue-116-shared-validation-helpers
Mar 28, 2026
Merged

feat(issue-116): add shared validation helpers#135
Ibinola merged 1 commit intoLead-Studios:mainfrom
mxllv:feat/issue-116-shared-validation-helpers

Conversation

@mxllv
Copy link
Copy Markdown
Contributor

@mxllv mxllv commented Mar 28, 2026

Summary

Added a small shared validation module so token-core and escrow paths can reuse the same checks for metadata inputs, amount semantics, ledger expiration boundaries, and frozen-account guards.

Changes

  • Added src/validation.rs with shared helpers for non-empty strings, decimal bounds, positive/non-negative amounts, expiration-ledger validation, and frozen-account checks
  • Updated metadata.rs to use the shared metadata validation helpers
  • Updated allowance.rs to use shared checks for non-negative allowance amounts and current-or-future expiration ledgers
  • Updated contract.rs, balance.rs, and escrow.rs to use shared positive-amount and frozen-account validation where those checks were duplicated or missing
  • Files affected: veritixpay/contract/token/src/lib.rs, veritixpay/contract/token/src/validation.rs, veritixpay/contract/token/src/metadata.rs, veritixpay/contract/token/src/allowance.rs, veritixpay/contract/token/src/balance.rs, veritixpay/contract/token/src/escrow.rs, veritixpay/contract/token/src/contract.rs

Validation

  • cd veritixpay/contract/token && cargo +stable build
  • cd veritixpay/contract/token && cargo +stable test
  • Results: build passed; tests passed (19 passed, 16 ignored)

Mismatch Handling (if applicable)

  • The current repo already had metadata validation in one place, frozen-account checks repeated in several others, and amount/expiration validation either duplicated or missing depending on the path
  • Added only the smallest viable scaffold: one focused validation.rs module and the direct call-site updates needed in token-core and escrow paths
  • The solution was kept minimal by avoiding broader storage, auth, or arithmetic refactors

Notes

  • approve continues to allow 0 as a revoke path, while negative allowances are now rejected through the shared helper
  • This branch intentionally centralizes validation only; it does not change event schemas or storage layout

Closes #116

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@mxllv Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ibinola Ibinola merged commit 8431b10 into Lead-Studios:main Mar 28, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a shared validation helper module for reusable input checks

2 participants