OperationRegistry

Process-singleton registry of in-flight value-bearing wallet operations (#261-264). Mirrors MidnightWallet.syncStatus's observable-state model:

  • active — the set of operations in flight. The foreground service keeps the process alive while it is non-empty; com.midnight.kuira.sdk callers in wallet-runtime hold the session-lock off it.

  • outcomes — a one-shot terminal stream the finalization notifier rides.

The SDK's built-ins (send / dust-registration / contract call) and any third-party dApp enroll through the SAME registry via run (wrapped publicly by MidnightSdk.runForegroundOperation), so there is ONE source of truth, not three. The registry is pure Kotlin/coroutines — no Android, fully unit-testable.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val active: StateFlow<List<ActiveOperation>>
Link copied to clipboard
Link copied to clipboard
val outcomes: SharedFlow<OperationOutcome>

Functions

Link copied to clipboard
suspend fun requestAttention(title: String, body: String? = null)

Request the user's ATTENTION for the operation the CURRENT coroutine is inside (#264): emits an OperationAttention a presentation edge turns into a heads-up notification, to pull a user who left the app back to a step that needs them. Tagged with the op's OperationDescriptor.contentIntent so the alert taps back to the right screen. No-op outside a tracked operation. The edge decides whether to actually alert (e.g. suppress when foreground), so callers may fire this unconditionally.

Link copied to clipboard
suspend fun <T> run(descriptor: OperationDescriptor, classify: (T) -> OperationResult = { OperationResult(OperationTerminalStatus.Success) }, block: suspend () -> T): T

Run block as a tracked operation: enroll it in active, run it, classify the result into a terminal OperationOutcome (emitted on outcomes), and de-enroll in finally — whether block returns OR throws.

Link copied to clipboard
suspend fun updateCurrentStage(stage: String?)

Update the live ActiveOperation.stage of the operation the CURRENT coroutine is running inside (identified by the context Marker) — so a tracked block can drive the foreground-service notification text ("Submitting commit…" → "Finalizing…") without threading an id around. No-op outside a tracked operation.