Updated on 2026-08-14
This commit is contained in:
parent
52cc0be3cb
commit
ba4e916cd0
17 changed files with 98 additions and 13 deletions
|
|
@ -26,6 +26,7 @@ dependencies {
|
|||
implementation(projects.domain.walletManager)
|
||||
implementation(projects.domain.demo)
|
||||
implementation(projects.domain.card)
|
||||
implementation(projects.domain.transaction)
|
||||
api(projects.domain.models)
|
||||
|
||||
/** Domain models */
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.tangem.domain.models.network.Network
|
|||
import com.tangem.domain.models.network.TxInfo
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.transaction.GaslessTransactionRepository
|
||||
import com.tangem.domain.transaction.models.AssetRequirementsCondition
|
||||
import com.tangem.domain.txhistory.models.PaginationWrapper
|
||||
import com.tangem.domain.txhistory.models.TxHistoryState
|
||||
|
|
@ -61,6 +62,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
private val userWalletsStore: UserWalletsStore,
|
||||
private val assetLoader: AssetLoader,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
private val gaslessTransactionRepository: GaslessTransactionRepository,
|
||||
blockchainSDKFactory: BlockchainSDKFactory,
|
||||
) : WalletManagersFacade {
|
||||
|
||||
|
|
@ -284,6 +286,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
|||
items = SdkTransactionHistoryItemConverter(
|
||||
smartContractMethods = readSmartContractMethods(),
|
||||
yieldSupplyAddresses = YIELD_SUPPLY_ADDRESSES,
|
||||
gaslessFeeAddresses = gaslessTransactionRepository.getGaslessFeeAddresses(),
|
||||
).convertList(itemsResult.data.items),
|
||||
)
|
||||
is Result.Failure -> error(itemsResult.error.message ?: itemsResult.error.customMessage)
|
||||
|
|
|
|||
|
|
@ -9,11 +9,13 @@ import com.tangem.blockchain.transactionhistory.models.TransactionHistoryItem as
|
|||
internal class SdkTransactionHistoryItemConverter(
|
||||
smartContractMethods: Map<String, SmartContractMethod>,
|
||||
yieldSupplyAddresses: Set<String>,
|
||||
gaslessFeeAddresses: Set<String>,
|
||||
) : Converter<SdkTransactionHistoryItem, TxInfo> {
|
||||
|
||||
private val typeConverter by lazy { SdkTransactionTypeConverter(
|
||||
smartContractMethods = smartContractMethods,
|
||||
yieldSupplyAddresses = yieldSupplyAddresses,
|
||||
gaslessFeeAddresses = gaslessFeeAddresses,
|
||||
) }
|
||||
|
||||
override fun convert(value: SdkTransactionHistoryItem): TxInfo = TxInfo(
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ import com.tangem.utils.converter.Converter
|
|||
internal class SdkTransactionTypeConverter(
|
||||
private val smartContractMethods: Map<String, SmartContractMethod>,
|
||||
private val yieldSupplyAddresses: Set<String>,
|
||||
gaslessFeeAddresses: Set<String>,
|
||||
) : Converter<TransactionHistoryItem, TxInfo.TransactionType> {
|
||||
|
||||
private val gaslessFeeAddressesLowercase: Set<String> = gaslessFeeAddresses.map { it.lowercase() }.toSet()
|
||||
|
||||
override fun convert(value: TransactionHistoryItem): TxInfo.TransactionType {
|
||||
val (type, destination) = value.type to value.destinationType
|
||||
val source = value.sourceType
|
||||
|
|
@ -125,8 +128,23 @@ internal class SdkTransactionTypeConverter(
|
|||
)
|
||||
}
|
||||
"supplyTopUp" -> TxInfo.TransactionType.YieldSupply.Topup
|
||||
"gaslessTransaction" -> getTypeForGaslessMethod(destination)
|
||||
null -> TxInfo.TransactionType.UnknownOperation
|
||||
else -> TxInfo.TransactionType.Operation(name = methodName.replaceFirstChar { it.titlecase() })
|
||||
} ?: TxInfo.TransactionType.Operation(name = methodName?.replaceFirstChar { it.titlecase() }.orEmpty())
|
||||
}
|
||||
|
||||
private fun getTypeForGaslessMethod(destination: TransactionHistoryItem.DestinationType): TxInfo.TransactionType {
|
||||
return when (destination) {
|
||||
is TransactionHistoryItem.DestinationType.Multiple -> TxInfo.TransactionType.UnknownOperation
|
||||
is TransactionHistoryItem.DestinationType.Single -> {
|
||||
val address = destination.addressType.address.lowercase()
|
||||
if (gaslessFeeAddressesLowercase.contains(address)) {
|
||||
TxInfo.TransactionType.GaslessFee
|
||||
} else {
|
||||
TxInfo.TransactionType.UnknownOperation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue