Skip to content

Commit

Permalink
Merge branch 'feature/staking' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Dec 6, 2024
2 parents e2eeac9 + 254f870 commit 3c69f50
Show file tree
Hide file tree
Showing 18 changed files with 436 additions and 40 deletions.
6 changes: 5 additions & 1 deletion Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
C03016042CFF498D0058A457 /* PublicBakerAttributeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016032CFF498D0058A457 /* PublicBakerAttributeCell.swift */; };
C03016062CFF49D90058A457 /* BakerDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016052CFF49D90058A457 /* BakerDetailsViewModel.swift */; };
C03016082D007DB00058A457 /* SuggestedActionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016072D007DB00058A457 /* SuggestedActionCell.swift */; };
C030160A2D0302A00058A457 /* UnstakeReminderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03016092D0302A00058A457 /* UnstakeReminderViewController.swift */; };
C031D3E927D114A600EABBE6 /* TokenDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C031D3E827D114A600EABBE6 /* TokenDetailsViewController.swift */; };
C031D3EB27D114BC00EABBE6 /* TokenDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C031D3EA27D114BC00EABBE6 /* TokenDetailsViewModel.swift */; };
C031D3ED27D114D000EABBE6 /* CollectiblesDetailsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C031D3EC27D114D000EABBE6 /* CollectiblesDetailsViewModel.swift */; };
Expand Down Expand Up @@ -551,6 +552,7 @@
C03016032CFF498D0058A457 /* PublicBakerAttributeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicBakerAttributeCell.swift; sourceTree = "<group>"; };
C03016052CFF49D90058A457 /* BakerDetailsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BakerDetailsViewModel.swift; sourceTree = "<group>"; };
C03016072D007DB00058A457 /* SuggestedActionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestedActionCell.swift; sourceTree = "<group>"; };
C03016092D0302A00058A457 /* UnstakeReminderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnstakeReminderViewController.swift; sourceTree = "<group>"; };
C031D3E827D114A600EABBE6 /* TokenDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenDetailsViewController.swift; sourceTree = "<group>"; };
C031D3EA27D114BC00EABBE6 /* TokenDetailsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenDetailsViewModel.swift; sourceTree = "<group>"; };
C031D3EC27D114D000EABBE6 /* CollectiblesDetailsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectiblesDetailsViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1649,6 +1651,7 @@
C0DB694C2CEF567A000C1A17 /* StakeConfirmViewController.swift */,
C04BA1F52CF765B900951249 /* StakeOnboardingContainerViewController.swift */,
C02810412CFA0D9E005EA5E8 /* StakeOnboardingContainerNavController.swift */,
C03016092D0302A00058A457 /* UnstakeReminderViewController.swift */,
);
path = Stake;
sourceTree = "<group>";
Expand Down Expand Up @@ -2124,6 +2127,7 @@
C02D7CAE27BEB240006A8E39 /* CurrencyViewController.swift in Sources */,
C04BA1F82CF766EA00951249 /* PageIndicatorContainerView.swift in Sources */,
C0EA19C029096D9400E6B40D /* CollectibleDetailImageCell.swift in Sources */,
C030160A2D0302A00058A457 /* UnstakeReminderViewController.swift in Sources */,
C0172A062A98B01C00163179 /* CGSize+extensions.swift in Sources */,
C08694E627BD1D94000A4909 /* AccountViewModel.swift in Sources */,
C02914382A6589EE00A8AF08 /* ConfirmPasscodeViewController.swift in Sources */,
Expand Down Expand Up @@ -2873,7 +2877,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/kukai-wallet/kukai-core-swift";
requirement = {
branch = feature/bakers_and_staking;
branch = develop;
kind = branch;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "feature/bakers_and_staking",
"revision" : "67b9f749b1e14d536877e9b6ec806c90fb33c43c"
"branch" : "develop",
"revision" : "e703138a3837b310396f6d8a951531e66dd6e496"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions Kukai Mobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>NSCalendarsUsageDescription</key>
<string>Allowing you to set reminders for actions that require multiple days to complete</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions Kukai Mobile/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"error-wc2-invalid-request"="Kukai received an invalid request. Please refresh the application you are trying to use with and try again";

"error-unknown"="Unknwon error occured";
"error-unknown-later"="Unknwon error occured fetching information. PLease try again later";

"warning-fee-very-high"="Warning: Transaction fee is very high";
23 changes: 16 additions & 7 deletions Kukai Mobile/Modules/Account/Account.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Suggested Action" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="M67-L6-D1a">
<rect key="frame" x="58" y="8" width="262.66666666666669" height="20"/>
<rect key="frame" x="58" y="8.0000000000000018" width="262.66666666666669" height="18.666666666666671"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="16"/>
<color key="textColor" name="Txt2"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Start staking to earn passive income, and participate in on-chain governance" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QWi-UQ-7HW">
<rect key="frame" x="58" y="30" width="262.66666666666669" height="45"/>
<rect key="frame" x="58" y="28.666666666666661" width="262.66666666666669" height="46.333333333333343"/>
<fontDescription key="fontDescription" name="Figtree-Medium" family="Figtree" pointSize="14"/>
<color key="textColor" name="Txt6"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -1026,6 +1026,7 @@
<segue destination="gR5-I4-y5S" kind="show" identifier="onramp" id="cfv-eY-Nia"/>
<segue destination="LdT-JN-wgl" kind="custom" identifier="total-estimated-info" customClass="BottomSheetMediumSegue" customModule="Kukai_Mobile" customModuleProvider="target" id="1e7-qw-UYx"/>
<segue destination="AkR-D9-ihp" kind="show" identifier="stake-onboarding" id="hL3-Uj-YWG"/>
<segue destination="UXe-18-6v7" kind="presentation" identifier="unstake-reminder" modalPresentationStyle="overCurrentContext" modalTransitionStyle="crossDissolve" id="rgC-MN-A70"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SsA-5r-8s8" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
Expand All @@ -1052,6 +1053,14 @@
</objects>
<point key="canvasLocation" x="-2592" y="-1545"/>
</scene>
<!--unstake-reminder-->
<scene sceneID="jlJ-gV-7ue">
<objects>
<viewControllerPlaceholder storyboardName="Stake" referencedIdentifier="unstake-reminder" id="UXe-18-6v7" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="OAz-Os-ahN" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2595" y="-1412"/>
</scene>
<!--Hidden Tokens-->
<scene sceneID="Qrr-xS-5hQ">
<objects>
Expand Down Expand Up @@ -1959,14 +1968,14 @@ The estimate uses exchange data that might not be up to date and does not take i
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="LearnMoreSectionHeaderCell" id="8tE-dd-LS5" customClass="LearnMoreSectionHeaderCell" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="20" y="55.333332061767578" width="353" height="52"/>
<rect key="frame" x="20" y="55.333332061767578" width="353" height="50.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="8tE-dd-LS5" id="9Xd-08-7t7">
<rect key="frame" x="0.0" y="0.0" width="353" height="52"/>
<rect key="frame" x="0.0" y="0.0" width="353" height="50.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="&lt;title&gt;" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Mln-Wy-ono">
<rect key="frame" x="0.0" y="24" width="343" height="20"/>
<rect key="frame" x="0.0" y="24" width="343" height="18.666666666666671"/>
<fontDescription key="fontDescription" name="Figtree-Medium" family="Figtree" pointSize="16"/>
<color key="textColor" name="Txt10"/>
<nil key="highlightedColor"/>
Expand All @@ -1986,7 +1995,7 @@ The estimate uses exchange data that might not be up to date and does not take i
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="LearnMoreItemCell" rowHeight="73" id="w8m-cu-iS3" customClass="LearnMoreItemCell" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="20" y="107.33333206176758" width="353" height="73"/>
<rect key="frame" x="20" y="106" width="353" height="73"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="w8m-cu-iS3" id="Fy2-WR-Ha9">
<rect key="frame" x="0.0" y="0.0" width="353" height="73"/>
Expand Down Expand Up @@ -2154,7 +2163,7 @@ The estimate uses exchange data that might not be up to date and does not take i
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="REq-Jb-cj8"/>
<segue reference="hL3-Uj-YWG"/>
<segue reference="zcN-zW-iIF"/>
</inferredMetricsTieBreakers>
<resources>
Expand Down
9 changes: 8 additions & 1 deletion Kukai Mobile/Modules/Account/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AccountViewController: UIViewController, UITableViewDelegate, EstimatedTot
viewModel.balancesMenuVC = menuVCForBalancesMore()
viewModel.estimatedTotalCellDelegate = self
viewModel.tableViewButtonDelegate = self
viewModel.popupDelegate = self
viewModel.makeDataSource(withTableView: tableView)
tableView.dataSource = viewModel.dataSource
tableView.delegate = self
Expand Down Expand Up @@ -74,7 +75,6 @@ class AccountViewController: UIViewController, UITableViewDelegate, EstimatedTot
tableView.deselectRow(at: indexPath, animated: true)

if let token = viewModel.token(atIndexPath: indexPath) {
TransactionService.shared.resetAllState()
TransactionService.shared.sendData.chosenToken = token
TransactionService.shared.sendData.chosenNFT = nil
self.performSegue(withIdentifier: "details", sender: self)
Expand Down Expand Up @@ -177,3 +177,10 @@ extension AccountViewController: UITableViewCellButtonDelegate {
}
}
}

extension AccountViewController: AccountViewModelPopups {

func unstakePreformed() {
self.performSegue(withIdentifier: "unstake-reminder", sender: nil)
}
}
14 changes: 14 additions & 0 deletions Kukai Mobile/Modules/Account/AccountViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ struct AccountButtonData: Hashable {
let buttonType: CustomisableButton.customButtonType
}

enum AccountViewModelError: Error {
case networkError
case calendarAccessError
}

protocol AccountViewModelPopups: AnyObject {
func unstakePreformed()
}

class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler {

struct accessibilityIdentifiers {
Expand All @@ -78,6 +87,7 @@ class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
var estimatedTotalCellDelegate: EstimatedTotalCellDelegate? = nil

weak var tableViewButtonDelegate: UITableViewCellButtonDelegate? = nil
weak var popupDelegate: AccountViewModelPopups? = nil


// MARK: - Init
Expand All @@ -104,6 +114,10 @@ class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
if self?.dataSource != nil && self?.isVisible == true && selectedAddress == address {
self?.refresh(animate: true)
}

if TransactionService.shared.didUnstake && DependencyManager.shared.activityService.pendingTransactionGroups.count == 0 {
self?.popupDelegate?.unstakePreformed()
}
}.store(in: &bag)

AccountViewModel.setupAccountActivityListener()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class HiddenCollectiblesViewController: UIViewController, UITableViewDelegate {
tableView.deselectRow(at: indexPath, animated: true)

if let nft = viewModel.nft(atIndexPath: indexPath) {
TransactionService.shared.resetAllState()
TransactionService.shared.sendData.chosenToken = nil
TransactionService.shared.sendData.chosenNFT = nft
(self.parent as? HiddenTokensMainViewController)?.openCollectibleDetails()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class HiddenTokensBalancesViewController: UIViewController, UITableViewDelegate
tableView.deselectRow(at: indexPath, animated: true)

if let token = viewModel.token(atIndexPath: indexPath) {
TransactionService.shared.resetAllState()
TransactionService.shared.sendData.chosenToken = token
TransactionService.shared.sendData.chosenNFT = nil
(self.parent as? HiddenTokensMainViewController)?.openTokenDetails()
Expand Down
13 changes: 11 additions & 2 deletions Kukai Mobile/Modules/Home/Base.lproj/Home.storyboard
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.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="B7V-6A-7eN">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="B7V-6A-7eN">
<device id="retina6_0" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
Expand Down Expand Up @@ -115,6 +115,7 @@
<segue destination="5kq-lD-FPQ" kind="custom" identifier="wallet-connect-generic" customClass="BottomSheetCustomSegue" customModule="Kukai_Mobile" customModuleProvider="target" id="bWZ-eJ-9bp"/>
<segue destination="SuN-lc-s6p" kind="custom" identifier="wallet-connect-delegate" customClass="BottomSheetCustomSegue" customModule="Kukai_Mobile" customModuleProvider="target" id="xUf-Hg-Wxw"/>
<segue destination="8lA-J4-epy" kind="show" identifier="connected-apps" id="yER-q9-xAZ"/>
<segue destination="nMz-6N-iys" kind="custom" identifier="wallet-connect-stake" customClass="BottomSheetCustomSegue" customModule="Kukai_Mobile" customModuleProvider="target" id="di3-hr-mfq"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="C8m-X9-tpS" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
Expand Down Expand Up @@ -1890,6 +1891,14 @@ For new accounts use the default path by selecting "Add Account" in the wallet m
</objects>
<point key="canvasLocation" x="2907" y="-2282"/>
</scene>
<!--confirm-stake-->
<scene sceneID="yRx-aA-fdw">
<objects>
<viewControllerPlaceholder storyboardName="Stake" referencedIdentifier="confirm-stake" id="nMz-6N-iys" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="EFK-gb-nrG" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-132" y="-2581"/>
</scene>
</scenes>
<resources>
<image name="Alert" width="24" height="24"/>
Expand Down
4 changes: 3 additions & 1 deletion Kukai Mobile/Modules/Home/HomeTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat
self.navigationController?.setNavigationBarHidden(false, animated: false)
self.navigationItem.hidesBackButton = true

TransactionService.shared.resetAllState()
updateAccountButton()
runWatchWalletChecks()

Expand Down Expand Up @@ -547,6 +546,9 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
case .delegate:
self.performSegue(withIdentifier: "wallet-connect-delegate", sender: nil)

case .stake:
self.performSegue(withIdentifier: "wallet-connect-stake", sender: nil)

case .generic:
self.performSegue(withIdentifier: "wallet-connect-generic", sender: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class SendAbstractConfirmViewController: UIViewController {
AccountViewModel.reconnectAccountActivityListenerIfNeeded()

if !isWalletConnectOp {
TransactionService.shared.resetAllState()
self.dismissAndReturn(collapseOnly: false)
return
}
Expand Down
Loading

0 comments on commit 3c69f50

Please sign in to comment.