Skip to content

feat: optimistic status updates#41

Merged
fcsondheim merged 2 commits into
mainfrom
optimistic-status
Jun 26, 2026
Merged

feat: optimistic status updates#41
fcsondheim merged 2 commits into
mainfrom
optimistic-status

Conversation

@fcsondheim

@fcsondheim fcsondheim commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

What

  • Optimistic StatusChangedEvent updates: SmartObjectProvider now applies StatusChangedEvent from 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 via lastConfirmedStateRef).

  • BCS decoder refactor: The three event BCS files (inventoryEventBcs, fuelEventBcs, statusEventBcs) previously each had a two-step decode* + *ToParsedJson pattern with an intermediate Decoded* type that downstream consumers never used directly. Each is now a single decode*ToJson(bytes): Record<string, unknown> function. A new eventBcsRegistry.ts holds a DECODERS_BY_SUFFIX dispatch table and exposes decodeEventBcsToJson(bytes, eventType) as the single entry point. checkpointStream.ts's parseEventPayloadFromStream drops from a 3-branch if/else to a 2-liner.

Adding a new event type

Add one entry to DECODERS_BY_SUFFIX in eventBcsRegistry.ts.

Why

Screenshots / Gifs

Where has this been tested?

  • In-game browser
  • External browser

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Coverage Report for @evefrontier/dapp-kit

Status Category Percentage Covered / Total
🔵 Lines 91.14% 762 / 836
🔵 Statements 89.05% 814 / 914
🔵 Functions 88.54% 170 / 192
🔵 Branches 77.21% 505 / 654
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/libs/dapp-kit/utils/events/checkpointStream.ts 83.7% 72.07% 92.3% 87.93% 83, 87, 112, 125-126, 130-132, 150, 193, 207-209, 280, 291, 322, 380-381, 392, 398-401
packages/libs/dapp-kit/utils/events/eventBcsRegistry.ts 75% 50% 100% 85.71% 22, 26
packages/libs/dapp-kit/utils/events/fuelEventBcs.ts 100% 100% 100% 100%
packages/libs/dapp-kit/utils/events/inventoryEventBcs.ts 100% 100% 100% 100%
packages/libs/dapp-kit/utils/events/statusEventBcs.ts 100% 100% 100% 100%
packages/libs/dapp-kit/utils/events/statusEventHandlers.ts 92.85% 89.47% 100% 100% 22, 64
Generated in workflow #90 for commit 7d29955 by the Vitest Coverage Report Action

@fcsondheim fcsondheim marked this pull request as ready for review June 25, 2026 16:08
Copilot AI review requested due to automatic review settings June 25, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StatusChangedEvent BCS decoding + status event filtering/application helpers, and wire status events into SmartObjectProvider’s checkpoint-stream flow.
  • Refactor inventory/fuel/status BCS decoding to a single-step decode*ToJson API and introduce eventBcsRegistry.ts for 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.

Comment thread packages/libs/dapp-kit/providers/SmartObjectProvider.tsx Outdated
Comment thread packages/libs/dapp-kit/utils/events/statusEventHandlers.ts
Comment thread packages/libs/dapp-kit/providers/SmartObjectProvider.tsx Outdated
@fcsondheim fcsondheim requested a review from ccp-raudur June 25, 2026 17:55

@ccp-bofai ccp-bofai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@fcsondheim fcsondheim merged commit da01068 into main Jun 26, 2026
3 checks passed
@fcsondheim fcsondheim deleted the optimistic-status branch June 26, 2026 13:26
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.

4 participants