Add hook to tempo sessions, triggered on each on-chain tx#667
Open
raubrey-stripe wants to merge 11 commits into
Open
Add hook to tempo sessions, triggered on each on-chain tx#667raubrey-stripe wants to merge 11 commits into
raubrey-stripe wants to merge 11 commits into
Conversation
Adds an `onSettled` callback to `tempo.session()` parameters that fires after every confirmed on-chain settlement or close transaction. Covers all three trigger paths: explicit `settle()`, auto-scheduled settlements, and cooperative `close()`. Errors in handlers are isolated and cannot break the settlement flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Renames onSettled → onSessionSettlement and promotes it to a first-class
server event ('session.settlement') in the Mppx event map. The hook now
fires for all on-chain transactions from session methods:
- trigger: 'scheduled' — auto-settlement when thresholds are crossed
- trigger: 'settle' — explicit settle() calls
- trigger: 'close' — cooperative channel close
Methods expose _bindSessionSettlementEmitter so Mppx.create() can wire
internal session settlements to the server event dispatcher. Users can
subscribe via mppx.onSessionSettlement() or mppx.on('session.settlement').
Adds tests covering all three trigger paths and error isolation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Removes the Mppx-level event system wiring (_bindSessionSettlementEmitter, ServerEventMap addition, onSessionSettlement on Mppx type). Settlement is session-specific so the hook lives naturally as a tempo.session() parameter rather than in the generic event map. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Removes the Tempo-specific `channel: ChannelStore.State` field from SessionSettlementContext. The remaining fields (txHash, channelId, trigger, amount) are universal across session implementations and will work unchanged when Solana sessions land. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
commit: |
The close payload in the onSessionSettlement test was missing the required descriptor field and had a stray captureAmount field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Provides both cumulative amount and incremental delta for each settlement event, so consumers can distinguish new settlement value from previously settled amounts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
…tle() Instead of reading the store after settle() returns, pass the onSessionSettlement callback through with a trigger override so delta is computed atomically inside settle(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
…ement Verifies that delta correctly reflects only the incremental amount when the channel already has prior on-chain settlements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
…ttlement Verifies that scheduled settlements correctly report delta as the incremental amount when the channel has prior on-chain settlements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Author
|
FYI @brendanjryan could I get another quick look?
|
brendanjryan
approved these changes
Jul 20, 2026
Collaborator
|
code LGTM -- some CI issues @raubrey-stripe |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Replace invalid '0xclose_sig' with actual Voucher.signVoucher output so close credential verification passes signature validation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding an onSessionSettled hook to fire on each on-chain settlement/transaction (I'm not opinionated on the naming here, whatever is best!).
This:
Some thoughts