From e47117cb34c16e27b7dca7cc1beeaeb9a833cd95 Mon Sep 17 00:00:00 2001 From: aminsato Date: Sat, 19 Oct 2024 11:09:45 +0330 Subject: [PATCH 1/5] Fix missing swap progress link --- .../ui/models/KeySignWrapperViewModel.kt | 6 +- .../ui/models/keysign/JoinKeysignViewModel.kt | 14 +-- .../ui/models/keysign/KeysignFlowViewModel.kt | 12 +-- .../ui/models/keysign/KeysignViewModel.kt | 18 ++-- .../ui/screens/TransactionDoneScreen.kt | 86 +++++++++---------- .../ui/screens/keysign/JoinKeysignView.kt | 4 +- .../wallet/ui/screens/keysign/Keysign.kt | 18 ++-- .../repositories/ExplorerLinkRepository.kt | 15 ++++ 8 files changed, 98 insertions(+), 75 deletions(-) diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/KeySignWrapperViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/KeySignWrapperViewModel.kt index 376d4768a..1eb9e8036 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/KeySignWrapperViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/KeySignWrapperViewModel.kt @@ -2,7 +2,7 @@ package com.vultisig.wallet.ui.models import androidx.lifecycle.ViewModel import com.vultisig.wallet.ui.models.keysign.KeysignViewModel -import com.vultisig.wallet.ui.models.keysign.TransitionTypeUiModel +import com.vultisig.wallet.ui.models.keysign.TransactionTypeUiModel import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject @@ -15,7 +15,7 @@ internal class KeySignWrapperViewModel @AssistedInject constructor( @Assisted val viewModel: KeysignViewModel, ) : ViewModel() { - val transactionUiModel = MutableStateFlow(null) + val transactionUiModel = MutableStateFlow(null) @AssistedFactory interface Factory { @@ -27,7 +27,7 @@ internal class KeySignWrapperViewModel @AssistedInject constructor( } fun loadTransaction() { - viewModel.transitionTypeUiModel?.let { transactionUiType -> + viewModel.transactionTypeUiModel?.let { transactionUiType -> transactionUiModel.update { transactionUiType } } } diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt index 7e76eb2d5..8a4a6c188 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/JoinKeysignViewModel.kt @@ -171,7 +171,7 @@ internal class JoinKeysignViewModel @Inject constructor( private var _jobWaitingForKeysignStart: Job? = null private var isNavigateToHome: Boolean = false - private var transitionTypeUiModel: TransitionTypeUiModel? = null + private var transactionTypeUiModel: TransactionTypeUiModel? = null private val keysignPayload: KeysignPayload? get() = _keysignPayload @@ -196,7 +196,7 @@ internal class JoinKeysignViewModel @Inject constructor( sessionApi = sessionApi, suiApi = suiApi, navigator = navigator, - transitionTypeUiModel = transitionTypeUiModel, + transactionTypeUiModel = transactionTypeUiModel, encryption = encryption, featureFlagApi = featureFlagApi, ) @@ -308,7 +308,7 @@ internal class JoinKeysignViewModel @Inject constructor( ), ) - transitionTypeUiModel = TransitionTypeUiModel.Swap(swapTransaction) + transactionTypeUiModel = TransactionTypeUiModel.Swap(swapTransaction) verifyUiModel.value = VerifyUiModel.Swap( VerifySwapUiModel( @@ -341,7 +341,7 @@ internal class JoinKeysignViewModel @Inject constructor( convertTokenValueToFiat(dstToken, quote.fees, currency) ), ) - transitionTypeUiModel = TransitionTypeUiModel.Swap(swapTransactionUiModel) + transactionTypeUiModel = TransactionTypeUiModel.Swap(swapTransactionUiModel) verifyUiModel.value = VerifyUiModel.Swap( VerifySwapUiModel( provider = R.string.swap_form_provider_thorchain.asUiText(), @@ -374,7 +374,7 @@ internal class JoinKeysignViewModel @Inject constructor( convertTokenValueToFiat(nativeToken, quote.fees, currency) ), ) - transitionTypeUiModel = TransitionTypeUiModel.Swap(swapTransactionUiModel) + transactionTypeUiModel = TransactionTypeUiModel.Swap(swapTransactionUiModel) verifyUiModel.value = VerifyUiModel.Swap( VerifySwapUiModel( provider = R.string.swap_form_provider_mayachain.asUiText(), @@ -417,7 +417,7 @@ internal class JoinKeysignViewModel @Inject constructor( ), memo = payload.memo ?: "", ) - transitionTypeUiModel = TransitionTypeUiModel.Deposit(depositTransactionUiModel) + transactionTypeUiModel = TransactionTypeUiModel.Deposit(depositTransactionUiModel) verifyUiModel.value = VerifyUiModel.Deposit( VerifyDepositUiModel( depositTransactionUiModel @@ -469,7 +469,7 @@ internal class JoinKeysignViewModel @Inject constructor( ) val transactionToUiModel = mapTransactionToUiModel(transaction) - transitionTypeUiModel = TransitionTypeUiModel.Send(transactionToUiModel) + transactionTypeUiModel = TransactionTypeUiModel.Send(transactionToUiModel) verifyUiModel.value = VerifyUiModel.Send( VerifyTransactionUiModel( transaction = transactionToUiModel, diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignFlowViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignFlowViewModel.kt index 1a001d5eb..2367d592c 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignFlowViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignFlowViewModel.kt @@ -160,7 +160,7 @@ internal class KeysignFlowViewModel @Inject constructor( networkOption.value == NetworkPromptOption.INTERNET || isFastSign } - private var transitionTypeUiModel: TransitionTypeUiModel? = null + private var transactionTypeUiModel: TransactionTypeUiModel? = null val keysignViewModel: KeysignViewModel @@ -186,7 +186,7 @@ internal class KeysignFlowViewModel @Inject constructor( navigator = navigator, encryption = encryption, featureFlagApi = featureFlagApi, - transitionTypeUiModel = transitionTypeUiModel + transactionTypeUiModel = transactionTypeUiModel ) init { @@ -417,20 +417,20 @@ internal class KeysignFlowViewModel @Inject constructor( else -> false } viewModelScope.launch { - transitionTypeUiModel = when { - isSwap -> TransitionTypeUiModel.Swap( + transactionTypeUiModel = when { + isSwap -> TransactionTypeUiModel.Swap( mapSwapTransactionToUiModel( swapTransactionRepository.getTransaction(transactionId) ) ) - isDeposit -> TransitionTypeUiModel.Deposit( + isDeposit -> TransactionTypeUiModel.Deposit( mapDepositTransactionUiModel( depositTransactionRepository.getTransaction(transactionId) ) ) - else -> TransitionTypeUiModel.Send( + else -> TransactionTypeUiModel.Send( mapTransactionToUiModel( transactionRepository.getTransaction( transactionId diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt index b73a94568..f898dfe26 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt @@ -67,10 +67,10 @@ internal sealed class KeysignState { } -internal sealed interface TransitionTypeUiModel { - data class Send(val transactionUiModel: TransactionUiModel) : TransitionTypeUiModel - data class Swap(val swapTransactionUiModel: SwapTransactionUiModel) : TransitionTypeUiModel - data class Deposit(val depositTransactionUiModel: DepositTransactionUiModel) : TransitionTypeUiModel +internal sealed interface TransactionTypeUiModel { + data class Send(val transactionUiModel: TransactionUiModel) : TransactionTypeUiModel + data class Swap(val swapTransactionUiModel: SwapTransactionUiModel) : TransactionTypeUiModel + data class Deposit(val depositTransactionUiModel: DepositTransactionUiModel) : TransactionTypeUiModel } internal class KeysignViewModel( @@ -95,13 +95,11 @@ internal class KeysignViewModel( private val sessionApi: SessionApi, private val encryption: Encryption, private val featureFlagApi: FeatureFlagApi, - val transitionTypeUiModel: TransitionTypeUiModel?, + val transactionTypeUiModel: TransactionTypeUiModel?, ) : ViewModel() { private var tssInstance: ServiceImpl? = null private var tssMessenger: TssMessenger? = null private val localStateAccessor: LocalStateAccessor = LocalStateAccessor(vault) - var isThorChainSwap = - keysignPayload.swapPayload is SwapPayload.ThorChain val currentState: MutableStateFlow = MutableStateFlow(KeysignState.CreatingInstance) private var _messagePuller: TssMessagePuller? = null @@ -117,6 +115,12 @@ internal class KeysignViewModel( private var featureFlag: FeatureFlagJson? = null private var isNavigateToHome: Boolean = false + val swapProgressLink = txHash.map { + explorerLinkRepository.getSwapProgressLink(it, keysignPayload.swapPayload) + }.stateIn( + viewModelScope, SharingStarted.WhileSubscribed(), null + ) + fun startKeysign() { viewModelScope.launch { withContext(Dispatchers.IO) { diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt index 1817ddc97..5e1a80c4f 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt @@ -3,6 +3,7 @@ package com.vultisig.wallet.ui.screens import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -12,7 +13,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalClipboardManager -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString @@ -36,7 +36,7 @@ import com.vultisig.wallet.ui.components.library.form.FormCard import com.vultisig.wallet.ui.components.library.form.FormDetails import com.vultisig.wallet.ui.models.TransactionUiModel import com.vultisig.wallet.ui.models.deposit.DepositTransactionUiModel -import com.vultisig.wallet.ui.models.keysign.TransitionTypeUiModel +import com.vultisig.wallet.ui.models.keysign.TransactionTypeUiModel import com.vultisig.wallet.ui.models.swap.SwapTransactionUiModel import com.vultisig.wallet.ui.screens.send.AddressField import com.vultisig.wallet.ui.screens.send.OtherField @@ -47,8 +47,8 @@ internal fun TransactionDoneScreen( navController: NavController, transactionHash: String, transactionLink: String, - isThorChainSwap: Boolean, - transitionTypeUiModel: TransitionTypeUiModel, + progressLink:String?, + transactionTypeUiModel: TransactionTypeUiModel, ) { UiBarContainer( navController = navController, @@ -58,8 +58,8 @@ internal fun TransactionDoneScreen( transactionHash = transactionHash, transactionLink = transactionLink, onComplete = navController::popBackStack, - isThorChainSwap = isThorChainSwap, - transitionTypeUiModel = transitionTypeUiModel, + progressLink = progressLink, + transactionTypeUiModel = transactionTypeUiModel, ) } } @@ -69,12 +69,11 @@ internal fun TransactionDoneView( transactionHash: String, transactionLink: String, onComplete: () -> Unit, - isThorChainSwap: Boolean = false, + progressLink: String?, onBack: () -> Unit = {}, - transitionTypeUiModel: TransitionTypeUiModel?, + transactionTypeUiModel: TransactionTypeUiModel?, ) { val uriHandler = LocalUriHandler.current - val context = LocalContext.current BackHandler(onBack = onBack) Column( modifier = Modifier @@ -125,39 +124,20 @@ internal fun TransactionDoneView( color = Theme.colors.turquoise800, style = Theme.menlo.subtitle3, ) - if (isThorChainSwap) { - Text( - modifier = Modifier - .align(Alignment.End) - .clickOnce { - uriHandler.openUri( - context.getString( - R.string.transaction_done_track_ninerealms, - transactionHash - ) - ) - }, - text = stringResource(R.string.transaction_swap_tracking_link), - color = Theme.colors.turquoise800, - style = Theme.montserrat.body3.copy( - textDecoration = TextDecoration.Underline, - lineHeight = 22.sp - ), - ) - } + when (transactionTypeUiModel) { + is TransactionTypeUiModel.Deposit -> + DepositTransactionDetail(transactionTypeUiModel.depositTransactionUiModel) - when (transitionTypeUiModel) { - is TransitionTypeUiModel.Deposit -> - DepositTransactionDetail(transitionTypeUiModel.depositTransactionUiModel) + is TransactionTypeUiModel.Send -> + TransactionDetail(transaction = transactionTypeUiModel.transactionUiModel) - is TransitionTypeUiModel.Send -> - TransactionDetail(transaction = transitionTypeUiModel.transactionUiModel) - - is TransitionTypeUiModel.Swap -> SwapTransactionDetail( - swapTransaction = - transitionTypeUiModel.swapTransactionUiModel - ) + is TransactionTypeUiModel.Swap -> SwapTransactionDetail( + swapTransaction = transactionTypeUiModel.swapTransactionUiModel, + progressLink = progressLink, + ) { progressLink -> + uriHandler.openUri(progressLink) + } else -> Unit } @@ -209,7 +189,11 @@ private fun DepositTransactionDetail(depositTransaction: DepositTransactionUiMod } @Composable -private fun SwapTransactionDetail(swapTransaction: SwapTransactionUiModel?) { +private fun ColumnScope.SwapTransactionDetail( + swapTransaction: SwapTransactionUiModel?, + progressLink: String?, + onProgressLinkClick: (String) -> Unit, +) { if (swapTransaction != null) { AddressField( title = stringResource(R.string.verify_transaction_from_title), @@ -231,8 +215,24 @@ private fun SwapTransactionDetail(swapTransaction: SwapTransactionUiModel?) { OtherField( title = stringResource(R.string.verify_swap_screen_estimated_fees), value = swapTransaction.estimatedFees, - divider = false, ) + + if (progressLink != null) { + Text( + modifier = Modifier + .padding(top = 8.dp) + .align(Alignment.End) + .clickOnce(onClick = { + onProgressLinkClick(progressLink) + }), + text = stringResource(R.string.transaction_swap_tracking_link), + color = Theme.colors.turquoise800, + style = Theme.montserrat.body3.copy( + textDecoration = TextDecoration.Underline, + lineHeight = 22.sp + ), + ) + } } } @@ -314,8 +314,8 @@ private fun TransactionDoneScreenPreview() { navController = rememberNavController(), transactionHash = "0x1234567890", transactionLink = "", - isThorChainSwap = true, - transitionTypeUiModel = TransitionTypeUiModel.Send( + progressLink = "https://track.ninerealms.com/", + transactionTypeUiModel = TransactionTypeUiModel.Send( TransactionUiModel( srcAddress = "0x1234567890", dstAddress = "0x1234567890", diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/JoinKeysignView.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/JoinKeysignView.kt index 5218b687f..fdf705efd 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/JoinKeysignView.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/JoinKeysignView.kt @@ -127,12 +127,12 @@ internal fun JoinKeysignView( state = kState, txHash = keysignViewModel.txHash.collectAsState().value, transactionLink = keysignViewModel.txLink.collectAsState().value, - isThorChainSwap = keysignViewModel.isThorChainSwap, + progressLink = keysignViewModel.swapProgressLink.collectAsState().value, onComplete = { navController.navigate(Destination.Home().route) }, onBack = keysignViewModel::navigateToHome, - transitionTypeUiModel = keysignViewModel.transitionTypeUiModel + transactionTypeUiModel = keysignViewModel.transactionTypeUiModel ) } diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt index 30b5629be..04705656c 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt @@ -27,7 +27,7 @@ import com.vultisig.wallet.ui.models.KeySignWrapperViewModel import com.vultisig.wallet.ui.models.TransactionUiModel import com.vultisig.wallet.ui.models.keysign.KeysignState import com.vultisig.wallet.ui.models.keysign.KeysignViewModel -import com.vultisig.wallet.ui.models.keysign.TransitionTypeUiModel +import com.vultisig.wallet.ui.models.keysign.TransactionTypeUiModel import com.vultisig.wallet.ui.screens.TransactionDoneView import com.vultisig.wallet.ui.theme.Theme import com.vultisig.wallet.ui.utils.showReviewPopUp @@ -65,11 +65,13 @@ internal fun Keysign( } KeysignScreen( state = state, + transactionTypeUiModel = wrapperViewModel.transactionUiModel.collectAsState().value, + errorMessage = keysignViewModel.errorMessage.value, transitionTypeUiModel = wrapperViewModel.transactionUiModel.collectAsState().value, txHash = keysignViewModel.txHash.collectAsState().value, transactionLink = keysignViewModel.txLink.collectAsState().value, onComplete = onComplete, - isThorChainSwap = viewModel.isThorChainSwap, + progressLink = keysignViewModel.swapProgressLink.collectAsState().value, onBack = { viewModel.navigateToHome() } @@ -83,8 +85,8 @@ internal fun KeysignScreen( transactionLink: String, onComplete: () -> Unit, onBack: () -> Unit = {}, - isThorChainSwap: Boolean = false, - transitionTypeUiModel: TransitionTypeUiModel? + progressLink:String?, + transactionTypeUiModel: TransactionTypeUiModel? ) { KeepScreenOn() val text = when (state) { @@ -107,9 +109,9 @@ internal fun KeysignScreen( transactionHash = txHash, transactionLink = transactionLink, onComplete = onComplete, - isThorChainSwap = isThorChainSwap, + progressLink = progressLink, onBack = onBack, - transitionTypeUiModel = transitionTypeUiModel, + transactionTypeUiModel = transactionTypeUiModel, ) } else { UiSpacer(weight = 1f) @@ -142,9 +144,11 @@ internal fun KeysignScreen( private fun KeysignPreview() { KeysignScreen( state = KeysignState.CreatingInstance, + progressLink = null, + errorMessage = "Error", txHash = "0x1234567890", transactionLink = "", - transitionTypeUiModel = TransitionTypeUiModel.Send( + transactionTypeUiModel = TransactionTypeUiModel.Send( TransactionUiModel( srcAddress = "0x1234567890", dstAddress = "0x1234567890", diff --git a/data/src/main/kotlin/com/vultisig/wallet/data/repositories/ExplorerLinkRepository.kt b/data/src/main/kotlin/com/vultisig/wallet/data/repositories/ExplorerLinkRepository.kt index 7a89ca48e..8711e027e 100644 --- a/data/src/main/kotlin/com/vultisig/wallet/data/repositories/ExplorerLinkRepository.kt +++ b/data/src/main/kotlin/com/vultisig/wallet/data/repositories/ExplorerLinkRepository.kt @@ -1,6 +1,7 @@ package com.vultisig.wallet.data.repositories import com.vultisig.wallet.data.models.Chain +import com.vultisig.wallet.data.models.payload.SwapPayload import javax.inject.Inject interface ExplorerLinkRepository { @@ -15,6 +16,10 @@ interface ExplorerLinkRepository { address: String, ): String + fun getSwapProgressLink( + tx: String, + payload: SwapPayload?, + ): String? } internal class ExplorerLinkRepositoryImpl @Inject constructor() : ExplorerLinkRepository { @@ -31,6 +36,16 @@ internal class ExplorerLinkRepositoryImpl @Inject constructor() : ExplorerLinkRe override fun getAddressLink(chain: Chain, address: String): String = "${chain.blockExplorerUrl}$address" + + override fun getSwapProgressLink( + tx: String, + payload: SwapPayload?, + ): String? = when (payload) { + is SwapPayload.ThorChain -> "https://track.ninerealms.com/$tx" + is SwapPayload.MayaChain -> "https://www.xscanner.org/tx/$tx" + else -> null + } + private val Chain.transactionExplorerUrl: String get() = when (this) { Chain.Avalanche, Chain.Arbitrum, Chain.Base, Chain.Blast, Chain.BscChain, From 3d76afeaffe0ac2d17842c9f69b6bcc814aa1312 Mon Sep 17 00:00:00 2001 From: aminsato Date: Sat, 19 Oct 2024 11:43:45 +0330 Subject: [PATCH 2/5] Update Keysign.kt --- .../java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt index 04705656c..55cdca264 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt @@ -66,8 +66,6 @@ internal fun Keysign( KeysignScreen( state = state, transactionTypeUiModel = wrapperViewModel.transactionUiModel.collectAsState().value, - errorMessage = keysignViewModel.errorMessage.value, - transitionTypeUiModel = wrapperViewModel.transactionUiModel.collectAsState().value, txHash = keysignViewModel.txHash.collectAsState().value, transactionLink = keysignViewModel.txLink.collectAsState().value, onComplete = onComplete, @@ -145,7 +143,6 @@ private fun KeysignPreview() { KeysignScreen( state = KeysignState.CreatingInstance, progressLink = null, - errorMessage = "Error", txHash = "0x1234567890", transactionLink = "", transactionTypeUiModel = TransactionTypeUiModel.Send( From 25e785d25883ea94f0fa96c007528b6e618e89ec Mon Sep 17 00:00:00 2001 From: aminsato Date: Sat, 19 Oct 2024 12:21:18 +0330 Subject: [PATCH 3/5] revert omitting isThorChainSwap --- .../ui/models/keysign/KeysignViewModel.kt | 2 ++ .../ui/screens/TransactionDoneScreen.kt | 26 +++++++++++++++++++ .../wallet/ui/screens/keysign/Keysign.kt | 3 +++ 3 files changed, 31 insertions(+) diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt index f898dfe26..7ea1754a2 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt @@ -99,6 +99,8 @@ internal class KeysignViewModel( ) : ViewModel() { private var tssInstance: ServiceImpl? = null private var tssMessenger: TssMessenger? = null + var isThorChainSwap = + keysignPayload.swapPayload is SwapPayload.ThorChain private val localStateAccessor: LocalStateAccessor = LocalStateAccessor(vault) val currentState: MutableStateFlow = MutableStateFlow(KeysignState.CreatingInstance) diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt index 5e1a80c4f..7bf82048f 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString @@ -47,6 +48,7 @@ internal fun TransactionDoneScreen( navController: NavController, transactionHash: String, transactionLink: String, + isThorChainSwap: Boolean, progressLink:String?, transactionTypeUiModel: TransactionTypeUiModel, ) { @@ -69,11 +71,13 @@ internal fun TransactionDoneView( transactionHash: String, transactionLink: String, onComplete: () -> Unit, + isThorChainSwap: Boolean = false, progressLink: String?, onBack: () -> Unit = {}, transactionTypeUiModel: TransactionTypeUiModel?, ) { val uriHandler = LocalUriHandler.current + val context = LocalContext.current BackHandler(onBack = onBack) Column( modifier = Modifier @@ -124,6 +128,27 @@ internal fun TransactionDoneView( color = Theme.colors.turquoise800, style = Theme.menlo.subtitle3, ) + if (isThorChainSwap) { + Text( + modifier = Modifier + .align(Alignment.End) + .clickOnce { + uriHandler.openUri( + context.getString( + R.string.transaction_done_track_ninerealms, + transactionHash + ) + ) + }, + text = stringResource(R.string.transaction_swap_tracking_link), + color = Theme.colors.turquoise800, + style = Theme.montserrat.body3.copy( + textDecoration = TextDecoration.Underline, + lineHeight = 22.sp + ), + + ) + } when (transactionTypeUiModel) { is TransactionTypeUiModel.Deposit -> @@ -314,6 +339,7 @@ private fun TransactionDoneScreenPreview() { navController = rememberNavController(), transactionHash = "0x1234567890", transactionLink = "", + isThorChainSwap = true, progressLink = "https://track.ninerealms.com/", transactionTypeUiModel = TransactionTypeUiModel.Send( TransactionUiModel( diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt index 55cdca264..9963a6f57 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt @@ -69,6 +69,7 @@ internal fun Keysign( txHash = keysignViewModel.txHash.collectAsState().value, transactionLink = keysignViewModel.txLink.collectAsState().value, onComplete = onComplete, + isThorChainSwap = viewModel.isThorChainSwap, progressLink = keysignViewModel.swapProgressLink.collectAsState().value, onBack = { viewModel.navigateToHome() @@ -83,6 +84,7 @@ internal fun KeysignScreen( transactionLink: String, onComplete: () -> Unit, onBack: () -> Unit = {}, + isThorChainSwap: Boolean = false, progressLink:String?, transactionTypeUiModel: TransactionTypeUiModel? ) { @@ -107,6 +109,7 @@ internal fun KeysignScreen( transactionHash = txHash, transactionLink = transactionLink, onComplete = onComplete, + isThorChainSwap = isThorChainSwap, progressLink = progressLink, onBack = onBack, transactionTypeUiModel = transactionTypeUiModel, From cc4763b5eb6533dbc33318bb12f7d34dbf9d4a25 Mon Sep 17 00:00:00 2001 From: aminsato Date: Sat, 19 Oct 2024 12:39:01 +0330 Subject: [PATCH 4/5] Revert "revert omitting isThorChainSwap" This reverts commit 25e785d25883ea94f0fa96c007528b6e618e89ec. --- .../ui/models/keysign/KeysignViewModel.kt | 2 -- .../ui/screens/TransactionDoneScreen.kt | 26 ------------------- .../wallet/ui/screens/keysign/Keysign.kt | 3 --- 3 files changed, 31 deletions(-) diff --git a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt index 7ea1754a2..f898dfe26 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/models/keysign/KeysignViewModel.kt @@ -99,8 +99,6 @@ internal class KeysignViewModel( ) : ViewModel() { private var tssInstance: ServiceImpl? = null private var tssMessenger: TssMessenger? = null - var isThorChainSwap = - keysignPayload.swapPayload is SwapPayload.ThorChain private val localStateAccessor: LocalStateAccessor = LocalStateAccessor(vault) val currentState: MutableStateFlow = MutableStateFlow(KeysignState.CreatingInstance) diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt index 7bf82048f..5e1a80c4f 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/TransactionDoneScreen.kt @@ -13,7 +13,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalClipboardManager -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString @@ -48,7 +47,6 @@ internal fun TransactionDoneScreen( navController: NavController, transactionHash: String, transactionLink: String, - isThorChainSwap: Boolean, progressLink:String?, transactionTypeUiModel: TransactionTypeUiModel, ) { @@ -71,13 +69,11 @@ internal fun TransactionDoneView( transactionHash: String, transactionLink: String, onComplete: () -> Unit, - isThorChainSwap: Boolean = false, progressLink: String?, onBack: () -> Unit = {}, transactionTypeUiModel: TransactionTypeUiModel?, ) { val uriHandler = LocalUriHandler.current - val context = LocalContext.current BackHandler(onBack = onBack) Column( modifier = Modifier @@ -128,27 +124,6 @@ internal fun TransactionDoneView( color = Theme.colors.turquoise800, style = Theme.menlo.subtitle3, ) - if (isThorChainSwap) { - Text( - modifier = Modifier - .align(Alignment.End) - .clickOnce { - uriHandler.openUri( - context.getString( - R.string.transaction_done_track_ninerealms, - transactionHash - ) - ) - }, - text = stringResource(R.string.transaction_swap_tracking_link), - color = Theme.colors.turquoise800, - style = Theme.montserrat.body3.copy( - textDecoration = TextDecoration.Underline, - lineHeight = 22.sp - ), - - ) - } when (transactionTypeUiModel) { is TransactionTypeUiModel.Deposit -> @@ -339,7 +314,6 @@ private fun TransactionDoneScreenPreview() { navController = rememberNavController(), transactionHash = "0x1234567890", transactionLink = "", - isThorChainSwap = true, progressLink = "https://track.ninerealms.com/", transactionTypeUiModel = TransactionTypeUiModel.Send( TransactionUiModel( diff --git a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt index 9963a6f57..55cdca264 100644 --- a/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt +++ b/app/src/main/java/com/vultisig/wallet/ui/screens/keysign/Keysign.kt @@ -69,7 +69,6 @@ internal fun Keysign( txHash = keysignViewModel.txHash.collectAsState().value, transactionLink = keysignViewModel.txLink.collectAsState().value, onComplete = onComplete, - isThorChainSwap = viewModel.isThorChainSwap, progressLink = keysignViewModel.swapProgressLink.collectAsState().value, onBack = { viewModel.navigateToHome() @@ -84,7 +83,6 @@ internal fun KeysignScreen( transactionLink: String, onComplete: () -> Unit, onBack: () -> Unit = {}, - isThorChainSwap: Boolean = false, progressLink:String?, transactionTypeUiModel: TransactionTypeUiModel? ) { @@ -109,7 +107,6 @@ internal fun KeysignScreen( transactionHash = txHash, transactionLink = transactionLink, onComplete = onComplete, - isThorChainSwap = isThorChainSwap, progressLink = progressLink, onBack = onBack, transactionTypeUiModel = transactionTypeUiModel, From ac789dd8aa5c99f64ded9450535a478c41757c81 Mon Sep 17 00:00:00 2001 From: aminsato Date: Sat, 19 Oct 2024 12:47:47 +0330 Subject: [PATCH 5/5] Update strings.xml --- app/src/main/res/values/strings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b9f99276a..fbb197814 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -289,7 +289,6 @@ %s message deposit Custom memo Swap tracking link - https://track.ninerealms.com/%1$s Source and destination assets cannot be the same. Address Book Address Book