diff --git a/novawallet/Common/Model/ChainRegistry/LocalChain/ChainModel.swift b/novawallet/Common/Model/ChainRegistry/LocalChain/ChainModel.swift index 5bb9a02f5b..560c1eeb15 100644 --- a/novawallet/Common/Model/ChainRegistry/LocalChain/ChainModel.swift +++ b/novawallet/Common/Model/ChainRegistry/LocalChain/ChainModel.swift @@ -239,6 +239,14 @@ struct ChainModel: Equatable, Codable, Hashable { var isUtilityTokenOnRelaychain: Bool { additional?.relaychainAsNative?.boolValue ?? false } + + var stakingMaxElectingVoters: UInt32? { + guard let value = additional?.stakingMaxElectingVoters?.unsignedIntValue else { + return nil + } + + return UInt32(value) + } } extension ChainModel: Identifiable { diff --git a/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainConsensusStateDepending.swift b/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainConsensusStateDepending.swift index 64b18d3b39..c5df8bbe6a 100644 --- a/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainConsensusStateDepending.swift +++ b/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainConsensusStateDepending.swift @@ -4,7 +4,8 @@ import SubstrateSdk protocol RelaychainConsensusStateDepending { func createNetworkInfoOperationFactory( - for durationFactory: StakingDurationOperationFactoryProtocol, + for chain: ChainModel, + durationFactory: StakingDurationOperationFactoryProtocol, operationQueue: OperationQueue ) -> NetworkStakingInfoOperationFactoryProtocol @@ -22,10 +23,12 @@ protocol RelaychainConsensusStateDepending { final class RelaychainConsensusStateDependingFactory: RelaychainConsensusStateDepending { func createNetworkInfoOperationFactory( - for durationFactory: StakingDurationOperationFactoryProtocol, + for chain: ChainModel, + durationFactory: StakingDurationOperationFactoryProtocol, operationQueue: OperationQueue ) -> NetworkStakingInfoOperationFactoryProtocol { let votersInfoOperationFactory = VotersInfoOperationFactory( + chain: chain, operationManager: OperationManager(operationQueue: operationQueue) ) diff --git a/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStakingSharedState.swift b/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStakingSharedState.swift index c870e70fb9..548f85a656 100644 --- a/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStakingSharedState.swift +++ b/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStakingSharedState.swift @@ -123,7 +123,8 @@ final class RelaychainStakingSharedState: RelaychainStakingSharedStateProtocol { ) return consensusDependingFactory.createNetworkInfoOperationFactory( - for: durationFactory, + for: stakingOption.chainAsset.chain, + durationFactory: durationFactory, operationQueue: operationQueue ) } diff --git a/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStartStakingState.swift b/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStartStakingState.swift index bb0c17ba75..848535598f 100644 --- a/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStartStakingState.swift +++ b/novawallet/Modules/Staking/Model/StakingSharedState/RelaychainStartStakingState.swift @@ -211,7 +211,8 @@ final class RelaychainStartStakingState: RelaychainStartStakingStateProtocol { ) return consensusDependingFactory.createNetworkInfoOperationFactory( - for: durationFactory, + for: chainAsset.chain, + durationFactory: durationFactory, operationQueue: operationQueue ) } diff --git a/novawallet/Modules/Staking/Operations/VotersInfoOperationFactory.swift b/novawallet/Modules/Staking/Operations/VotersInfoOperationFactory.swift index a3921f3f92..69891b6c13 100644 --- a/novawallet/Modules/Staking/Operations/VotersInfoOperationFactory.swift +++ b/novawallet/Modules/Staking/Operations/VotersInfoOperationFactory.swift @@ -11,9 +11,11 @@ protocol VotersInfoOperationFactoryProtocol { final class VotersInfoOperationFactory { let operationManager: OperationManagerProtocol + let chain: ChainModel - init(operationManager: OperationManagerProtocol) { + init(chain: ChainModel, operationManager: OperationManagerProtocol) { self.operationManager = operationManager + self.chain = chain } private func createBagsListResolutionOperation( @@ -54,6 +56,10 @@ final class VotersInfoOperationFactory { private func createMaxElectingVotersOperation( dependingOn codingFactoryOperation: BaseOperation ) -> BaseOperation { + if let maxElectingVoter = chain.stakingMaxElectingVoters { + return BaseOperation.createWithResult(maxElectingVoter) + } + let valueOperation = PrimitiveConstantOperation( path: ElectionProviderMultiPhase.maxElectingVoters, fallbackValue: UInt32.max