Skip to content

Commit

Permalink
Merge branch 'feature/stability_improvements' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Jun 18, 2024
2 parents 12c0dbc + 433ef50 commit f7a3dfb
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "b3297211ac399e2a4ef6238f571e8146fb66ac7c"
"revision" : "8ad6dac35574b37170d2aaa05d536e8787c72c0e"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class TokenDetailsBalanceAndBakerCell: UITableViewCell {
@IBOutlet weak var tokenIcon: UIImageView!
@IBOutlet weak var balance: UILabel!
@IBOutlet weak var value: UILabel!
@IBOutlet weak var bakerHeading: UILabel?
@IBOutlet weak var bakerButton: CustomisableButton?

func setup(data: TokenDetailsBalanceAndBakerData) {
if data.isStaked {
if data.isDelegated {
bakerButton?.customButtonType = .none
bakerButton?.setTitle(data.bakerName + " ", for: .normal)
bakerButton?.setTitleColor(.colorNamed("Txt6"), for: .normal)
Expand All @@ -24,6 +25,12 @@ class TokenDetailsBalanceAndBakerCell: UITableViewCell {
bakerButton?.customButtonType = .secondary
}

if data.isStaked {
bakerHeading?.text = "Staked"
} else {
bakerHeading?.text = data.isDelegated ? "Delegated" : "Not Delegated"
}

balance.text = data.balance
balance.accessibilityIdentifier = "token-detials-balance"
value.text = data.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -104,6 +104,7 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="bakerButton" destination="SJw-6f-S0R" id="Hpv-5c-EdT"/>
<outlet property="bakerHeading" destination="P0a-eF-wJZ" id="afT-xi-f5f"/>
<outlet property="balance" destination="mYK-bA-h7Q" id="ty5-ro-WSY"/>
<outlet property="tokenIcon" destination="BWT-yR-fDJ" id="pOe-g4-Bfh"/>
<outlet property="value" destination="M0S-MN-rKw" id="nRR-sz-h5H"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -26,31 +26,31 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" text="Balance" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eg7-gH-urm">
<rect key="frame" x="16" y="24" width="264" height="14"/>
<rect key="frame" x="16" y="24" width="267.33333333333331" height="14"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="12"/>
<color key="textColor" name="Txt10"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="Not Delegated" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6Q5-qQ-inm">
<rect key="frame" x="296" y="24" width="81" height="14"/>
<rect key="frame" x="299.33333333333331" y="24" width="77.666666666666686" height="14"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="12"/>
<color key="textColor" name="Txt10"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="752" text="&lt;balance&gt;" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Koh-l9-dib">
<rect key="frame" x="48" y="42" width="232" height="21"/>
<rect key="frame" x="48.000000000000014" y="42" width="235.33333333333337" height="21"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="18"/>
<color key="textColor" name="Txt2"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="&lt;value&gt;" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QwJ-sD-uhn">
<rect key="frame" x="48" y="63" width="232" height="16"/>
<rect key="frame" x="48.000000000000014" y="63" width="235.33333333333337" height="16"/>
<fontDescription key="fontDescription" name="Figtree-SemiBold" family="Figtree" pointSize="12"/>
<color key="textColor" name="Txt10"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" semanticContentAttribute="forceRightToLeft" horizontalHuggingPriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hfb-Ue-zc0" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="296" y="42" width="81" height="37"/>
<rect key="frame" x="299.33333333333331" y="42" width="77.666666666666686" height="37"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="14"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Delegate">
Expand Down Expand Up @@ -96,6 +96,7 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="bakerButton" destination="hfb-Ue-zc0" id="FU4-go-7Ae"/>
<outlet property="bakerHeading" destination="6Q5-qQ-inm" id="anf-QB-Hop"/>
<outlet property="balance" destination="Koh-l9-dib" id="pAR-Tk-vyt"/>
<outlet property="tokenIcon" destination="Xr0-6M-FZU" id="tm5-0h-IF9"/>
<outlet property="value" destination="QwJ-sD-uhn" id="mTo-Tg-QA8"/>
Expand All @@ -105,7 +106,7 @@
</objects>
<designables>
<designable name="hfb-Ue-zc0">
<size key="intrinsicContentSize" width="58" height="29"/>
<size key="intrinsicContentSize" width="56" height="29"/>
</designable>
</designables>
<resources>
Expand Down
15 changes: 8 additions & 7 deletions Kukai Mobile/Modules/Account/TokenDetailsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ struct TokenDetailsBalanceAndBakerData: Hashable, Identifiable {
let id = UUID()
let balance: String
let value: String
let isStakingPossible: Bool
let isDelegationPossible: Bool
let isDelegated: Bool
let isStaked: Bool
let bakerName: String
}
Expand Down Expand Up @@ -153,7 +154,7 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
return cell

} else if let obj = item as? TokenDetailsBalanceAndBakerData {
let reuse = obj.isStakingPossible ? (obj.isStaked ? "TokenDetailsBalanceAndBakerCell_baker" : "TokenDetailsBalanceAndBakerCell_nobaker") : "TokenDetailsBalanceAndBakerCell_nostaking"
let reuse = obj.isDelegationPossible ? (obj.isDelegated ? "TokenDetailsBalanceAndBakerCell_baker" : "TokenDetailsBalanceAndBakerCell_nobaker") : "TokenDetailsBalanceAndBakerCell_nostaking"

if let cell = tableView.dequeueReusableCell(withIdentifier: reuse, for: indexPath) as? TokenDetailsBalanceAndBakerCell {

Expand Down Expand Up @@ -226,7 +227,7 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
]

// TODO: remove testnet check in future when remote serivce supports ghostnet
if balanceAndBakerData?.isStakingPossible == true && balanceAndBakerData?.isStaked == true && DependencyManager.shared.currentNetworkType != .testnet {
if balanceAndBakerData?.isDelegationPossible == true && balanceAndBakerData?.isDelegated == true && DependencyManager.shared.currentNetworkType != .testnet {
data.append(stakingRewardLoadingData)
}

Expand Down Expand Up @@ -284,7 +285,7 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
}

// TODO: remove testnet check in future when remote serivce supports ghostnet
if balanceAndBakerData?.isStakingPossible == true && balanceAndBakerData?.isStaked == true && DependencyManager.shared.currentNetworkType != .testnet {
if balanceAndBakerData?.isDelegationPossible == true && balanceAndBakerData?.isDelegated == true && DependencyManager.shared.currentNetworkType != .testnet {
loadBakerData { [weak self] result in
guard let self = self else { return }

Expand Down Expand Up @@ -331,7 +332,7 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
let bakerString = (account.delegate?.alias ?? account.delegate?.address.truncateTezosAddress() ?? "") + " "

buttonData = TokenDetailsButtonData(isFavourited: true, canBeUnFavourited: false, isHidden: false, canBeHidden: false, canBePurchased: true, canBeViewedOnline: false, hasMoreButton: false)
balanceAndBakerData = TokenDetailsBalanceAndBakerData(balance: tokenBalance, value: tokenValue, isStakingPossible: true, isStaked: (account.delegate != nil), bakerName: bakerString)
balanceAndBakerData = TokenDetailsBalanceAndBakerData(balance: tokenBalance, value: tokenValue, isDelegationPossible: true, isDelegated: (account.delegate != nil), isStaked: account.xtzStakedBalance > .zero(), bakerName: bakerString)

} else {
self.tokenHeaderData.tokenURL = token.thumbnailURL
Expand Down Expand Up @@ -370,12 +371,12 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
tokenBalanceValueString = DependencyManager.shared.coinGeckoService.format(decimal: xtzPrice, numberStyle: .currency, maximumFractionDigits: 2)
}

balanceAndBakerData = TokenDetailsBalanceAndBakerData(balance: tokenBalance, value: tokenBalanceValueString, isStakingPossible: false, isStaked: false, bakerName: "")
balanceAndBakerData = TokenDetailsBalanceAndBakerData(balance: tokenBalance, value: tokenBalanceValueString, isDelegationPossible: false, isDelegated: false, isStaked: false, bakerName: "")

} else {
let dashedString = DependencyManager.shared.coinGeckoService.dashedCurrencyString()
tokenHeaderData.fiatAmount = dashedString
balanceAndBakerData = TokenDetailsBalanceAndBakerData(balance: tokenBalance, value: dashedString, isStakingPossible: false, isStaked: false, bakerName: "")
balanceAndBakerData = TokenDetailsBalanceAndBakerData(balance: tokenBalance, value: dashedString, isDelegationPossible: false, isDelegated: false, isStaked: false, bakerName: "")
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions Kukai Mobile/Modules/Activity/Cells/ActivityItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ class ActivityItemCell: UITableViewCell, UITableViewCellContainerView, UITableVi

destinationIconStackView.isHidden = true

} else if data.type == .staking {
typeIcon.isHidden = true
typeLabel.text = ""
toLabel.isHidden = false

let url = TzKTClient.avatarURL(forToken: data.baker?.address ?? "")
MediaProxyService.load(url: url, to: iconView, withCacheType: .temporary, fallback: UIImage.unknownToken())
iconView.backgroundColor = .white
iconView.customCornerRadius = 20

if data.subType == .stake {
titleLabel.text = "Stake: \( (data.primaryToken?.balance ?? .zero()).normalisedRepresentation) XTZ"
toLabel.text = "To: "

} else if data.subType == .unstake {
titleLabel.text = "Unstake: \( (data.primaryToken?.balance ?? .zero()).normalisedRepresentation) XTZ"
toLabel.text = "From: "
}

destinationLabel.text = data.baker?.alias ?? data.baker?.address.truncateTezosAddress() ?? "..."
destinationIconStackView.isHidden = true

} else {

// Icon and title
Expand Down
13 changes: 11 additions & 2 deletions Kukai Mobile/Services/ActivityService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ public class ActivityService {
Logger.app.info("ActivityService: add pending from \(fromWallet.address) with opHash: \(opHash)")
let destination = TzKTAddress(alias: destinationAlias, address: destinationAddress)
let previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0)
var transaction = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId + 1, opHash: opHash, type: type, counter: counter, fromWallet: fromWallet, destination: destination, xtzAmount: xtzAmount, parameters: parameters, primaryToken: primaryToken)
var kind: String? = nil

if parameters?["entrypoint"] == "stake" && destinationAddress == fromWallet.address {
kind = "stake"

} else if parameters?["entrypoint"] == "unstake" && destinationAddress == fromWallet.address {
kind = "unstake"
}

var transaction = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId + 1, opHash: opHash, type: type, counter: counter, fromWallet: fromWallet, destination: destination, xtzAmount: xtzAmount, parameters: parameters, primaryToken: primaryToken, baker: nil, kind: kind)
transaction.processAdditionalData(withCurrentWalletAddress: fromWallet.address)

if let group = TzKTTransactionGroup(withTransactions: [transaction], currentWalletAddress: fromWallet.address) {
Expand All @@ -134,7 +143,7 @@ public class ActivityService {
var transactions: [TzKTTransaction] = []
for info in batchInfo {
previousId += 1
var temp = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId, opHash: opHash, type: info.type, counter: counter, fromWallet: fromWallet, destination: info.destination, xtzAmount: info.xtzAmount, parameters: info.parameters, primaryToken: info.primaryToken)
var temp = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId, opHash: opHash, type: info.type, counter: counter, fromWallet: fromWallet, destination: info.destination, xtzAmount: info.xtzAmount, parameters: info.parameters, primaryToken: info.primaryToken, baker: nil, kind: nil)
temp.processAdditionalData(withCurrentWalletAddress: fromWallet.address)

transactions.append(temp)
Expand Down

0 comments on commit f7a3dfb

Please sign in to comment.