From 09ac95cda1db49ffb794509611b6f2a91dbee980 Mon Sep 17 00:00:00 2001 From: Simon McLoughlin Date: Sun, 31 Mar 2024 12:29:26 +0100 Subject: [PATCH] testing bug fix for account delegated to dead baker --- Sources/KukaiCoreSwift/Clients/TzKTClient.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sources/KukaiCoreSwift/Clients/TzKTClient.swift b/Sources/KukaiCoreSwift/Clients/TzKTClient.swift index 08e60868..ae8bcf86 100644 --- a/Sources/KukaiCoreSwift/Clients/TzKTClient.swift +++ b/Sources/KukaiCoreSwift/Clients/TzKTClient.swift @@ -354,6 +354,21 @@ public class TzKTClient { return } } + // Inactive baker, display next reward as zero + else if previousRewardIndex == 0 { + let futureCycle = currentCycles.first + let futureReward = RewardDetails(bakerAlias: pReward?.bakerAlias, + bakerLogo: pReward?.bakerLogo, + paymentAddress: pReward?.paymentAddress ?? configToUse.address, + amount: .zero(), + cycle: futureCycle?.index ?? 0, + fee: 0, + date: futureCycle?.endDate ?? Date(), + meetsMinDelegation: pReward?.meetsMinDelegation ?? true) + DispatchQueue.main.async { completion(Result.success(AggregateRewardInformation(previousReward: pReward, estimatedPreviousReward: nil, estimatedNextReward: futureReward))) } + return + } + let lastCompleteCycle = currentCycles[TzKTClient.numberOfFutureCyclesReturned + 1] estimatedPreviousReward = self?.rewardDetail(fromConfig: configToUse, rewards: currentDelegatorRewards, cycles: currentCycles, selectedIndex: previousRewardIndex, dateForDisplay: lastCompleteCycle.endDate ?? Date())