Skip to content

Commit

Permalink
Increment to version 4.0.34
Browse files Browse the repository at this point in the history
  • Loading branch information
angelix committed Sep 16, 2024
1 parent 73309cb commit beb05ff
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 149 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [4.0.34] - 2024-09-04

### Changed
- Update dependencies
-
- ### Fixed
- Various bug fixes

## [4.0.33] - 2024-08-15

- ### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.blockstream.common.gdk.data.Network
import com.blockstream.common.gdk.data.Transaction
import com.blockstream.common.looks.transaction.Completed
import com.blockstream.common.looks.transaction.TransactionLook
import com.blockstream.common.looks.transaction.TransactionStatus
import com.blockstream.common.looks.wallet.WalletListLook
import kotlinx.datetime.Clock

Expand Down Expand Up @@ -129,4 +130,4 @@ fun previewTransaction() = Transaction(
it.accountInjected = previewAccount()
}

fun previewTransactionLook() = TransactionLook(Completed, 1, previewTransaction(), listOf("12311.123 BTC"))
fun previewTransactionLook(status: TransactionStatus = Completed()) = TransactionLook(status, previewTransaction(), listOf("12311.123 BTC"))
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,8 @@ class GdkSession constructor(
// Init SDK
initLightningSdk(lightningMnemonic)

if (hasLightning || ((isRestore || isSmartDiscovery) && settingsManager.isLightningEnabled())) {
// SmartDiscovery only for SW wallets, on HW ln mnemonic is not available
if (hasLightning || ((isRestore || (isSmartDiscovery && !isHardwareWallet)) && settingsManager.isLightningEnabled())) {
// Make it async to speed up login process
val job = scope.async {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import com.blockstream.common.utils.Loggable
import com.blockstream.common.utils.toAmountLookOrNa
import org.jetbrains.compose.resources.StringResource

data class TransactionLook(
data class TransactionLook constructor(
val status: TransactionStatus,
val confirmations: Long,
val transaction: Transaction,
val assets: List<String>
) {
Expand All @@ -27,11 +26,11 @@ data class TransactionLook(
val directionText: StringResource
get() = when {
transaction.txType == Transaction.Type.IN -> {
if (confirmations > 0) Res.string.id_received else Res.string.id_receiving
if (status.confirmations > 0) Res.string.id_received else Res.string.id_receiving
}

transaction.txType == Transaction.Type.OUT -> {
if (confirmations > 0) Res.string.id_sent else Res.string.id_sending
if (status.confirmations > 0) Res.string.id_sent else Res.string.id_sending
}

transaction.txType == Transaction.Type.REDEPOSIT -> Res.string.id_redeposited
Expand All @@ -45,7 +44,6 @@ data class TransactionLook(

return TransactionLook(
transaction = transaction,
confirmations = transaction.getConfirmations(session),
status = TransactionStatus.create(transaction, session),
assets = transaction.assets.map {
session.starsOrNull ?: it.second.toAmountLookOrNa(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.blockstream.common.gdk.data.Transaction


sealed interface TransactionStatus {
val confirmations: Long

val onProgress: Boolean
get() = this is Unconfirmed || this is Confirmed

Expand All @@ -16,15 +18,15 @@ sealed interface TransactionStatus {
Failed()
}
confirmations == 0L -> {
Unconfirmed(transaction.network.confirmationsRequired)
Unconfirmed(confirmationsRequired = transaction.network.confirmationsRequired)
}

confirmations < transaction.network.confirmationsRequired -> {
Confirmed(confirmations = confirmations, transaction.network.confirmationsRequired)
}

confirmations >= transaction.network.confirmationsRequired -> {
Completed
Completed(confirmations = confirmations)
}

else -> {
Expand All @@ -35,7 +37,11 @@ sealed interface TransactionStatus {
}
}

class Unconfirmed(val confirmationsRequired: Long = 6) : TransactionStatus
class Confirmed(val confirmations: Long, val confirmationsRequired : Long = 6) : TransactionStatus
object Completed : TransactionStatus
class Failed(val error: String = "") : TransactionStatus
data class Unconfirmed(val confirmationsRequired: Long = 6): TransactionStatus {
override val confirmations: Long= 0
}
data class Confirmed(override val confirmations: Long, val confirmationsRequired : Long = 6) : TransactionStatus
data class Completed(override val confirmations: Long = Long.MAX_VALUE) : TransactionStatus
data class Failed(val error: String = "") : TransactionStatus {
override val confirmations: Long= 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ abstract class AddAccountViewModelAbstract(greenWallet: GreenWallet, val assetId
}


if (appInfo.isDevelopmentOrDebug) {
logger.i { "Development/Debug feature setCloseToAddress" }
session.accounts.value.filter { it.isBitcoin }.let { accounts ->
accounts.find { it.type == AccountType.BIP84_SEGWIT }
?: accounts.find { it.type == AccountType.BIP49_SEGWIT_WRAPPED }
}?.also {
session.lightningSdk.setCloseToAddress(session.getReceiveAddress(it).address)
}
}
// if (appInfo.isDevelopmentOrDebug) {
// logger.i { "Development/Debug feature setCloseToAddress" }
// session.accounts.value.filter { it.isBitcoin }.let { accounts ->
// accounts.find { it.type == AccountType.BIP84_SEGWIT }
// ?: accounts.find { it.type == AccountType.BIP49_SEGWIT_WRAPPED }
// }?.also {
// session.lightningSdk.setCloseToAddress(session.getReceiveAddress(it).address)
// }
// }

// If wallet is new and LN is created, default to Satoshi
if (isEmptyWallet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class TransactionViewModelPreview(status : TransactionStatus) : TransactionViewM
companion object {
fun previewUnconfirmed() = TransactionViewModelPreview(Unconfirmed())
fun previewConfirmed() = TransactionViewModelPreview(Confirmed(confirmations = 3, confirmationsRequired = 6))
fun previewCompleted() = TransactionViewModelPreview(Completed)
fun previewCompleted() = TransactionViewModelPreview(Completed(Long.MAX_VALUE))
fun previewFailed() = TransactionViewModelPreview(Failed())
}
}
3 changes: 2 additions & 1 deletion compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins {
Expand Down Expand Up @@ -112,6 +112,7 @@ kotlin {
/** ----------------------------------------------------------------------------------------- */

/** --- Material --------------------------------------------------------------------------- */
implementation(libs.compose.material3)
implementation(libs.compose.material3.android)
/** ----------------------------------------------------------------------------------------- */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.tooling.preview.Preview
import com.blockstream.common.extensions.previewTransactionLook
import com.blockstream.common.looks.transaction.Confirmed
import com.blockstream.compose.theme.GreenThemePreview


Expand All @@ -16,7 +17,7 @@ fun GreenTransactionPreview() {

}

GreenTransaction(transactionLook = previewTransactionLook(), showAccount = false) {
GreenTransaction(transactionLook = previewTransactionLook(status = Confirmed(1, 2)), showAccount = false) {

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fun TransactionStatusIconPreview() {
Column {

TransactionStatusIcon(
transactionStatus = Completed,
transactionStatus = Completed(),
icons = listOf(painterResource(id = R.drawable.bitcoin))
)
TransactionStatusIcon(
transactionStatus = Completed,
transactionStatus = Completed(),
icons = listOf(painterResource(id = R.drawable.bitcoin), painterResource(id = R.drawable.liquid)),
isSwap = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ fun GreenTransaction(
) {
if (status is Confirmed) {
LinearProgressIndicator(progress = {
(status.confirmations / status.confirmationsRequired).toFloat()
status.confirmations / status.confirmationsRequired.toFloat()
}, modifier = Modifier.fillMaxWidth())
} else {
LinearProgressIndicator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fun TransactionStatus.color() = when (this) {
fun TransactionStatus.title() = when (this) {
is Unconfirmed -> stringResource(Res.string.id_transaction_confirmed_ss, "0", confirmationsRequired.toString())
is Confirmed -> stringResource(Res.string.id_transaction_confirmed_ss, confirmations.toString(), confirmationsRequired.toString())
Completed -> stringResource(Res.string.id_transaction_completed)
is Completed -> stringResource(Res.string.id_transaction_completed)
is Failed -> stringResource(Res.string.id_transaction_failed)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import com.blockstream.compose.components.GreenRow
import com.blockstream.compose.components.ScreenContainer
import com.blockstream.compose.dialogs.LightningShortcutDialog
import com.blockstream.compose.extensions.drawDiagonalLabel
import com.blockstream.compose.navigation.setNavigationResult
import com.blockstream.compose.screens.jade.JadeQRScreen
import com.blockstream.compose.sheets.AssetsBottomSheet
import com.blockstream.compose.sideeffects.OpenDialogData
Expand Down Expand Up @@ -110,10 +109,7 @@ data class ChooseAccountTypeScreen(
}

companion object {
@Composable
fun getNavigationResult(fn: (AccountAsset) -> Unit) = com.blockstream.compose.navigation.getNavigationResult(this::class, fn)

internal fun setNavigationResult(result: AccountAsset) = setNavigationResult(this::class, result)
internal fun setResult(result: AccountAsset) = ReviewAddAccountScreen.setResult(result)
}
}

Expand All @@ -137,8 +133,7 @@ fun ChooseAccountTypeScreen(
HandleSideEffect(viewModel) {
when(it) {
is SideEffects.AccountCreated -> {
// TODO make it unique
ChooseAccountTypeScreen.setNavigationResult(it.accountAsset)
ChooseAccountTypeScreen.setResult(it.accountAsset)
}
is SideEffects.LightningShortcut -> {
lightningShortcutViewModel = SimpleGreenViewModel(viewModel.greenWallet)
Expand Down Expand Up @@ -180,7 +175,7 @@ fun ChooseAccountTypeScreen(
}
}

AssetsBottomSheet.getNavigationResult {
AssetsBottomSheet.getResult {
viewModel.asset.value = it
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ import com.blockstream.common.data.GreenWallet
import com.blockstream.common.data.SetupArgs
import com.blockstream.common.events.Events
import com.blockstream.common.extensions.isNotBlank
import com.blockstream.common.gdk.data.AccountAsset
import com.blockstream.common.models.add.ReviewAddAccountViewModel
import com.blockstream.common.models.add.ReviewAddAccountViewModelAbstract
import com.blockstream.common.sideeffects.SideEffects
import com.blockstream.compose.components.GreenButton
import com.blockstream.compose.components.GreenColumn
import com.blockstream.compose.components.ScreenContainer
import com.blockstream.compose.navigation.getNavigationResult
import com.blockstream.compose.navigation.setNavigationResult
import com.blockstream.compose.theme.MonospaceFont
import com.blockstream.compose.theme.displayMedium
import com.blockstream.compose.theme.labelLarge
Expand Down Expand Up @@ -61,14 +65,27 @@ data class ReviewAddAccountScreen(

ReviewAddAccountScreen(viewModel = viewModel)
}

companion object {
@Composable
fun getResult(fn: (AccountAsset) -> Unit) = getNavigationResult(this::class, fn)

internal fun setResult(result: AccountAsset) = setNavigationResult(this::class, result)
}
}

@Composable
fun ReviewAddAccountScreen(
viewModel: ReviewAddAccountViewModelAbstract
) {

HandleSideEffect(viewModel)
HandleSideEffect(viewModel) {
when(it) {
is SideEffects.AccountCreated -> {
ReviewAddAccountScreen.setResult(it.accountAsset)
}
}
}

val onProgress by viewModel.onProgress.collectAsStateWithLifecycle()
val onProgressDescription by viewModel.onProgressDescription.collectAsStateWithLifecycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import com.blockstream.compose.components.GreenRow
import com.blockstream.compose.components.LearnMoreButton
import com.blockstream.compose.extensions.onValueChange
import com.blockstream.compose.managers.rememberPlatformManager
import com.blockstream.compose.screens.add.ReviewAddAccountScreen
import com.blockstream.compose.sheets.ChooseAssetAccountBottomSheet
import com.blockstream.compose.sheets.DenominationBottomSheet
import com.blockstream.compose.sheets.LocalBottomSheetNavigatorM3
Expand Down Expand Up @@ -133,6 +134,10 @@ fun ReceiveScreen(
viewModel: ReceiveViewModelAbstract
) {

ReviewAddAccountScreen.getResult {
viewModel.postEvent(Events.SetAccountAsset(it))
}

ChooseAssetAccountBottomSheet.getResult {
viewModel.accountAsset.value = it
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.blockstream.common.data.Denomination
import com.blockstream.common.data.GreenWallet
import com.blockstream.common.extensions.isNotBlank
import com.blockstream.common.gdk.data.AccountAsset
import com.blockstream.common.models.add.ChooseAccountTypeViewModel
import com.blockstream.common.models.send.CreateTransactionViewModelAbstract
import com.blockstream.common.models.send.SendConfirmViewModel
import com.blockstream.common.models.send.SendConfirmViewModelAbstract
Expand Down Expand Up @@ -87,7 +86,6 @@ fun SendConfirmScreen(
viewModel: SendConfirmViewModelAbstract
) {
val look by viewModel.transactionConfirmLook.collectAsStateWithLifecycle()
val onProgress by viewModel.onProgress.collectAsStateWithLifecycle()
val onProgressSending by viewModel.onProgressSending.collectAsStateWithLifecycle()
val onProgressDescription by viewModel.onProgressDescription.collectAsStateWithLifecycle()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fun TwoFactorSetupScreen(
) {
val focusRequester = remember { FocusRequester() }

CountriesBottomSheet.getNavigationResult {
CountriesBottomSheet.getResult {
viewModel.country.value = it.dialCodeString
focusRequester.requestFocus()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down Expand Up @@ -317,15 +316,17 @@ fun Descriptor(
)
}

GreenRow(space = 0, padding = 0, verticalAlignment = Alignment.Top) {
SelectionContainer(modifier = Modifier.weight(1f)) {
Text(
text = descriptor,
style = bodyMedium,
color = whiteMedium,
fontFamily = MonospaceFont()
)
}
Row(verticalAlignment = Alignment.Top, modifier = Modifier.fillMaxWidth()) {
// Disabled SelectionContainer as it fills all space, propably aa bug
// SelectionContainer(modifier = Modifier.weight(1f)) {
Text(
text = descriptor,
style = bodyMedium,
color = whiteMedium,
fontFamily = MonospaceFont(),
modifier = Modifier.weight(1f)
)
// }

Row {
IconButton(onCopy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ data class AssetsBottomSheet(

companion object {
@Composable
fun getNavigationResult(fn: (AssetBalance) -> Unit) = getNavigationResult(this::class, fn)
fun getResult(fn: (AssetBalance) -> Unit) = getNavigationResult(this::class, fn)

internal fun setResult(result: AssetBalance) =
setNavigationResult(this::class, result)
Expand Down
Loading

0 comments on commit beb05ff

Please sign in to comment.