Skip to content

feat(treasury): transfer tokens on deposit (#656) - #828

Merged
levoski1 merged 2 commits into
WHEELBACK:mainfrom
meshmesh001:feature/treasury-deposit-transfer
Sep 30, 2026
Merged

levoski1 merged 2 commits into
WHEELBACK:mainfrom
meshmesh001:feature/treasury-deposit-transfer

Conversation

@meshmesh001

Copy link
Copy Markdown

Summary

This PR resolves issue #656 by implementing real token transfers in the treasury deposit entrypoint, replacing the previous no-op implementation.

Changes Made

  1. Token Transfer & Custody:

    • Updated deposit(e: Env, from: Address, token: Address, amount: u64) -> Result<(), TreasuryError> to accept a token: Address parameter.
    • Enforced token allowlist verification (DataKey::TokenAllowlist), rejecting any token not on the allowlist with TreasuryError::TokenNotAllowed before pause/auth checks.
    • Enforced pause checks (check_not_paused) and caller authentication (from.require_auth()).
    • Implemented real token movement into treasury custody using the Soroban token interface: token::Client::new(&e, &token).transfer(&from, &e.current_contract_address(), &(amount as i128)).
  2. Event Emission:

    • Added deposit(env: &Env, token: &Address, from: &Address, amount: &u64) helper in COMEBACKHERE-contracts/contracts/treasury/src/events.rs.
    • Emitted deposit event upon successful deposit with (token, from, amount).
  3. ABI & Documentation Updates:

    • Regenerated abis/treasury.json ABI snapshots including the new deposit event and public function declarations.
    • Updated docs/error-codes.md documentation for TreasuryError::TokenNotAllowed.
    • Fixed CONTRACTS_ROOT directory resolution in scripts/generate_abi_metadata.py.
  4. Unit Tests:

    • Added unit tests using register_stellar_asset_contract_v2 verifying balance changes before and after deposit.
    • Added unit tests for paused state rejection and non-allowlisted token rejection paths.
    • Added test verifying event emission on deposit.

Existing Callers

  • comebackhere-frontend/src/components/TreasuryManager.tsx already constructs arguments [from, token, stroops] when submitting deposits.
  • frontend/src/components/TreasuryManagerPage/TreasuryManagerPage.tsx submits { token, amount } to /treasury/deposit.
  • README.md sequence diagram lists deposit interaction.

Closes #656
Closes #656
Closes #656
Closes #656

- Accept token address in treasury deposit entrypoint and transfer tokens into treasury
- Reject tokens that are not on the treasury allowlist
- Emit deposit event via events::deposit with token, from, and amount
- Update abis/treasury.json ABI snapshots
- Update error codes documentation for TokenNotAllowed
- Add unit tests for deposit transfer, allowlist validation, and pause checks

Closes WHEELBACK#656
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@meshmesh001 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

@levoski1
levoski1 merged commit 3e785fe into WHEELBACK:main Sep 30, 2026
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.

Implement real token transfer in treasury deposit

2 participants