Skip to content

[CT-13] Implement Workspace Owner Withdrawal Validator in Rust #1030

@devwums

Description

@devwums

Problem

No logic validates whether a workspace owner is eligible to withdraw their accumulated escrow earnings. Withdrawals lack caller verification and balance checks.

Proposed Solution

Create contracts/cntr/withdrawal_validator.rs implementing pub fn validate_withdrawal(owner_address: &str, caller_address: &str, available_balance: i128, requested_amount: i128) -> Result<(), &'static str>. Validates: caller must be the owner, amount must be positive, amount must not exceed available balance. All implementation must live inside contracts/cntr/.

Acceptance Criteria

  • File at contracts/cntr/withdrawal_validator.rs
  • Returns Err("Unauthorized: caller is not the owner") when caller != owner
  • Returns Err("Withdrawal amount must be positive") when requested_amount <= 0
  • Returns Err("Insufficient balance") when requested_amount > available_balance
  • Returns Ok(()) when all validations pass
  • At least 6 unit tests covering all error branches and the success path
  • Compiles with cargo test

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions