WalletPanelViewModel

class WalletPanelViewModel @Inject constructor(sdkProvider: MidnightSdkProvider, sigilStateStore: SigilStateStore, driveAuth: DriveAuthManager) : ViewModel

Wallet panel presenter: drives the canonical WalletConfig and translates SDK / seed state into WalletStatus for the panel UI.

The config authority. The panel is the only surface with the network / proving-mode / proof-server toggles, so it's where config changes enter the system. It passes the current WalletConfig to MidnightSdkProvider.ensureSdk, which builds (or rebuilds) the one shared SDK. Other consumers (BBoard, Kicks) follow that SDK via the provider — they never build their own. That's what makes the app sync once instead of once per consumer.

Does NOT own the SDK lifecycle. MidnightSdkProvider is a process singleton that survives activity recreation, so there's no SDK to close in onCleared. The provider also owns seed bootstrap (it delegates to WalletSeedSource) and wallet proving-key readiness; this VM just requests the SDK and reads balances off it.

Public surface: status (observe), refreshBalance / registerDust (act). Funding needs no handler — the Receive screen shows the airdrop command and the SDK's subscription picks up the credit on its own.

Constructors

Link copied to clipboard
@Inject
constructor(sdkProvider: MidnightSdkProvider, sigilStateStore: SigilStateStore, driveAuth: DriveAuthManager)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val retryRequests: SharedFlow<WalletConfig>
Link copied to clipboard
val status: StateFlow<WalletStatus>

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard

Enable cross-device Dust cloud sync: obtain the Drive drive.appdata grant, then run a full sync. This is bidirectional — once consent exists, wallet.refresh() first restores from the cloud checkpoint if this device has none (so a fresh device deltas instead of replaying genesis), then uploads the latest checkpoint. If consent is already granted it runs silently; otherwise it emits an IntentSenderRequest via consentRequests for the panel to launch — the result returns through onConsentResult.

Link copied to clipboard
Link copied to clipboard
fun onConsentResult(config: WalletConfig, activity: FragmentActivity, data: Intent?)

Continue after the Drive consent activity returns.

Link copied to clipboard
fun refreshBalance(config: WalletConfig, activity: FragmentActivity, force: Boolean = false)

Bootstrap (if needed) and refresh balances. Progressive: emits Ready as soon as the SDK is built so the user sees their addresses immediately, then re-emits Ready after the full resync lands so the values catch up.

Link copied to clipboard

Register the wallet's NIGHT key for Dust generation, then poll until the first Dust UTXO surfaces (or DUST_VISIBLE_TIMEOUT_MS elapses). Must run once after the wallet first holds NIGHT — until then the chain won't release spendable Dust and contract calls (fee-paying) fail.