diff --git a/domain/legacy/src/main/assets/contract_methods.json b/domain/legacy/src/main/assets/contract_methods.json index e07b98657c..f7bad0ed28 100644 --- a/domain/legacy/src/main/assets/contract_methods.json +++ b/domain/legacy/src/main/assets/contract_methods.json @@ -121,5 +121,25 @@ }, "0xd0e30db0": { "name":"deposit" + }, + "0x9f50973e": { + "info":"swapExactETCForTokens", + "source":"https://etc.blockscout.com/tx/0xc748777532541e51368089c71c93cb0e410bf93c13908bea2d07ecbbb65aa839", + "name":"swap" + }, + "0x3417c606": { + "info":"swapETCForExactTokens", + "source":"https://etc.blockscout.com/tx/0xb2c5a4418112c0b29654642f9c724bf7b2f9056fc6dd2c22209ed89fe982f0af", + "name":"swap" + }, + "0x65f705d3": { + "info":"swapExactTokensForETC", + "source":"https://etc.blockscout.com/tx/0xdd5d372e8d770e436bd44367bbc64b57d02e7339a1f1b849f7a995a57c65f3dd", + "name":"swap" + }, + "0xb4bc722b": { + "info":"swapTokensForExactETC", + "source":"https://etc.blockscout.com/tx/0xd79e03ca6b71529c94d576ff78c55b4371e2ef3ff8f9a47007995e5b9e77f879", + "name":"swap" } } diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt index df99d53034..d1a57e7726 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt @@ -463,11 +463,7 @@ class DefaultWalletManagersFacade( derivationPath = network.derivationPath.value, ) - val txData = walletManager?.createTransaction(amount, fee, destination)?.copy( - extras = null, // todo add memo [[REDACTED_JIRA]] - ) - - return txData + return walletManager?.createTransaction(amount, fee, destination) } override suspend fun sendTransaction( diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt index 2277937e9d..b0f110d438 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt @@ -97,12 +97,8 @@ class GetCryptoCurrencyActionsUseCase( // copy address activeList.add(TokenActionsState.ActionState.CopyAddress(true)) - // buy - if (rampManager.availableForBuy(cryptoCurrency)) { - activeList.add(TokenActionsState.ActionState.Buy(true)) - } else { - disabledList.add(TokenActionsState.ActionState.Buy(false)) - } + // receive + activeList.add(TokenActionsState.ActionState.Receive(true)) // send if (isSendDisabled(cryptoCurrencyStatus = cryptoCurrencyStatus, coinStatus = coinStatus)) { @@ -111,9 +107,6 @@ class GetCryptoCurrencyActionsUseCase( activeList.add(TokenActionsState.ActionState.Send(true)) } - // receive - activeList.add(TokenActionsState.ActionState.Receive(true)) - // swap if (marketCryptoCurrencyRepository.isExchangeable(userWalletId, cryptoCurrency)) { activeList.add(TokenActionsState.ActionState.Swap(true)) @@ -121,6 +114,13 @@ class GetCryptoCurrencyActionsUseCase( disabledList.add(TokenActionsState.ActionState.Swap(false)) } + // buy + if (rampManager.availableForBuy(cryptoCurrency)) { + activeList.add(TokenActionsState.ActionState.Buy(true)) + } else { + disabledList.add(TokenActionsState.ActionState.Buy(false)) + } + // sell if (rampManager.availableForSell(cryptoCurrency)) { activeList.add(TokenActionsState.ActionState.Sell(true)) diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/MemoVerification.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/MemoVerification.kt index ae24d705fd..2e63cb625f 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/MemoVerification.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/MemoVerification.kt @@ -41,7 +41,12 @@ private fun isAssignableValue(value: String): Boolean { } } -private enum class XlmMemoType { TEXT, ID } +fun determineXlmMemoType(value: String): XlmMemoType = when { + value.isNotEmpty() && value.isDigitsOnly() -> XlmMemoType.ID + else -> XlmMemoType.TEXT +} + +enum class XlmMemoType { TEXT, ID } private const val XRP_TAG_MAX_NUMBER = 4294967295 private const val XLM_MEMO_MAX_LENGTH = 28 \ No newline at end of file diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt index 4fdc321d9f..7d29e9d5cd 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt @@ -6,8 +6,15 @@ import androidx.compose.runtime.setValue import androidx.lifecycle.* import androidx.paging.PagingData import arrow.core.getOrElse +import com.tangem.blockchain.blockchains.binance.BinanceTransactionExtras +import com.tangem.blockchain.blockchains.cosmos.CosmosTransactionExtras +import com.tangem.blockchain.blockchains.stellar.StellarMemo +import com.tangem.blockchain.blockchains.stellar.StellarTransactionExtras +import com.tangem.blockchain.blockchains.ton.TonTransactionExtras import com.tangem.blockchain.blockchains.xrp.XrpAddressService +import com.tangem.blockchain.blockchains.xrp.XrpTransactionBuilder import com.tangem.blockchain.common.Blockchain +import com.tangem.blockchain.common.TransactionExtras import com.tangem.blockchain.common.address.Address import com.tangem.blockchain.common.transaction.Fee import com.tangem.blockchain.common.transaction.TransactionFee @@ -80,7 +87,7 @@ internal class SendViewModel @Inject constructor( private val selectedAppCurrencyFlow: StateFlow = createSelectedAppCurrencyFlow() - private var inneRrouter: InnerSendRouter by Delegates.notNull() + private var innerRouter: InnerSendRouter by Delegates.notNull() private var stateRouter: StateRouter by Delegates.notNull() private val stateFactory = SendStateFactory( @@ -111,7 +118,7 @@ internal class SendViewModel @Inject constructor( } fun setRouter(router: InnerSendRouter, stateRouter: StateRouter) { - inneRrouter = router + innerRouter = router this.stateRouter = stateRouter uiState = uiState.copy(currentState = stateRouter.currentState) } @@ -428,7 +435,7 @@ internal class SendViewModel @Inject constructor( destination = recipient.value, userWalletId = userWalletId, network = cryptoCurrency.network, - ) ?: return + )?.copy(extras = getMemoExtras(cryptoCurrency.network.id.value, memo?.value)) ?: return sendTransactionUseCase( txData = txData, @@ -475,7 +482,7 @@ internal class SendViewModel @Inject constructor( override fun showFee() = stateRouter.showFee(isFromSend = true) - override fun onExploreClick(txUrl: String) = inneRrouter.openUrl(txUrl) + override fun onExploreClick(txUrl: String) = innerRouter.openUrl(txUrl) private fun getTxUrl(hash: String): String { val blockchain = Blockchain.fromId(cryptoCurrency.network.id.value) @@ -491,6 +498,25 @@ internal class SendViewModel @Inject constructor( } // endregion + private fun getMemoExtras(networkId: String, memo: String?): TransactionExtras? { + val blockchain = Blockchain.fromId(networkId) + if (memo == null) return null + return when (blockchain) { + Blockchain.Stellar -> { + val xmlMemo = when (determineXlmMemoType(memo)) { + XlmMemoType.TEXT -> StellarMemo.Text(memo) + XlmMemoType.ID -> StellarMemo.Id(memo.toBigInteger()) + } + StellarTransactionExtras(xmlMemo) + } + Blockchain.Binance -> BinanceTransactionExtras(memo) + Blockchain.XRP -> memo.toLongOrNull()?.let { XrpTransactionBuilder.XrpTransactionExtras(it) } + Blockchain.Cosmos -> CosmosTransactionExtras(memo) + Blockchain.TON -> TonTransactionExtras(memo) + else -> null + } + } + companion object { private const val XRP_X_ADDRESS = 'X' private const val DEFAULT_VALUE = "0.00" diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index d4c8361ff8..b13cd5c2fc 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -88,7 +88,7 @@ spr-client = "3.6.2" # endregion Other libraries # region Tangem -tangemBlockchainSdk = "develop-408" +tangemBlockchainSdk = "develop-409" #tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds tangemCardSdk = "develop-312" #tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^