Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AND-7983 [Staking] Implemented enter staking Polkadot #3846

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal object NetworkModule {

private const val PROD_V2_TANGEM_TECH_BASE_URL = "https://api.tangem-tech.com/v2/"
private const val TANGEM_TECH_MARKETS_SERVICE_TIMEOUT_SECONDS = 60L
private const val STAKE_KIT_API_TIMEOUT_SECONDS = 60L

@Provides
@Singleton
Expand Down Expand Up @@ -88,6 +89,10 @@ internal object NetworkModule {
context = context,
apiConfigsManager = apiConfigsManager,
clientBuilder = {
this.callTimeout(STAKE_KIT_API_TIMEOUT_SECONDS, TimeUnit.SECONDS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мб заюзаем наш класс Timeouts?
плюс эти 4 строки где-то в соседнем апи тоже используются, можно
вынести проставление таймаутов + обработку аннотаций в отдельный метод/экстеншн-метод с параметром timeoutSeconds

.connectTimeout(STAKE_KIT_API_TIMEOUT_SECONDS, TimeUnit.SECONDS)
.readTimeout(STAKE_KIT_API_TIMEOUT_SECONDS, TimeUnit.SECONDS)
.applyTimeoutAnnotations()
addInterceptor(
NetworkLogsSaveInterceptor(appLogsStore),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ internal class DefaultStakingRepository(
-> TransactionData.Compiled.Data.Bytes(unsignedTransaction.hexToBytes())
Blockchain.BSC,
Blockchain.Ethereum,
Blockchain.Polkadot,
-> TransactionData.Compiled.Data.RawString(unsignedTransaction)
Blockchain.Tron -> {
val tronStakeKitTransaction = tronStakeKitTransactionAdapter.fromJson(unsignedTransaction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,27 @@ enum class StakingActionType {
MIGRATE -> "Migrate"
UNKNOWN -> "Unknown"
}

val canChooseValidator
get() = when (this) {
STAKE,
RESTAKE,
VOTE,
VOTE_LOCKED,
-> true

UNSTAKE,
CLAIM_REWARDS,
RESTAKE_REWARDS,
CLAIM_UNSTAKED,
WITHDRAW,
UNLOCK_LOCKED,
STAKE_LOCKED,
REVOKE,
REVOTE,
REBOND,
MIGRATE,
UNKNOWN,
-> false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.tangem.features.staking.impl.presentation.state.transformers.validat

import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
import com.tangem.features.staking.impl.presentation.state.StakingStates
import com.tangem.features.staking.impl.presentation.state.StakingStep
import com.tangem.features.staking.impl.presentation.state.StakingUiState
Expand All @@ -20,7 +19,7 @@ internal class ValidatorSelectChangeTransformer(
val isRestake = prevState.actionType == StakingActionCommonType.Pending.Restake
val isEnter = prevState.actionType == StakingActionCommonType.Enter
val isFromInfoScreen = prevState.currentStep == StakingStep.InitialInfo
val isVoteLocked = confirmationState?.pendingAction?.type == StakingActionType.VOTE_LOCKED
val canChooseValidator = confirmationState?.pendingAction?.type?.canChooseValidator ?: false

val activeValidator = selectedValidator.takeIf { isFromInfoScreen && isRestake }
?: validatorState?.activeValidator
Expand All @@ -39,7 +38,7 @@ internal class ValidatorSelectChangeTransformer(
isPrimaryButtonEnabled = true,
isClickable = true,
activeValidator = activeValidator,
isVisibleOnConfirmation = isEnter || isRestake || isVoteLocked,
isVisibleOnConfirmation = isEnter || isRestake || canChooseValidator,
),
)
}
Expand Down
Loading