Updated on 2026-08-14
This commit is contained in:
parent
33b7a53905
commit
c5560c3c6a
101 changed files with 274 additions and 272 deletions
|
|
@ -26,17 +26,19 @@ internal class PreviewCustomTokenSelectorComponent(
|
|||
) : CustomTokenSelectorComponent {
|
||||
|
||||
private val previewItems = List(size = itemsSize) { index ->
|
||||
val derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/$index")
|
||||
|
||||
when (params) {
|
||||
is Params.DerivationPathSelector -> {
|
||||
val d = SelectedDerivationPath(
|
||||
id = Network.ID(index.toString()),
|
||||
value = Network.DerivationPath.Card("m/44'/0'/0'/0/$index"),
|
||||
id = Network.ID(value = index.toString(), derivationPath = derivationPath),
|
||||
value = derivationPath,
|
||||
name = "Network $index",
|
||||
isDefault = false,
|
||||
)
|
||||
|
||||
DerivationPathUM(
|
||||
id = d.id?.value ?: "",
|
||||
id = d.id?.rawId?.value ?: "",
|
||||
value = d.value.value.orEmpty(),
|
||||
networkName = stringReference(d.name),
|
||||
isSelected = d.value == params.selectedDerivationPath?.value,
|
||||
|
|
@ -45,16 +47,16 @@ internal class PreviewCustomTokenSelectorComponent(
|
|||
}
|
||||
is Params.NetworkSelector -> {
|
||||
val n = SelectedNetwork(
|
||||
id = Network.ID(index.toString()),
|
||||
id = Network.ID(value = index.toString(), derivationPath = derivationPath),
|
||||
name = "Network $index",
|
||||
derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/$index"),
|
||||
derivationPath = derivationPath,
|
||||
canHandleTokens = false,
|
||||
)
|
||||
|
||||
CurrencyNetworkUM(
|
||||
network = Network(
|
||||
id = n.id,
|
||||
backendId = n.id.value,
|
||||
backendId = n.id.rawId.value,
|
||||
name = "Network $index",
|
||||
currencySymbol = "N$index",
|
||||
derivationPath = Network.DerivationPath.Card(""),
|
||||
|
|
@ -76,7 +78,7 @@ internal class PreviewCustomTokenSelectorComponent(
|
|||
}
|
||||
}.toImmutableList()
|
||||
|
||||
val previewState = CustomTokenSelectorUM(
|
||||
private val previewState = CustomTokenSelectorUM(
|
||||
header = when (params) {
|
||||
is Params.DerivationPathSelector -> CustomTokenSelectorUM.HeaderUM.CustomDerivationButton(
|
||||
value = null,
|
||||
|
|
|
|||
|
|
@ -150,13 +150,14 @@ internal class PreviewManageTokensComponent(
|
|||
)
|
||||
|
||||
private fun getCurrencyNetworks(currencyIndex: Int) = List(size = 3) { networkIndex ->
|
||||
val derivationPath = Network.DerivationPath.Card("")
|
||||
CurrencyNetworkUM(
|
||||
network = Network(
|
||||
id = Network.ID(networkIndex.toString()),
|
||||
id = Network.ID(value = networkIndex.toString(), derivationPath = derivationPath),
|
||||
backendId = networkIndex.toString(),
|
||||
name = "Network $networkIndex",
|
||||
currencySymbol = "N$networkIndex",
|
||||
derivationPath = Network.DerivationPath.Card(""),
|
||||
derivationPath = derivationPath,
|
||||
isTestnet = false,
|
||||
standardType = Network.StandardType.ERC20,
|
||||
hasFiatFeeRate = false,
|
||||
|
|
|
|||
|
|
@ -90,13 +90,15 @@ internal class PreviewOnboardingManageTokensComponent(
|
|||
)
|
||||
|
||||
private fun getCurrencyNetworks() = List(size = 3) { networkIndex ->
|
||||
val derivationPath = Network.DerivationPath.Card("")
|
||||
|
||||
CurrencyNetworkUM(
|
||||
network = Network(
|
||||
id = Network.ID(networkIndex.toString()),
|
||||
id = Network.ID(value = networkIndex.toString(), derivationPath = derivationPath),
|
||||
backendId = networkIndex.toString(),
|
||||
name = "Network $networkIndex",
|
||||
currencySymbol = "N$networkIndex",
|
||||
derivationPath = Network.DerivationPath.Card(""),
|
||||
derivationPath = derivationPath,
|
||||
isTestnet = false,
|
||||
standardType = Network.StandardType.ERC20,
|
||||
hasFiatFeeRate = false,
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ internal data class CurrencyNetworkUM(
|
|||
override val onSelectedStateChange: (Boolean) -> Unit,
|
||||
) : SelectableItemUM {
|
||||
|
||||
override val id: String = network.id.value
|
||||
override val id: String = network.rawId
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ private class AddCustomTokenComponentPreviewProvider : PreviewParameterProvider<
|
|||
userWalletId = UserWalletId(stringValue = "321"),
|
||||
step = AddCustomTokenConfig.Step.FORM,
|
||||
selectedNetwork = SelectedNetwork(
|
||||
id = Network.ID(value = "1"),
|
||||
id = Network.ID(value = "1", derivationPath = Network.DerivationPath.None),
|
||||
name = "Ethereum",
|
||||
derivationPath = Network.DerivationPath.None,
|
||||
canHandleTokens = false,
|
||||
|
|
@ -88,7 +88,7 @@ private class AddCustomTokenComponentPreviewProvider : PreviewParameterProvider<
|
|||
userWalletId = UserWalletId(stringValue = "321"),
|
||||
step = AddCustomTokenConfig.Step.NETWORK_SELECTOR,
|
||||
selectedNetwork = SelectedNetwork(
|
||||
id = Network.ID(value = "0"),
|
||||
id = Network.ID(value = "0", derivationPath = Network.DerivationPath.None),
|
||||
name = "Ethereum",
|
||||
derivationPath = Network.DerivationPath.None,
|
||||
canHandleTokens = false,
|
||||
|
|
@ -100,7 +100,7 @@ private class AddCustomTokenComponentPreviewProvider : PreviewParameterProvider<
|
|||
userWalletId = UserWalletId(stringValue = "321"),
|
||||
step = AddCustomTokenConfig.Step.DERIVATION_PATH_SELECTOR,
|
||||
selectedDerivationPath = SelectedDerivationPath(
|
||||
id = Network.ID(value = "0"),
|
||||
id = Network.ID(value = "0", derivationPath = Network.DerivationPath.None),
|
||||
value = Network.DerivationPath.None,
|
||||
name = "Ethereum",
|
||||
isDefault = false,
|
||||
|
|
|
|||
|
|
@ -266,20 +266,23 @@ private fun Preview_CustomTokenNetworkSelectorContent(
|
|||
|
||||
private class CustomTokenNetworkSelectorComponentPreviewProvider :
|
||||
PreviewParameterProvider<CustomTokenSelectorComponent> {
|
||||
|
||||
private val derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/0")
|
||||
|
||||
override val values: Sequence<CustomTokenSelectorComponent>
|
||||
get() = sequenceOf(
|
||||
PreviewCustomTokenSelectorComponent(
|
||||
params = CustomTokenSelectorComponent.Params.DerivationPathSelector(
|
||||
userWalletId = UserWalletId(stringValue = "321"),
|
||||
selectedNetwork = SelectedNetwork(
|
||||
id = Network.ID(value = "0"),
|
||||
id = Network.ID(value = "0", derivationPath = derivationPath),
|
||||
name = "Ethereum",
|
||||
derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/0"),
|
||||
derivationPath = derivationPath,
|
||||
canHandleTokens = true,
|
||||
),
|
||||
selectedDerivationPath = SelectedDerivationPath(
|
||||
id = Network.ID(value = "0"),
|
||||
value = Network.DerivationPath.Card("m/44'/0'/0'/0/0"),
|
||||
id = Network.ID(value = "0", derivationPath = derivationPath),
|
||||
value = derivationPath,
|
||||
name = "",
|
||||
isDefault = false,
|
||||
),
|
||||
|
|
@ -290,9 +293,9 @@ private class CustomTokenNetworkSelectorComponentPreviewProvider :
|
|||
params = CustomTokenSelectorComponent.Params.NetworkSelector(
|
||||
userWalletId = UserWalletId(stringValue = "321"),
|
||||
selectedNetwork = SelectedNetwork(
|
||||
id = Network.ID(value = "0"),
|
||||
id = Network.ID(value = "0", derivationPath = derivationPath),
|
||||
name = "Ethereum",
|
||||
derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/0"),
|
||||
derivationPath = derivationPath,
|
||||
canHandleTokens = true,
|
||||
),
|
||||
onNetworkSelected = {},
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ internal fun Network.toDerivationPathModel(
|
|||
onSelectedStateChange: (Boolean) -> Unit,
|
||||
): DerivationPathUM? {
|
||||
return DerivationPathUM(
|
||||
id = id.value,
|
||||
id = rawId,
|
||||
value = derivationPath.value ?: return null,
|
||||
networkName = stringReference(name),
|
||||
isSelected = isSelected,
|
||||
|
|
@ -25,7 +25,7 @@ internal fun SelectedNetwork.toDerivationPathModel(
|
|||
onSelectedStateChange: (Boolean) -> Unit,
|
||||
): DerivationPathUM? {
|
||||
return DerivationPathUM(
|
||||
id = id.value,
|
||||
id = id.rawId.value,
|
||||
value = derivationPath.value ?: return null,
|
||||
networkName = resourceReference(R.string.custom_token_derivation_path_default),
|
||||
isSelected = isSelected,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ internal fun CurrencyNetworkUM.select(isSelected: Boolean): CurrencyNetworkUM {
|
|||
|
||||
@DrawableRes
|
||||
internal fun Network.ID.getIconRes(isColored: Boolean): Int = if (isColored) {
|
||||
getActiveIconRes(value)
|
||||
getActiveIconRes(rawId.value)
|
||||
} else {
|
||||
getGreyedOutIconRes(value)
|
||||
getGreyedOutIconRes(rawId.value)
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ internal class UpdateDataStateTransformer(
|
|||
private fun List<NFTCollection>.transform(state: NFTCollectionsStateUM): ImmutableList<NFTCollectionUM> = map {
|
||||
NFTCollectionUM(
|
||||
id = it.collectionIdProvider(),
|
||||
networkIconId = getActiveIconRes(it.network.id.value),
|
||||
networkIconId = getActiveIconRes(it.network.rawId),
|
||||
name = it.name.orEmpty(),
|
||||
description = TextReference.PluralRes(
|
||||
R.plurals.nft_collections_count,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DefaultNFTDetailsBlockComponent @AssistedInject constructor(
|
|||
assetName = stringReference(params.nftAsset.name.orEmpty()),
|
||||
collectionName = stringReference(params.nftCollectionName),
|
||||
assetImage = params.nftAsset.media?.url,
|
||||
networkIconRes = getActiveIconRes(params.nftAsset.network.id.value),
|
||||
networkIconRes = getActiveIconRes(params.nftAsset.network.rawId),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ internal class UpdateDataStateTransformer(
|
|||
private fun Network.transform(enabled: Boolean): NFTNetworkUM {
|
||||
val custom = derivationPath is Network.DerivationPath.Custom
|
||||
return NFTNetworkUM(
|
||||
id = id.value + derivationPath.value,
|
||||
id = rawId + derivationPath.value,
|
||||
chainRowUM = ChainRowUM(
|
||||
name = name,
|
||||
type = "",
|
||||
icon = CurrencyIconState.CoinIcon(
|
||||
url = null,
|
||||
fallbackResId = getActiveIconRes(id.value),
|
||||
fallbackResId = getActiveIconRes(rawId),
|
||||
isGrayscale = !enabled,
|
||||
showCustomBadge = custom,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ internal class SendConfirmModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage,
|
||||
blockchainId = cryptoCurrency.network.id.value,
|
||||
blockchainId = cryptoCurrency.network.rawId,
|
||||
derivationPath = cryptoCurrency.network.derivationPath.value,
|
||||
destinationAddress = confirmData.enteredDestination.orEmpty(),
|
||||
tokenSymbol = if (amount?.type is AmountType.Token) {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import com.tangem.domain.feedback.models.FeedbackEmailType
|
|||
import com.tangem.domain.qrscanning.models.SourceType
|
||||
import com.tangem.domain.qrscanning.usecases.ListenToQrScanningUseCase
|
||||
import com.tangem.domain.qrscanning.usecases.ParseQrCodeUseCase
|
||||
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
|
||||
import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase
|
||||
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
|
||||
import com.tangem.domain.tokens.error.CurrencyStatusError
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.transaction.error.GetFeeError
|
||||
|
|
@ -301,7 +301,7 @@ internal class SendModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage.orEmpty(),
|
||||
blockchainId = cryptoCurrency.network.id.value,
|
||||
blockchainId = cryptoCurrency.network.rawId,
|
||||
derivationPath = cryptoCurrency.network.derivationPath.value,
|
||||
destinationAddress = "",
|
||||
tokenSymbol = "",
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage,
|
||||
blockchainId = cryptoCurrency.network.id.value,
|
||||
blockchainId = cryptoCurrency.network.rawId,
|
||||
derivationPath = cryptoCurrency.network.derivationPath.value,
|
||||
destinationAddress = confirmData.enteredDestination.orEmpty(),
|
||||
tokenSymbol = null,
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ import com.tangem.domain.feedback.SendFeedbackEmailUseCase
|
|||
import com.tangem.domain.feedback.models.BlockchainErrorInfo
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.domain.tokens.GetCryptoCurrenciesUseCase
|
||||
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
|
||||
import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase
|
||||
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.transaction.error.GetFeeError
|
||||
|
|
@ -166,7 +166,7 @@ internal class NFTSendModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage.orEmpty(),
|
||||
blockchainId = cryptoCurrency.network.id.value,
|
||||
blockchainId = cryptoCurrency.network.rawId,
|
||||
derivationPath = cryptoCurrency.network.derivationPath.value,
|
||||
destinationAddress = "",
|
||||
tokenSymbol = null,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ internal class BitcoinCustomFeeConverter(
|
|||
) : CustomFeeConverter<Fee.Bitcoin> {
|
||||
|
||||
private val currencyStatus = feeCryptoCurrencyStatus.value
|
||||
private val network = feeCryptoCurrencyStatus.currency.network.id.value
|
||||
private val network = feeCryptoCurrencyStatus.currency.network.rawId
|
||||
|
||||
override fun convert(value: Fee.Bitcoin): ImmutableList<CustomFeeFieldUM> {
|
||||
val feeValue = value.amount.value
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ internal class SendFeeInitialStateTransformer(
|
|||
isCustomSelected = false,
|
||||
isFeeConvertibleToFiat = feeCryptoCurrencyStatus.currency.network.hasFiatFeeRate,
|
||||
isTronToken = cryptoCurrency is CryptoCurrency.Token &&
|
||||
isTron(cryptoCurrency.network.id.value),
|
||||
isTron(cryptoCurrency.network.rawId),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ internal class NotificationsModel @Inject constructor(
|
|||
)
|
||||
},
|
||||
)
|
||||
if (!BlockchainUtils.isCardano(currency.network.id.value)) {
|
||||
if (!BlockchainUtils.isCardano(currency.network.rawId)) {
|
||||
addDustWarningNotification(
|
||||
dustValue = currencyCheck.dustValue,
|
||||
feeValue = feeValue,
|
||||
|
|
@ -375,7 +375,7 @@ internal class NotificationsModel @Inject constructor(
|
|||
private suspend fun MutableList<NotificationUM>.addTronNetworkFeesNotification() {
|
||||
val cryptoCurrency = cryptoCurrencyStatus.currency
|
||||
val isTronToken = cryptoCurrency is CryptoCurrency.Token &&
|
||||
isTron(cryptoCurrency.network.id.value)
|
||||
isTron(cryptoCurrency.network.rawId)
|
||||
|
||||
if (isTronToken && getTronFeeNotificationShowCountUseCase() <= TRON_FEE_NOTIFICATION_MAX_SHOW_COUNT) {
|
||||
add(
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ internal class SendModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage,
|
||||
blockchainId = cryptoCurrency.network.id.value,
|
||||
blockchainId = cryptoCurrency.network.rawId,
|
||||
derivationPath = cryptoCurrency.network.derivationPath.value,
|
||||
destinationAddress = recipient.orEmpty(),
|
||||
tokenSymbol = if (amount?.type is AmountType.Token) {
|
||||
|
|
@ -742,7 +742,7 @@ internal class SendModel @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun checkIfXrpAddressValue(value: String): Boolean {
|
||||
return BlockchainUtils.decodeRippleXAddress(value, cryptoCurrency.network.id.value)?.let { decodedAddress ->
|
||||
return BlockchainUtils.decodeRippleXAddress(value, cryptoCurrency.network.rawId)?.let { decodedAddress ->
|
||||
uiState.value =
|
||||
recipientStateFactory.onRecipientAddressValueChange(value, isXAddress = true, isValuePasted = true)
|
||||
uiState.value = recipientStateFactory.getOnXAddressMemoState()
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ internal class SendNotificationFactory(
|
|||
)
|
||||
},
|
||||
)
|
||||
if (!BlockchainUtils.isCardano(currency.network.id.value)) {
|
||||
if (!BlockchainUtils.isCardano(currency.network.rawId)) {
|
||||
addDustWarningNotification(
|
||||
dustValue = currencyCheck.dustValue,
|
||||
feeValue = feeValue,
|
||||
|
|
@ -306,7 +306,7 @@ internal class SendNotificationFactory(
|
|||
) {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: BigDecimal.ZERO
|
||||
val isTezos = isTezos(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTezos = isTezos(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val threshold = getTezosThreshold()
|
||||
val isTotalBalance = sendAmount >= balance && balance > threshold
|
||||
if (!ignoreAmountReduce && isTotalBalance && isTezos) {
|
||||
|
|
@ -356,7 +356,7 @@ internal class SendNotificationFactory(
|
|||
private suspend fun MutableList<NotificationUM>.addTronNetworkFeesNotification() {
|
||||
val cryptoCurrency = cryptoCurrencyStatusProvider().currency
|
||||
val isTronToken = cryptoCurrency is CryptoCurrency.Token &&
|
||||
isTron(cryptoCurrency.network.id.value)
|
||||
isTron(cryptoCurrency.network.rawId)
|
||||
|
||||
if (isTronToken && getTronFeeNotificationShowCountUseCase() <= TRON_FEE_NOTIFICATION_MAX_SHOW_COUNT) {
|
||||
add(
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ internal class SendFeeStateConverter(
|
|||
isCustomSelected = false,
|
||||
isFeeConvertibleToFiat = cryptoCurrencyStatusProvider().currency.network.hasFiatFeeRate,
|
||||
isTronToken = cryptoCurrencyStatusProvider().currency is CryptoCurrency.Token &&
|
||||
isTron(cryptoCurrencyStatusProvider().currency.network.id.value),
|
||||
isTron(cryptoCurrencyStatusProvider().currency.network.rawId),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -12,10 +12,10 @@ import com.tangem.core.ui.utils.parseToBigDecimal
|
|||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.features.send.impl.R
|
||||
import com.tangem.features.send.impl.presentation.model.SendClickIntents
|
||||
import com.tangem.features.send.impl.presentation.state.StateRouter
|
||||
import com.tangem.features.send.impl.presentation.state.fee.checkExceedBalance
|
||||
import com.tangem.features.send.impl.presentation.state.fields.SendTextField
|
||||
import com.tangem.features.send.impl.presentation.model.SendClickIntents
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isUseBitcoinFeeConverter
|
||||
import com.tangem.utils.Provider
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -34,7 +34,7 @@ internal class BitcoinCustomFeeConverter(
|
|||
override fun convert(value: Fee.Bitcoin): ImmutableList<SendTextField.CustomFee> {
|
||||
val feeValue = value.amount.value
|
||||
val feeCurrency = feeCryptoCurrencyStatusProvider()?.value
|
||||
val network = feeCryptoCurrencyStatusProvider()?.currency?.network?.id?.value
|
||||
val network = feeCryptoCurrencyStatusProvider()?.currency?.network?.rawId
|
||||
return if (network != null && isUseBitcoinFeeConverter(network)) {
|
||||
persistentListOf(
|
||||
SendTextField.CustomFee(
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import com.tangem.core.ui.utils.parseToBigDecimal
|
|||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.features.send.impl.R
|
||||
import com.tangem.features.send.impl.presentation.state.fields.SendTextField
|
||||
import com.tangem.features.send.impl.presentation.model.SendClickIntents
|
||||
import com.tangem.features.send.impl.presentation.state.fields.SendTextField
|
||||
import com.tangem.utils.Provider
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -29,7 +29,7 @@ internal class KaspaCustomFeeConverter(
|
|||
override fun convert(value: Fee.Kaspa): ImmutableList<SendTextField.CustomFee> {
|
||||
val feeValue = value.amount.value
|
||||
val feeCurrency = feeCryptoCurrencyStatusProvider()?.value
|
||||
val network = feeCryptoCurrencyStatusProvider()?.currency?.network?.id?.value
|
||||
val network = feeCryptoCurrencyStatusProvider()?.currency?.network?.rawId
|
||||
return if (network != null) {
|
||||
persistentListOf(
|
||||
SendTextField.CustomFee(
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ internal class StakingModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onActiveStake(activeStake: BalanceState) {
|
||||
val networkId = cryptoCurrencyStatus.currency.network.id.value
|
||||
val networkId = cryptoCurrencyStatus.currency.network.rawId
|
||||
if (isSingleAction(networkId, activeStake)) {
|
||||
prepareForConfirmation(
|
||||
balanceType = activeStake.type,
|
||||
|
|
@ -854,7 +854,7 @@ internal class StakingModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage,
|
||||
blockchainId = network.id.value,
|
||||
blockchainId = network.rawId,
|
||||
derivationPath = network.derivationPath.value,
|
||||
destinationAddress = validator?.address.orEmpty(),
|
||||
tokenSymbol = (cryptoCurrencyStatus.currency as? CryptoCurrency.Token)?.symbol,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ internal class BalanceItemConverter(
|
|||
|
||||
private fun BalanceItem.getBalanceValue(): BigDecimal {
|
||||
val isIncludeStakingTotalBalance = BlockchainUtils.isIncludeStakingTotalBalance(
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
)
|
||||
val yieldBalance = cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data
|
||||
return if (isIncludeStakingTotalBalance) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ internal class YieldBalancesConverter(
|
|||
.toPersistentList()
|
||||
|
||||
private fun getRewardBlockType(): RewardBlockType {
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.id.value
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.rawId
|
||||
val yieldBalance = cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data
|
||||
val rewards = yieldBalance?.balance?.items
|
||||
?.filter { it.type == BalanceType.REWARDS && !it.amount.isZero() }
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ internal class StakingFeeTransactionLoader @AssistedInject constructor(
|
|||
?: error("No available address")
|
||||
|
||||
val gasEstimate = if (isCompositePendingActions(
|
||||
networkId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
pendingActions = pendingActions,
|
||||
)
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
onConstructError: (StakingError) -> Unit,
|
||||
) = coroutineScope {
|
||||
val isComposePendingActions = isCompositePendingActions(
|
||||
cryptoCurrencyStatus.currency.network.id.value,
|
||||
confirmationState.pendingActions,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
pendingActions = confirmationState.pendingActions,
|
||||
)
|
||||
if (isComposePendingActions) {
|
||||
confirmationState.pendingActions?.map { action ->
|
||||
|
|
@ -156,7 +156,7 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
?.map { transaction ->
|
||||
async {
|
||||
getConstructedStakingTransactionUseCase(
|
||||
networkId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
fee = fee,
|
||||
amount = amount.convertToSdkAmount(cryptoCurrencyStatus.currency),
|
||||
transactionId = transaction.id,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ internal class SetConfirmationStateInitTransformer(
|
|||
) : Transformer<StakingUiState> {
|
||||
|
||||
private val networkId
|
||||
get() = cryptoCurrencyStatus.currency.network.id.value
|
||||
get() = cryptoCurrencyStatus.currency.network.rawId
|
||||
|
||||
private val isComposePendingActions
|
||||
get() = isCompositePendingActions(networkId, pendingActions)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ import com.tangem.domain.staking.model.stakekit.Yield
|
|||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.*
|
||||
import com.tangem.features.staking.impl.presentation.state.FeeState
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.getRewardScheduleText
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ internal class SetConfirmationStateLoadingTransformer(
|
|||
}
|
||||
val rewardSchedule = getRewardScheduleText(
|
||||
rewardSchedule = yield.metadata.rewardSchedule,
|
||||
networkId = cryptoCurrency.network.id.value,
|
||||
networkId = cryptoCurrency.network.rawId,
|
||||
decapitalize = true,
|
||||
)
|
||||
return if (isEnterAction && amountDecimal != null && rewardSchedule != null) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ internal class SetInitialDataStateTransformer(
|
|||
title = TextReference.EMPTY,
|
||||
cryptoCurrencyName = cryptoCurrency.name,
|
||||
cryptoCurrencySymbol = cryptoCurrency.symbol,
|
||||
cryptoCurrencyBlockchainId = cryptoCurrency.network.id.value,
|
||||
cryptoCurrencyBlockchainId = cryptoCurrency.network.rawId,
|
||||
clickIntents = clickIntents,
|
||||
currentStep = StakingStep.InitialInfo,
|
||||
initialInfoState = createInitialInfoState(),
|
||||
|
|
@ -150,7 +150,7 @@ internal class SetInitialDataStateTransformer(
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
): RoundedListWithDividersItemData? {
|
||||
val minimumCryptoAmount = yield.args.enter.args[Yield.Args.ArgType.AMOUNT]?.minimum ?: return null
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.id.value
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.rawId
|
||||
if (!showMinimumRequirementInfo(blockchainId)) return null
|
||||
|
||||
val formattedAmount = minimumCryptoAmount.format { crypto(cryptoCurrencyStatus.currency) }
|
||||
|
|
@ -193,7 +193,7 @@ internal class SetInitialDataStateTransformer(
|
|||
private fun createRewardScheduleItem(): RoundedListWithDividersItemData? {
|
||||
val endTextReference = getRewardScheduleText(
|
||||
rewardSchedule = yield.metadata.rewardSchedule,
|
||||
networkId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
decapitalize = false,
|
||||
) ?: return null
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ internal class AmountRequirementStateTransformer(
|
|||
val cryptoAmountValue = amountState.amountTextField.cryptoAmount.value ?: return false
|
||||
|
||||
val isEnterOrExit = actionType is StakingActionCommonType.Enter || actionType is StakingActionCommonType.Exit
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.rawId)
|
||||
|
||||
val isIntegerOnly = cryptoAmountValue.isZero() || cryptoAmountValue.remainder(BigDecimal.ONE).isZero()
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
onClick = prevState.clickIntents::openTokenDetails,
|
||||
onAnalyticsEvent = { /* no-op */ },
|
||||
)
|
||||
if (!BlockchainUtils.isCardano(network.id.value)) {
|
||||
if (!BlockchainUtils.isCardano(network.rawId)) {
|
||||
addDustWarningNotification(
|
||||
dustValue = currencyCheck.dustValue,
|
||||
feeValue = feeValue,
|
||||
|
|
@ -278,7 +278,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
|
||||
private fun MutableList<NotificationUM>.addTonUnstakeNotification(actionType: StakingActionCommonType) {
|
||||
val amount = cryptoCurrencyStatusProvider().value.amount.orZero()
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.rawId
|
||||
|
||||
if (isTon(cryptoCurrencyNetworkIdValue) && actionType !is StakingActionCommonType.Enter) {
|
||||
val notification = if (amount < TON_BALANCE_EXTRA_FEE_THRESHOLD) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
private fun MutableList<NotificationUM>.addExitInfoNotifications(prevState: StakingUiState) {
|
||||
val cooldownPeriodDays = yield.metadata.cooldownPeriod?.days
|
||||
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.rawId
|
||||
if (cooldownPeriodDays != null) {
|
||||
add(
|
||||
StakingNotification.Info.Unstake(
|
||||
|
|
@ -155,7 +155,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addTronRevoteNotification() {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val hasStakedBalance = (cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data)?.balance
|
||||
?.items?.any {
|
||||
it.type == BalanceType.PREPARING ||
|
||||
|
|
@ -174,7 +174,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addCardanoStakeNotification() {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.rawId)
|
||||
|
||||
if (isCardano) {
|
||||
add(
|
||||
|
|
@ -188,7 +188,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addCardanoStakeMinimumAmountNotification(feeValue: BigDecimal) {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val balance = cryptoCurrencyStatus.value.amount.orZero()
|
||||
if (isCardano && balance - feeValue < MINIMUM_STAKE_BALANCE) {
|
||||
add(
|
||||
|
|
@ -202,7 +202,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addCardanoRestakeMinimumAmountNotification(feeValue: BigDecimal) {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val balance = cryptoCurrencyStatus.value.amount.orZero()
|
||||
if (isCardano && balance - feeValue < MINIMUM_RESTAKE_BALANCE) {
|
||||
add(
|
||||
|
|
@ -223,7 +223,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
val isEntireBalance = sendingAmount.plus(feeValue) == balance
|
||||
|
||||
if (isEntireBalance && isSubtractAvailable && !isCardano(cryptoCurrencyStatus.currency.network.id.value)) {
|
||||
if (isEntireBalance && isSubtractAvailable && !isCardano(cryptoCurrencyStatus.currency.network.rawId)) {
|
||||
add(StakingNotification.Info.StakeEntireBalance)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ internal fun checkAndCalculateSubtractedAmount(
|
|||
reduceAmountBy: BigDecimal,
|
||||
): BigDecimal {
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: return amountValue
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val feeValueRounded = if (isTron) {
|
||||
feeValue.round(MathContext(0, RoundingMode.UP))
|
||||
} else {
|
||||
|
|
@ -32,7 +32,7 @@ internal fun checkAndCalculateSubtractedAmount(
|
|||
)
|
||||
return if (isFeeCoverage) {
|
||||
val reducedAmount = balance.minus(reduceAmountBy).minus(feeValueRounded)
|
||||
if (isTron(cryptoCurrencyStatus.currency.network.id.value)) {
|
||||
if (isTron(cryptoCurrencyStatus.currency.network.rawId)) {
|
||||
reducedAmount.setScale(0, RoundingMode.DOWN)
|
||||
} else {
|
||||
reducedAmount
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
is TxFeeState.MultipleFeeState -> feeState.normalFee.feeValue
|
||||
is TxFeeState.SingleFeeState -> feeState.fee.feeValue
|
||||
},
|
||||
blockchain = Blockchain.fromId(currency.network.id.value),
|
||||
blockchain = Blockchain.fromId(currency.network.rawId),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -1387,7 +1387,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
val callData = SmartContractCallDataProviderFactory.getApprovalCallData(
|
||||
spenderAddress = requireNotNull(spenderAddress) { "Spender address is null" },
|
||||
amount = swapAmount.value.convertToSdkAmount(fromToken),
|
||||
blockchain = Blockchain.fromId(fromToken.network.id.value),
|
||||
blockchain = Blockchain.fromId(fromToken.network.rawId),
|
||||
)
|
||||
val feeData = try {
|
||||
val extras = createTransactionExtrasUseCase(
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
package com.tangem.feature.swap.domain.converters
|
||||
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.lib.crypto.models.Currency
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
class SwapCurrencyConverter : Converter<CryptoCurrency, Currency> {
|
||||
|
||||
override fun convert(value: CryptoCurrency): Currency {
|
||||
return when (value) {
|
||||
is CryptoCurrency.Token -> {
|
||||
Currency.NonNativeToken(
|
||||
id = value.id.value,
|
||||
name = value.name,
|
||||
symbol = value.symbol,
|
||||
networkId = value.network.id.value,
|
||||
contractAddress = value.contractAddress,
|
||||
decimalCount = value.decimals,
|
||||
)
|
||||
}
|
||||
is CryptoCurrency.Coin -> {
|
||||
Currency.NativeToken(
|
||||
id = value.id.value,
|
||||
name = value.name,
|
||||
symbol = value.symbol,
|
||||
networkId = value.network.id.value,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1353,7 +1353,7 @@ internal class SwapModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage,
|
||||
blockchainId = network.id.value,
|
||||
blockchainId = network.rawId,
|
||||
derivationPath = network.derivationPath.value,
|
||||
destinationAddress = transaction?.txTo.orEmpty(),
|
||||
tokenSymbol = fromCurrencyStatus.currency.symbol,
|
||||
|
|
@ -1375,7 +1375,7 @@ internal class SwapModel @Inject constructor(
|
|||
private fun CryptoCurrency.getNetworkInfo(): NetworkInfo {
|
||||
return NetworkInfo(
|
||||
name = this.network.name,
|
||||
blockchainId = this.network.id.value,
|
||||
blockchainId = this.network.rawId,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ internal class SwapNotificationsFactory(
|
|||
}
|
||||
is TxFeeState.SingleFeeState -> feeState.fee
|
||||
}
|
||||
val isCardano = BlockchainUtils.isCardano(fromCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = BlockchainUtils.isCardano(fromCurrencyStatus.currency.network.rawId)
|
||||
// blockchain specific
|
||||
|
||||
addExistentialWarningNotification(
|
||||
|
|
@ -305,7 +305,7 @@ internal class SwapNotificationsFactory(
|
|||
fromAmount: SwapAmount,
|
||||
onReduceByAmount: (SwapAmount, BigDecimal) -> Unit,
|
||||
) {
|
||||
val isTezos = isTezos(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTezos = isTezos(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: BigDecimal.ZERO
|
||||
val threshold = getTezosThreshold()
|
||||
val isTotalBalance = fromAmount.value >= balance && balance > threshold
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ import com.tangem.feature.swap.domain.models.domain.IncludeFeeInAmount
|
|||
import com.tangem.feature.swap.domain.models.domain.NetworkInfo
|
||||
import com.tangem.feature.swap.domain.models.domain.SwapProvider
|
||||
import com.tangem.feature.swap.domain.models.ui.*
|
||||
import com.tangem.feature.swap.model.SwapNotificationsFactory
|
||||
import com.tangem.feature.swap.model.SwapProcessDataState
|
||||
import com.tangem.feature.swap.models.*
|
||||
import com.tangem.feature.swap.models.states.*
|
||||
import com.tangem.feature.swap.models.states.events.SwapEvent
|
||||
import com.tangem.feature.swap.presentation.R
|
||||
import com.tangem.feature.swap.model.SwapNotificationsFactory
|
||||
import com.tangem.feature.swap.utils.formatToUIRepresentation
|
||||
import com.tangem.feature.swap.model.SwapProcessDataState
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.StringsSigns.DASH_SIGN
|
||||
import com.tangem.utils.StringsSigns.PERCENT
|
||||
|
|
@ -93,7 +93,7 @@ internal class StateBuilder(
|
|||
canSelectAnotherToken = false,
|
||||
isNotNativeToken = initialCurrencyFrom is CryptoCurrency.Token,
|
||||
balance = "",
|
||||
networkIconRes = getActiveIconRes(initialCurrencyFrom.network.id.value),
|
||||
networkIconRes = getActiveIconRes(initialCurrencyFrom.network.rawId),
|
||||
isBalanceHidden = true,
|
||||
),
|
||||
receiveCardData = SwapCardState.SwapCardData(
|
||||
|
|
@ -106,7 +106,7 @@ internal class StateBuilder(
|
|||
canSelectAnotherToken = false,
|
||||
balance = "",
|
||||
isNotNativeToken = initialCurrencyTo is CryptoCurrency.Token,
|
||||
networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.id.value) },
|
||||
networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.rawId) },
|
||||
coinId = initialCurrencyTo?.network?.backendId,
|
||||
isBalanceHidden = true,
|
||||
),
|
||||
|
|
@ -153,7 +153,7 @@ internal class StateBuilder(
|
|||
tokenCurrency = uiStateHolder.sendCardData.tokenCurrency,
|
||||
canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken,
|
||||
balance = fromToken.getFormattedAmount(isNeedSymbol = false),
|
||||
networkIconRes = getActiveIconRes(fromToken.currency.network.id.value),
|
||||
networkIconRes = getActiveIconRes(fromToken.currency.network.rawId),
|
||||
isBalanceHidden = isBalanceHiddenProvider(),
|
||||
),
|
||||
receiveCardData = SwapCardState.Empty(
|
||||
|
|
@ -206,7 +206,7 @@ internal class StateBuilder(
|
|||
isNotNativeToken = fromToken is CryptoCurrency.Token,
|
||||
canSelectAnotherToken = canSelectSendToken,
|
||||
balance = if (!canSelectSendToken) uiStateHolder.sendCardData.balance else "",
|
||||
networkIconRes = getActiveIconRes(fromToken.network.id.value),
|
||||
networkIconRes = getActiveIconRes(fromToken.network.rawId),
|
||||
isBalanceHidden = isBalanceHiddenProvider(),
|
||||
),
|
||||
receiveCardData = SwapCardState.SwapCardData(
|
||||
|
|
@ -220,7 +220,7 @@ internal class StateBuilder(
|
|||
isNotNativeToken = toToken is CryptoCurrency.Token,
|
||||
canSelectAnotherToken = canSelectReceiveToken,
|
||||
balance = if (!canSelectReceiveToken) uiStateHolder.receiveCardData.balance else "",
|
||||
networkIconRes = getActiveIconRes(toToken.network.id.value),
|
||||
networkIconRes = getActiveIconRes(toToken.network.rawId),
|
||||
isBalanceHidden = isBalanceHiddenProvider(),
|
||||
),
|
||||
notifications = persistentListOf(),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ internal class TokenDetailsBalanceSelectStateConverter(
|
|||
|
||||
val yieldBalance = cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data
|
||||
val stakingCryptoAmount = yieldBalance?.getTotalWithRewardsStakingBalance(
|
||||
cryptoCurrencyStatus.currency.network.id.value,
|
||||
cryptoCurrencyStatus.currency.network.rawId,
|
||||
)
|
||||
val stakingFiatAmount = stakingCryptoAmount?.let { cryptoCurrencyStatus.value.fiatRate?.multiply(it) }
|
||||
copy(
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ internal class TokenDetailsLoadedBalanceConverter(
|
|||
): TokenDetailsBalanceBlockState {
|
||||
val stakingCryptoAmount =
|
||||
(status.value.yieldBalance as? YieldBalance.Data)?.getTotalWithRewardsStakingBalance(
|
||||
status.currency.network.id.value,
|
||||
status.currency.network.rawId,
|
||||
)
|
||||
val stakingFiatAmount = stakingCryptoAmount?.let { status.value.fiatRate?.multiply(it) }
|
||||
val isBalanceSelectorEnabled = !stakingCryptoAmount.isNullOrZero()
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ internal class TokenDetailsSkeletonStateConverter(
|
|||
private fun MutableList<TangemDropdownMenuItem>.addGenerateXPubMenuItem(cryptoCurrency: CryptoCurrency) {
|
||||
val userWallet = getUserWalletUseCase(userWalletId).getOrNull() ?: return
|
||||
|
||||
val isBitcoin = isBitcoin(cryptoCurrency.network.id.value)
|
||||
val isBitcoin = isBitcoin(cryptoCurrency.network.rawId)
|
||||
val hasDerivations = networkHasDerivationUseCase(
|
||||
scanResponse = userWallet.scanResponse,
|
||||
network = cryptoCurrency.network,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ internal class TokenDetailsStakingInfoConverter(
|
|||
private fun getStakingInfoBlock(status: CryptoCurrencyStatus, state: TokenDetailsState): StakingBlockUM? {
|
||||
val yieldBalance = status.value.yieldBalance as? YieldBalance.Data
|
||||
|
||||
val stakingCryptoAmount = yieldBalance?.getTotalStakingBalance(status.currency.network.id.value)
|
||||
val stakingCryptoAmount = yieldBalance?.getTotalStakingBalance(status.currency.network.rawId)
|
||||
val pendingBalances = yieldBalance?.balance?.items ?: emptyList()
|
||||
|
||||
val iconState = state.tokenInfoBlockState.iconState
|
||||
|
|
@ -144,7 +144,7 @@ internal class TokenDetailsStakingInfoConverter(
|
|||
}
|
||||
|
||||
private fun getRewardText(status: CryptoCurrencyStatus, stakingRewardAmount: BigDecimal?): TextReference {
|
||||
val blockchainId = status.currency.network.id.value
|
||||
val blockchainId = status.currency.network.rawId
|
||||
val rewardBlockType = when {
|
||||
isSolana(blockchainId) || isBSC(blockchainId) -> RewardBlockType.RewardUnavailable
|
||||
stakingRewardAmount.isNullOrZero() -> RewardBlockType.NoRewards
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class ExpressStatusBottomSheetStateProvider : PreviewParameterProvider<ExpressSt
|
|||
get() = CryptoCurrency.Coin(
|
||||
id = ID(
|
||||
ID.Prefix.COIN_PREFIX,
|
||||
ID.Body.NetworkId(network.id.value),
|
||||
ID.Body.NetworkId(network.rawId),
|
||||
ID.Suffix.RawID("token1"),
|
||||
),
|
||||
network = network,
|
||||
|
|
@ -97,7 +97,7 @@ class ExpressStatusBottomSheetStateProvider : PreviewParameterProvider<ExpressSt
|
|||
)
|
||||
|
||||
private val network = Network(
|
||||
id = Network.ID("network1"),
|
||||
id = Network.ID(value = "network1", derivationPath = Network.DerivationPath.None),
|
||||
name = "Network One",
|
||||
isTestnet = false,
|
||||
standardType = Network.StandardType.ERC20,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ internal class CryptoCurrencyToDraggableItemConverter(
|
|||
private fun getFormattedFiatAmount(currency: CryptoCurrencyStatus, appCurrency: AppCurrency): String {
|
||||
val yieldBalance = currency.value.yieldBalance as? YieldBalance.Data
|
||||
val fiatRate = currency.value.fiatRate ?: BigDecimal.ZERO
|
||||
val fiatYieldBalance = yieldBalance?.getTotalWithRewardsStakingBalance(currency.currency.network.id.value)
|
||||
val fiatYieldBalance = yieldBalance?.getTotalWithRewardsStakingBalance(currency.currency.network.rawId)
|
||||
?.multiply(fiatRate).orZero()
|
||||
|
||||
val fiatAmount = currency.value.fiatAmount ?: return BigDecimalFormatConstants.EMPTY_BALANCE_SIGN
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ internal class WcAppInfoModel @Inject constructor(
|
|||
),
|
||||
)
|
||||
// TODO: [REDACTED_JIRA] Change it to UiManager
|
||||
private val tempAvailableNetworksState = MutableStateFlow<Set<Network.ID>>(setOf())
|
||||
private val tempAvailableNetworksState = MutableStateFlow<Set<Network.RawID>>(setOf())
|
||||
|
||||
init {
|
||||
loadDAppInfo()
|
||||
|
|
@ -157,7 +157,7 @@ internal class WcAppInfoModel @Inject constructor(
|
|||
|
||||
private fun onConnect() {
|
||||
val enabledAvailableNetworks =
|
||||
proposalNetwork.available.filter { network -> network.id in tempAvailableNetworksState.value }
|
||||
proposalNetwork.available.filter { network -> network.id.rawId in tempAvailableNetworksState.value }
|
||||
wcPairUseCase.approve(
|
||||
WcSessionApprove(
|
||||
wallet = selectedUserWalletFlow.value,
|
||||
|
|
@ -191,7 +191,7 @@ internal class WcAppInfoModel @Inject constructor(
|
|||
|
||||
private fun onCheckedChange(isChecked: Boolean, networkId: String) {
|
||||
tempAvailableNetworksState.update {
|
||||
if (isChecked) it.plus(Network.ID(networkId)) else it.minus(Network.ID(networkId))
|
||||
if (isChecked) it.plus(Network.RawID(networkId)) else it.minus(Network.RawID(networkId))
|
||||
}
|
||||
networksState.transformerUpdate(WcSelectNetworksCheckedTransformer(networkId, isChecked))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ internal class WcConnectedAppInfoModel @Inject constructor(
|
|||
networks = session.networks
|
||||
.map {
|
||||
WcNetworkInfoItem.Required(
|
||||
id = it.id.value,
|
||||
id = it.rawId,
|
||||
icon = it.iconResId,
|
||||
name = it.name,
|
||||
symbol = it.currencySymbol,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ internal object WcNetworksInfoConverter : Converter<WcSessionProposal.ProposalNe
|
|||
items = (value.required + value.available)
|
||||
.map {
|
||||
WcNetworkInfoItem.Required(
|
||||
id = it.id.value,
|
||||
id = it.rawId,
|
||||
icon = it.iconResId,
|
||||
name = it.name,
|
||||
symbol = it.currencySymbol,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ internal class WcSelectNetworksTransformer(
|
|||
return prevState.copy(
|
||||
missing = proposalNetwork.missingRequired.map { network ->
|
||||
WcNetworkInfoItem.Required(
|
||||
id = network.id.value,
|
||||
id = network.rawId,
|
||||
icon = network.iconResId,
|
||||
name = network.name,
|
||||
symbol = network.currencySymbol,
|
||||
|
|
@ -24,7 +24,7 @@ internal class WcSelectNetworksTransformer(
|
|||
}.toImmutableList(),
|
||||
required = proposalNetwork.required.map { network ->
|
||||
WcNetworkInfoItem.Checked(
|
||||
id = network.id.value,
|
||||
id = network.rawId,
|
||||
icon = network.iconResId,
|
||||
name = network.name,
|
||||
symbol = network.currencySymbol,
|
||||
|
|
@ -32,18 +32,18 @@ internal class WcSelectNetworksTransformer(
|
|||
}.toImmutableList(),
|
||||
available = proposalNetwork.available.map { network ->
|
||||
WcNetworkInfoItem.Checkable(
|
||||
id = network.id.value,
|
||||
id = network.rawId,
|
||||
icon = network.iconResId,
|
||||
name = network.name,
|
||||
symbol = network.currencySymbol,
|
||||
checked = false,
|
||||
onCheckedChange = { onCheckedChange(it, network.id.value) },
|
||||
onCheckedChange = { onCheckedChange(it, network.rawId) },
|
||||
)
|
||||
}.toImmutableList(),
|
||||
notAdded = proposalNetwork.notAdded.map { network ->
|
||||
WcNetworkInfoItem.ReadOnly(
|
||||
id = network.id.value,
|
||||
icon = getGreyedOutIconRes(network.id.value),
|
||||
id = network.rawId,
|
||||
icon = getGreyedOutIconRes(network.rawId),
|
||||
name = network.name,
|
||||
symbol = network.currencySymbol,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ private fun WcMessageSignUseCase.signTypedDataToUM(
|
|||
walletName = session.wallet.name,
|
||||
networkInfo = WcNetworkInfoUM(
|
||||
name = network.name,
|
||||
iconRes = getActiveIconRes(network.id.value),
|
||||
iconRes = getActiveIconRes(network.rawId),
|
||||
),
|
||||
addressText = walletAddress.toShortAddressText(),
|
||||
isLoading = signState.domainStep == WcSignStep.Signing,
|
||||
|
|
@ -104,7 +104,7 @@ private fun WcMessageSignUseCase.messageSignToUM(
|
|||
walletName = session.wallet.name,
|
||||
networkInfo = WcNetworkInfoUM(
|
||||
name = network.name,
|
||||
iconRes = getActiveIconRes(network.id.value),
|
||||
iconRes = getActiveIconRes(network.rawId),
|
||||
),
|
||||
isLoading = signState.domainStep == WcSignStep.Signing,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue