Skip to content

Feat/inventory optimistic updates#37

Draft
ccp-raudur wants to merge 3 commits into
mainfrom
feat/inventory-optimistic-updates
Draft

Feat/inventory optimistic updates#37
ccp-raudur wants to merge 3 commits into
mainfrom
feat/inventory-optimistic-updates

Conversation

@ccp-raudur

Copy link
Copy Markdown

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?

  • In-game browser
  • [x ] External browser

ccp-raudur and others added 2 commits June 16, 2026 09:45
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>
Copilot AI review requested due to automatic review settings June 18, 2026 13:29
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Coverage Report for @evefrontier/dapp-kit

Status Category Percentage Covered / Total
🔵 Lines 90.09% 737 / 818
🔵 Statements 88.77% 767 / 864
🔵 Functions 86.78% 151 / 174
🔵 Branches 77.05% 477 / 619
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/libs/dapp-kit/providers/eventRefresh.ts 81.78% 73.63% 82% 85.08% 121, 127, 131-135, 155, 210, 215, 227-228, 232-234, 256, 319, 324, 347, 364, 385-386, 404, 408, 416, 484, 513, 565, 586, 600-602, 666, 679, 696, 736-738, 751, 757-760, 783-819
packages/libs/dapp-kit/utils/constants.ts 95.65% 62.5% 91.66% 95.65% 129-130
packages/libs/dapp-kit/utils/inventory.ts 88.23% 79.54% 100% 93.47% 13, 76, 85, 111, 115, 131
packages/libs/dapp-kit/utils/inventoryEventBcs.ts 88.88% 100% 80% 87.5% 4
packages/libs/dapp-kit/utils/transforms.ts 100% 60.24% 100% 100%
Generated in workflow #74 for commit 1429bc1 by the Vitest Coverage Report Action

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

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 thread packages/libs/ui-components/modules/InventoryView.tsx Outdated
Comment thread packages/libs/ui-components/components/EveLinearBar.tsx Outdated
Comment on lines +343 to +345
useEffect(() => {
if (!selectedObjectId) return

void unsubscribe()
}
}
}, [selectedObjectId, selectedTenant, isObjectIdDirect, fetchObjectData])
Comment thread packages/libs/dapp-kit/providers/eventRefresh.ts
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'),
})

@ccp-raudur ccp-raudur marked this pull request as draft June 18, 2026 13:39
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.

2 participants