ShieldedRepository

@Singleton
open class ShieldedRepository @Inject constructor(dataStore: DataStore<Preferences>, indexerClient: IndexerClient, networkConfig: NetworkConfig)

Repository for shielded (zswap) wallet operations.

Uses its OWN WebSocket client, independent from the shared IndexerClient. This prevents the unshielded SubscriptionManager from killing the shielded subscription when it resets the shared WebSocket connection.

Constructors

Link copied to clipboard
@Inject
constructor(dataStore: DataStore<Preferences>, indexerClient: IndexerClient, networkConfig: NetworkConfig)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun deleteState(address: String)
Link copied to clipboard
suspend fun getBalances(address: String): Map<String, BigInteger>

Get current shielded balances.

Link copied to clipboard
suspend fun getCoinCount(address: String): Int

Get number of shielded coins.

Link copied to clipboard
suspend fun hasCachedState(address: String): Boolean

Check if cached shielded state exists.

Link copied to clipboard
suspend fun loadCheckpoint(address: String): ZswapCheckpoint?

Load the checkpoint (state + cursor) as ONE consistent snapshot — both keys from a single DataStore emission, so the pair can't be torn across a concurrent write. Returns null if EITHER half is missing or the state fails to deserialize (a legacy state saved by saveState has no cursor → reads as absent → caller does a clean full sync that establishes the cursor). The returned ZswapCheckpoint.state is owned by the caller and must be closed.

Link copied to clipboard
suspend fun loadState(address: String): ZswapLocalState?
Link copied to clipboard
suspend fun saveCheckpoint(address: String, state: ZswapLocalState, cursor: Long)

Persist the checkpoint (serialized state + resume cursor) ATOMICALLY — both keys in one edit — so a reader can never observe a torn pair (an old state with a new cursor would make the next delta resume at the wrong frontier; see loadCheckpoint).

Link copied to clipboard
suspend fun saveState(address: String, state: ZswapLocalState)
Link copied to clipboard
open fun subscribeToZswapEvents(fromId: Long? = null): Flow<RawLedgerEvent>

Subscribe to zswap events using dedicated WebSocket (not shared with unshielded).

Link copied to clipboard
suspend fun syncFromBlockchain(address: String, zswapSeed: ByteArray): Boolean

Sync shielded (zswap) state from blockchain (#279/#1 — checkpoint + delta).