Skip to content

fix: validate withdraw_to recipient and document pause policy#382

Open
ayomidearegbeshola29-dev wants to merge 1 commit into
CalloraOrg:mainfrom
ayomidearegbeshola29-dev:bug/vault-withdraw-to-validation
Open

fix: validate withdraw_to recipient and document pause policy#382
ayomidearegbeshola29-dev wants to merge 1 commit into
CalloraOrg:mainfrom
ayomidearegbeshola29-dev:bug/vault-withdraw-to-validation

Conversation

@ayomidearegbeshola29-dev
Copy link
Copy Markdown

Issue #359 Implementation Complete

Summary

Successfully implemented recipient validation for withdraw_to and documented the pause-allowed behavior for emergency withdrawals.

Branch Information

  • Branch Name: bug/vault-withdraw-to-validation
  • Status: Pushed to remote
  • Commit: ae1f7ee

Changes Made

1. Code Changes (contracts/vault/src/lib.rs)

  • Added recipient validation to reject vault self-address
  • Added recipient validation to reject token contract address
  • Added comprehensive function-level documentation for withdraw and withdraw_to
  • Documented pause-allowed behavior explicitly
  • Confirmed CEI ordering with inline comments
  • State updates now occur before external token transfers

2. Test Changes (contracts/vault/src/test.rs)

Added 4 new comprehensive tests:

  • withdraw_to_vault_address_fails() - Validates self-address rejection
  • withdraw_to_token_address_fails() - Validates token-address rejection
  • withdraw_to_while_paused_succeeds() - Confirms emergency withdrawal works
  • withdraw_while_paused_succeeds() - Confirms emergency withdrawal works

3. Documentation (VAULT_WITHDRAW_COMPLIANCE.md)

  • Updated with complete implementation details
  • Added security analysis of recipient validation
  • Documented CEI pattern and its security benefits
  • Added acceptance criteria status

Files Modified

  1. contracts/vault/src/lib.rs - 150 lines changed
  2. contracts/vault/src/test.rs - 75 lines added
  3. VAULT_WITHDRAW_COMPLIANCE.md - 75 lines changed

Next Steps

Create Pull Request

Visit the following URL to create the pull request:

https://github.com/ayomidearegbeshola29-dev/Callora-Contracts/pull/new/bug/vault-withdraw-to-validation

PR Details

Acceptance Criteria Status

  • ✅ Self-address recipient rejected
  • ✅ Token-address recipient rejected
  • ✅ Pause-allowed behavior documented at function level
  • ✅ CEI ordering confirmed
  • ✅ Tests cover paused and invalid-recipient cases
  • ✅ Minimum 95% line coverage maintained
  • ✅ No unwrap() in prod paths (only checked arithmetic with guards)

Testing

All new functionality is covered by tests. To run tests:

cargo test --package callora-vault

Security Considerations

  • Recipient Guards: Prevents common mistakes that could lock funds or create accounting issues
  • CEI Pattern: Protects against reentrancy attacks
  • Pause Policy: Documented emergency recovery behavior
  • No Breaking Changes: All existing functionality preserved

Implementation completed successfully. Ready for review.

closes #359

- Add recipient validation to reject vault and token addresses
- Document pause-allowed behavior at function level for withdraw/withdraw_to
- Confirm CEI ordering with state updates before external calls
- Add comprehensive tests for recipient validation and paused withdrawals
- Update VAULT_WITHDRAW_COMPLIANCE.md with implementation details

Fixes CalloraOrg#359
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@ayomidearegbeshola29-dev 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

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.

Vault: add withdraw_to recipient validation and pause-policy documentation

1 participant