Problem
The resource_credits contract can deduct credits without validating the balance, potentially allowing negative credit balances that corrupt member state.
Proposed Solution
Create contracts/cntr/credit_deduction.rs implementing pub fn validate_deduction(current_balance: i128, deduction_amount: i128) -> Result<i128, &'static str>. Returns Ok(new_balance) only when deduction_amount > 0 and current_balance >= deduction_amount. All implementation must live inside contracts/cntr/.
Acceptance Criteria
Problem
The resource_credits contract can deduct credits without validating the balance, potentially allowing negative credit balances that corrupt member state.
Proposed Solution
Create
contracts/cntr/credit_deduction.rsimplementingpub fn validate_deduction(current_balance: i128, deduction_amount: i128) -> Result<i128, &'static str>. ReturnsOk(new_balance)only whendeduction_amount > 0andcurrent_balance >= deduction_amount. All implementation must live insidecontracts/cntr/.Acceptance Criteria
contracts/cntr/credit_deduction.rsErr("Deduction amount must be positive")whendeduction_amount <= 0Err("Insufficient credits")when balance would go negativeOk(current_balance - deduction_amount)on successcargo test