Skip to content

feat(#105): lock sweep destination to one address per account - #197

Merged
phertyameen merged 11 commits into
bridgelet-org:mainfrom
Tyler7x:fix/105-lock-sweep-destination
Jun 25, 2026
Merged

feat(#105): lock sweep destination to one address per account#197
phertyameen merged 11 commits into
bridgelet-org:mainfrom
Tyler7x:fix/105-lock-sweep-destination

Conversation

@Tyler7x

@Tyler7x Tyler7x commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #105

Implements the single-destination restriction for sweep(). Once the function is called successfully, the destination address is persisted in contract storage and any subsequent sweep attempt with a different address is rejected.

Changes

contracts/ephemeral_account/src/storage.rs

  • Added SweepDestination variant to DataKey.
  • Added set_sweep_destination / get_sweep_destination helpers.

contracts/ephemeral_account/src/errors.rs

  • Added Error::SweepDestinationLocked = 15 — returned when a sweep is attempted with a destination that differs from the locked address.

contracts/ephemeral_account/src/lib.rs

  • In sweep(): before executing, check get_sweep_destination. If already set and differs from destination, return SweepDestinationLocked. Otherwise, persist the destination on the first call.
  • Updated sweep() rustdoc to document the locking behaviour.

contracts/ephemeral_account/src/test.rs

  • Added test_sweep_destination_locked: creates an account, pre-populates SweepDestination via env.as_contract, then calls sweep() with a different address and asserts Error(Contract, #15).

Testing

cargo test -p ephemeral_account

Tyler7x added 5 commits June 24, 2026 16:14
…account

On first sweep() call the destination is stored under SweepDestination
in contract storage. Any subsequent sweep() call with a different
destination is rejected with Error::SweepDestinationLocked (bridgelet-org#15).
Verifies that sweeping with a different destination than the locked
one reverts with Error::SweepDestinationLocked (bridgelet-org#15).
@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 please resolve conflict

@phertyameen

Copy link
Copy Markdown
Contributor

@Tyler7x Please resolve conflict

@phertyameen
phertyameen merged commit 7511fa0 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.

Lock sweep destination to one address per account

2 participants