[820] Idempotent whitelist/freeze with event suppression - #1001
Merged
orunganiekan merged 4 commits intoAug 31, 2026
Merged
Conversation
…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
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.
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.freeze()andunfreeze()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 eventstest_unfreeze_merchant_non_frozen_suppresses_event— unfreeze on non-frozen emits 0 eventstest_add_merchant_idempotent_suppresses_event— duplicate add emits 0 new eventstest_remove_merchant_non_whitelisted_suppresses_event— remove on non-whitelisted emits 0 eventstest_freeze_merchant_idempotent_preserves_reason— re-freeze with None preserves original reasontest_freeze_unfreeze_freeze_emits_exactly_three_events— 3 state changes → 3 eventstest_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).