Skip to content

feat: implement pausable functionality for critical contract operations - #35

Merged
Divineifed1 merged 1 commit into
Exquisitech:mainfrom
BigJohn-dev:Implement-pausable-functionality-for-critical-contract-operations
Jul 30, 2026
Merged

feat: implement pausable functionality for critical contract operations#35
Divineifed1 merged 1 commit into
Exquisitech:mainfrom
BigJohn-dev:Implement-pausable-functionality-for-critical-contract-operations

Conversation

@BigJohn-dev

Copy link
Copy Markdown
Contributor

Closes #25

Summary

Completes pausable functionality for critical contract operations in the renaissance-vault contract, bringing it in line with renaissance-betting and renaissance-rewards (which already ship a Pausable utility).

The vault already had the infrastructure — a Paused storage key and an ensure_not_paused guard on its critical functions — but the wiring was incomplete: there were no public pause()/unpause() entry points, so the vault could never actually be paused, and pause failures surfaced as a misleading InvalidAmount error.

Changes

vault/src/lib.rs

  • Public pause() / unpause() / is_paused() functions, gated to the vault admin via a new require_admin helper (Address::require_auth). pause() is idempotent.
  • pause/unpause emit Paused / Unpaused events logging the admin account that triggered the action.
  • Added a clear VaultError::Paused (208) variant (plus Unauthorized (209)). ensure_not_paused now returns Paused directly instead of masquerading as InvalidAmount.
  • The four critical state-changing functions — deposit, withdraw, lock_for_bet, payout — already called ensure_not_paused, so they now revert with the clear Paused error when the vault is paused.

vault/src/test.rs

  • The pre-existing test file no longer compiled against the pinned soroban-sdk 21.4.0 (stale .get_address() / .mint() / AddressEnvTestUtils API, 87 errors). Rewrote it to the current SDK API, matching the working patterns in the betting crate, preserving all prior coverage.
  • Added Pausable unit tests:
    • pause/unpause toggle state; pause idempotency
    • Paused / Unpaused events emitted and logging the admin
    • pause requires admin auth
    • deposit / withdraw / lock_for_bet / payout revert with Paused while paused
    • operations resume after unpause

Acceptance criteria

  • Contract includes a standard Pausable utility
  • pause() / unpause() protected by an admin/owner check
  • Critical state-changing functions guarded by the not-paused check (deposit, withdraw, lock_for_bet, payout)
  • Calling a pausable function while paused reverts with a clear error (VaultError::Paused)
  • pause() / unpause() emit Paused / Unpaused events logging the triggering account
  • Unit tests verify correct execution when not paused and reverts when paused

@Divineifed1

Copy link
Copy Markdown
Contributor

@BigJohn-dev fix CI

@Divineifed1
Divineifed1 merged commit 6904d96 into Exquisitech:main Jul 30, 2026
1 of 2 checks passed
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.

Title: feat: Implement pausable functionality for critical contract operations

2 participants