Updated on 2026-08-14
This commit is contained in:
parent
fe09587f6d
commit
605f17c873
8 changed files with 19 additions and 38 deletions
|
|
@ -3,7 +3,7 @@ package com.tangem.tap.common.redux.legacy
|
|||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.domain.feedback.models.BlockchainErrorInfo
|
||||
import com.tangem.domain.redux.LegacyAction
|
||||
import com.tangem.domain.tokens.utils.convertToAmount
|
||||
import com.tangem.domain.utils.convertToSdkAmount
|
||||
import com.tangem.tap.common.extensions.inject
|
||||
import com.tangem.tap.common.extensions.stripZeroPlainString
|
||||
import com.tangem.tap.common.feedback.FeedbackEmail
|
||||
|
|
@ -42,7 +42,7 @@ internal object LegacyMiddleware {
|
|||
is LegacyAction.SendEmailTransactionFailed -> {
|
||||
if (store.inject(DaggerGraphState::feedbackManagerFeatureToggles).isLocalLogsEnabled) {
|
||||
|
||||
val amount = action.amount?.convertToAmount(action.cryptoCurrency)
|
||||
val amount = action.amount?.convertToSdkAmount(action.cryptoCurrency)
|
||||
store.inject(DaggerGraphState::saveBlockchainErrorUseCase).invoke(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = action.errorMessage,
|
||||
|
|
@ -55,7 +55,7 @@ internal object LegacyMiddleware {
|
|||
""
|
||||
},
|
||||
amount = amount?.value?.stripZeroPlainString() ?: "unknown",
|
||||
fee = action.fee?.convertToAmount(action.cryptoCurrency)
|
||||
fee = action.fee?.convertToSdkAmount(action.cryptoCurrency)
|
||||
?.value?.stripZeroPlainString() ?: "unknown",
|
||||
),
|
||||
)
|
||||
|
|
@ -73,8 +73,8 @@ internal object LegacyMiddleware {
|
|||
)?.let { walletManager ->
|
||||
store.state.globalState.feedbackManager?.infoHolder?.updateOnSendError(
|
||||
walletManager = walletManager,
|
||||
amountToSend = action.amount?.convertToAmount(action.cryptoCurrency),
|
||||
feeAmount = action.fee?.convertToAmount(action.cryptoCurrency),
|
||||
amountToSend = action.amount?.convertToSdkAmount(action.cryptoCurrency),
|
||||
feeAmount = action.fee?.convertToSdkAmount(action.cryptoCurrency),
|
||||
destinationAddress = action.destinationAddress,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package com.tangem.domain.tokens.utils
|
||||
package com.tangem.domain.utils
|
||||
|
||||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import java.math.BigDecimal
|
||||
import com.tangem.blockchain.common.Amount as SdkAmount
|
||||
|
||||
/** Converts `BigDecimal` [cryptoCurrency] to [Amount] */
|
||||
fun BigDecimal.convertToAmount(cryptoCurrency: CryptoCurrency) = Amount(
|
||||
/** Converts `BigDecimal` [cryptoCurrency] to [SdkAmount] */
|
||||
fun BigDecimal.convertToSdkAmount(cryptoCurrency: CryptoCurrency): SdkAmount = SdkAmount(
|
||||
currencySymbol = cryptoCurrency.symbol,
|
||||
value = this,
|
||||
decimals = cryptoCurrency.decimals,
|
||||
|
|
@ -1,14 +1,9 @@
|
|||
plugins {
|
||||
alias(deps.plugins.android.library)
|
||||
alias(deps.plugins.kotlin.android)
|
||||
alias(deps.plugins.kotlin.jvm)
|
||||
alias(deps.plugins.kotlin.serialization)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.tangem.domain.tokens.model"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
/** Project - Core */
|
||||
implementation(projects.core.analytics.models)
|
||||
|
|
@ -17,13 +12,7 @@ dependencies {
|
|||
implementation(projects.domain.txhistory.models)
|
||||
implementation(projects.domain.staking.models)
|
||||
|
||||
/** SDK dependencies */
|
||||
implementation(deps.tangem.blockchain) {
|
||||
exclude(module = "joda-time")
|
||||
}
|
||||
|
||||
/** Other dependencies */
|
||||
implementation(deps.kotlin.serialization)
|
||||
implementation(deps.jodatime)
|
||||
implementation(deps.timber)
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package com.tangem.domain.tokens.model
|
||||
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Represents a network address configuration.
|
||||
*/
|
||||
|
|
@ -47,11 +45,5 @@ sealed class NetworkAddress {
|
|||
enum class Type {
|
||||
Primary, Secondary,
|
||||
}
|
||||
|
||||
init {
|
||||
if (value.isEmpty()) {
|
||||
Timber.w("Address value is blank")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@ package com.tangem.domain.transaction.usecase
|
|||
import arrow.core.Either
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.utils.convertToAmount
|
||||
import com.tangem.domain.transaction.TransactionRepository
|
||||
import com.tangem.domain.utils.convertToAmount
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import com.tangem.domain.tokens.model.CryptoCurrency
|
|||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
|
||||
import com.tangem.domain.tokens.repository.CurrencyChecksRepository
|
||||
import com.tangem.domain.tokens.utils.convertToAmount
|
||||
import com.tangem.domain.transaction.usecase.ValidateTransactionUseCase
|
||||
import com.tangem.domain.utils.convertToSdkAmount
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.features.send.impl.R
|
||||
import com.tangem.features.send.impl.presentation.analytics.SendAnalyticEvents
|
||||
|
|
@ -447,7 +447,7 @@ internal class SendNotificationFactory(
|
|||
val sendingCurrency = cryptoCurrencyStatusProvider().currency
|
||||
|
||||
validateTransactionUseCase(
|
||||
amount = sendingAmount.convertToAmount(sendingCurrency),
|
||||
amount = sendingAmount.convertToSdkAmount(sendingCurrency),
|
||||
fee = fee ?: return,
|
||||
memo = state.recipientState?.memoTextField?.value,
|
||||
destination = requireNotNull(state.recipientState?.addressTextField?.value),
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ import com.tangem.domain.tokens.error.CurrencyStatusError
|
|||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.repository.CurrencyChecksRepository
|
||||
import com.tangem.domain.tokens.utils.convertToAmount
|
||||
import com.tangem.domain.transaction.error.GetFeeError
|
||||
import com.tangem.domain.transaction.error.ValidateAddressError
|
||||
import com.tangem.domain.transaction.usecase.*
|
||||
import com.tangem.domain.txhistory.usecase.GetExplorerTransactionUrlUseCase
|
||||
import com.tangem.domain.txhistory.usecase.GetFixedTxHistoryItemsUseCase
|
||||
import com.tangem.domain.utils.convertToSdkAmount
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
|
|
@ -855,7 +855,7 @@ internal class SendViewModel @Inject constructor(
|
|||
|
||||
viewModelScope.launch {
|
||||
createTransactionUseCase(
|
||||
amount = receivingAmount.convertToAmount(cryptoCurrency),
|
||||
amount = receivingAmount.convertToSdkAmount(cryptoCurrency),
|
||||
fee = fee,
|
||||
memo = memo,
|
||||
destination = recipient,
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ import com.tangem.domain.tokens.model.FeePaidCurrency
|
|||
import com.tangem.domain.tokens.repository.CurrenciesRepository
|
||||
import com.tangem.domain.tokens.repository.CurrencyChecksRepository
|
||||
import com.tangem.domain.tokens.repository.QuotesRepository
|
||||
import com.tangem.domain.tokens.utils.convertToAmount
|
||||
import com.tangem.domain.transaction.error.GetFeeError
|
||||
import com.tangem.domain.transaction.error.SendTransactionError
|
||||
import com.tangem.domain.transaction.models.TransactionType
|
||||
import com.tangem.domain.transaction.usecase.*
|
||||
import com.tangem.domain.utils.convertToSdkAmount
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase
|
||||
|
|
@ -216,7 +216,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
permissionOptions.approveData.approveData
|
||||
}
|
||||
val approveTransaction = createTransactionUseCase(
|
||||
amount = BigDecimal.ZERO.convertToAmount(permissionOptions.fromToken),
|
||||
amount = BigDecimal.ZERO.convertToSdkAmount(permissionOptions.fromToken),
|
||||
fee = getFeeForTransaction(
|
||||
fee = permissionOptions.txFee,
|
||||
blockchain = Blockchain.fromId(permissionOptions.fromToken.network.id.value),
|
||||
|
|
@ -518,7 +518,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
)
|
||||
|
||||
validateTransactionUseCase(
|
||||
amount = amount.value.convertToAmount(fromToken),
|
||||
amount = amount.value.convertToSdkAmount(fromToken),
|
||||
fee = fee,
|
||||
memo = null,
|
||||
destination = getTokenAddress(fromToken),
|
||||
|
|
@ -791,7 +791,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
if (demoConfig.isDemoCardId(cardId)) return SwapTransactionState.UnknownError
|
||||
|
||||
val txData = createTransactionUseCase(
|
||||
amount = amount.value.convertToAmount(currencyToSend.currency),
|
||||
amount = amount.value.convertToSdkAmount(currencyToSend.currency),
|
||||
fee = getFeeForTransaction(
|
||||
fee = txFee,
|
||||
blockchain = Blockchain.fromId(currencyToSend.currency.network.id.value),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue