ensureWalletKeysAvailable

suspend fun ensureWalletKeysAvailable(onDownloadProgress: (Float) -> Unit = {}, logger: (String) -> Unit = {})

One-call wallet-key provisioning. Tries the dev shortcut first (installFromLocalTmp — adb-pushed files in /data/local/tmp/), then falls back to the S3 download (downloadWalletKeys) when the local-tmp pass didn't populate the BLS params + zswap/dust keys. After this returns, hasWalletKeys is true unless the download itself failed (in which case the underlying IOException propagates).

Why this lives here: every dApp that builds a com.midnight.kuira.sdk.MidnightSdk

  • does local proving needs the same recipe. Bolting it onto each dApp (com.midnight.kuira.dapp.wallet.WalletPanelViewModel, Kicks's MatchManager, future consumers) duplicates the conditional and leaves a trap: the first dev who skips the fallback ships a "works on my pre-staged machine, blows up on fresh emulator with BLS params file not found" regression (the exact 2026-05-19 emulator-B incident).

Idempotent + cheap on the hot path: once wallet keys are in keysDir, subsequent calls hit the hasWalletKeys() check and return immediately without I/O.

Parameters

onDownloadProgress

Forwarded to downloadWalletKeys. Only fires when the S3 fallback runs.

logger

Status sink (start / complete lines for the fallback path). Defaults to silent.