init() is the single most important lifecycle moment for the contract — it sets the admin, records the USDC SAC address, and whitelists USDC. Yet it emits no event; it only writes a log! line, which is not part of the durable event stream that indexers and explorers consume. Every other state-changing entry point (deposit, withdraw, pause, update_admin, …) publishes a #[contractevent]. Initialization should too, so downstream tooling can detect deployment/init deterministically and capture the initial admin and asset without a separate get_admin() round-trip.
Add the event struct and publish it at the end of init:
#[contractevent]
pub struct InitEvent {
#[topic]
pub admin: Address,
pub usdc_sac: Address,
}
// at the end of init(), before Ok(()):
InitEvent { admin: admin.clone(), usdc_sac: usdc_sac.clone() }.publish(&env);
Because init can only ever succeed once (guarded by AlreadyInitialized), the event is emitted exactly once per contract instance.
Acceptance criteria
Relevant files
contracts/agent-vault/src/lib.rs (event struct + init)
contracts/agent-vault/src/tests.rs
Notes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.
init()is the single most important lifecycle moment for the contract — it sets the admin, records the USDC SAC address, and whitelists USDC. Yet it emits no event; it only writes alog!line, which is not part of the durable event stream that indexers and explorers consume. Every other state-changing entry point (deposit,withdraw,pause,update_admin, …) publishes a#[contractevent]. Initialization should too, so downstream tooling can detect deployment/init deterministically and capture the initial admin and asset without a separateget_admin()round-trip.Add the event struct and publish it at the end of
init:Because
initcan only ever succeed once (guarded byAlreadyInitialized), the event is emitted exactly once per contract instance.Acceptance criteria
InitEvent { admin, usdc_sac }is defined with#[contractevent],adminas a#[topic]initpublishesInitEventon successenv.events()afterinitwith the correct admin and assetinitstill fails withAlreadyInitializedand emits no additional eventcargo testandcargo clippy --all-targets -- -D warningspassRelevant files
contracts/agent-vault/src/lib.rs(event struct +init)contracts/agent-vault/src/tests.rsNotes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.