Updated on 2026-08-14
This commit is contained in:
commit
a13ccd7e6e
338 changed files with 4879 additions and 7536 deletions
|
|
@ -20,6 +20,7 @@ import com.tangem.lib.crypto.models.*
|
|||
import com.tangem.lib.crypto.models.transactions.SendTxResult
|
||||
import com.tangem.tap.common.analytics.events.AnalyticsParam
|
||||
import com.tangem.tap.common.analytics.events.Basic
|
||||
import com.tangem.tap.common.analytics.events.Basic.TransactionSent.MemoType
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
import com.tangem.tap.domain.TangemSigner
|
||||
import com.tangem.tap.domain.tokens.models.BlockchainNetwork
|
||||
|
|
@ -36,14 +37,11 @@ class TransactionManagerImpl(
|
|||
) : TransactionManager {
|
||||
|
||||
override suspend fun sendApproveTransaction(
|
||||
networkId: String,
|
||||
feeAmount: BigDecimal,
|
||||
gasLimit: Int,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
txData: ApproveTxData,
|
||||
derivationPath: String?,
|
||||
analyticsData: AnalyticsData,
|
||||
): SendTxResult {
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(networkId)) { "blockchain not found" }
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(txData.networkId)) { "blockchain not found" }
|
||||
val walletManager = getActualWalletManager(blockchain, derivationPath)
|
||||
walletManager.update()
|
||||
val amount = Amount(value = BigDecimal.ZERO, blockchain = blockchain)
|
||||
|
|
@ -51,40 +49,55 @@ class TransactionManagerImpl(
|
|||
walletManager = walletManager,
|
||||
amount = amount,
|
||||
blockchain = blockchain,
|
||||
feeAmount = feeAmount,
|
||||
gasLimit = gasLimit,
|
||||
destinationAddress = destinationAddress,
|
||||
dataToSign = dataToSign,
|
||||
feeAmount = txData.feeAmount,
|
||||
gasLimit = txData.gasLimit,
|
||||
destinationAddress = txData.destinationAddress,
|
||||
dataToSign = txData.dataToSign,
|
||||
successEvent = AnalyticsParam.TxSentFrom.Approve(
|
||||
blockchain = blockchain.fullName,
|
||||
token = analyticsData.tokenSymbol,
|
||||
feeType = AnalyticsParam.FeeType.fromString(analyticsData.feeType),
|
||||
permissionType = analyticsData.permissionType ?: "",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun sendTransaction(
|
||||
networkId: String,
|
||||
amountToSend: BigDecimal,
|
||||
feeAmount: BigDecimal,
|
||||
gasLimit: Int,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
txData: SwapTxData,
|
||||
isSwap: Boolean,
|
||||
currencyToSend: Currency,
|
||||
derivationPath: String?,
|
||||
analyticsData: AnalyticsData,
|
||||
): SendTxResult {
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(networkId)) { "blockchain not found" }
|
||||
val blockchain = requireNotNull(Blockchain.fromNetworkId(txData.networkId)) { "blockchain not found" }
|
||||
val walletManager = getActualWalletManager(blockchain, derivationPath)
|
||||
walletManager.update()
|
||||
val amount = if (isSwap) {
|
||||
createAmountForSwap(amountToSend, currencyToSend, blockchain)
|
||||
createAmountForSwap(txData.amountToSend, txData.currencyToSend, blockchain)
|
||||
} else {
|
||||
createAmount(amountToSend, currencyToSend, blockchain)
|
||||
createAmount(txData.amountToSend, txData.currencyToSend, blockchain)
|
||||
}
|
||||
val successEvent = if (isSwap) {
|
||||
AnalyticsParam.TxSentFrom.Swap(
|
||||
blockchain = blockchain.fullName,
|
||||
token = analyticsData.tokenSymbol,
|
||||
feeType = AnalyticsParam.FeeType.fromString(analyticsData.feeType),
|
||||
)
|
||||
} else {
|
||||
AnalyticsParam.TxSentFrom.Send(
|
||||
blockchain = blockchain.fullName,
|
||||
token = analyticsData.tokenSymbol,
|
||||
feeType = AnalyticsParam.FeeType.fromString(analyticsData.feeType),
|
||||
)
|
||||
}
|
||||
return sendTransactionInternal(
|
||||
walletManager = walletManager,
|
||||
amount = amount,
|
||||
blockchain = blockchain,
|
||||
feeAmount = feeAmount,
|
||||
gasLimit = gasLimit,
|
||||
destinationAddress = destinationAddress,
|
||||
dataToSign = dataToSign,
|
||||
feeAmount = txData.feeAmount,
|
||||
gasLimit = txData.gasLimit,
|
||||
destinationAddress = txData.destinationAddress,
|
||||
dataToSign = txData.dataToSign,
|
||||
successEvent = successEvent,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +110,7 @@ class TransactionManagerImpl(
|
|||
gasLimit: Int,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
successEvent: AnalyticsParam.TxSentFrom,
|
||||
): SendTxResult {
|
||||
val txData = walletManager.createTransaction(
|
||||
amount = amount,
|
||||
|
|
@ -112,7 +126,10 @@ class TransactionManagerImpl(
|
|||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
return SendTxResult.UnknownError(ex)
|
||||
}
|
||||
return handleSendResult(sendResult)
|
||||
return handleSendResult(
|
||||
result = sendResult,
|
||||
successEvent = successEvent,
|
||||
)
|
||||
}
|
||||
|
||||
override fun getExplorerTransactionLink(networkId: String, txAddress: String): String {
|
||||
|
|
@ -337,10 +354,10 @@ class TransactionManagerImpl(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleSendResult(result: SimpleResult): SendTxResult {
|
||||
private fun handleSendResult(result: SimpleResult, successEvent: AnalyticsParam.TxSentFrom): SendTxResult {
|
||||
when (result) {
|
||||
is SimpleResult.Success -> {
|
||||
analytics.send(Basic.TransactionSent(AnalyticsParam.TxSentFrom.Swap))
|
||||
analytics.send(Basic.TransactionSent(sentFrom = successEvent, memoType = MemoType.Null))
|
||||
return SendTxResult.Success
|
||||
}
|
||||
is SimpleResult.Failure -> {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.tap.proxy.redux
|
|||
import com.tangem.domain.card.ScanCardUseCase
|
||||
import com.tangem.features.tester.api.TesterRouter
|
||||
import com.tangem.features.wallet.navigation.WalletRouter
|
||||
import com.tangem.tap.domain.walletconnect2.domain.WalletConnectInteractor
|
||||
import org.rekotlin.Action
|
||||
|
||||
sealed interface DaggerGraphAction : Action {
|
||||
|
|
@ -11,5 +12,6 @@ sealed interface DaggerGraphAction : Action {
|
|||
val testerRouter: TesterRouter,
|
||||
val scanCardUseCase: ScanCardUseCase,
|
||||
val walletRouter: WalletRouter,
|
||||
val walletConnectInteractor: WalletConnectInteractor,
|
||||
) : DaggerGraphAction
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ object DaggerGraphReducer {
|
|||
testerRouter = action.testerRouter,
|
||||
scanCardUseCase = action.scanCardUseCase,
|
||||
walletRouter = action.walletRouter,
|
||||
walletConnectInteractor = action.walletConnectInteractor,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.domain.card.ScanCardUseCase
|
|||
import com.tangem.features.tester.api.TesterRouter
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import com.tangem.features.wallet.navigation.WalletRouter
|
||||
import com.tangem.tap.domain.walletconnect2.domain.WalletConnectInteractor
|
||||
import com.tangem.tap.domain.walletconnect2.domain.WalletConnectRepository
|
||||
import com.tangem.tap.domain.walletconnect2.domain.WalletConnectSessionsRepository
|
||||
import com.tangem.tap.features.customtoken.api.featuretoggles.CustomTokenFeatureToggles
|
||||
import org.rekotlin.StateType
|
||||
|
||||
|
|
@ -17,6 +20,9 @@ data class DaggerGraphState(
|
|||
val scanCardUseCase: ScanCardUseCase? = null,
|
||||
val walletFeatureToggles: WalletFeatureToggles? = null,
|
||||
val walletRouter: WalletRouter? = null,
|
||||
val walletConnectRepository: WalletConnectRepository? = null,
|
||||
val walletConnectSessionsRepository: WalletConnectSessionsRepository? = null,
|
||||
val walletConnectInteractor: WalletConnectInteractor? = null,
|
||||
) : StateType {
|
||||
|
||||
inline fun <reified T> get(getDependency: DaggerGraphState.() -> T?): T {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue