Skip to content

[Task]: Emit events when assets are added or removed from the whitelist #37

Description

@grantfox-oss

add_asset() and remove_asset() update the asset whitelist in persistent storage with no on-chain event. Indexers and clients cannot detect whitelist changes without polling is_supported_asset() for every token they care about.

Add two event structs:

#[contractevent]
pub struct AddAssetEvent {
    #[topic]
    pub asset: Address,
    pub admin: Address,
}

#[contractevent]
pub struct RemoveAssetEvent {
    #[topic]
    pub asset: Address,
    pub admin: Address,
}

Emit AddAssetEvent at the end of add_asset() and RemoveAssetEvent at the end of remove_asset(). Only these two functions are modified.

Acceptance criteria

  • AddAssetEvent and RemoveAssetEvent are defined with #[contractevent]
  • add_asset() emits AddAssetEvent after writing to storage
  • remove_asset() emits RemoveAssetEvent after removing from storage (only if the key existed)
  • Tests verify both events are emitted using env.events().all()
  • cargo test and cargo clippy -- -D warnings pass

Relevant files

  • contracts/agent-vault/src/lib.rs (only add_asset and remove_asset functions)
  • 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions