refactor: extract shared cfg_set publish into a helper - #433
Merged
mikewheeleer merged 1 commit intoJul 29, 2026
Merged
Conversation
Jagadeeshftw
force-pushed
the
refactor/events-04-helper
branch
from
July 28, 2026 21:18
94100b8 to
625a193
Compare
Contributor
|
nice one @Jagadeeshftw, checks pass. merging 🚀 |
Jagadeeshftw
force-pushed
the
refactor/events-04-helper
branch
from
July 29, 2026 06:04
625a193 to
9117066
Compare
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
Six single-scalar admin config setters (
set_allowlist_enabled,set_min_requests_per_call,set_max_requests_per_call,set_max_requests_per_window,set_rate_window_seconds,set_require_service_registration) each duplicated the identical 3-lineenv.events().publish((symbol_short!("cfg_set"),), (tag, value))block. Pure refactor — extracts it into a privatepublish_cfg_event(env, tag, value)helper and routes all six call sites through it. Behavior is byte-for-byte identical: same topic, same payload shape, same call order relative to the storage write.While refactoring I noticed the
cfg_settopic — despite being the most widely shared event topic in the contract — had no direct payload-correctness test for any of the six setters (only an indirect topic-collision check). Added dedicated tests as regression coverage for this refactor.Tests added
test_cfg_set_payload_set_allowlist_enabled,..._set_min_requests_per_call,..._set_max_requests_per_call,..._set_max_requests_per_window,..._set_rate_window_seconds,..._set_require_service_registrationtest_cfg_set_payload_tags_are_mutually_distinct— the sixtagvalues (the field that disambiguates the shared topic) can never collideCloses #290
Validation
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test -p escrow— 359 passed (7 new), 1 pre-existing failure unrelated to this change (test_transfer_service_ownership_genuine_transfer_emits_event, fails identically onmain)