Context
Depends on #4 (trait-based architecture). The contract currently emits all events using the deprecated env.events().publish() pattern. Since soroban-sdk 23+ the standard is to define #[contractevent] structs and call .publish(e) on them. OZ v0.6.0 already ships typed event structs for all standard operations.
Current pattern (deprecated)
env.events().publish(
(Symbol::new(&env, MINT_EVENT), &to),
amount
);
env.events().publish(
(Symbol::new(&env, TRANSFER_EVENT), &from, &to),
amount
);
Target pattern (v0.6.0 / soroban-sdk 23+)
OZ already provides these events in stellar_tokens::fungible:
stellar_tokens::fungible::emit_mint(e, &to, amount)
stellar_tokens::fungible::emit_transfer(e, &from, &to, None, amount)
stellar_tokens::fungible::emit_approve(e, &owner, &spender, amount, live_until_ledger)
And in stellar_contract_utils::pausable:
stellar_contract_utils::pausable::emit_paused(e)
stellar_contract_utils::pausable::emit_unpaused(e)
For any custom events (e.g., batch_mint) define them as:
#[contractevent]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BatchMint {
#[topic]
pub to: Address,
pub amount: i128,
}
// then emit with:
BatchMint { to: account.clone(), amount }.publish(e);
Files to update
Contracts/stablecoin/src/contract.rs — replace all env.events().publish() calls
Contracts/stablecoin/src/types.rs — remove MINT_EVENT, BURN_EVENT, TRANSFER_EVENT, PAUSE_EVENT, UNPAUSE_EVENT string constants (no longer needed)
- Add any custom event struct definitions (e.g., for
batch_mint)
Acceptance criteria
Context
Depends on #4 (trait-based architecture). The contract currently emits all events using the deprecated
env.events().publish()pattern. Since soroban-sdk 23+ the standard is to define#[contractevent]structs and call.publish(e)on them. OZ v0.6.0 already ships typed event structs for all standard operations.Current pattern (deprecated)
Target pattern (v0.6.0 / soroban-sdk 23+)
OZ already provides these events in
stellar_tokens::fungible:stellar_tokens::fungible::emit_mint(e, &to, amount)stellar_tokens::fungible::emit_transfer(e, &from, &to, None, amount)stellar_tokens::fungible::emit_approve(e, &owner, &spender, amount, live_until_ledger)And in
stellar_contract_utils::pausable:stellar_contract_utils::pausable::emit_paused(e)stellar_contract_utils::pausable::emit_unpaused(e)For any custom events (e.g.,
batch_mint) define them as:Files to update
Contracts/stablecoin/src/contract.rs— replace allenv.events().publish()callsContracts/stablecoin/src/types.rs— removeMINT_EVENT,BURN_EVENT,TRANSFER_EVENT,PAUSE_EVENT,UNPAUSE_EVENTstring constants (no longer needed)batch_mint)Acceptance criteria
env.events().publish()in the codebaseemit_mint,emit_transfer, etc.) are used for SEP-41 operations#[contractevent]structs with#[topic]on address fieldstypes.rsare removed