Skip to content

Commit

Permalink
Merge pull request #384 from soramitsu/develop
Browse files Browse the repository at this point in the history
v1.9.5
  • Loading branch information
ERussel authored Sep 7, 2021
2 parents 9151b48 + f7b11d7 commit 6e08172
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 239 deletions.
8 changes: 4 additions & 4 deletions fearless.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
843F657A265854A700829C14 /* CrowdloanDisplayInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843F6579265854A700829C14 /* CrowdloanDisplayInfo.swift */; };
84403D7F25E91BC100494FD4 /* SuperIdentity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84403D7E25E91BC100494FD4 /* SuperIdentity.swift */; };
84412EE126DAC3300049577A /* SubqueryHistoryOperationFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84412EE026DAC3300049577A /* SubqueryHistoryOperationFactory.swift */; };
84415BCA26E783EB005A3683 /* PayoutValidatorsForNominatorFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84415BC926E783EB005A3683 /* PayoutValidatorsForNominatorFactory.swift */; };
8443FDB12554B7640092893D /* TitledMnemonicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8443FDB02554B7640092893D /* TitledMnemonicView.swift */; };
8443FDB6255540570092893D /* ExportMnemonicData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8443FDB5255540570092893D /* ExportMnemonicData.swift */; };
8443FE24255586230092893D /* ExportMnemonicConfirmProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8443FE23255586230092893D /* ExportMnemonicConfirmProtocols.swift */; };
Expand Down Expand Up @@ -558,7 +559,6 @@
8470D6D2253E3382009E9A5D /* StorageSubscriptionContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8470D6D1253E3382009E9A5D /* StorageSubscriptionContainer.swift */; };
8470D6D4253E35F0009E9A5D /* StorageUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8470D6D3253E35F0009E9A5D /* StorageUpdate.swift */; };
847119C0262EF3BD00716580 /* PayoutValidatorsFactoryProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847119BF262EF3BD00716580 /* PayoutValidatorsFactoryProtocol.swift */; };
847119C8262EF45400716580 /* PayoutValidatorsForNominatorFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847119C7262EF45400716580 /* PayoutValidatorsForNominatorFactory.swift */; };
847119CD262EF61F00716580 /* PayoutValidatorForValidatorFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847119CC262EF61F00716580 /* PayoutValidatorForValidatorFactory.swift */; };
847119D5262EF95A00716580 /* PayoutInfoFactoryProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847119D4262EF95A00716580 /* PayoutInfoFactoryProtocol.swift */; };
847119EB262EFF3800716580 /* ValidatorPayoutInfoFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847119EA262EFF3800716580 /* ValidatorPayoutInfoFactory.swift */; };
Expand Down Expand Up @@ -1830,6 +1830,7 @@
84403D7E25E91BC100494FD4 /* SuperIdentity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuperIdentity.swift; sourceTree = "<group>"; };
84403D8725E92A9C00494FD4 /* InitiatedBonding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitiatedBonding.swift; sourceTree = "<group>"; };
84412EE026DAC3300049577A /* SubqueryHistoryOperationFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubqueryHistoryOperationFactory.swift; sourceTree = "<group>"; };
84415BC926E783EB005A3683 /* PayoutValidatorsForNominatorFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayoutValidatorsForNominatorFactory.swift; sourceTree = "<group>"; };
8443FDB02554B7640092893D /* TitledMnemonicView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitledMnemonicView.swift; sourceTree = "<group>"; };
8443FDB5255540570092893D /* ExportMnemonicData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportMnemonicData.swift; sourceTree = "<group>"; };
8443FE23255586230092893D /* ExportMnemonicConfirmProtocols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportMnemonicConfirmProtocols.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2007,7 +2008,6 @@
8470D6D1253E3382009E9A5D /* StorageSubscriptionContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageSubscriptionContainer.swift; sourceTree = "<group>"; };
8470D6D3253E35F0009E9A5D /* StorageUpdate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageUpdate.swift; sourceTree = "<group>"; };
847119BF262EF3BD00716580 /* PayoutValidatorsFactoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayoutValidatorsFactoryProtocol.swift; sourceTree = "<group>"; };
847119C7262EF45400716580 /* PayoutValidatorsForNominatorFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayoutValidatorsForNominatorFactory.swift; sourceTree = "<group>"; };
847119CC262EF61F00716580 /* PayoutValidatorForValidatorFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayoutValidatorForValidatorFactory.swift; sourceTree = "<group>"; };
847119D4262EF95A00716580 /* PayoutInfoFactoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayoutInfoFactoryProtocol.swift; sourceTree = "<group>"; };
847119EA262EFF3800716580 /* ValidatorPayoutInfoFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidatorPayoutInfoFactory.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7244,8 +7244,8 @@
847119EA262EFF3800716580 /* ValidatorPayoutInfoFactory.swift */,
8490386A262E22DC0016D541 /* NominatorPayoutInfoFactory.swift */,
847119BF262EF3BD00716580 /* PayoutValidatorsFactoryProtocol.swift */,
847119C7262EF45400716580 /* PayoutValidatorsForNominatorFactory.swift */,
847119CC262EF61F00716580 /* PayoutValidatorForValidatorFactory.swift */,
84415BC926E783EB005A3683 /* PayoutValidatorsForNominatorFactory.swift */,
);
path = PayoutRewardsService;
sourceTree = "<group>";
Expand Down Expand Up @@ -7980,6 +7980,7 @@
849013DE24A927E2008F705E /* LocalizationManager+Shared.swift in Sources */,
849013DC24A927E2008F705E /* ApplicationConfigs.swift in Sources */,
84ACEBFA261E684A00AAE665 /* WalletHistoryFilter.swift in Sources */,
84415BCA26E783EB005A3683 /* PayoutValidatorsForNominatorFactory.swift in Sources */,
84E7D67C26376A0A0037EB23 /* YourValidatorListInteractor+Subscription.swift in Sources */,
8401AEC32642A71D000B03E3 /* StakingRebondConfirmationViewController.swift in Sources */,
849014BE24AA87E4008F705E /* PinSetupPresenter.swift in Sources */,
Expand Down Expand Up @@ -8426,7 +8427,6 @@
8490144F24A93E2E008F705E /* UIImage+Drawing.swift in Sources */,
8444D13F267133CF00AF6D8C /* CrowdloanAddMemo.swift in Sources */,
84D97EC42520787500F07405 /* TransferConfirmConfigurator.swift in Sources */,
847119C8262EF45400716580 /* PayoutValidatorsForNominatorFactory.swift in Sources */,
84EBC54324F656D100459D15 /* SortDescriptor+Storage.swift in Sources */,
8494D8742525331B00614D8F /* PriceInfo.swift in Sources */,
845532D02684690D00C2645D /* ParachainSlotLease.swift in Sources */,
Expand Down
9 changes: 7 additions & 2 deletions fearless/Common/Model/ChainHistoryRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ struct ChainHistoryRange {
let activeEra: EraIndex
let historyDepth: UInt32

var erasRange: [EraIndex] {
var eraRange: EraRange {
let start = max(currentEra - historyDepth, 0)
let end = max(activeEra - 1, 0)
return Array(start ... end)
return EraRange(start, end)
}

var eraList: [EraIndex] {
let range = eraRange
return Array(range.start ... range.end)
}
}
2 changes: 2 additions & 0 deletions fearless/Common/Model/SubstrateAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ typealias LeasingPeriod = UInt32
typealias Slot = UInt64
typealias SessionIndex = UInt32
typealias Moment = UInt32
typealias EraIndex = UInt32
typealias EraRange = (start: EraIndex, end: EraIndex)

extension AccountId {
static func matchHex(_ value: String) -> AccountId? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ extension PayoutRewardsService {
) throws -> BaseOperation<[Data: [EraIndex]]> {
ClosureOperation<[Data: [EraIndex]]> {
let ledgerInfo = try ledgerInfoOperation.extractNoCancellableResultData()
let erasRange = try historyRangeOperation.extractNoCancellableResultData().erasRange
let eraList = try historyRangeOperation.extractNoCancellableResultData().eraList

return ledgerInfo
.reduce(into: [Data: [EraIndex]]()) { dict, ledger in
let erasClaimedRewards = Set(ledger.claimedRewards.map(\.value))
let erasUnclaimedRewards = Set(erasRange).subtracting(erasClaimedRewards)
let erasUnclaimedRewards = Set(eraList).subtracting(erasClaimedRewards)
dict[ledger.stash] = Array(erasUnclaimedRewards)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ final class PayoutRewardsService: PayoutRewardsServiceProtocol {
historyRangeWrapper.allOperations.forEach { $0.addDependency(codingFactoryOperation) }

let validatorsWrapper = validatorsResolutionFactory
.createResolutionOperation(for: selectedAccountAddress)
.createResolutionOperation(for: selectedAccountAddress) {
try historyRangeWrapper.targetOperation.extractNoCancellableResultData().eraRange
}

validatorsWrapper.addDependency(wrapper: historyRangeWrapper)

let controllersWrapper: CompoundOperationWrapper<[Data]> = try createFetchAndMapOperation(
dependingOn: validatorsWrapper.targetOperation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import RobinHood
import IrohaCrypto

final class PayoutValidatorsForValidatorFactory: PayoutValidatorsFactoryProtocol {
func createResolutionOperation(for address: AccountAddress) -> CompoundOperationWrapper<[AccountId]> {
func createResolutionOperation(
for address: AccountAddress,
eraRangeClosure _: @escaping () throws -> EraRange?
) -> CompoundOperationWrapper<[AccountId]> {
let operation = ClosureOperation<[AccountId]> {
let accountId = try SS58AddressFactory().accountId(from: address)
return [accountId]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import Foundation
import RobinHood

protocol PayoutValidatorsFactoryProtocol {
func createResolutionOperation(for address: AccountAddress) -> CompoundOperationWrapper<[AccountId]>
func createResolutionOperation(
for address: AccountAddress,
eraRangeClosure: @escaping () throws -> EraRange?
) -> CompoundOperationWrapper<[AccountId]>
}
Loading

0 comments on commit 6e08172

Please sign in to comment.