Skip to content

feat(settlement): emit a batch-summary event from settle_all - #321

Merged
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:feature/settlement-02-event
Jul 28, 2026
Merged

feat(settlement): emit a batch-summary event from settle_all#321
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:feature/settlement-02-event

Conversation

@thlpkee20-wq

Copy link
Copy Markdown
Contributor

Closes #302

`settle()` and `settle_all()` already emit a
`settled(agent, service_id, requests, billed)` event per settlement —
`settle_all` publishes one per service in the sweep. This adds a single
`settl_all(agent, count, total_billed)` event after the loop, so
indexers can track a full `settle_all` drain without summing every
per-service `settled` event themselves.

  • `count` is the number of services swept (including zero-billed ones,
    matching `settle_all`'s existing "drain and stamp even when usage is
    zero" contract).
  • `total_billed` saturates at `i128::MAX`, like every other lifetime
    counter in this contract.
  • No topic collision: `settl_all` (9 chars, within the `symbol_short!`
    limit) doesn't match any existing topic.
  • No change to fund movement — this only adds a read-side event.

Test plan

settle() and settle_all() already emit a settled(agent, service_id,
requests, billed) event per settlement — settle_all publishes one per
service in the sweep. This adds a single settl_all(agent, count,
total_billed) event after the loop, so indexers can track a full
settle_all drain without summing every per-service settled event
themselves. count is the number of services swept (including
zero-billed ones, matching settle_all's existing "drain and stamp even
when usage is zero" contract); total_billed saturates at i128::MAX like
every other lifetime counter in this contract.

No topic collision: settl_all (9 chars, within the symbol_short! limit)
does not match any existing topic.
@mikewheeleer

Copy link
Copy Markdown
Contributor

looks good @thlpkee20-wq — well scoped and easy to review. merging 👍

@mikewheeleer
mikewheeleer merged commit a65baca into Agentpay-Org:main Jul 28, 2026
1 check failed
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.

Emit a dedicated event when settlement state changes

2 participants