DustSubscriptionManager

@Singleton
class DustSubscriptionManager @Inject constructor(indexerClient: IndexerClient, dustRepository: DustRepository)

Manages subscription to dust-related blockchain events and syncs them to DustLocalState.

Workflow:

Indexer (GraphQL) → Subscribe to events → Filter dust events → Replay into DustLocalState → Update database cache

Event Processing:

  1. Subscribe to zswap ledger events (all blockchain events)

  2. Filter for dust-specific events (DustInitialUtxo, DustSpendProcessed, etc.)

  3. Batch events and replay into DustLocalState

  4. Save updated state to persistent storage

  5. Sync UTXOs to database cache

Usage:

@Inject lateinit var dustSubscriptionManager: DustSubscriptionManager

dustSubscriptionManager.startDustSync(
address = userAddress,
seed = userSeed
).collect { state ->
when (state) {
is DustSyncState.Syncing -> updateUI("Syncing dust: ${state.progress}%")
is DustSyncState.Synced -> updateUI("Dust synced: ${state.balance}")
is DustSyncState.Error -> showError(state.message)
}
}

See also

/midnight-wallet/packages/dust-wallet/src/Syncing.ts (TypeScript SDK reference)

Constructors

Link copied to clipboard
@Inject
constructor(indexerClient: IndexerClient, dustRepository: DustRepository)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
sealed class DustSyncState

State of dust synchronization.

Functions

Link copied to clipboard
fun startDustSync(address: String, seed: ByteArray, fromEventId: Long? = null): Flow<DustSubscriptionManager.DustSyncState>

Starts dust event synchronization for an address.

Link copied to clipboard

Stops dust synchronization (cancels flow collection).