feat: optimistic status updates#41
Merged
Merged
Conversation
Coverage Report for @evefrontier/dapp-kit
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aaf9b92 to
237a9a8
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the dapp-kit event pipeline to support optimistic StatusChangedEvent application (similar to existing optimistic fuel/inventory handling), and refactors event BCS decoding into a single registry-based dispatcher to simplify checkpoint stream parsing.
Changes:
- Add
StatusChangedEventBCS decoding + status event filtering/application helpers, and wire status events intoSmartObjectProvider’s checkpoint-stream flow. - Refactor inventory/fuel/status BCS decoding to a single-step
decode*ToJsonAPI and introduceeventBcsRegistry.tsfor suffix-based dispatch. - Update/add Vitest coverage for the BCS decoders (including a new status-event BCS test vector).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/libs/dapp-kit/utils/events/statusEventHandlers.ts | New helpers to identify and apply status events to an assembly. |
| packages/libs/dapp-kit/utils/events/statusEventBcs.ts | New BCS struct/enum definitions and decoder for StatusChangedEvent. |
| packages/libs/dapp-kit/utils/events/inventoryEventBcs.ts | Simplifies inventory BCS decoding to decodeInventoryEventBcsToJson. |
| packages/libs/dapp-kit/utils/events/fuelEventBcs.ts | Simplifies fuel BCS decoding to decodeFuelEventBcsToJson. |
| packages/libs/dapp-kit/utils/events/eventBcsRegistry.ts | New decoder registry + single decodeEventBcsToJson entry point. |
| packages/libs/dapp-kit/utils/events/checkpointStream.ts | Uses the registry to parse stream event payloads. |
| packages/libs/dapp-kit/utils/events/tests/eventRefresh.test.ts | Small adjustment to accommodate decoder refactor. |
| packages/libs/dapp-kit/utils/tests/statusEventBcs.test.ts | New tests for status-event BCS decoding and enum discriminants. |
| packages/libs/dapp-kit/utils/tests/inventoryEventBcs.test.ts | Updates tests for new inventory decoder API. |
| packages/libs/dapp-kit/utils/tests/fuelEventBcs.test.ts | Updates tests for new fuel decoder API. |
| packages/libs/dapp-kit/providers/SmartObjectProvider.tsx | Adds optimistic status event application + state stale-refetch protection. |
ccp-raudur
reviewed
Jun 25, 2026
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.
What
Optimistic
StatusChangedEventupdates:SmartObjectProvidernow appliesStatusChangedEventfrom the gRPC checkpoint stream immediately (before the next refetch), consistent with the existing optimistic inventory and fuel update behaviour. State is discarded if the confirmed refetch matches the last-acknowledged value (stale-refetch protection vialastConfirmedStateRef).BCS decoder refactor: The three event BCS files (
inventoryEventBcs,fuelEventBcs,statusEventBcs) previously each had a two-stepdecode* + *ToParsedJsonpattern with an intermediateDecoded*type that downstream consumers never used directly. Each is now a singledecode*ToJson(bytes): Record<string, unknown>function. A neweventBcsRegistry.tsholds aDECODERS_BY_SUFFIXdispatch table and exposesdecodeEventBcsToJson(bytes, eventType)as the single entry point.checkpointStream.ts'sparseEventPayloadFromStreamdrops from a 3-branch if/else to a 2-liner.Adding a new event type
Add one entry to
DECODERS_BY_SUFFIXineventBcsRegistry.ts.Why
Screenshots / Gifs
Where has this been tested?