Updated on 2026-08-14
This commit is contained in:
parent
aa52b659ce
commit
4d028cc8e4
3 changed files with 19 additions and 14 deletions
|
|
@ -58,7 +58,9 @@ internal class SdkTransactionHistoryItemConverter(
|
|||
} else {
|
||||
mapToInteractionAddressType(sourceType = sourceType)
|
||||
}
|
||||
is SdkTransactionHistoryItem.TransactionType.ContractMethod -> mapToInteractionAddressType(destinationType)
|
||||
is SdkTransactionHistoryItem.TransactionType.ContractMethod,
|
||||
is SdkTransactionHistoryItem.TransactionType.ContractMethodName,
|
||||
-> mapToInteractionAddressType(destinationType)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.tangem.domain.txhistory.models.TxHistoryItem
|
|||
import com.tangem.domain.walletmanager.model.SmartContractMethod
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
class SdkTransactionTypeConverter(
|
||||
internal class SdkTransactionTypeConverter(
|
||||
private val assetReader: AssetReader,
|
||||
private val moshi: Moshi,
|
||||
) : Converter<TransactionHistoryItem.TransactionType, TxHistoryItem.TransactionType> {
|
||||
|
|
@ -27,20 +27,23 @@ class SdkTransactionTypeConverter(
|
|||
|
||||
override fun convert(value: TransactionHistoryItem.TransactionType): TxHistoryItem.TransactionType {
|
||||
return when (value) {
|
||||
TransactionHistoryItem.TransactionType.Transfer -> TxHistoryItem.TransactionType.Transfer
|
||||
is TransactionHistoryItem.TransactionType.ContractMethod -> {
|
||||
return when (val name = smartContractMethods[value.id]?.name) {
|
||||
"transfer" -> TxHistoryItem.TransactionType.Transfer
|
||||
"approve" -> TxHistoryItem.TransactionType.Approve
|
||||
"swap" -> TxHistoryItem.TransactionType.Swap
|
||||
null -> TxHistoryItem.TransactionType.UnknownOperation
|
||||
else -> TxHistoryItem.TransactionType.Operation(name = name.replaceFirstChar { it.titlecase() })
|
||||
}
|
||||
}
|
||||
is TransactionHistoryItem.TransactionType.ContractMethod ->
|
||||
getTransactionType(methodName = smartContractMethods[value.id]?.name)
|
||||
is TransactionHistoryItem.TransactionType.ContractMethodName -> getTransactionType(methodName = value.name)
|
||||
is TransactionHistoryItem.TransactionType.Transfer -> TxHistoryItem.TransactionType.Transfer
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTransactionType(methodName: String?): TxHistoryItem.TransactionType {
|
||||
return when (methodName) {
|
||||
"transfer" -> TxHistoryItem.TransactionType.Transfer
|
||||
"approve" -> TxHistoryItem.TransactionType.Approve
|
||||
"swap" -> TxHistoryItem.TransactionType.Swap
|
||||
null -> TxHistoryItem.TransactionType.UnknownOperation
|
||||
else -> TxHistoryItem.TransactionType.Operation(name = methodName.replaceFirstChar { it.titlecase() })
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated(message = "Use AssetReader instead")
|
||||
private fun readSmartContractMethods(): Map<String, SmartContractMethod> {
|
||||
val json = assetReader.readJson("contract_methods")
|
||||
return adapter.fromJson(json) ?: emptyMap()
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ markdown = "0.7.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "develop-633"
|
||||
tangemBlockchainSdk = "develop-635"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "develop-354"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue