Skip to content

feat: implement Treasury.withdraw_fees() with unit tests (#965) - #1176

Merged
Ehonrie merged 2 commits into
Netwalls:mainfrom
adewuyito:feat/issue-965-withdraw-fees
Jul 29, 2026
Merged

feat: implement Treasury.withdraw_fees() with unit tests (#965)#1176
Ehonrie merged 2 commits into
Netwalls:mainfrom
adewuyito:feat/issue-965-withdraw-fees

Conversation

@adewuyito

@adewuyito adewuyito commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements withdraw_fees() in the Treasury smart contract with all acceptance criteria:

  • Admin authorization via admin.require_auth()
  • Validates amount <= BALANCE before withdrawal
  • Transfers XLM to recipient via token::Client
  • Logs withdrawal to WITHDRAWAL_LOG and emits FeesWithdrawn event

Changes

  • contracts/treasury/src/lib.rs: withdraw_fees() fully implemented with 6 new unit tests
  • contracts/treasury/src/lib.rs: deposit_fees() duplicate let caller removed
  • contracts/shared/src/lib.rs: stray #![no_std] and duplicate pub mod types removed
  • contracts/shared/src/types.rs: Option<Outcome> replaced with OptionalOutcome enum (Soroban SDK v27 compatibility)

Testing

All 10 unit tests pass:

  • test_withdraw_fees_happy_path
  • test_withdraw_fees_full_balance
  • test_withdraw_fees_exceeds_balance_panics
  • test_withdraw_fees_non_admin_panics
  • test_withdraw_fees_multiple_withdrawals_logged
  • test_withdraw_fees_zero_balance_panics
  • 4 existing initialize tests

Resolves #965

- Implements withdraw_fees() in the Treasury smart contract
- Admin authorization via admin.require_auth()
- Validates amount <= BALANCE before withdrawal
- Transfers XLM to recipient via token::Client
- Logs withdrawal to WITHDRAWAL_LOG and emits FeesWithdrawn event

Changes:
- contracts/treasury/src/lib.rs: withdraw_fees() fully implemented
- contracts/treasury/src/lib.rs: deposit_fees() duplicate caller removed
- contracts/treasury/src/lib.rs: bare amount expression removed
- contracts/shared/src/lib.rs: stray #![no_std] and duplicate module removed
- contracts/shared/src/types.rs: Option<Outcome> -> OptionalOutcome enum

Tests: 10 passed (6 new + 4 existing)

Resolves Netwalls#965
@adewuyito
adewuyito force-pushed the feat/issue-965-withdraw-fees branch from dd0e95b to 06cd957 Compare July 29, 2026 09:01
@Ehonrie
Ehonrie merged commit fa363cb into Netwalls:main Jul 29, 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.

[contracts] Implement Treasury.withdraw_fees()

2 participants