Skip to content

fix(tokens): emit transfer/mint/burn/approve events in wpi-token and mock-usdc - #66

Merged
Junman140 merged 2 commits into
Pi-Defi-world:mainfrom
Dannyswiss1:fix/token-event-emission
Aug 18, 2026
Merged

fix(tokens): emit transfer/mint/burn/approve events in wpi-token and mock-usdc#66
Junman140 merged 2 commits into
Pi-Defi-world:mainfrom
Dannyswiss1:fix/token-event-emission

Conversation

@Dannyswiss1

Copy link
Copy Markdown
Contributor

Summary

Closes #3

mint, burn, transfer, transfer_from, and approve in both wpi-token
and mock-usdc performed state mutations silently — no env.events().publish(...)
calls anywhere. Wallets, block explorers (StellarExpert), and the future
relayer/indexer confirmation logic had no on-chain signal to observe token
activity.

Changes

Added event emission to every state-mutating entrypoint in both contracts,
using the conventional Soroban token topic/data shape:

Function Topics Data
transfer / transfer_from ("transfer", from, to) amount
mint ("mint", admin, to) amount
burn ("burn", admin, from) amount
approve ("approve", owner, spender) amount
  • transfer and transfer_from both route through the shared
    transfer_internal helper, so the event is emitted exactly once per
    transfer regardless of call path (no duplicate events for the
    transfer_from case).
  • No event fires on no-op paths (e.g. amount <= 0 in mint/burn, or any
    error return) since no balance/supply state actually changes there —
    consistent with the existing early-return behavior.
  • Identical treatment applied to both wpi-token and mock-usdc since they
    share the same interface shape.

Testing

  • cargo build -p wpi-token -p mock-usdc — compiles clean.
  • No existing test suite in this workspace for these contracts.

Follow-up (not in this PR)

  • Acceptance criteria call for verifying event rendering against
    StellarExpert/Freighter on testnet — needs a manual testnet deploy once
    merged.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d489644a-68cb-492c-b962-36ca0a71d17e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Reworks the event emission added in the previous commit and repairs
pre-existing CI breakage inherited from "chore: sync contract sources
from PUSD-MAIN" (a83a15d), which left main red.

Events (the actual issue fix):
- soroban-sdk 23.0.1 deprecates `env.events().publish(...)`, so the
  previous commit's calls became hard errors under the CI clippy step's
  `-D warnings`. Ported to the `#[contractevent]` macro.
- Topic/data shape is unchanged and still matches the conventional
  Soroban token layout: struct name supplies the leading topic, `#[topic]`
  fields follow, and `data_format = "single-value"` keeps `amount` as the
  bare payload rather than a map:
    ("transfer", from, to)     -> amount
    ("mint", admin, to)        -> amount
    ("burn", admin, from)      -> amount
    ("approve", owner, spender)-> amount

Pre-existing CI failures, unrelated to events:
- cargo fmt: the sync commit landed all three contracts unformatted;
  `cargo fmt --all` applied.
- clippy: needless_borrows_for_generic_args in mock-amm; bind the pool
  address to a local before passing it to `transfer`.
- relayer typecheck: scripts/e2e-demo.ts omitted the required
  `BurnEvent.redemptionId`; added a demo id matching the file's
  existing `demo-*` fixture naming.
- The sync commit deleted scripts/verify_dependency_provenance.sh along
  with the [patch.crates-io] pinning it validated, but ci.yml and
  release.yml still invoked it, so both workflows failed on a missing
  file. Removed the dead steps.

Supply-chain note: that deletion dropped the ark-*/wasmi_core git-rev
pinning entirely. Restoring it is a dependency change in its own right
and is deliberately left to a follow-up PR.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Junman140
Junman140 merged commit 4b39240 into Pi-Defi-world:main Aug 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue 3 — No events emitted anywhere

2 participants