Skip to content

Commit 9363f4f

Browse files
committed
refactor: move logic to repository
1 parent 77e460b commit 9363f4f

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

app/src/main/java/to/bitkit/repositories/WalletRepo.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ import kotlinx.coroutines.CoroutineDispatcher
77
import kotlinx.coroutines.flow.Flow
88
import kotlinx.coroutines.tasks.await
99
import kotlinx.coroutines.withContext
10+
import org.lightningdevkit.ldknode.Network
1011
import to.bitkit.data.AppDb
1112
import to.bitkit.data.AppStorage
1213
import to.bitkit.data.SettingsStore
1314
import to.bitkit.data.entities.ConfigEntity
1415
import to.bitkit.data.keychain.Keychain
1516
import to.bitkit.di.BgDispatcher
17+
import to.bitkit.env.Env
1618
import to.bitkit.models.BalanceState
1719
import to.bitkit.models.NewTransactionSheetDetails
1820
import to.bitkit.models.NewTransactionSheetDirection
1921
import to.bitkit.models.NewTransactionSheetType
22+
import to.bitkit.models.Toast
2023
import to.bitkit.services.BlocktankNotificationsService
2124
import to.bitkit.services.CoreService
25+
import to.bitkit.ui.shared.toast.ToastEventBus
2226
import to.bitkit.utils.Bip21Utils
2327
import to.bitkit.utils.Logger
2428
import uniffi.bitkitcore.IBtInfo
@@ -67,6 +71,10 @@ class WalletRepo @Inject constructor(
6771
}
6872

6973
suspend fun wipeWallet(): Result<Unit> = withContext(bgDispatcher) {
74+
if (Env.network != Network.REGTEST) {
75+
return@withContext Result.failure(Exception("Can only wipe on regtest."))
76+
}
77+
7078
try {
7179
keychain.wipe()
7280
appStorage.clear()

app/src/main/java/to/bitkit/viewmodels/WalletViewModel.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,6 @@ class WalletViewModel @Inject constructor(
375375

376376
fun wipeStorage() {
377377
viewModelScope.launch {
378-
if (Env.network != Network.REGTEST) {
379-
ToastEventBus.send(
380-
type = Toast.ToastType.ERROR,
381-
title = "Error",
382-
description = "Can only wipe on regtest."
383-
)
384-
return@launch
385-
}
386-
387378
if (lightningRepo.nodeLifecycleState.value.isRunningOrStarting()) {
388379
stopLightningNode()
389380
}

0 commit comments

Comments
 (0)