Feat/inventory optimistic updates#37
Draft
ccp-raudur wants to merge 3 commits into
Draft
Conversation
Replace event polling with SubscribeCheckpoints for ItemMinted/Burned events, with optimistic UI updates, staggered GraphQL refetch, and 10s poll fallback. Co-authored-by: Cursor <cursoragent@cursor.com>
Coverage Report for @evefrontier/dapp-kit
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Adds near-real-time (optimistic) Smart Storage Unit inventory updates by subscribing to Sui checkpoint-stream events and applying mint/burn deltas locally, with periodic GraphQL refetches as the source of truth.
Changes:
- Introduces inventory utilities for sorting, optimistic used-capacity adjustments, and safe merging of refetch results with stream-updated state.
- Adds gRPC checkpoint-stream subscription + event application logic, wired into
SmartObjectProvider. - Updates UI inventory rendering and capacity bar display (including optional whole-number display).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/libs/ui-components/modules/InventoryView.tsx | Uses fetched Datahub item details per type_id, updates list keys, tweaks capacity bar props. |
| packages/libs/ui-components/components/EveLinearBar.tsx | Adds wholeNumbers display option for numerator/denominator. |
| packages/libs/dapp-kit/utils/transforms.ts | Sorts storage inventory items by quantity during GraphQL transform. |
| packages/libs/dapp-kit/utils/inventoryEventBcs.ts | Adds BCS decoding helpers for inventory move events (used when stream JSON is absent). |
| packages/libs/dapp-kit/utils/inventory.ts | New utilities for optimistic used-capacity updates, item sorting, and merge logic for refetch vs optimistic state. |
| packages/libs/dapp-kit/utils/constants.ts | Adds SUI_GRPC_URLS and getSuiGrpcBaseUrl for network-specific gRPC endpoints. |
| packages/libs/dapp-kit/utils/tests/transforms.test.ts | Tests inventory sorting behavior in transformToAssembly. |
| packages/libs/dapp-kit/utils/tests/inventoryEventBcs.test.ts | Adds BCS decoding test (currently depends on live testnet RPC). |
| packages/libs/dapp-kit/utils/tests/inventory.test.ts | Tests inventory utility behaviors (used capacity adjustments, merging, equality). |
| packages/libs/dapp-kit/providers/SmartObjectProvider.tsx | Primes volume cache, merges refetch results with optimistic state, and subscribes to inventory stream events. |
| packages/libs/dapp-kit/providers/eventRefresh.ts | New checkpoint-stream subscription, event extraction/decoding, optimistic application, and refetch scheduling logic. |
| packages/libs/dapp-kit/providers/tests/eventRefresh.test.ts | Comprehensive unit tests for event extraction, dedupe, scheduling, and optimistic assembly updates. |
| packages/libs/dapp-kit/config/dapp-kit.ts | Uses shared SUI_GRPC_URLS for dApp kit gRPC client configuration. |
Comment on lines
+343
to
+345
| useEffect(() => { | ||
| if (!selectedObjectId) return | ||
|
|
| void unsubscribe() | ||
| } | ||
| } | ||
| }, [selectedObjectId, selectedTenant, isObjectIdDirect, fetchObjectData]) |
Comment on lines
+625
to
+628
| const run = async () => { | ||
| const seenEventIds = new Set<string>() | ||
| let lastCheckpointSequence: number | null = null | ||
| let isInitialSession = true |
Comment on lines
+17
to
+21
| it('decodes mint and burn inventory events from chain BCS bytes', async () => { | ||
| const transport = new JsonRpcHTTPTransport({ | ||
| url: getJsonRpcFullnodeUrl('testnet'), | ||
| }) | ||
|
|
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
Real-time updates to our storage unit inventory in the dApp UI
Why
We want it to be quicker
Where has this been tested?