Feat/policy expired event - #248
Merged
jhayniffy merged 2 commits intoMar 29, 2026
Merged
Conversation
… outcome - Emit PolicyExpired (holder, policy_id, expiry_ledger, reported_at_ledger) once per term - Instance storage dedupe keyed by holder + policy_id + end_ledger term - process_expired keeper: NotFound / NotYetExpired / idempotent Ok - renew_policy: Ok(Lapsed) when expired so Soroban does not roll back emission - RenewPolicyOutcome enum (Renewed | Lapsed); PolicyError::Expired reserved - Read API get_pol_exp_evt_end_ledger (32-char export limit) - Tests for keeper, renew path, natural initiate + expiry Made-with: Cursor
|
@favourawaku 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an on-chain
PolicyExpiredevent and keeper hook so indexers and the notification service can detect policy expiry without scanning every policy’send_ledger. Expiry is recorded at most once per policy term (perend_ledger).closes #200
Changes
PolicyExpiredcontract event: topicsholder,policy_id; dataexpiry_ledger,reported_at_ledger. Documented thatreported_at_ledgermay be afterexpiry_ledger(keeper / caller delay).process_expired(holder, policy_id): emits whenledger >= end_ledgerif not already recorded;NotFoundif no policy;NotYetExpiredifnow < end_ledger**; idempotentOkif already notified for this term.renew_policy: if already expired, runs the same emit/dedupe path, then returnsOk(RenewPolicyOutcome::Lapsed)(notErr), so Soroban does not roll back instance storage and the event can persist. Successful renewal returnsOk(Renewed(Policy)).end_ledgerfor which expiry was already emitted (new term after renewal can emit again).get_pol_exp_evt_end_ledger: read-only helper for tests/indexers (name shortened for the 32-character Soroban export limit).contracts/niffyinsure/tests/policy_expired.rs** (keeper, renewLapsed, open-claim rejection, fullinitiate+ duration +process_expired`).Notes for integrators
renew_policysuccess +Lapsedas “no renewal; expiry notice may have been recorded,” and regenerate client bindings from the updated spec.PolicyError::Expired(118) is kept for ABI stability but is not returned fromrenew_policyanymore.policy_id(and holder) as documented on the event.Testing
cargo testincontracts/niffyinsure(all tests passing).