Updated on 2026-08-14
This commit is contained in:
parent
0d8422ec5f
commit
b95807397d
2 changed files with 18 additions and 3 deletions
|
|
@ -12,10 +12,13 @@ import com.tangem.domain.transaction.TransactionRepository
|
|||
import com.tangem.domain.transaction.WalletAddressServiceRepository
|
||||
import com.tangem.domain.transaction.usecase.*
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
|
|
@ -46,6 +49,7 @@ internal object TransactionDomainModule {
|
|||
walletManagersFacade: WalletManagersFacade,
|
||||
singleNetworkStatusFetcher: SingleNetworkStatusFetcher,
|
||||
tangemHotWalletSignerFactory: TangemHotWalletSigner.Factory,
|
||||
dispatchers: CoroutineDispatcherProvider,
|
||||
): SendTransactionUseCase {
|
||||
return SendTransactionUseCase(
|
||||
demoConfig = DemoConfig(),
|
||||
|
|
@ -53,6 +57,7 @@ internal object TransactionDomainModule {
|
|||
transactionRepository = transactionRepository,
|
||||
walletManagersFacade = walletManagersFacade,
|
||||
singleNetworkStatusFetcher = singleNetworkStatusFetcher,
|
||||
parallelUpdatingScope = CoroutineScope(SupervisorJob() + dispatchers.io),
|
||||
getHotWalletSigner = tangemHotWalletSignerFactory::create,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,19 @@ import com.tangem.domain.transaction.error.SendTransactionError
|
|||
import com.tangem.domain.transaction.error.parseWrappedError
|
||||
import com.tangem.domain.transaction.models.EventTransactionTypeDto
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class SendTransactionUseCase(
|
||||
private val demoConfig: DemoConfig,
|
||||
private val cardSdkConfigRepository: CardSdkConfigRepository,
|
||||
private val transactionRepository: TransactionRepository,
|
||||
private val walletManagersFacade: WalletManagersFacade,
|
||||
private val singleNetworkStatusFetcher: SingleNetworkStatusFetcher,
|
||||
private val parallelUpdatingScope: CoroutineScope,
|
||||
private val getHotWalletSigner: (UserWallet.Hot) -> TransactionSigner,
|
||||
) {
|
||||
suspend operator fun invoke(
|
||||
|
|
@ -122,9 +128,13 @@ class SendTransactionUseCase(
|
|||
.map { it.first() }
|
||||
}
|
||||
|
||||
private suspend fun processSentTransactionsHashes(transactions: List<TransactionData>, hashes: List<String>) {
|
||||
transactions.forEachIndexed { ind, tx ->
|
||||
sendHashToBackendIfNeeded(tx, hashes[ind])
|
||||
private fun processSentTransactionsHashes(transactions: List<TransactionData>, hashes: List<String>) {
|
||||
parallelUpdatingScope.launch {
|
||||
withContext(NonCancellable) {
|
||||
transactions.forEachIndexed { ind, tx ->
|
||||
sendHashToBackendIfNeeded(tx, hashes[ind])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue