Description
create_stream calls emit_stream_created(&env, stream_id, &payer, &info.recipient, rate_per_second, initial_balance) at src/lib.rs:136, but that function does not exist anywhere in the crate, and the test test_create_stream_emits_event (src/lib.rs:680) deserialises a StreamCreatedEvent struct (src/lib.rs:708) that is also never defined. docs/events.md already specifies a full event catalogue, yet the contract emits no events at all. This issue implements the stream_created event end-to-end so off-chain indexers can rebuild stream history as docs/events.md promises.
Requirements and context
Functional
- Define
#[contracttype] pub struct StreamCreatedEvent { payer: Address, recipient: Address, rate_per_second: i128, initial_balance: i128 } to match the data payload asserted in test_create_stream_emits_event (src/lib.rs:707–712).
- Implement
fn emit_stream_created(env: &Env, stream_id: u32, payer: &Address, recipient: &Address, rate_per_second: i128, initial_balance: i128) that publishes via env.events().publish(...).
- The inline test expects topics
topic[0] == Symbol "stream_created" and topic[1] == stream_id (src/lib.rs:702–705). Note this conflicts with docs/events.md, which specifies a two-symbol topic (stream, created) with stream_id in the data payload. Pick one canonical topic shape, make the test and docs/events.md agree, and document the decision in the PR.
- Ensure exactly one event is emitted per
create_stream and none on start/stop (test_no_spurious_stream_created_events, src/lib.rs:717).
Non-functional / repo conventions
- Keep the event helper free of auth side effects; it must only read the values passed in.
- Stay within the WASM budget checked by
scripts/check-wasm-size.sh; events add to size.
- Follow the existing accounting fields —
initial_balance is the value escrowed at creation, not the running balance.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/stream-created-event.
2. Implement changes — add the StreamCreatedEvent type and emit_stream_created to src/lib.rs (or a new src/events.rs module re-exported from lib.rs); reconcile docs/events.md.
3. Write/extend tests — extend the inline #[cfg(test)] mod test using soroban_sdk::testutils::Events; assert topic and data payload exactly as in src/lib.rs:694–713.
4. Test and commit
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --features testutils
./scripts/check-wasm-size.sh
Example commit message
feat(events): emit stream_created event from create_stream
Guidelines
- Target 95% line coverage (
docs/coverage.sh, CONTRIBUTING.md).
- Add
/// doc-comments to the event type/helper and update docs/events.md (topic + payload table) so the doc matches the implementation.
- Timeframe: 96 hours.
Description
create_streamcallsemit_stream_created(&env, stream_id, &payer, &info.recipient, rate_per_second, initial_balance)atsrc/lib.rs:136, but that function does not exist anywhere in the crate, and the testtest_create_stream_emits_event(src/lib.rs:680) deserialises aStreamCreatedEventstruct (src/lib.rs:708) that is also never defined.docs/events.mdalready specifies a full event catalogue, yet the contract emits no events at all. This issue implements thestream_createdevent end-to-end so off-chain indexers can rebuild stream history asdocs/events.mdpromises.Requirements and context
Functional
#[contracttype] pub struct StreamCreatedEvent { payer: Address, recipient: Address, rate_per_second: i128, initial_balance: i128 }to match the data payload asserted intest_create_stream_emits_event(src/lib.rs:707–712).fn emit_stream_created(env: &Env, stream_id: u32, payer: &Address, recipient: &Address, rate_per_second: i128, initial_balance: i128)that publishes viaenv.events().publish(...).topic[0] == Symbol "stream_created"andtopic[1] == stream_id(src/lib.rs:702–705). Note this conflicts withdocs/events.md, which specifies a two-symbol topic(stream, created)withstream_idin the data payload. Pick one canonical topic shape, make the test anddocs/events.mdagree, and document the decision in the PR.create_streamand none onstart/stop(test_no_spurious_stream_created_events,src/lib.rs:717).Non-functional / repo conventions
scripts/check-wasm-size.sh; events add to size.initial_balanceis the value escrowed at creation, not the runningbalance.Acceptance criteria
StreamCreatedEventdefined andemit_stream_createdimplemented;src/lib.rs:136resolves.test_create_stream_emits_eventandtest_no_spurious_stream_created_eventspass.docs/events.md.create_stream; no spurious events on other entry points.cargo clippy --all-targets --all-features -- -D warningspasses.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/stream-created-event.2. Implement changes — add the
StreamCreatedEventtype andemit_stream_createdtosrc/lib.rs(or a newsrc/events.rsmodule re-exported fromlib.rs); reconciledocs/events.md.3. Write/extend tests — extend the inline
#[cfg(test)] mod testusingsoroban_sdk::testutils::Events; assert topic and data payload exactly as insrc/lib.rs:694–713.4. Test and commit
cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test --features testutils ./scripts/check-wasm-size.shExample commit message
Guidelines
docs/coverage.sh, CONTRIBUTING.md).///doc-comments to the event type/helper and updatedocs/events.md(topic + payload table) so the doc matches the implementation.