Preflight device registration and wallet subscription for REST calls#592
Open
DRadmir wants to merge 3 commits into
Open
Preflight device registration and wallet subscription for REST calls#592DRadmir wants to merge 3 commits into
DRadmir wants to merge 3 commits into
Conversation
gemdev111
reviewed
Jul 2, 2026
| } | ||
|
|
||
| private suspend fun getOrCreateDevice(device: Device): Device { | ||
| override suspend fun invoke() { |
Contributor
There was a problem hiding this comment.
Can you recheck this please:
Wallet calls that fire during the first registration each also run a full syncDeviceInfo() - they pass the isDeviceRegistered() check before the flag flips. The mutex prevents double-register, but each still does an extra GET /devices. A few redundant calls on first launch
iOS coalesces this in its sync coordinator
gemdev111
approved these changes
Jul 2, 2026
Wallet-scoped device REST calls could 404 before the device was registered. Add a DeviceRegistrationInterceptor that ensures the device is registered (via EnsureDeviceRegistered) before wallet-tagged requests proceed, and provide a separate device API client without the preflight to avoid recursion during registration itself. Closes #550
A newly created or imported wallet could fire GET /v2/devices/assets before it was subscribed on the backend, returning 404 "Wallet not found": the subscription reconcile ran inline, racing the eager asset sync triggered by session activation. Mirror the device-registration preflight one level up: mark subscriptions dirty on wallet create/import (InvalidateSubscriptions in setupWallet, before session activation) and reconcile them lazily via a SubscriptionSyncInterceptor that ensures subscriptions are synced before any wallet-tagged request proceeds. Reconcile runs through the registration-free device client to avoid interceptor recursion and is serialized with a mutex to prevent concurrent reconciles. Closes #603
Concurrent wallet-scoped requests each ran a full device sync — an extra GET /devices per request on first launch. Add DeviceSyncCoordinator (mirroring iOS) that dedupes concurrent syncs into one; ensureSubscriptionsSynced waits for any in-flight sync, then re-checks the dirty flag before syncing.
4261da8 to
771c0c2
Compare
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.
Wallet-scoped device REST calls could 404 on fresh state:
Both are fixed with a transport-level preflight: wallet-tagged requests wait until the device is registered and its subscriptions are synced before proceeding. Subscriptions are marked dirty on wallet create/import and reconciled lazily, matching iOS.
Closes #550
Closes #603
Closes #620
TODO: testing