Skip to content

[820] Idempotent whitelist/freeze with event suppression - #1001

Merged
orunganiekan merged 4 commits into
SiLioLabs:masterfrom
gloriaibrahim2002-blip:fix/820-idempotent-whitelist-freeze-events
Aug 31, 2026
Merged

[820] Idempotent whitelist/freeze with event suppression#1001
orunganiekan merged 4 commits into
SiLioLabs:masterfrom
gloriaibrahim2002-blip:fix/820-idempotent-whitelist-freeze-events

Conversation

@gloriaibrahim2002-blip

Copy link
Copy Markdown
Contributor

Closes #820

Summary

Idempotent Admin Mutations

Standardized the idempotent policy across all whitelist/freeze admin operations: when an operation is a noop (storage already in the desired state), no storage is written and no event is emitted. This prevents event spam to indexers when keepers or admin scripts retry operations.

Changes

contract/src/whitelist.rs:

  • freeze(): Added early return if already frozen. No storage write, no event emitted on noop.
  • unfreeze(): Added early return if not frozen. No storage write, no event emitted on noop.
  • add_merchant(): Already idempotent (existing early return, no event) — unchanged.
  • remove_merchant(): Already idempotent (existing early return, no event) — unchanged.
  • Added doc comments to freeze() and unfreeze() explaining the idempotency policy.

Tests Added

7 new tests verifying event suppression on noops:

  • test_freeze_merchant_idempotent_suppresses_event — duplicate freeze emits 0 new events
  • test_unfreeze_merchant_non_frozen_suppresses_event — unfreeze on non-frozen emits 0 events
  • test_add_merchant_idempotent_suppresses_event — duplicate add emits 0 new events
  • test_remove_merchant_non_whitelisted_suppresses_event — remove on non-whitelisted emits 0 events
  • test_freeze_merchant_idempotent_preserves_reason — re-freeze with None preserves original reason
  • test_freeze_unfreeze_freeze_emits_exactly_three_events — 3 state changes → 3 events
  • test_freeze_freeze_unfreeze_unfreeze_emits_two_events — 4 calls → 2 events (2 noops)

All 443 tests pass (2 pre-existing failures in upstream unrelated to this change).

gloriaibrahim2002-blip and others added 4 commits August 31, 2026 11:36
…Labs#820)

- freeze(): early return if already frozen — no storage write, no event
- unfreeze(): early return if not frozen — no storage write, no event
- add_merchant(): already idempotent (existing early return, no event)
- remove_merchant(): already idempotent (existing early return, no event)
- Added doc comments explaining the idempotency policy for each function
- Added 7 new tests verifying event suppression on noops:
  - test_freeze_merchant_idempotent_suppresses_event
  - test_unfreeze_merchant_non_frozen_suppresses_event
  - test_add_merchant_idempotent_suppresses_event
  - test_remove_merchant_non_whitelisted_suppresses_event
  - test_freeze_merchant_idempotent_preserves_reason
  - test_freeze_unfreeze_freeze_emits_exactly_three_events
  - test_freeze_freeze_unfreeze_unfreeze_emits_two_events
- Fixed pre-existing broken functions in test.rs:
  - test_estimate_does_not_perform_auto_resume_storage_writes (missing body)
  - test_subscribe_contract_as_user_panics (missing closing brace)
- App.tsx: remove duplicate imports, duplicate state declarations, fix
  broken JSX (unclosed gate banner, unclosed RPC failure banner)
- stellar.test.ts: close missing describe block, deduplicate imports
- ConfirmModal.tsx: merge duplicate button opening tags
- PayPerUseForm.tsx: remove duplicate forwardRef signature, add missing
  imports (useMemo, validateStroopAmount), remove incomplete handleSubmit
- SubscribeForm.tsx: remove duplicate variable declarations, fix missing
  && operator, fix undefined amount references
- stellar.ts: remove duplicate const account declaration
- scripts/package.json: remove duplicate key, fix missing comma
@orunganiekan
orunganiekan merged commit 44f8ba6 into SiLioLabs:master Aug 31, 2026
0 of 3 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.

Issue 024: Implement idempotent whitelist and freeze operations with event suppression rules

2 participants