**Title:** fix: publish all four bulk payment contract events to the ledger - #570
Merged
Wilfred007 merged 4 commits intoAug 20, 2026
Merged
Conversation
added 4 commits
August 19, 2026 14:54
The BatchExecutedEvent struct was being constructed as a bare expression and immediately dropped, so no event was ever emitted to the ledger. Add .publish(&env) call so the event reaches the Soroban event stream.
…h_partial Both per-payment event structs were constructed and immediately dropped inside the partial batch loop. Add .publish(&env) calls so each individual payment outcome is emitted to the ledger.
The BatchPartialEvent struct was constructed as a bare expression and immediately dropped at the end of execute_batch_partial. Add .publish(&env) so the batch summary event reaches the ledger.
Add two tests that verify the .publish(&env) calls actually emit events to the Soroban ledger: - test_execute_batch_emits_batch_executed_event: checks that execute_batch publishes a BatchExecutedEvent with the correct topic. - test_execute_batch_partial_emits_all_events: checks that execute_batch_partial publishes PaymentSentEvent, PaymentSkippedEvent, and BatchPartialEvent when some payments succeed and others are skipped. Uses env.events().all() with Symbol matching via FromVal to inspect the event topics emitted by the contract under test.
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.
Body:
Summary
All four event types in
contracts/bulk_payment/src/lib.rswere constructed as bare struct expressions and immediately dropped, so zero events were ever emitted to the Soroban ledger. This broke the backend contract event indexer (contractEventIndexer.ts) which depends on these events for real-time payment tracking and analytics, and violated on-chain auditability for bulk payments.Changes
contracts/bulk_payment/src/lib.rs— Added.publish(&env)to all four event construction sites:BatchExecutedEventinexecute_batch(line 161)PaymentSkippedEventinexecute_batch_partialloop (line 217)PaymentSentEventinexecute_batch_partialloop (line 228)BatchPartialEventinexecute_batch_partial(line 253)contracts/bulk_payment/src/test.rs— Added 2 new tests + helper:has_event()helper that matches events by contract address and snake_case topic symbol viaenv.events().all()+Symbol::from_valtest_execute_batch_emits_batch_executed_event— verifiesexecute_batchpublishesbatch_executed_eventtest_execute_batch_partial_emits_all_events— verifiesexecute_batch_partialpublishespayment_sent_event,payment_skipped_event, andbatch_partial_eventwhen some payments succeed and others are skippedTesting
Result: 15/15 passing (13 existing + 2 new event emission tests)
test_execute_batch_emits_batch_executed_eventtest_execute_batch_partial_emits_all_eventsTradeoffs
#[contractevent]macro generates snake_case topic symbols (e.g.,batch_executed_eventforBatchExecutedEvent). The tests match on this format. If the macro behavior changes in a future Soroban SDK version, the tests will catch it.test_snapshots/) capture the full event data for manual inspection if needed.Architecture
The fix is minimal — each event struct already had the correct fields populated at the right call sites. The only change is appending
.publish(&env)to convert the struct expression from a no-op into an actual Soroban event emission. The backend indexer (contractEventIndexer.ts) fetches all contract events from Soroban RPC generically, so no indexer-side changes are needed.Out of scope
cross_asset_paymenthas the identical bug (separate issue)Closes #390