Skip to content

feat(#106): implement real on-chain token.transfer() in sweep() - #198

Merged
phertyameen merged 10 commits into
bridgelet-org:mainfrom
Tyler7x:feat/106-real-token-transfer
Jun 25, 2026
Merged

feat(#106): implement real on-chain token.transfer() in sweep()#198
phertyameen merged 10 commits into
bridgelet-org:mainfrom
Tyler7x:feat/106-real-token-transfer

Conversation

@Tyler7x

@Tyler7x Tyler7x commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #106

Replaces the stub comment in sweep() with real on-chain token transfers using the Soroban token::TokenClient interface.

Changes

contracts/ephemeral_account/src/lib.rs

  • Added token to the soroban_sdk import.
  • In sweep(), after setting status to Swept (re-entrancy guard), iterate over all recorded payments and call:
    token::TokenClient::new(&env, &payment.asset)
        .transfer(&contract_address, &destination, &payment.amount);
  • Updated sweep() rustdoc to describe the transfer behaviour.

contracts/ephemeral_account/src/test.rs

  • Added test_sweep_executes_token_transfer: registers a Stellar asset contract, mints 500 tokens to the ephemeral contract, records the payment, calls sweep(), then asserts the contract balance is 0 and the destination balance is 500.

Notes

  • Status is set to Swept before the token calls to prevent re-entrancy — consistent with checks-effects-interactions.
  • Existing tests that use a non-token asset address still pass because mock_all_auths() intercepts the token calls without requiring a real contract.

Testing

cargo test -p ephemeral_account

Tyler7x added 3 commits June 24, 2026 16:18
…sweep()

Replace the stub comment with actual token::TokenClient::transfer()
calls. For each recorded payment, calls:

  token::TokenClient::new(&env, &payment.asset)
      .transfer(&contract_address, &destination, &payment.amount)

Status is set to Swept before transfers to prevent re-entrancy.
Verifies that sweep() calls token::TokenClient::transfer() for each
recorded payment, moving the balance from the contract to destination.
@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

@phertyameen

Copy link
Copy Markdown
Contributor

@Tyler7x resolve conflict please

@Tyler7x

Tyler7x commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@phertyameen resolved

@phertyameen
phertyameen merged commit 181c7be into bridgelet-org:main Jun 25, 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.

Replace sweep() stub — implement real on-chain token transfer

2 participants