You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In insurance/src/lib.rs, deactivate_policy flips Policy.active = false and removes the id from DataKey::ActivePolicies, but the policy record stays in DataKey::Policy(id) storage forever. There is no way to reactivate a policy that was deactivated by mistake, and no way to enumerate deactivated policies — get_active_policies only walks the active set, and there is no get_deactivated_policies. Deactivated policies become invisible, un-restorable storage residue.
Why this matters: insurance policies get suspended for missed payments or admin error, then resumed. A one-way deactivate with no reactivation and no visibility means an integrator must create a brand-new policy (new id, lost history) to recover — and can never audit what was deactivated. A symmetric reactivate + a deactivated-list query make the lifecycle complete and auditable.
🎯 Requirements & Context
Functional requirements
Add reactivate_policy(env, caller, policy_id) -> Result<bool, InsuranceError> that re-adds the id to ActivePolicies (respecting MAX_POLICIES), sets active = true, refreshes next_payment_date, and is authorised to the same set as deactivate_policy (policy owner or contract owner).
Add get_deactivated_policies(env, owner, cursor, limit) -> PolicyPage paginated by OwnerPolicies(owner) filtered on active == false, using clamp_limit from remitwise_common.
Emit a new PolicyReactivatedEvent and document it alongside the existing PolicyDeactivatedEvent in EVENTS.md.
Reject reactivation when it would exceed MAX_POLICIES with MaxPoliciesReached, and reject reactivating an already-active policy with a clear typed error.
Context & constraints
Soroban SDK 21.7.7. Keep PolicyPage (items: Vec<u32>, next_cursor, count) as the return shape used by get_active_policies.
Reactivation must not duplicate the id in ActivePolicies.
Factor the active-set add/remove into helpers shared by create_policy, deactivate_policy, and the new reactivate_policy.
Add /// doc-comments covering the active⇄inactive transitions and the cap interaction.
3. Test & commit
cargo test -p insurance
Edge cases: reactivate after deactivate restores into the active page; reactivating when contract is at MAX_POLICIES; get_deactivated_policies cursor termination and owner isolation; double-reactivate is rejected.
Example commit message
feat(insurance): add reactivate_policy and get_deactivated_policies
Makes policy deactivation reversible and auditable: reactivation respects
MAX_POLICIES, emits PolicyReactivatedEvent, and a new paginated query lists
inactive policies that were previously invisible.
📋 Description
In
insurance/src/lib.rs,deactivate_policyflipsPolicy.active = falseand removes the id fromDataKey::ActivePolicies, but the policy record stays inDataKey::Policy(id)storage forever. There is no way to reactivate a policy that was deactivated by mistake, and no way to enumerate deactivated policies —get_active_policiesonly walks the active set, and there is noget_deactivated_policies. Deactivated policies become invisible, un-restorable storage residue.🎯 Requirements & Context
Functional requirements
reactivate_policy(env, caller, policy_id) -> Result<bool, InsuranceError>that re-adds the id toActivePolicies(respectingMAX_POLICIES), setsactive = true, refreshesnext_payment_date, and is authorised to the same set asdeactivate_policy(policy owner or contract owner).get_deactivated_policies(env, owner, cursor, limit) -> PolicyPagepaginated byOwnerPolicies(owner)filtered onactive == false, usingclamp_limitfromremitwise_common.PolicyReactivatedEventand document it alongside the existingPolicyDeactivatedEventinEVENTS.md.MAX_POLICIESwithMaxPoliciesReached, and reject reactivating an already-active policy with a clear typed error.Context & constraints
PolicyPage(items: Vec<u32>,next_cursor,count) as the return shape used byget_active_policies.ActivePolicies.🛠️ Suggested Execution
1. Branch
2. Implement
create_policy,deactivate_policy, and the newreactivate_policy.///doc-comments covering the active⇄inactive transitions and the cap interaction.3. Test & commit
cargo test -p insuranceMAX_POLICIES;get_deactivated_policiescursor termination and owner isolation; double-reactivate is rejected.Example commit message
✅ Acceptance Criteria & Guidelines
reactivate_policy+ cap/duplicate guardsget_deactivated_policiespagination + owner isolationPolicyReactivatedEventemitted + documentedEVENTS.mdupdatedcargo test -p insurance+ clippy clean💬 Community & Support
Questions and design discussion — join the Remitwise contributor community on Discord: https://discord.gg/CtQuPZFMA
Please comment when you pick this up. 🚀