Skip to content

No event emitted when transfer_admin succeeds in any contract; admin handover is silent on-chain #55

Description

@cybermax4200

Labels: type: bug, type: observability, difficulty: intermediate, area: eco-token, area: task-registry, area: reward-engine

Why this matters now

Phase 4 backend integration requires the off-chain indexer to track admin changes for governance auditing. A silent admin transfer is indistinguishable from no transfer at all — a compromised admin could rotate the role and the backend would never know. This is a finding every security auditor will raise.

Problem / What

transfer_admin is implemented in all three contracts (eco-token/src/token.rs, task-registry/src/registry.rs, reward-engine/src/verification.rs) and is tested, but none of them emit a contract event. Every other privileged operation in these contracts (mint, burn, transfer, task creation, sponsor changes, oracle changes) emits a typed #[contractevent] struct. Admin transfer is the only governance-critical operation that is silent.

Key Challenges

  • Define a consistent AdminTransferredEvent { previous_admin: Address, new_admin: Address } struct (with previous_admin as a topic) in each contract.
  • The event must be emitted after the storage write (not before), so it reflects committed state.
  • All three contracts need the same change applied consistently.

Acceptance Criteria

  • AdminTransferredEvent { previous_admin, new_admin } is defined and emitted in transfer_admin in all three contracts.
  • previous_admin is a #[topic] field so indexers can filter by outgoing admin address.
  • Tests in each contract assert the event is emitted with correct fields after a successful transfer_admin call.
  • No event is emitted on a failed (panicking) call.
  • All existing tests pass.

Relevant files / functions

File Symbol
contracts/eco-token/src/token.rs transfer_admin
contracts/task-registry/src/registry.rs transfer_admin
contracts/reward-engine/src/verification.rs transfer_admin

Out of scope

  • Adding events to other admin-only operations (covered separately)
  • Changes to existing event structs

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions