feat(events): contract pause, unpause, config-updated and approval-revoked events - #938
Merged
Merged
Conversation
…voked events Implements the four administrative lifecycle events tracked by ANYTECHS#931–ANYTECHS#934. New event types (clips_nft/src/types.rs): - ContractPausedEvent — admin, optional reason, timestamp (ANYTECHS#933) - ContractUnpausedEvent — admin, timestamp (ANYTECHS#934) - ConfigUpdatedEvent — field, previous value, new value, admin, timestamp, with ConfigField/ConfigValue (ANYTECHS#932) - ApprovalRevokedEvent — owner, approved account, scope (token id or all-tokens), timestamp (ANYTECHS#931) New emitter modules, one per event family, following the existing `*_event.rs` convention: - pause_event.rs → "ctr_pause" / "ctr_unpse" - config_updated_event.rs → "cfg_updt" - approval_revoked_event.rs → "aprv_rvk" Emission is wired to real state changes: - ClipsNftContract::pause / unpause / is_paused — admin-gated via config_guard, refusing a redundant pause or unpause so a received event always marks an actual transition - config::set_config now emits one typed ConfigUpdatedEvent per changed setting, replacing the ad-hoc `ConfigUpdateEvent`. Coverage widens from four fields to every field, including max_batch_transfer_size, version and the owner address, which previously changed silently - payment_currency::add_currency_by / remove_currency_by and the matching add_currency / remove_currency entry points report supported-asset changes - token_approval::revoke_approval and operator_approval::revoke_operator remove the permission and emit; both are no-ops that emit nothing when there was no approval to revoke Also fixes the crate build, which was broken on main by conflicting event definitions merged in ANYTECHS#936: duplicated `pub use` re-exports in marketplace/mod.rs, `ListingCancelledEvent`/`NftSoldEvent` defined and re-exported in marketplace/types.rs, a missing ListingId import, two interleaved emit_listing_cancelled call sites, a RoyaltyPaidEvent literal missing sale_reference, and a create_listing call passing a shared reference where a mutable one is required. 15 integration tests in clips_nft/tests/test_admin_lifecycle_events.rs cover every event, both the emitting and the silent path. Closes ANYTECHS#931 Closes ANYTECHS#932 Closes ANYTECHS#933 Closes ANYTECHS#934 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@Calebux 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.
Implements the four administrative lifecycle events tracked by #931–#934.
Closes #931
Closes #932
Closes #933
Closes #934
Event types
Added to
clips_nft/src/types.rs:ContractPausedEventctr_pauseContractUnpausedEventctr_unpseConfigUpdatedEventcfg_updtApprovalRevokedEventaprv_rvkConfigUpdatedEventcarries aConfigFieldenum (platform fee, max royalty, batch size, supported asset, mint cooldown, admin, contract limit) and aConfigValueenum (Unset/Number/Address), so numeric and address settings share one event shape while still reporting both the previous and the new value.ApprovalRevokedEventcarries anApprovalScopeof eitherToken(id)for a single-token approval orAllTokensfor an operator permission, covering the issue's "token ID or approval scope".Emitters live in three new modules that follow the existing
*_event.rsconvention:pause_event.rs,config_updated_event.rs,approval_revoked_event.rs.Where the events fire
ClipsNftContract::pause/unpause/is_paused— new admin-gated entry points. There was previously no way to reachpause_state, so the pause events had no trigger. Both refuse a redundant call (ContractPaused/NotPaused), which means a received event always marks a real transition.config::set_config— now emits one typedConfigUpdatedEventper setting that actually changed. This replaces the ad-hocConfigUpdateEvent(a free-textkeyplus twou32s, which could not represent an address). Coverage widens from four fields to every field, includingmax_batch_transfer_size,versionand theowneraddress, all of which previously changed silently.payment_currency::add_currency_by/remove_currency_byand the matchingadd_currency/remove_currencyentry points — report supported-asset changes.token_approval::revoke_approval/operator_approval::revoke_operator— remove the permission and emit. Both are no-ops that emit nothing when there was no approval to revoke, so subscribers never see a phantom revocation.Breaking change
config::ConfigUpdateEventand the"config_update"topic are replaced byConfigUpdatedEventon"cfg_updt". Nothing in the repository consumed the old shape, but any external indexer watching"config_update"needs updating.Build fix included
maindid not compile before this branch. The conflicting event definitions merged in #936 left:pub usere-exports inmarketplace/mod.rsListingCancelledEventandNftSoldEventboth defined and re-exported fromevents::listinginmarketplace/types.rsListingIdimport inmarketplace/types.rsemit_listing_cancelledcall sites (lib.rs::cancel_listing,marketplace/listing_validator.rs::cancel_listing) — one of them a syntax errorRoyaltyPaidEventliteral missing thesale_referencefieldcreate_listingpassing&listingwhere&mut ListingRequestis requiredThose are fixed here because the new events cannot be built or tested otherwise. In each case the centralised
events::listingmodule won, per its own module docs. The resolution is minimal — no behaviour beyond making the two competing versions agree.Still failing on this branch, and out of scope:
cargo test --lib(thesrc/tests/modules) and several older integration test targets do not compile, mostly from soroban-sdk API drift and the same #936 merge. That is pre-existing and worth its own issue.Tests
clips_nft/tests/test_admin_lifecycle_events.rs— 15 integration tests through the contract client, asserting the full(emitter, topics, data)tuple for each event:Every event is covered on both paths: it fires on a real state change, and stays silent on a no-op or a rejected call (already paused, non-admin caller, duplicate asset, absent approval).
🤖 Generated with Claude Code