Updated on 2026-08-14
This commit is contained in:
parent
724a1fe19b
commit
4ee802212b
11 changed files with 33 additions and 39 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.tap.di.domain
|
||||
|
||||
import android.content.Context
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.tangem.datasource.asset.AssetReader
|
||||
import com.tangem.datasource.config.ConfigManager
|
||||
import com.tangem.datasource.di.SdkMoshi
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
|
|
@ -11,7 +11,6 @@ import com.tangem.domain.walletmanager.WalletManagersFacade
|
|||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
@ -25,14 +24,14 @@ internal object WalletManagersFacadeModule {
|
|||
walletManagersStore: WalletManagersStore,
|
||||
userWalletsStore: UserWalletsStore,
|
||||
configManager: ConfigManager,
|
||||
@ApplicationContext appContext: Context,
|
||||
assetReader: AssetReader,
|
||||
@SdkMoshi moshi: Moshi,
|
||||
): WalletManagersFacade {
|
||||
return DefaultWalletManagersFacade(
|
||||
walletManagersStore = walletManagersStore,
|
||||
userWalletsStore = userWalletsStore,
|
||||
configManager = configManager,
|
||||
assetManager = appContext.assets,
|
||||
assetReader = assetReader,
|
||||
moshi = moshi,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,9 +238,12 @@ private fun Amount(state: TransactionState, isBalanceHidden: Boolean, modifier:
|
|||
text = if (isBalanceHidden) Strings.STARS else state.amount,
|
||||
modifier = modifier,
|
||||
textAlign = TextAlign.End,
|
||||
color = when (state.direction) {
|
||||
Direction.INCOMING -> TangemTheme.colors.text.accent
|
||||
Direction.OUTGOING -> TangemTheme.colors.text.primary1
|
||||
color = when (state.status) {
|
||||
Status.Failed -> TangemTheme.colors.text.warning
|
||||
else -> when (state.direction) {
|
||||
Direction.INCOMING -> TangemTheme.colors.text.accent
|
||||
Direction.OUTGOING -> TangemTheme.colors.text.primary1
|
||||
}
|
||||
},
|
||||
style = TangemTheme.typography.body2,
|
||||
)
|
||||
|
|
@ -317,7 +320,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
collection = listOf(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Confirmed,
|
||||
|
|
@ -329,7 +331,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Unconfirmed,
|
||||
|
|
@ -341,7 +342,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Unconfirmed,
|
||||
|
|
@ -353,7 +353,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Failed,
|
||||
|
|
@ -365,7 +364,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Confirmed,
|
||||
|
|
@ -377,7 +375,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Unconfirmed,
|
||||
|
|
@ -389,7 +386,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Confirmed,
|
||||
|
|
@ -401,7 +397,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Confirmed,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ sealed interface TransactionState {
|
|||
/**
|
||||
* Content state
|
||||
*
|
||||
* @property address address
|
||||
* @property amount amount
|
||||
* @property timestamp timestamp
|
||||
* @property status transaction status
|
||||
|
|
@ -25,7 +24,6 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Content(
|
||||
override val txHash: String,
|
||||
val address: TextReference,
|
||||
val amount: String,
|
||||
val timestamp: String,
|
||||
val status: Status,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.tangem.blockchain.common.txhistory.TransactionHistoryRequest
|
|||
import com.tangem.blockchain.extensions.Result
|
||||
import com.tangem.blockchain.extensions.SimpleResult
|
||||
import com.tangem.crypto.hdWallet.DerivationPath
|
||||
import com.tangem.datasource.asset.AssetReader
|
||||
import com.tangem.datasource.config.ConfigManager
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.datasource.local.walletmanager.WalletManagersStore
|
||||
|
|
@ -43,7 +44,7 @@ class DefaultWalletManagersFacade(
|
|||
private val walletManagersStore: WalletManagersStore,
|
||||
private val userWalletsStore: UserWalletsStore,
|
||||
configManager: ConfigManager,
|
||||
assetManager: AssetManager,
|
||||
assetReader: AssetReader,
|
||||
moshi: Moshi,
|
||||
) : WalletManagersFacade {
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ class DefaultWalletManagersFacade(
|
|||
private val walletManagerFactory by lazy { WalletManagerFactory(configManager) }
|
||||
private val sdkTokenConverter by lazy { SdkTokenConverter() }
|
||||
private val txHistoryStateConverter by lazy { SdkTransactionHistoryStateConverter() }
|
||||
private val txHistoryItemConverter by lazy { SdkTransactionHistoryItemConverter(assetManager, moshi) }
|
||||
private val txHistoryItemConverter by lazy { SdkTransactionHistoryItemConverter(assetReader, moshi) }
|
||||
|
||||
override suspend fun update(
|
||||
userWalletId: UserWalletId,
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
package com.tangem.domain.walletmanager.utils
|
||||
|
||||
import android.content.res.AssetManager
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.tangem.blockchain.common.txhistory.TransactionHistoryItem
|
||||
import com.tangem.datasource.asset.AssetReader
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.blockchain.common.txhistory.TransactionHistoryItem as SdkTransactionHistoryItem
|
||||
|
||||
internal class SdkTransactionHistoryItemConverter(
|
||||
assetManager: AssetManager,
|
||||
assetReader: AssetReader,
|
||||
moshi: Moshi,
|
||||
) : Converter<SdkTransactionHistoryItem, TxHistoryItem> {
|
||||
|
||||
private val typeConverter by lazy {
|
||||
SdkTransactionTypeConverter(assetManager, moshi)
|
||||
SdkTransactionTypeConverter(assetReader, moshi)
|
||||
}
|
||||
|
||||
override fun convert(value: SdkTransactionHistoryItem): TxHistoryItem = TxHistoryItem(
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
package com.tangem.domain.walletmanager.utils
|
||||
|
||||
import android.content.res.AssetManager
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.Types
|
||||
import com.tangem.blockchain.common.txhistory.TransactionHistoryItem
|
||||
import com.tangem.datasource.asset.AssetReader
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.walletmanager.model.SmartContractMethod
|
||||
import com.tangem.utils.converter.Converter
|
||||
import okio.buffer
|
||||
import okio.source
|
||||
|
||||
class SdkTransactionTypeConverter(
|
||||
private val assetManager: AssetManager,
|
||||
private val assetReader: AssetReader,
|
||||
private val moshi: Moshi,
|
||||
) : Converter<TransactionHistoryItem.TransactionType, TxHistoryItem.TransactionType> {
|
||||
|
||||
|
|
@ -43,8 +41,7 @@ class SdkTransactionTypeConverter(
|
|||
}
|
||||
|
||||
private fun readSmartContractMethods(): Map<String, SmartContractMethod> {
|
||||
return assetManager.open("contract_methods.json").use { stream ->
|
||||
adapter.fromJson(stream.source().buffer())
|
||||
} ?: emptyMap()
|
||||
val json = assetReader.readJson("contract_methods")
|
||||
return adapter.fromJson(json) ?: emptyMap()
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,6 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter(
|
|||
private fun createTransactionStateItem(item: TxHistoryItem): TransactionState {
|
||||
return TransactionState.Content(
|
||||
txHash = item.txHash,
|
||||
address = stringReference("mocked address"),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.timestampInMillis.toTimeFormat(),
|
||||
status = item.status.tiUiStatus(),
|
||||
|
|
@ -99,7 +98,10 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter(
|
|||
if (isOutgoing) TransactionState.Content.Direction.OUTGOING else TransactionState.Content.Direction.INCOMING
|
||||
|
||||
private fun TxHistoryItem.getAmount(): String {
|
||||
val prefix = if (isOutgoing) "-" else "+"
|
||||
val prefix = when (status) {
|
||||
TxHistoryItem.TransactionStatus.Failed -> ""
|
||||
else -> if (isOutgoing) "-" else "+"
|
||||
}
|
||||
return prefix + amount.toFormattedCurrencyString(currency = symbol, decimals = decimals)
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@ internal class TokenDetailsTxHistoryTransactionStateConverter(
|
|||
private fun createTransactionStateItem(item: TxHistoryItem): TransactionState {
|
||||
return TransactionState.Content(
|
||||
txHash = item.txHash,
|
||||
address = stringReference("mocked address"),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
|
|
@ -101,7 +100,10 @@ internal class TokenDetailsTxHistoryTransactionStateConverter(
|
|||
}
|
||||
|
||||
private fun TxHistoryItem.getAmount(): String {
|
||||
val prefix = if (isOutgoing) "-" else "+"
|
||||
val prefix = when (status) {
|
||||
TxHistoryItem.TransactionStatus.Failed -> ""
|
||||
else -> if (isOutgoing) "-" else "+"
|
||||
}
|
||||
return prefix + amount.toFormattedCurrencyString(currency = symbol, decimals = decimals)
|
||||
}
|
||||
}
|
||||
|
|
@ -420,7 +420,6 @@ internal object WalletPreviewData {
|
|||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = TransactionState.Content.Status.Unconfirmed,
|
||||
|
|
@ -435,7 +434,6 @@ internal object WalletPreviewData {
|
|||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = TransactionState.Content.Status.Confirmed,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ internal class WalletTxHistoryTransactionStateConverter(
|
|||
private fun createTransactionStateItem(item: TxHistoryItem): TransactionState {
|
||||
return TransactionState.Content(
|
||||
txHash = item.txHash,
|
||||
address = stringReference("mocked address"),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
|
|
@ -101,7 +100,10 @@ internal class WalletTxHistoryTransactionStateConverter(
|
|||
}
|
||||
|
||||
private fun TxHistoryItem.getAmount(): String {
|
||||
val prefix = if (isOutgoing) "-" else "+"
|
||||
val prefix = when (status) {
|
||||
TxHistoryItem.TransactionStatus.Failed -> ""
|
||||
else -> if (isOutgoing) "-" else "+"
|
||||
}
|
||||
return prefix + amount.toFormattedCurrencyString(currency = symbol, decimals = decimals)
|
||||
}
|
||||
}
|
||||
|
|
@ -83,8 +83,8 @@ spr-client = "3.6.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
#tangemBlockchainSdk = "release-app_5.0-363"
|
||||
tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemBlockchainSdk = "release-app_5.0-365"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "release-app_5.0-308"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds
|
||||
# endregion Tangem
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue