Updated on 2026-08-14
This commit is contained in:
parent
0a07579089
commit
8224c05d1a
9 changed files with 19 additions and 20 deletions
|
|
@ -5,7 +5,7 @@ import com.tangem.blockchain.common.TransactionStatus
|
|||
import com.tangem.blockchain.common.Wallet
|
||||
|
||||
data class PendingTransaction(
|
||||
val transactionData: TransactionData,
|
||||
val transactionData: TransactionData.Uncompiled,
|
||||
val type: PendingTransactionType,
|
||||
) {
|
||||
val address: String? = when (type) {
|
||||
|
|
@ -21,7 +21,7 @@ data class PendingTransaction(
|
|||
|
||||
enum class PendingTransactionType { Incoming, Outgoing, Unknown }
|
||||
|
||||
fun TransactionData.toPendingTransaction(walletAddress: String): PendingTransaction? {
|
||||
fun TransactionData.Uncompiled.toPendingTransaction(walletAddress: String): PendingTransaction? {
|
||||
if (this.status == TransactionStatus.Confirmed) return null
|
||||
|
||||
val type: PendingTransactionType = when {
|
||||
|
|
@ -32,7 +32,7 @@ fun TransactionData.toPendingTransaction(walletAddress: String): PendingTransact
|
|||
return PendingTransaction(this, type)
|
||||
}
|
||||
|
||||
fun List<TransactionData>.toPendingTransactions(walletAddress: String): List<PendingTransaction> {
|
||||
fun List<TransactionData.Uncompiled>.toPendingTransactions(walletAddress: String): List<PendingTransaction> {
|
||||
return this.mapNotNull { it.toPendingTransaction(walletAddress) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,9 +91,8 @@ class WalletConnectSdkHelper {
|
|||
|
||||
val destinationAddress = requireNotNull(transaction.to) { "Destination address is null" }
|
||||
|
||||
val transactionData = TransactionData(
|
||||
val transactionData = TransactionData.Uncompiled(
|
||||
amount = Amount(value, wallet.blockchain),
|
||||
// TODO refactoring
|
||||
fee = Fee.Common(Amount(fee, wallet.blockchain)),
|
||||
sourceAddress = transaction.from,
|
||||
destinationAddress = destinationAddress,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ internal class DefaultTransactionRepository(
|
|||
isSwap: Boolean,
|
||||
txExtras: TransactionExtras?,
|
||||
hash: String?,
|
||||
): TransactionData? = withContext(coroutineDispatcherProvider.io) {
|
||||
): TransactionData.Uncompiled? = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
|
|
@ -45,7 +45,7 @@ internal class DefaultTransactionRepository(
|
|||
derivationPath = network.derivationPath.value,
|
||||
)
|
||||
|
||||
return@withContext walletManager?.createTransactionInternal(
|
||||
return@withContext walletManager?.createTransactionDataInternal(
|
||||
amount = amount,
|
||||
fee = fee,
|
||||
memo = memo,
|
||||
|
|
@ -78,7 +78,7 @@ internal class DefaultTransactionRepository(
|
|||
val validator = walletManager as? TransactionValidator
|
||||
|
||||
if (validator != null) {
|
||||
val transaction = walletManager.createTransactionInternal(
|
||||
val transactionData = walletManager.createTransactionDataInternal(
|
||||
amount = amount,
|
||||
fee = fee ?: Fee.Common(amount = amount),
|
||||
memo = memo,
|
||||
|
|
@ -89,7 +89,7 @@ internal class DefaultTransactionRepository(
|
|||
hash = hash,
|
||||
)
|
||||
|
||||
validator.validate(transaction = transaction)
|
||||
validator.validate(transactionData = transactionData)
|
||||
} else {
|
||||
Timber.e("${walletManager?.wallet?.blockchain} does not support transaction validation")
|
||||
Result.success(Unit)
|
||||
|
|
@ -112,7 +112,7 @@ internal class DefaultTransactionRepository(
|
|||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
private fun WalletManager.createTransactionInternal(
|
||||
private fun WalletManager.createTransactionDataInternal(
|
||||
amount: Amount,
|
||||
fee: Fee,
|
||||
memo: String?,
|
||||
|
|
@ -121,7 +121,7 @@ internal class DefaultTransactionRepository(
|
|||
isSwap: Boolean,
|
||||
txExtras: TransactionExtras?,
|
||||
hash: String?,
|
||||
): TransactionData {
|
||||
): TransactionData.Uncompiled {
|
||||
// TODO: refactor workaround to use general mechanism in bsdk for build tx for DEX
|
||||
val txAmount = if (isSwap) {
|
||||
createAmountForSwap(amount)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ import java.math.BigDecimal
|
|||
internal class TransactionDataToTxHistoryItemConverter(
|
||||
private val walletAddresses: Set<Address>,
|
||||
private val feePaidCurrency: FeePaidCurrency,
|
||||
) : Converter<TransactionData, TxHistoryItem?> {
|
||||
) : Converter<TransactionData.Uncompiled, TxHistoryItem?> {
|
||||
|
||||
override fun convert(value: TransactionData): TxHistoryItem? {
|
||||
override fun convert(value: TransactionData.Uncompiled): TxHistoryItem? {
|
||||
val hash = value.hash ?: return null
|
||||
val millis = value.date?.timeInMillis ?: return null
|
||||
val amount = getTransactionAmountValue(value.amount, value.fee?.amount) ?: return null
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
|
||||
private fun getCurrentTransactions(
|
||||
txHistoryItemConverter: TransactionDataToTxHistoryItemConverter,
|
||||
recentTransactions: Set<TransactionData>,
|
||||
recentTransactions: Set<TransactionData.Uncompiled>,
|
||||
): Set<CryptoCurrencyTransaction> {
|
||||
val unconfirmedTransactions = recentTransactions.filter {
|
||||
it.status == TransactionStatus.Unconfirmed
|
||||
|
|
@ -122,7 +122,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
|
||||
private fun createCurrencyTransaction(
|
||||
txHistoryItemConverter: TransactionDataToTxHistoryItemConverter,
|
||||
data: TransactionData,
|
||||
data: TransactionData.Uncompiled,
|
||||
): CryptoCurrencyTransaction? {
|
||||
return when (val type = data.amount.type) {
|
||||
is AmountType.Coin -> {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ interface TransactionRepository {
|
|||
isSwap: Boolean,
|
||||
txExtras: TransactionExtras?,
|
||||
hash: String?,
|
||||
): TransactionData?
|
||||
): TransactionData.Uncompiled?
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
suspend fun validateTransaction(
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ internal class SendStateFactory(
|
|||
)
|
||||
}
|
||||
|
||||
fun getTransactionSendState(txData: TransactionData, txUrl: String): SendUiState {
|
||||
fun getTransactionSendState(txData: TransactionData.Uncompiled, txUrl: String): SendUiState {
|
||||
val state = currentStateProvider()
|
||||
val sendState = state.sendState ?: return state
|
||||
return state.copy(
|
||||
|
|
|
|||
|
|
@ -870,7 +870,7 @@ internal class SendViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun sendTransaction(txData: TransactionData) {
|
||||
private suspend fun sendTransaction(txData: TransactionData.Uncompiled) {
|
||||
sendTransactionUseCase(
|
||||
txData = txData,
|
||||
userWallet = userWallet,
|
||||
|
|
@ -911,7 +911,7 @@ internal class SendViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun updateTransactionStatus(txData: TransactionData) {
|
||||
private suspend fun updateTransactionStatus(txData: TransactionData.Uncompiled) {
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
userWalletId = userWalletId,
|
||||
network = cryptoCurrency.network,
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ markdown = "0.7.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "develop-684"
|
||||
tangemBlockchainSdk = "develop-688"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "develop-366"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue