Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Mixin/Service/Job/RefreshAccountJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ final class RefreshAccountJob: AsynchronousJob {
}
await MainActor.run {
let intro = TIPIntroViewController(context: context)
let navigation = TIPNavigationController(intro: intro)
UIApplication.homeNavigationController?.present(navigation, animated: true)
let tip = TIPNavigationController(intro: intro)
guard var presenter: UIViewController = UIApplication.homeContainerViewController else {
return
}
while let p = presenter.presentedViewController {
presenter = p
}
presenter.present(tip, animated: true)
}
} catch {
Logger.tip.warn(category: "RefreshAccountJob", message: "Check counter: \(error)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ final class TIPActionViewController: UIViewController {
failedSigners: [],
legacyPIN: nil,
forRecover: false,
skipAccountUpdate: false,
progressHandler: showProgress
)
AppGroupUserDefaults.Wallet.lastPINVerifiedDate = Date()
Expand Down Expand Up @@ -112,6 +113,7 @@ final class TIPActionViewController: UIViewController {
failedSigners: [],
legacyPIN: old,
forRecover: false,
skipAccountUpdate: false,
progressHandler: showProgress
).account
case let .tip(old):
Expand All @@ -120,6 +122,7 @@ final class TIPActionViewController: UIViewController {
newPIN: new,
isCounterBalanced: true,
failedSigners: [],
skipAccountUpdate: false,
progressHandler: showProgress
)
}
Expand Down Expand Up @@ -152,6 +155,7 @@ final class TIPActionViewController: UIViewController {
failedSigners: [],
legacyPIN: pin,
forRecover: false,
skipAccountUpdate: false,
progressHandler: showProgress
)
AppGroupUserDefaults.Wallet.lastPINVerifiedDate = Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,30 @@ final class TIPPopupInputViewController: PinValidationViewController {

override func viewDidLoad() {
super.viewDidLoad()
switch action {
titleLabel.text = switch action {
case .migrate:
titleLabel.text = R.string.localizable.enter_your_pin()
R.string.localizable.enter_your_pin()
case let .continue(context, _):
switch context.action {
case .change:
if oldPIN == nil {
titleLabel.text = R.string.localizable.enter_your_old_pin()
} else {
titleLabel.text = R.string.localizable.enter_your_new_pin()
}
case .create:
titleLabel.text = R.string.localizable.enter_your_pin()
case .migrate:
if oldPIN == nil {
titleLabel.text = R.string.localizable.enter_your_old_pin()
} else {
titleLabel.text = R.string.localizable.enter_your_new_pin()
switch context.situation {
case .pendingUpdate, .pendingSign:
switch context.action {
case .change:
if oldPIN == nil {
R.string.localizable.enter_your_old_pin()
} else {
R.string.localizable.enter_your_new_pin()
}
case .create:
R.string.localizable.enter_your_pin()
case .migrate:
if oldPIN == nil {
R.string.localizable.enter_your_old_pin()
} else {
R.string.localizable.enter_your_new_pin()
}
}
case .tipCounterExceedsNodeCounter:
R.string.localizable.enter_your_pin()
}
}
descriptionLabel.text = nil
Expand All @@ -68,53 +73,121 @@ final class TIPPopupInputViewController: PinValidationViewController {
case .create:
switch context.situation {
case .pendingSign(let failedSigners):
continueCreate(with: pin, failedSigners: failedSigners, onSuccess: onSuccess)
continueCreate(
with: pin,
failedSigners: failedSigners,
skipAccountUpdate: false,
onSuccess: onSuccess
)
case .pendingUpdate:
continueCreate(with: pin, failedSigners: [], onSuccess: onSuccess)
continueCreate(
with: pin,
failedSigners: [],
skipAccountUpdate: false,
onSuccess: onSuccess
)
case .tipCounterExceedsNodeCounter:
continueCreate(
with: pin,
failedSigners: [],
skipAccountUpdate: true,
onSuccess: onSuccess
)
}
case .change:
if let old = oldPIN {
switch context.situation {
case .pendingSign(let failedSigners):
continueChange(old: old, isOldPINLegacy: false, new: pin, failedSigners: failedSigners, onSuccess: onSuccess)
case .pendingUpdate:
continueChange(old: old, isOldPINLegacy: false, new: pin, failedSigners: [], onSuccess: onSuccess)
switch context.situation {
case .pendingSign(let failedSigners):
if let old = oldPIN {
continueChange(
old: old,
isOldPINLegacy: false,
new: pin,
failedSigners: failedSigners,
skipAccountUpdate: false,
onSuccess: onSuccess
)
} else {
inputNewPIN(oldPIN: pin)
}
} else {
loadingIndicator.stopAnimating()
titleLabel.text = R.string.localizable.enter_your_new_pin()
descriptionLabel.text = nil
pinField.clear()
pinField.isHidden = false
pinField.receivesInput = true
self.oldPIN = pin
case .pendingUpdate:
if let old = oldPIN {
continueChange(
old: old,
isOldPINLegacy: false,
new: pin,
failedSigners: [],
skipAccountUpdate: false,
onSuccess: onSuccess
)
} else {
inputNewPIN(oldPIN: pin)
}
case .tipCounterExceedsNodeCounter:
continueChange(
old: pin,
isOldPINLegacy: false,
new: pin,
failedSigners: [],
skipAccountUpdate: true,
onSuccess: onSuccess
)
}
case .migrate:
if let old = oldPIN {
let failedSigners: [TIPSigner]
switch context.situation {
case .pendingSign(let signers):
failedSigners = signers
case .pendingUpdate:
failedSigners = []
switch context.situation {
case .pendingSign(let failedSigners):
if let old = oldPIN {
continueChange(
old: old,
isOldPINLegacy: true,
new: pin,
failedSigners: failedSigners,
skipAccountUpdate: false,
onSuccess: onSuccess
)
} else {
inputNewPIN(oldPIN: pin)
}
continueChange(old: old, isOldPINLegacy: true, new: pin, failedSigners: failedSigners, onSuccess: onSuccess)
} else {
loadingIndicator.stopAnimating()
titleLabel.text = R.string.localizable.enter_your_new_pin()
descriptionLabel.text = nil
pinField.clear()
pinField.isHidden = false
pinField.receivesInput = true
self.oldPIN = pin
case .pendingUpdate:
if let old = oldPIN {
continueChange(
old: old,
isOldPINLegacy: true,
new: pin,
failedSigners: [],
skipAccountUpdate: false,
onSuccess: onSuccess
)
} else {
inputNewPIN(oldPIN: pin)
}
case .tipCounterExceedsNodeCounter:
continueChange(
old: pin,
isOldPINLegacy: true,
new: pin,
failedSigners: [],
skipAccountUpdate: true,
onSuccess: onSuccess
)
}
}
}
}

private func inputNewPIN(oldPIN: String) {
loadingIndicator.stopAnimating()
titleLabel.text = R.string.localizable.enter_your_new_pin()
descriptionLabel.text = nil
pinField.clear()
pinField.isHidden = false
pinField.receivesInput = true
self.oldPIN = oldPIN
}

private func continueCreate(
with pin: String,
failedSigners: [TIPSigner],
skipAccountUpdate: Bool,
onSuccess: @MainActor @Sendable @escaping () -> Void
) {
#if DEBUG
Expand All @@ -131,6 +204,7 @@ final class TIPPopupInputViewController: PinValidationViewController {
failedSigners: failedSigners,
legacyPIN: nil,
forRecover: false,
skipAccountUpdate: skipAccountUpdate,
progressHandler: nil
)
AppGroupUserDefaults.Wallet.lastPINVerifiedDate = Date()
Expand All @@ -157,6 +231,7 @@ final class TIPPopupInputViewController: PinValidationViewController {
isOldPINLegacy: Bool,
new: String,
failedSigners: [TIPSigner],
skipAccountUpdate: Bool,
onSuccess: @MainActor @Sendable @escaping () -> Void
) {
#if DEBUG
Expand All @@ -175,13 +250,14 @@ final class TIPPopupInputViewController: PinValidationViewController {
failedSigners: failedSigners,
legacyPIN: old,
forRecover: false,
skipAccountUpdate: skipAccountUpdate,
progressHandler: nil
)
} else {
let isCounterBalanced: Bool
switch action {
case .continue(let context, _):
isCounterBalanced = context.maxNodeCounter == context.accountTIPCounter
isCounterBalanced = context.maxNodeCounter <= context.accountTIPCounter
case .migrate:
isCounterBalanced = true
}
Expand All @@ -190,6 +266,7 @@ final class TIPPopupInputViewController: PinValidationViewController {
newPIN: new,
isCounterBalanced: isCounterBalanced,
failedSigners: failedSigners,
skipAccountUpdate: skipAccountUpdate,
progressHandler: nil
)
}
Expand Down
Loading