Skip to content

feat(ephemeral_account): recover, upgrade authority, simulate_sweep#214

Merged
phertyameen merged 40 commits into
bridgelet-org:mainfrom
JudeDaniel6:fix/issues-107-109-122-juanedaniel6
Jun 29, 2026
Merged

feat(ephemeral_account): recover, upgrade authority, simulate_sweep#214
phertyameen merged 40 commits into
bridgelet-org:mainfrom
JudeDaniel6:fix/issues-107-109-122-juanedaniel6

Conversation

@JudeDaniel6

Copy link
Copy Markdown
Contributor

Summary

Resolves all open issues assigned to JudeDaniel6 in a single PR.


Closes #107 — Recovery sweep for expired accounts

Added recover(env, caller) function:

  • Only callable after is_expired() is true
  • Caller must be creator or recovery_address (enforced via require_auth)
  • Sweeps state + reserve to recovery_address, emitting AccountExpired event
  • Returns Error::NotExpired / Error::Unauthorized / Error::InvalidStatus as appropriate

Closes #109 — Contract upgrade authority

Added upgrade(env, new_wasm_hash) function:

  • Restricted to the admin address set at deploy time
  • Admin stored in a new DataKey::Admin slot during initialize()
  • Calls env.deployer().update_current_contract_wasm()
  • Returns Error::NotUpgradeAdmin (error code 15) for non-admin callers
  • initialize() gains a new required admin: Address parameter

Closes #114 — Prevent double-initialization (already implemented)

The guard (storage::is_initialized check + Error::AlreadyInitialized) and its test (test_double_initialize_is_rejected) were already present. No code changes needed; closing via this PR.

Closes #122 — Dry-run sweep simulation endpoint

Added simulate_sweep(env, destination) -> (Vec<Payment>, u32) view function:

  • Returns the Payment list that would be transferred and an error code (0 = success)
  • Does not execute any on-chain state change
  • Surfaces NotInitialized, AlreadySwept, NoPaymentReceived, AccountExpired as numeric codes

Files changed

File Change
errors.rs Add NotUpgradeAdmin = 15
storage.rs Add DataKey::Admin, set_admin, get_admin
lib.rs Update initialize signature; add recover, upgrade, simulate_sweep
test.rs Update all initialize call-sites to 5 args; add 8 new tests

Testing

All existing tests updated for the new initialize signature. New tests added:

  • test_recover_succeeds_for_creator_after_expiry
  • test_recover_succeeds_for_recovery_address_after_expiry
  • test_recover_returns_not_expired_before_expiry
  • test_recover_returns_unauthorized_for_stranger
  • test_upgrade_returns_not_upgrade_admin_for_non_admin
  • test_simulate_sweep_returns_payments_on_happy_path
  • test_simulate_sweep_returns_error_when_no_payment
  • test_simulate_sweep_returns_error_when_expired

khaadish and others added 30 commits June 21, 2026 18:26
…Initialization

fix(sweep-controller): store creator address during initialization
…erification

fix: Implement real Ed25519 signature verification in verify_sweep_authorization()
…ansfers

feat: Implement token transfers in SweepController
Integrate-wasm-opt-into-the-build-pip
GitHub-Actions-workflow-contract-build-and-test
…pt-into-the-build-pipeline

Integrate-wasm-opt-into-the-build-pip
…nto GitHub-Actions-workflow-contract-build-and-test
fixes
…orkflow-contract-build-and-test

GitHub actions workflow contract build and test
implemented the mutil batch account
auto-deploy-contracts-to-testnet
test: add ephemeral account unit coverage
AJ0070 and others added 9 commits June 27, 2026 09:44
fixes
Experiment: add pre-authorized gas-free claim flow
fixes
…racts-to-testnet

auto-deploy-contracts-to-testnet
…org#109, bridgelet-org#122

Issue bridgelet-org#107 — recover(): auth-gated recovery sweep callable only by
creator or recovery_address after account expiry.

Issue bridgelet-org#109 — upgrade(): admin-restricted WASM upgrade via
update_current_contract_wasm(); admin stored at initialize() time.

Issue bridgelet-org#122 — simulate_sweep(): view function that returns expected
Payment vec and an error_code (0 = ok) without executing on-chain.

Supporting changes:
- initialize() accepts new  parameter
- errors.rs: add NotUpgradeAdmin (15)
- storage.rs: add Admin DataKey + get/set_admin helpers
- test.rs: update all initialize() calls to 5 args; add tests for
  recover/upgrade/simulate_sweep; add NotUpgradeAdmin to error enum test

Issue bridgelet-org#114 (double-init prevention) was already fully implemented.
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@JudeDaniel6 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 phertyameen merged commit 6436a8d into bridgelet-org:main Jun 29, 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

10 participants