Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-19 11:53:17 +04:00
parent 9be5646b78
commit 60bbe797b9
11 changed files with 240 additions and 60 deletions

View file

@ -276,8 +276,10 @@ internal class DefaultWalletManagersFacade @Inject constructor(
is Result.Success -> PaginationWrapper(
currentPage = sdkPageConverter.convert(page),
nextPage = sdkPageConverter.convert(itemsResult.data.nextPage),
items = SdkTransactionHistoryItemConverter(smartContractMethods = readSmartContractMethods())
.convertList(itemsResult.data.items),
items = SdkTransactionHistoryItemConverter(
smartContractMethods = readSmartContractMethods(),
yieldSupplyAddresses = YIELD_SUPPLY_ADDRESSES,
).convertList(itemsResult.data.items),
)
is Result.Failure -> error(itemsResult.error.message ?: itemsResult.error.customMessage)
}

View file

@ -8,9 +8,13 @@ import com.tangem.blockchain.transactionhistory.models.TransactionHistoryItem as
internal class SdkTransactionHistoryItemConverter(
smartContractMethods: Map<String, SmartContractMethod>,
yieldSupplyAddresses: Set<String>,
) : Converter<SdkTransactionHistoryItem, TxInfo> {
private val typeConverter by lazy { SdkTransactionTypeConverter(smartContractMethods) }
private val typeConverter by lazy { SdkTransactionTypeConverter(
smartContractMethods = smartContractMethods,
yieldSupplyAddresses = yieldSupplyAddresses,
) }
override fun convert(value: SdkTransactionHistoryItem): TxInfo = TxInfo(
txHash = value.txHash,
@ -24,7 +28,7 @@ internal class SdkTransactionHistoryItemConverter(
SdkTransactionHistoryItem.TransactionStatus.Failed -> TxInfo.TransactionStatus.Failed
SdkTransactionHistoryItem.TransactionStatus.Unconfirmed -> TxInfo.TransactionStatus.Unconfirmed
},
type = typeConverter.convert(value.type to value.destinationType.toDomain()),
type = typeConverter.convert(value),
amount = requireNotNull(value.amount.value) { "Transaction amount value must not be null" },
)

View file

@ -1,5 +1,6 @@
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.transactionhistory.models.TransactionHistoryItem
import com.tangem.blockchain.transactionhistory.models.TransactionHistoryItem.TransactionType
import com.tangem.blockchain.yieldsupply.providers.ethereum.yield.EthereumYieldSupplyEnterCallData
import com.tangem.blockchain.yieldsupply.providers.ethereum.yield.EthereumYieldSupplyExitCallData
@ -11,17 +12,29 @@ import com.tangem.utils.converter.Converter
internal class SdkTransactionTypeConverter(
private val smartContractMethods: Map<String, SmartContractMethod>,
) : Converter<Pair<TransactionType, TxInfo.DestinationType>, TxInfo.TransactionType> {
private val yieldSupplyAddresses: Set<String>,
) : Converter<TransactionHistoryItem, TxInfo.TransactionType> {
override fun convert(value: Pair<TransactionType, TxInfo.DestinationType>): TxInfo.TransactionType {
val (type, destination) = value
override fun convert(value: TransactionHistoryItem): TxInfo.TransactionType {
val (type, destination) = value.type to value.destinationType
val source = value.sourceType
return when (type) {
is TransactionType.ContractMethod -> {
getTransactionType(methodName = smartContractMethods[type.id]?.name, type.callData, destination)
getTransactionType(
methodName = smartContractMethods[type.id]?.name,
callData = type.callData,
destination = destination,
source = source,
)
}
is TransactionType.ContractMethodName -> {
getTransactionType(methodName = type.name, type.callData, destination)
getTransactionType(
methodName = type.name,
callData = type.callData,
destination = destination,
source = source,
)
}
is TransactionType.Transfer -> {
TxInfo.TransactionType.Transfer
@ -48,7 +61,8 @@ internal class SdkTransactionTypeConverter(
private fun getTransactionType(
methodName: String?,
callData: String?,
destination: TxInfo.DestinationType,
destination: TransactionHistoryItem.DestinationType,
source: TransactionHistoryItem.SourceType,
): TxInfo.TransactionType {
return when (methodName) {
"transfer" -> TxInfo.TransactionType.Transfer
@ -70,7 +84,21 @@ internal class SdkTransactionTypeConverter(
"withdrawRewardsPOL",
-> TxInfo.TransactionType.Staking.ClaimRewards
"redelegate" -> TxInfo.TransactionType.Staking.Restake
"yieldSend" -> TxInfo.TransactionType.YieldSupply.Send
"yieldSend" -> {
val sourceAddresses = when (source) {
is TransactionHistoryItem.SourceType.Multiple -> source.addresses
is TransactionHistoryItem.SourceType.Single -> listOf(source.address)
}.map {
it.lowercase()
}.toSet()
val isYieldSupplyWithdraw =
yieldSupplyAddresses.intersect(sourceAddresses).isNotEmpty()
TxInfo.TransactionType.YieldSupply.Send(
isYieldSupplyWithdraw = isYieldSupplyWithdraw,
)
}
"enterProtocolByOwner" -> callData?.let { data ->
TxInfo.TransactionType.YieldSupply.Enter(
EthereumYieldSupplyEnterCallData.decode(data)?.tokenContractAddress.orEmpty(),
@ -82,7 +110,7 @@ internal class SdkTransactionTypeConverter(
)
}
"deployYieldModule" -> TxInfo.TransactionType.YieldSupply.DeployContract(
(destination as? TxInfo.DestinationType.Single)?.addressType?.address.orEmpty(),
(destination as? TransactionHistoryItem.DestinationType.Single)?.addressType?.address.orEmpty(),
)
"initYieldToken" -> callData?.let { data ->
TxInfo.TransactionType.YieldSupply.InitializeToken(

View file

@ -0,0 +1,113 @@
package com.tangem.data.walletmanager.utils
// Remove after moving this data to BE
internal val YIELD_SUPPLY_ADDRESSES: Set<String> = setOf(
"0x00901a076785e0906d1028c7d6372d247bec7d61",
"0x00907f9921424583e7ffbfedf84f92b7b2be4977",
"0x018008bfb33d285247a21d44e50697654f754e63",
"0x067ae75628177fd257c2b1e500993e1a0babcbd1",
"0x078f358208685046a11c85e8ad32895ded33a249",
"0x0a1d576f3efef75b330424287a95a366e8281d54",
"0x0b925ed163218f6662a35e0f0371ac234f9e9371",
"0x0c0d01abf3e6adfca0989ebba9d6e85dd58eab1e",
"0x10ac93971cdb1f5c778144084242374473c350da",
"0x191c10aa4af7c30e871e70c95db0e4eb77237530",
"0x1ba9843bd4327c6c77011406de5fa8749f7e3479",
"0x1c0e06a0b1a4c160c17545ff2a951bfca57c0002",
"0x23878914efe38d27c4d67ab83ed1b93a74d4086a",
"0x24ab03a9a5bc2c49e5523e8d915a3536ac38b91d",
"0x2516e7b3f76294e03c42aa4c5b5b4dce9c436fb8",
"0x285866acb0d60105b4ed350a463361c2d9afa0e2",
"0x2d62109243b87c4ba3ee7ba1d91b0dd0a074d7b1",
"0x2e94171493fabe316b6205f1585779c887771e2f",
"0x2edff5af94334fbd7c38ae318edf1c40e072b73b",
"0x312ffc57778cefa11989733e6e08143e7e229c1c",
"0x32a6268f9ba3642dda7892add74f1d34469a4259",
"0x38a5357ce55c81add62abc84fb32981e2626adef",
"0x38c503a438185cde29b5cf4dc1442fd6f074f1cc",
"0x38d693ce1df5aadf7bc62595a37d667ad57922e5",
"0x3fe6a295459fae07df8a0cecc36f37160fe86aa9",
"0x40b4baecc69b882e8804f9286b12228c27f8c9bf",
"0x4199cc1f5ed0d796563d7ccb2e036253e2c18281",
"0x44705f578135cc5d703b4c9c122528c73eb87145",
"0x4579a27af00a62c0eb156349f31b345c08386419",
"0x481a2acf3a72ffdc602a9541896ca1db87f86cf7",
"0x4b0821e768ed9039a70ed1e80e15e76a5be5df5f",
"0x4c612e3b15b96ff9a6faed838f8d07d479a8dd4c",
"0x4d5f47fa6a74757f35c14fd3a6ef8e3c9bc514e8",
"0x4e2a4d9b3df7aae73b418bd39f3af9e148e3f479",
"0x4e65fe4dba92790696d040ac24aa414708f5c0ab",
"0x4f5923fc5fd4a93352581b38b7cd26943012decf",
"0x513c7e3a9c69ca3e22550ef58ac1c0088e918fff",
"0x545bd6c032efdde65a377a6719def2796c8e0f2e",
"0x56a7ddc4e848ebf43845854205ad71d5d5f72d3d",
"0x5b502e3796385e1e9755d7043b9c945c3accec9c",
"0x5c647ce0ae10658ec44fa4e11a51c96e94efd1dd",
"0x5e8c8a7243651db1384c0ddfdbe39761e8e7e51a",
"0x5ee5bf7ae06d1be5997a1a72006fe6c607ec6de8",
"0x5f4a0873a3a02f7c0cb0e13a1d4362a1ad90e751",
"0x5f9190496e0dfc831c3bd307978de4a245e2f5cd",
"0x5fefd7069a7d91d01f269dade14526ccf3487810",
"0x625e7708f30ca75bfd92586e17077590c60eb4cd",
"0x62fc96b27a510cf4977b59ff952dc32378cc221d",
"0x6533afac2e7bccb20dca161449a13a32d391fb00",
"0x65906988adee75306021c417a1a3458040239602",
"0x67eaf2bee4384a2f84da9eb8105c661c123736ba",
"0x6ab707aca953edaefbc4fd23ba73294241490620",
"0x6b030ff3fb9956b1b69f475b77ae0d3cf2cc5afa",
"0x6d80113e533a2c0fe82eabd35f1875dcea89ea97",
"0x71aef7b30728b9bb371578f36c5a1f1502a5723e",
"0x724dc807b04555b71ed48a6896b6f41593b8c637",
"0x75bd1a659bdc62e4c313950d44a2416fab43e785",
"0x7b95ec873268a6bfc6427e7a28e396db9d0ebc65",
"0x7c307e128efa31f540f2e2d976c995e0b65f51f6",
"0x80a94c36747cf51b2fbabdff045f6d22c1930ed1",
"0x80ca0d8c38d2e2bcbab66aa1648bd1c7160500fe",
"0x82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee",
"0x82f9c5ad306bba1ad0de49bb5fa6f01bf61085ef",
"0x8437d7c167dfb82ed4cb79cd44b7a32a1dd95c77",
"0x8a2b6f94ff3a89a03e8c02ee92b55af90c9454a2",
"0x8a458a9dc9048e005d22849f470891b840296619",
"0x8a9fde6925a839f6b1932d16b36ac026f8d3fbdb",
"0x8eb270e296023e9d92081fdf967ddd7878724424",
"0x8ffdf2de812095b1d19cb146e4c004587c0a0692",
"0x90072a4aa69b5eb74984ab823efc5f91e90b3a72",
"0x90da57e0a6c0d166bf15764e03b83745dc90025b",
"0x927709711794f3de5ddbf1d176bee2d55ba13c21",
"0x977b6fc5de62598b08c85ac8cf2b745874e8b78c",
"0x98c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c",
"0x99cbc45ea5bb7ef3a5bc08fb1b7e56bb2442ef0d",
"0x9a44fd41566876a39655f74971a3a6ea0a17a454",
"0x9b00a09492a626678e5a3009982191586c444df9",
"0xa4d94019934d8333ef880abffbf2fdd611c762bd",
"0xa700b4eb416be35b2911fd5dee80678ff64ff6c9",
"0xa9251ca9de909cb71783723713b21e4233fbf1b1",
"0xaa0200d169ff3ba9385c12e073c5d1d30434ae7b",
"0xaa6e91c82942aeae040303bf96c15a6dbcb82ca0",
"0xb76cf92076adbf1d9c39294fa8e7a67579fde357",
"0xb82fa9f31612989525992fcfbb09ab22eff5c85a",
"0xbcffb4b3beadc989bd1458740952af6ec8fbe431",
"0xbdb9300b7cde636d9cd4aff00f6f009ffbbc8ee6",
"0xbdfa7b7893081b35fb54027489e2bc7a38275129",
"0xbdfd4e51d3c14a232135f04988a42576efb31519",
"0xbe54767735fb7acca2aa7e2d209a6f705073536d",
"0xc45a479877e1e9dfe9fcd4056c699575a1045daa",
"0xc7b4c17861357b8abb91f25581e7263e08dcb59c",
"0xcc9ee9483f662091a1de4795249e24ac0ac2630f",
"0xcca43cef272c30415866914351fdfc3e881bb7c2",
"0xcf3d55c10db69f28fd1a75bd73f3d8a2d9c595ad",
"0xd4a0e0b9149bcee3c920d2e00b5de09138fd8bb7",
"0xd4e245848d6e1220dbe62e155d89fa327e43cb06",
"0xdd5745756c2de109183c6b5bb886f9207bef114d",
"0xde6ef6cb4abd3a473ffc2942eef5d84536f8e864",
"0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8",
"0xe728577e9a1fe7032bc309b4541f58f45443866e",
"0xea1132120ddcdda2f119e99fa7a27a0d036f7ac9",
"0xebe517846d0f36eced99c735cbf6131e1feb775d",
"0xec4ef66d4fceeba34abb4de69db391bc5476ccc8",
"0xf329e36c7bf6e5e86ce2150875a84ce77f477375",
"0xf59036caebea7dc4b86638dfa2e3c97da9fccd40",
"0xf611aeb5013fd2c0511c9cd55c7dc5c1140741a6",
"0xf6d2224916ddfbbab6e6bd0d1b7034f4ae0cab18",
"0xfa82580c16a31d0c1bc632a36f82e83efef3eec0",
)