Skip to content

Insurance: add pause/unpause guard coverage for create_policy, pay_premium, and deactivate_policy #714

@Baskarayelu

Description

@Baskarayelu

📋 Description

remittance_split, savings_goals, and bill_payments all gate their state-mutating entrypoints behind a pause flag (is_paused, pause, unpause, and in some cases per-function pause). The insurance contract in insurance/src/lib.rs has no pause mechanism at all — its DataKey enum has no Paused/PauseAdmin variants and none of its mutators check a kill switch.

Why this matters: When the emergency_killswitch is triggered during an incident, insurance is a hole in the perimeter: premiums and policy creation keep flowing while every other contract is frozen. A consistent pause guard is a baseline security control for a financial contract.

🎯 Requirements & Context

Functional requirements

  • Add Paused, PauseAdmin, and UpgradeAdmin to DataKey, plus set_pause_admin, pause, unpause, is_paused, set_upgrade_admin, get_upgrade_admin_public, and get_version/set_version entrypoints, matching the signatures used in savings_goals.
  • Insert a paused check at the top of create_policy, pay_premium, batch_pay_premiums, set_external_ref, and deactivate_policy; read-only getters remain callable while paused.
  • Use the existing ContractPaused/UnauthorizedPause naming convention (add variants to InsuranceError).
  • Authorize pause/admin operations against a configurable pause admin set at init.

Context & constraints

  • Soroban SDK 21.7.7, #![no_std]. Pause state lives in INSTANCE storage; bump TTL on mutation.
  • Keep behavior identical to the savings_goals pause module so it is reviewable by analogy.

🛠️ Suggested Execution

1. Fork & branch

git checkout -b feat/insurance-pause-guard

2. Implement changes

  • Add a private require_not_paused helper called by each mutator.
  • Add doc comments on each new entrypoint.
  • Tests: paused mutator rejected; getter still works; unauthorized pause rejected; unpause restores.

3. Test & commit

cargo test -p insurance -- --nocapture
  • Edge cases: pause then unpause then mutate; non-admin attempting pause; pause admin rotation.

Example commit message

feat(insurance): add pause guard to state-mutating entrypoints

Adds pause/unpause/admin controls and gates create_policy,
pay_premium and deactivate_policy, aligning insurance with the
workspace kill-switch posture.

✅ Acceptance Criteria & Guidelines

Requirement Target
All mutators gated by pause check Required
Read-only getters unaffected by pause Required
Pause-path test coverage ≥ 95%
cargo test -p insurance + clippy clean Required
Timeframe 96 hours from assignment

💬 Community & Support

Questions and help getting set up — join the Remitwise contributor community on Discord: https://discord.gg/CtQuPZFMA

Please comment when you pick this up so we avoid duplicate work. 🚀

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions