Skip to content

Commit 5d7ddc4

Browse files
refactor: apply ktlint recommendations
1 parent 6c7ffcf commit 5d7ddc4

9 files changed

Lines changed: 46 additions & 16 deletions

File tree

app/src/main/java/org/bitcoindevkit/devkitwallet/data/Kyoto.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,22 @@ class Kyoto private constructor(
111111

112112
fun create(wallet: Wallet, dataDir: String, network: Network): Kyoto {
113113
Log.i(TAG, "Starting Kyoto node")
114-
val peers: List<Peer> = when(network) {
114+
val peers: List<Peer> = when (network) {
115115
Network.REGTEST -> {
116116
val ip: IpAddress = IpAddress.fromIpv4(10u, 0u, 2u, 2u)
117117
val peer1: Peer = Peer(ip, 18444u, false)
118118
listOf(peer1)
119119
}
120+
120121
Network.SIGNET -> {
121122
val ip: IpAddress = IpAddress.fromIpv4(68u, 47u, 229u, 218u)
122123
val peer1: Peer = Peer(ip, null, false)
123124
listOf(peer1)
124125
}
125-
else -> { listOf() }
126+
127+
else -> {
128+
listOf()
129+
}
126130
}
127131

128132
val (client, node) =

app/src/main/java/org/bitcoindevkit/devkitwallet/domain/BlockchainClientsConfig.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,22 @@ class BlockchainClientsConfig {
4343
Network.REGTEST -> {
4444
config.addClient(EsploraClient("http://10.0.2.2:3002"), true)
4545
}
46+
4647
Network.TESTNET -> {
4748
config.addClient(ElectrumClient("ssl://electrum.blockstream.info:60002"), true)
4849
}
49-
Network.TESTNET4 -> throw IllegalArgumentException("This app does not support testnet 4 yet")
50+
51+
Network.TESTNET4 -> {
52+
throw IllegalArgumentException("This app does not support testnet 4 yet")
53+
}
54+
5055
Network.SIGNET -> {
5156
config.addClient(ElectrumClient("ssl://mempool.space:60602"), true)
5257
}
53-
Network.BITCOIN -> throw IllegalArgumentException("This app does not support mainnet")
58+
59+
Network.BITCOIN -> {
60+
throw IllegalArgumentException("This app does not support mainnet")
61+
}
5462
}
5563
return config
5664
}

app/src/main/java/org/bitcoindevkit/devkitwallet/domain/Wallet.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,17 @@ class Wallet private constructor(
142142

143143
val (confirmationBlock, confirmationTimestamp, pending) =
144144
when (val position = tx.chainPosition) {
145-
is ChainPosition.Unconfirmed -> Triple(null, null, true)
146-
is ChainPosition.Confirmed ->
145+
is ChainPosition.Unconfirmed -> {
146+
Triple(null, null, true)
147+
}
148+
149+
is ChainPosition.Confirmed -> {
147150
Triple(
148151
ConfirmationBlock(position.confirmationBlockTime.blockId.height),
149152
Timestamp(position.confirmationBlockTime.confirmationTime),
150153
false,
151154
)
155+
}
152156
}
153157
TxDetails(
154158
tx.transaction,

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/DevkitWalletActivity.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ package org.bitcoindevkit.devkitwallet.presentation
88
import android.content.Context
99
import android.os.Bundle
1010
import android.util.Log
11-
import androidx.activity.compose.setContent
1211
import androidx.activity.ComponentActivity
12+
import androidx.activity.compose.setContent
1313
import androidx.compose.runtime.getValue
1414
import androidx.compose.runtime.mutableStateOf
1515
import androidx.compose.runtime.setValue
@@ -58,24 +58,29 @@ class DevkitWalletActivity : ComponentActivity() {
5858
try {
5959
activeWallet =
6060
when (walletCreateType) {
61-
is WalletCreateType.FROMSCRATCH ->
61+
is WalletCreateType.FROMSCRATCH -> {
6262
Wallet.createWallet(
6363
newWalletConfig = walletCreateType.newWalletConfig,
6464
internalAppFilesPath = filesDir.absolutePath,
6565
userPreferencesRepository = userPreferencesRepository,
6666
)
67-
is WalletCreateType.LOADEXISTING ->
67+
}
68+
69+
is WalletCreateType.LOADEXISTING -> {
6870
Wallet.loadActiveWallet(
6971
activeWallet = walletCreateType.activeWallet,
7072
internalAppFilesPath = filesDir.absolutePath,
7173
userPreferencesRepository = userPreferencesRepository,
7274
)
73-
is WalletCreateType.RECOVER ->
75+
}
76+
77+
is WalletCreateType.RECOVER -> {
7478
Wallet.recoverWallet(
7579
recoverWalletConfig = walletCreateType.recoverWalletConfig,
7680
internalAppFilesPath = filesDir.absolutePath,
7781
userPreferencesRepository = userPreferencesRepository,
7882
)
83+
}
7984
}
8085
} catch (e: Throwable) {
8186
Log.i(TAG, "Could not build wallet: $e")

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/navigation/AppNavigation.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import androidx.navigation.toRoute
2424
import org.bitcoindevkit.devkitwallet.data.SingleWallet
2525
import org.bitcoindevkit.devkitwallet.domain.Wallet
2626
import org.bitcoindevkit.devkitwallet.presentation.WalletCreateType
27+
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.ActiveWalletsScreen
28+
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.CreateNewWalletScreen
29+
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.RecoverWalletScreen
30+
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.WalletChoiceScreen
2731
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.settings.AboutScreen
2832
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.settings.BlockchainClientScreen
2933
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.settings.LogsScreen
3034
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.settings.RecoveryDataScreen
3135
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.settings.SettingsScreen
32-
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.ActiveWalletsScreen
33-
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.CreateNewWalletScreen
34-
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.RecoverWalletScreen
35-
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.intro.WalletChoiceScreen
3636
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.wallet.RBFScreen
3737
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.wallet.ReceiveScreen
3838
import org.bitcoindevkit.devkitwallet.presentation.ui.screens.wallet.SendScreen

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/screens/wallet/TransactionScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ fun TransactionDetailButton(content: String, navController: NavController, txid:
8585
"increase fees" -> {
8686
navController.navigate(RbfScreen(txid!!))
8787
}
88+
8889
"back to transaction list" -> {
8990
navController.navigateUp()
9091
}

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/screens/wallet/WalletHomeScreen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ internal fun WalletHomeScreen(
141141
color = colorScheme.onSurface,
142142
)
143143
}
144+
144145
CurrencyUnit.Satoshi -> {
145146
Text(
146147
text = "${state.balance} sat",
@@ -397,10 +398,12 @@ fun isOnline(context: Context): Boolean {
397398
Log.i("Internet", "NetworkCapabilities.TRANSPORT_CELLULAR")
398399
return true
399400
}
401+
400402
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
401403
Log.i("Internet", "NetworkCapabilities.TRANSPORT_WIFI")
402404
return true
403405
}
406+
404407
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
405408
Log.i("Internet", "NetworkCapabilities.TRANSPORT_ETHERNET")
406409
return true

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/viewmodels/SendViewModel.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ internal class SendViewModel(private val wallet: Wallet) : ViewModel() {
3636
// Create, sign, and broadcast
3737
val psbt: Psbt =
3838
when (txInfo.transactionType) {
39-
TransactionType.STANDARD ->
39+
TransactionType.STANDARD -> {
4040
wallet.createTransaction(
4141
recipientList = txInfo.recipients,
4242
feeRate = FeeRate.fromSatPerVb(txInfo.feeRate),
4343
opReturnMsg = txInfo.opReturnMsg,
4444
)
45+
}
46+
4547
// TransactionType.SEND_ALL -> Wallet.createSendAllTransaction(recipientList[0].address, FeeRate.fromSatPerVb(feeRate), rbfEnabled, opReturnMsg)
46-
TransactionType.SEND_ALL -> throw NotImplementedError("Send all not implemented")
48+
TransactionType.SEND_ALL -> {
49+
throw NotImplementedError("Send all not implemented")
50+
}
4751
}
4852
val isSigned = wallet.sign(psbt)
4953
if (isSigned) {

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/viewmodels/WalletViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ internal class WalletViewModel(
3333
private val kyotoCoroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO)
3434
private var kyoto: Kyoto? = null
3535

36+
@Suppress("ktlint:standard:no-multi-spaces")
3637
fun onAction(action: WalletScreenAction) {
3738
when (action) {
3839
WalletScreenAction.SwitchUnit -> switchUnit()

0 commit comments

Comments
 (0)