Skip to content

fix: ContractPaused(2) guard on all state-changing functions#155

Merged
levoski1 merged 2 commits into
WHEELBACK:mainfrom
Markodiba6399:fix/contract-paused-guard
Jun 27, 2026
Merged

fix: ContractPaused(2) guard on all state-changing functions#155
levoski1 merged 2 commits into
WHEELBACK:mainfrom
Markodiba6399:fix/contract-paused-guard

Conversation

@Markodiba6399

@Markodiba6399 Markodiba6399 commented Jun 27, 2026

Copy link
Copy Markdown

Summary

  • Compliance: Added is_paused/check_not_paused helpers and guards on every write function (allow_address, block_address, allow_address_until, transfer_admin, clear_address). All five now return Result<(), ContractError> and return ContractPaused(2) when paused. clear_address also gains AddressNotFound(4) when the address has no active record, and now calls storage.remove() instead of silently overwriting.
  • Treasury: Guards added to all 11 write functions. Fixed two missing error variants (Unauthorized = 5, InvalidThreshold = 6) that were referenced in code but absent from the enum. Fixed execute_settlement which never updated settlement status to Executed.
  • Invoice (COMEBACKHERE-contracts): Added missing check_not_paused guard to set_grace_window.
  • Invoice (contracts/): Expanded the stub into a working contract with nonce deduplication, expiry, pay/cancel, and paused guard; added 11 boundary tests covering all six InvoiceError variants.
  • Settlement (contracts/): Fixed pre-existing missing PartialEq/Debug derives on ApproveResult.

Test plan

  • cd contracts && cargo test — 20 tests (14 invoice + 6 settlement), all pass
  • cd COMEBACKHERE-contracts && cargo test — 31 tests (12 compliance + 4 invoice + 15 treasury), all pass
  • Paused guard tests verify ContractPaused(2) is returned before any storage mutation
  • Treasury threshold tests: partial approval → InsufficientApprovals, exact threshold → executes, over threshold → executes, zero threshold → InvalidThreshold
  • clear_address tests: removes allowed/blocked entries, returns AddressNotFound when not present or already cleared

closes #100
closes #101
closes #102
closes #103

- compliance: add is_paused/check_not_paused helpers; guard allow_address,
  block_address, allow_address_until, transfer_admin, clear_address;
  return ContractPaused(2) consistently on all write paths
- treasury: guard set_signer, propose_settlement, approve_settlement,
  execute_settlement, update_threshold, raise_dispute, resolve_dispute,
  deposit, withdraw, add/remove_token_from_allowlist; add missing
  Unauthorized=5 and InvalidThreshold=6 error variants; fix
  execute_settlement not updating status to Executed
- invoice (COMEBACKHERE-contracts): add missing check_not_paused guard
  to set_grace_window
- contracts/invoice: expand stub to full implementation with nonce
  deduplication, expiry, pay/cancel functions, and paused guard on
  create_invoice; add InvoiceError boundary tests for all six variants
  (Unauthorized, InvalidAmount, Expired, NotFound, DuplicateNonce,
  AmountPrecision)
- contracts/settlement: add missing PartialEq/Debug to ApproveResult
- feat: clear_address now returns AddressNotFound(4) when address has no
  active record instead of silently overwriting; calls storage.remove()
- test: treasury threshold/approval_weight tests covering partial
  approval, exact threshold, over-threshold, zero-threshold rejection,
  and multi-signer weight accumulation
- build: align workspace to resolver=2, soroban-sdk 20.0.0 across all
  three COMEBACKHERE contracts, bump rust-toolchain to 1.85.0 (required
  for edition2024 in transitive deps)
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Markodiba6399 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 d8ebe69 into WHEELBACK:main Jun 27, 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

3 participants