mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
UI fixes
This commit is contained in:
parent
1cf14df907
commit
f21bdec23f
7 changed files with 177 additions and 202 deletions
|
|
@ -38,6 +38,8 @@ public final class ContextMenuController: ViewController, KeyShortcutResponder,
|
|||
self.hasHapticFeedback = hasHapticFeedback
|
||||
|
||||
super.init(navigationBarPresentationData: nil)
|
||||
|
||||
self.statusBar.statusBarStyle = .Ignore
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@
|
|||
{
|
||||
[UIView animateWithDuration:0.2 animations:^
|
||||
{
|
||||
[strongSelf->_context setApplicationStatusBarAlpha:1.0f];
|
||||
//[strongSelf->_context setApplicationStatusBarAlpha:1.0f];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -475,12 +475,12 @@
|
|||
{
|
||||
[UIView animateWithDuration:0.3 animations:^
|
||||
{
|
||||
[_context setApplicationStatusBarAlpha:1.0f];
|
||||
//[_context setApplicationStatusBarAlpha:1.0f];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_context setApplicationStatusBarAlpha:1.0f];
|
||||
//[_context setApplicationStatusBarAlpha:1.0f];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,13 +96,13 @@ public final class TonInstance {
|
|||
})
|
||||
}
|
||||
|
||||
fileprivate func exportKey(key: TONKey, serverSalt: Data) -> Signal<[String], NoError> {
|
||||
fileprivate func exportKey(key: TONKey, localPassword: Data) -> Signal<[String], NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.export(key, localPassword: serverSalt).start(next: { wordList in
|
||||
let cancel = ton.export(key, localPassword: localPassword).start(next: { wordList in
|
||||
guard let wordList = wordList as? [String] else {
|
||||
assertionFailure()
|
||||
return
|
||||
|
|
@ -120,18 +120,18 @@ public final class TonInstance {
|
|||
}
|
||||
}
|
||||
|
||||
fileprivate func createWallet(keychain: TonKeychain, serverSalt: Data) -> Signal<(WalletInfo, [String]), CreateWalletError> {
|
||||
fileprivate func createWallet(keychain: TonKeychain, localPassword: Data) -> Signal<(WalletInfo, [String]), CreateWalletError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.createKey(withLocalPassword: serverSalt, mnemonicPassword: Data()).start(next: { key in
|
||||
let cancel = ton.createKey(withLocalPassword: localPassword, mnemonicPassword: Data()).start(next: { key in
|
||||
guard let key = key as? TONKey else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
let cancel = keychain.encrypt(key.secret).start(next: { encryptedSecretData in
|
||||
let _ = self.exportKey(key: key, serverSalt: serverSalt).start(next: { wordList in
|
||||
let _ = self.exportKey(key: key, localPassword: localPassword).start(next: { wordList in
|
||||
subscriber.putNext((WalletInfo(publicKey: WalletPublicKey(rawValue: key.publicKey), encryptedSecret: encryptedSecretData), wordList))
|
||||
subscriber.putCompletion()
|
||||
}, error: { error in
|
||||
|
|
@ -154,13 +154,13 @@ public final class TonInstance {
|
|||
}
|
||||
}
|
||||
|
||||
fileprivate func importWallet(keychain: TonKeychain, wordList: [String], serverSalt: Data) -> Signal<WalletInfo, ImportWalletInternalError> {
|
||||
fileprivate func importWallet(keychain: TonKeychain, wordList: [String], localPassword: Data) -> Signal<WalletInfo, ImportWalletInternalError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.importKey(withLocalPassword: serverSalt, mnemonicPassword: Data(), wordList: wordList).start(next: { key in
|
||||
let cancel = ton.importKey(withLocalPassword: localPassword, mnemonicPassword: Data(), wordList: wordList).start(next: { key in
|
||||
guard let key = key as? TONKey else {
|
||||
subscriber.putError(.generic)
|
||||
return
|
||||
|
|
@ -322,14 +322,14 @@ public final class TonInstance {
|
|||
}
|
||||
}
|
||||
|
||||
fileprivate func sendGramsFromWallet(decryptedSecret: Data, serverSalt: Data, walletInfo: WalletInfo, fromAddress: String, toAddress: String, amount: Int64, textMessage: String, forceIfDestinationNotInitialized: Bool, timeout: Int32, randomId: Int64) -> Signal<Never, SendGramsFromWalletError> {
|
||||
fileprivate func sendGramsFromWallet(decryptedSecret: Data, localPassword: Data, walletInfo: WalletInfo, fromAddress: String, toAddress: String, amount: Int64, textMessage: String, forceIfDestinationNotInitialized: Bool, timeout: Int32, randomId: Int64) -> Signal<Never, SendGramsFromWalletError> {
|
||||
let key = TONKey(publicKey: walletInfo.publicKey.rawValue, secret: decryptedSecret)
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.sendGrams(from: key, localPassword: serverSalt, fromAddress: fromAddress, toAddress: toAddress, amount: amount, textMessage: textMessage, forceIfDestinationNotInitialized: forceIfDestinationNotInitialized, timeout: timeout, randomId: randomId).start(next: { result in
|
||||
let cancel = ton.sendGrams(from: key, localPassword: localPassword, fromAddress: fromAddress, toAddress: toAddress, amount: amount, textMessage: textMessage, forceIfDestinationNotInitialized: forceIfDestinationNotInitialized, timeout: timeout, randomId: randomId).start(next: { result in
|
||||
guard let result = result as? TONSendGramsResult else {
|
||||
subscriber.putError(.generic)
|
||||
return
|
||||
|
|
@ -366,36 +366,30 @@ public final class TonInstance {
|
|||
}
|
||||
}
|
||||
|
||||
fileprivate func walletRestoreWords(walletInfo: WalletInfo, keychain: TonKeychain, serverSalt: Data) -> Signal<[String], WalletRestoreWordsError> {
|
||||
return keychain.decrypt(walletInfo.encryptedSecret)
|
||||
|> mapError { error -> WalletRestoreWordsError in
|
||||
return .secretDecryptionFailed(error)
|
||||
}
|
||||
|> mapToSignal { decryptedSecret -> Signal<[String], WalletRestoreWordsError> in
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.export(TONKey(publicKey: walletInfo.publicKey.rawValue, secret: decryptedSecret), localPassword: serverSalt).start(next: { wordList in
|
||||
guard let wordList = wordList as? [String] else {
|
||||
subscriber.putError(.generic)
|
||||
return
|
||||
}
|
||||
subscriber.putNext(wordList)
|
||||
}, error: { _ in
|
||||
fileprivate func walletRestoreWords(publicKey: WalletPublicKey, decryptedSecret: Data, localPassword: Data) -> Signal<[String], WalletRestoreWordsError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.export(TONKey(publicKey: publicKey.rawValue, secret: decryptedSecret), localPassword: localPassword).start(next: { wordList in
|
||||
guard let wordList = wordList as? [String] else {
|
||||
subscriber.putError(.generic)
|
||||
}, completed: {
|
||||
subscriber.putCompletion()
|
||||
})
|
||||
disposable.set(ActionDisposable {
|
||||
cancel?.dispose()
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
subscriber.putNext(wordList)
|
||||
}, error: { _ in
|
||||
subscriber.putError(.generic)
|
||||
}, completed: {
|
||||
subscriber.putCompletion()
|
||||
})
|
||||
disposable.set(ActionDisposable {
|
||||
cancel?.dispose()
|
||||
})
|
||||
}
|
||||
|
||||
return disposable
|
||||
}
|
||||
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,35 +415,6 @@ public final class TonInstance {
|
|||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func deleteLocalWalletData(walletInfo: WalletInfo, keychain: TonKeychain, serverSalt: Data) -> Signal<Never, DeleteLocalWalletDataError> {
|
||||
return keychain.decrypt(walletInfo.encryptedSecret)
|
||||
|> mapError { error -> DeleteLocalWalletDataError in
|
||||
return .secretDecryptionFailed(error)
|
||||
}
|
||||
|> mapToSignal { decryptedSecret -> Signal<Never, DeleteLocalWalletDataError> in
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
self.impl.with { impl in
|
||||
impl.withInstance { ton in
|
||||
let cancel = ton.delete(TONKey(publicKey: walletInfo.publicKey.rawValue, secret: decryptedSecret)).start(next: { _ in
|
||||
assertionFailure()
|
||||
}, error: { _ in
|
||||
subscriber.putError(.generic)
|
||||
}, completed: {
|
||||
subscriber.putCompletion()
|
||||
})
|
||||
disposable.set(ActionDisposable {
|
||||
cancel?.dispose()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct WalletPublicKey: Codable, Hashable {
|
||||
|
|
@ -567,24 +532,18 @@ public enum CreateWalletError {
|
|||
case generic
|
||||
}
|
||||
|
||||
public func createWallet(postbox: Postbox, network: Network, tonInstance: TonInstance, keychain: TonKeychain) -> Signal<(WalletInfo, [String]), CreateWalletError> {
|
||||
return getServerWalletSalt(network: network)
|
||||
|> mapError { _ -> CreateWalletError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { serverSalt -> Signal<(WalletInfo, [String]), CreateWalletError> in
|
||||
return tonInstance.createWallet(keychain: keychain, serverSalt: serverSalt)
|
||||
|> mapToSignal { walletInfo, wordList -> Signal<(WalletInfo, [String]), CreateWalletError> in
|
||||
return postbox.transaction { transaction -> (WalletInfo, [String]) in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.walletCollection, { current in
|
||||
var walletCollection = (current as? WalletCollection) ?? WalletCollection(wallets: [])
|
||||
walletCollection.wallets = [WalletStateRecord(info: walletInfo, exportCompleted: false, state: nil)]
|
||||
return walletCollection
|
||||
})
|
||||
return (walletInfo, wordList)
|
||||
}
|
||||
|> castError(CreateWalletError.self)
|
||||
public func createWallet(postbox: Postbox, tonInstance: TonInstance, keychain: TonKeychain, localPassword: Data) -> Signal<(WalletInfo, [String]), CreateWalletError> {
|
||||
return tonInstance.createWallet(keychain: keychain, localPassword: localPassword)
|
||||
|> mapToSignal { walletInfo, wordList -> Signal<(WalletInfo, [String]), CreateWalletError> in
|
||||
return postbox.transaction { transaction -> (WalletInfo, [String]) in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.walletCollection, { current in
|
||||
var walletCollection = (current as? WalletCollection) ?? WalletCollection(wallets: [])
|
||||
walletCollection.wallets = [WalletStateRecord(info: walletInfo, exportCompleted: false, state: nil)]
|
||||
return walletCollection
|
||||
})
|
||||
return (walletInfo, wordList)
|
||||
}
|
||||
|> castError(CreateWalletError.self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -611,30 +570,24 @@ public enum ImportWalletError {
|
|||
case generic
|
||||
}
|
||||
|
||||
public func importWallet(postbox: Postbox, network: Network, tonInstance: TonInstance, keychain: TonKeychain, wordList: [String]) -> Signal<WalletInfo, ImportWalletError> {
|
||||
return getServerWalletSalt(network: network)
|
||||
|> mapError { _ -> ImportWalletError in
|
||||
return .generic
|
||||
public func importWallet(postbox: Postbox, tonInstance: TonInstance, keychain: TonKeychain, wordList: [String], localPassword: Data) -> Signal<WalletInfo, ImportWalletError> {
|
||||
return tonInstance.importWallet(keychain: keychain, wordList: wordList, localPassword: localPassword)
|
||||
|> `catch` { error -> Signal<WalletInfo, ImportWalletError> in
|
||||
switch error {
|
||||
case .generic:
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { serverSalt in
|
||||
return tonInstance.importWallet(keychain: keychain, wordList: wordList, serverSalt: serverSalt)
|
||||
|> `catch` { error -> Signal<WalletInfo, ImportWalletError> in
|
||||
switch error {
|
||||
case .generic:
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { walletInfo -> Signal<WalletInfo, ImportWalletError> in
|
||||
return postbox.transaction { transaction -> WalletInfo in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.walletCollection, { current in
|
||||
var walletCollection = (current as? WalletCollection) ?? WalletCollection(wallets: [])
|
||||
walletCollection.wallets = [WalletStateRecord(info: walletInfo, exportCompleted: true, state: nil)]
|
||||
return walletCollection
|
||||
})
|
||||
return walletInfo
|
||||
}
|
||||
|> castError(ImportWalletError.self)
|
||||
|> mapToSignal { walletInfo -> Signal<WalletInfo, ImportWalletError> in
|
||||
return postbox.transaction { transaction -> WalletInfo in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.walletCollection, { current in
|
||||
var walletCollection = (current as? WalletCollection) ?? WalletCollection(wallets: [])
|
||||
walletCollection.wallets = [WalletStateRecord(info: walletInfo, exportCompleted: true, state: nil)]
|
||||
return walletCollection
|
||||
})
|
||||
return walletInfo
|
||||
}
|
||||
|> castError(ImportWalletError.self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -647,7 +600,7 @@ public func deleteAllLocalWalletsData(postbox: Postbox, network: Network, tonIns
|
|||
|> then(
|
||||
postbox.transaction { transaction -> Void in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.walletCollection, { current in
|
||||
let walletCollection = (current as? WalletCollection) ?? WalletCollection(wallets: [])
|
||||
let walletCollection = WalletCollection(wallets: [])
|
||||
return walletCollection
|
||||
})
|
||||
}
|
||||
|
|
@ -656,50 +609,12 @@ public func deleteAllLocalWalletsData(postbox: Postbox, network: Network, tonIns
|
|||
)
|
||||
}
|
||||
|
||||
public enum DeleteLocalWalletDataError {
|
||||
case generic
|
||||
case secretDecryptionFailed(TonKeychainDecryptDataError)
|
||||
}
|
||||
|
||||
public func deleteLocalWalletData(postbox: Postbox, network: Network, tonInstance: TonInstance, keychain: TonKeychain, walletInfo: WalletInfo) -> Signal<Never, DeleteLocalWalletDataError> {
|
||||
return getServerWalletSalt(network: network)
|
||||
|> mapError { _ -> DeleteLocalWalletDataError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { serverSalt -> Signal<Never, DeleteLocalWalletDataError> in
|
||||
return tonInstance.deleteLocalWalletData(walletInfo: walletInfo, keychain: keychain, serverSalt: serverSalt)
|
||||
|> then(
|
||||
postbox.transaction { transaction -> Void in
|
||||
transaction.updatePreferencesEntry(key: PreferencesKeys.walletCollection, { current in
|
||||
var walletCollection = (current as? WalletCollection) ?? WalletCollection(wallets: [])
|
||||
for i in 0 ..< walletCollection.wallets.count {
|
||||
if walletCollection.wallets[i].info.publicKey == walletInfo.publicKey {
|
||||
walletCollection.wallets.remove(at: i)
|
||||
break
|
||||
}
|
||||
}
|
||||
return walletCollection
|
||||
})
|
||||
}
|
||||
|> castError(DeleteLocalWalletDataError.self)
|
||||
|> ignoreValues
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public enum WalletRestoreWordsError {
|
||||
case generic
|
||||
case secretDecryptionFailed(TonKeychainDecryptDataError)
|
||||
}
|
||||
|
||||
public func walletRestoreWords(network: Network, walletInfo: WalletInfo, tonInstance: TonInstance, keychain: TonKeychain) -> Signal<[String], WalletRestoreWordsError> {
|
||||
return getServerWalletSalt(network: network)
|
||||
|> mapError { _ -> WalletRestoreWordsError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { serverSalt in
|
||||
return tonInstance.walletRestoreWords(walletInfo: walletInfo, keychain: keychain, serverSalt: serverSalt)
|
||||
}
|
||||
public func walletRestoreWords(tonInstance: TonInstance, publicKey: WalletPublicKey, decryptedSecret: Data, localPassword: Data) -> Signal<[String], WalletRestoreWordsError> {
|
||||
return tonInstance.walletRestoreWords(publicKey: publicKey, decryptedSecret: decryptedSecret, localPassword: localPassword)
|
||||
}
|
||||
|
||||
public struct WalletState: Codable, Equatable {
|
||||
|
|
@ -842,11 +757,11 @@ public enum SendGramsFromWalletError {
|
|||
case network
|
||||
}
|
||||
|
||||
public func sendGramsFromWallet(network: Network, tonInstance: TonInstance, walletInfo: WalletInfo, decryptedSecret: Data, serverSalt: Data, toAddress: String, amount: Int64, textMessage: String, forceIfDestinationNotInitialized: Bool, timeout: Int32, randomId: Int64) -> Signal<Never, SendGramsFromWalletError> {
|
||||
public func sendGramsFromWallet(network: Network, tonInstance: TonInstance, walletInfo: WalletInfo, decryptedSecret: Data, localPassword: Data, toAddress: String, amount: Int64, textMessage: String, forceIfDestinationNotInitialized: Bool, timeout: Int32, randomId: Int64) -> Signal<Never, SendGramsFromWalletError> {
|
||||
return walletAddress(publicKey: walletInfo.publicKey, tonInstance: tonInstance)
|
||||
|> castError(SendGramsFromWalletError.self)
|
||||
|> mapToSignal { fromAddress in
|
||||
return tonInstance.sendGramsFromWallet(decryptedSecret: decryptedSecret, serverSalt: serverSalt, walletInfo: walletInfo, fromAddress: fromAddress, toAddress: toAddress, amount: amount, textMessage: textMessage, forceIfDestinationNotInitialized: forceIfDestinationNotInitialized, timeout: timeout, randomId: randomId)
|
||||
return tonInstance.sendGramsFromWallet(decryptedSecret: decryptedSecret, localPassword: localPassword, walletInfo: walletInfo, fromAddress: fromAddress, toAddress: toAddress, amount: amount, textMessage: textMessage, forceIfDestinationNotInitialized: forceIfDestinationNotInitialized, timeout: timeout, randomId: randomId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,10 +104,20 @@ public func walletSettingsController(context: AccountContext, tonContext: TonCon
|
|||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, strings: presentationData.strings, type: .loading(cancelled: nil))
|
||||
presentControllerImpl?(controller, nil)
|
||||
let _ = (walletRestoreWords(network: context.account.network, walletInfo: walletInfo, tonInstance: tonContext.instance, keychain: tonContext.keychain)
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] wordList in
|
||||
controller?.dismiss()
|
||||
pushControllerImpl?(WalletWordDisplayScreen(context: context, tonContext: tonContext, walletInfo: walletInfo, wordList: wordList, mode: .export, walletCreatedPreloadState: nil))
|
||||
let _ = (tonContext.keychain.decrypt(walletInfo.encryptedSecret)
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] decryptedSecret in
|
||||
let _ = (getServerWalletSalt(network: context.account.network)
|
||||
|> deliverOnMainQueue).start(next: { serverSalt in
|
||||
let _ = (walletRestoreWords(tonInstance: tonContext.instance, publicKey: walletInfo.publicKey, decryptedSecret: decryptedSecret, localPassword: serverSalt)
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] wordList in
|
||||
controller?.dismiss()
|
||||
pushControllerImpl?(WalletWordDisplayScreen(context: context, tonContext: tonContext, walletInfo: walletInfo, wordList: wordList, mode: .export, walletCreatedPreloadState: nil))
|
||||
}, error: { [weak controller] _ in
|
||||
controller?.dismiss()
|
||||
})
|
||||
}, error: { [weak controller] _ in
|
||||
controller?.dismiss()
|
||||
})
|
||||
}, error: { [weak controller] _ in
|
||||
controller?.dismiss()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public final class WalletSplashScreen: ViewController {
|
|||
}
|
||||
|
||||
private func sendGrams(walletInfo: WalletInfo, decryptedSecret: Data, address: String, amount: Int64, textMessage: String, forceIfDestinationNotInitialized: Bool, randomId: Int64, serverSalt: Data) {
|
||||
let _ = (sendGramsFromWallet(network: self.context.account.network, tonInstance: self.tonContext.instance, walletInfo: walletInfo, decryptedSecret: decryptedSecret, serverSalt: serverSalt, toAddress: address, amount: amount, textMessage: textMessage, forceIfDestinationNotInitialized: forceIfDestinationNotInitialized, timeout: 0, randomId: randomId)
|
||||
let _ = (sendGramsFromWallet(network: self.context.account.network, tonInstance: self.tonContext.instance, walletInfo: walletInfo, decryptedSecret: decryptedSecret, localPassword: serverSalt, toAddress: address, amount: amount, textMessage: textMessage, forceIfDestinationNotInitialized: forceIfDestinationNotInitialized, timeout: 0, randomId: randomId)
|
||||
|> deliverOnMainQueue).start(error: { [weak self] error in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
|
|
@ -213,15 +213,7 @@ public final class WalletSplashScreen: ViewController {
|
|||
switch strongSelf.mode {
|
||||
case .intro:
|
||||
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, type: .loading(cancelled: nil))
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
let _ = (createWallet(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, tonInstance: strongSelf.tonContext.instance, keychain: strongSelf.tonContext.keychain)
|
||||
|> deliverOnMainQueue).start(next: { walletInfo, wordList in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
controller.dismiss()
|
||||
(strongSelf.navigationController as? NavigationController)?.replaceController(strongSelf, with: WalletSplashScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, mode: .created(walletInfo, wordList), walletCreatedPreloadState: nil), animated: true)
|
||||
}, error: { _ in
|
||||
let displayError: () -> Void = {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
|
@ -230,6 +222,22 @@ public final class WalletSplashScreen: ViewController {
|
|||
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
|
||||
})
|
||||
], actionLayout: .vertical), in: .window(.root))
|
||||
}
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
let _ = (getServerWalletSalt(network: strongSelf.context.account.network)
|
||||
|> deliverOnMainQueue).start(next: { serverSalt in
|
||||
let _ = (createWallet(postbox: strongSelf.context.account.postbox, tonInstance: strongSelf.tonContext.instance, keychain: strongSelf.tonContext.keychain, localPassword: serverSalt)
|
||||
|> deliverOnMainQueue).start(next: { walletInfo, wordList in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
controller.dismiss()
|
||||
(strongSelf.navigationController as? NavigationController)?.replaceController(strongSelf, with: WalletSplashScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, mode: .created(walletInfo, wordList), walletCreatedPreloadState: nil), animated: true)
|
||||
}, error: { _ in
|
||||
displayError()
|
||||
})
|
||||
}, error: { _ in
|
||||
displayError()
|
||||
})
|
||||
case let .created(walletInfo, wordList):
|
||||
if let wordList = wordList {
|
||||
|
|
@ -237,20 +245,50 @@ public final class WalletSplashScreen: ViewController {
|
|||
} else {
|
||||
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, type: .loading(cancelled: nil))
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
let _ = (walletRestoreWords(network: strongSelf.context.account.network, walletInfo: walletInfo, tonInstance: strongSelf.tonContext.instance, keychain: strongSelf.tonContext.keychain)
|
||||
|> deliverOnMainQueue).start(next: { wordList in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.mode = .created(walletInfo, wordList)
|
||||
controller.dismiss()
|
||||
strongSelf.push(WalletWordDisplayScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, walletInfo: walletInfo, wordList: wordList, mode: .check, walletCreatedPreloadState: strongSelf.walletCreatedPreloadState))
|
||||
}, error: { error in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
controller.dismiss()
|
||||
if case let .secretDecryptionFailed(.cancelled) = error {
|
||||
|
||||
let context = strongSelf.context
|
||||
let tonContext = strongSelf.tonContext
|
||||
let _ = (strongSelf.tonContext.keychain.decrypt(walletInfo.encryptedSecret)
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] decryptedSecret in
|
||||
let _ = (getServerWalletSalt(network: context.account.network)
|
||||
|> deliverOnMainQueue).start(next: { [weak controller] serverSalt in
|
||||
let _ = (walletRestoreWords(tonInstance: tonContext.instance, publicKey: walletInfo.publicKey, decryptedSecret: decryptedSecret, localPassword: serverSalt)
|
||||
|> deliverOnMainQueue).start(next: { wordList in
|
||||
controller?.dismiss()
|
||||
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
strongSelf.mode = .created(walletInfo, wordList)
|
||||
strongSelf.push(WalletWordDisplayScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, walletInfo: walletInfo, wordList: wordList, mode: .check, walletCreatedPreloadState: strongSelf.walletCreatedPreloadState))
|
||||
}, error: { _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
controller?.dismiss()
|
||||
|
||||
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Wallet_Created_ExportErrorTitle, text: strongSelf.presentationData.strings.Wallet_Created_ExportErrorText, actions: [
|
||||
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
|
||||
})
|
||||
], actionLayout: .vertical), in: .window(.root))
|
||||
})
|
||||
}, error: { [weak controller] _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
controller?.dismiss()
|
||||
|
||||
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Wallet_Created_ExportErrorTitle, text: strongSelf.presentationData.strings.Wallet_Created_ExportErrorText, actions: [
|
||||
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
|
||||
})
|
||||
], actionLayout: .vertical), in: .window(.root))
|
||||
})
|
||||
}, error: { [weak controller] error in
|
||||
controller?.dismiss()
|
||||
if case .cancelled = error {
|
||||
} else {
|
||||
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Wallet_Created_ExportErrorTitle, text: strongSelf.presentationData.strings.Wallet_Created_ExportErrorText, actions: [
|
||||
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
|
||||
|
|
|
|||
|
|
@ -2178,30 +2178,8 @@ public final class WalletWordCheckScreen: ViewController {
|
|||
], actionLayout: .vertical), in: .window(.root))
|
||||
return
|
||||
}
|
||||
let _ = (importWallet(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network, tonInstance: strongSelf.tonContext.instance, keychain: strongSelf.tonContext.keychain, wordList: enteredWords)
|
||||
|> deliverOnMainQueue).start(next: { walletInfo in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if let navigationController = strongSelf.navigationController as? NavigationController {
|
||||
var controllers = navigationController.viewControllers
|
||||
controllers = controllers.filter { controller in
|
||||
if controller is WalletSplashScreen {
|
||||
return false
|
||||
}
|
||||
if controller is WalletWordDisplayScreen {
|
||||
return false
|
||||
}
|
||||
if controller is WalletWordCheckScreen {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
controllers.append(WalletSplashScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, mode: .success(walletInfo), walletCreatedPreloadState: strongSelf.walletCreatedPreloadState))
|
||||
strongSelf.view.endEditing(true)
|
||||
navigationController.setViewControllers(controllers, animated: true)
|
||||
}
|
||||
}, error: { error in
|
||||
|
||||
let displayError: () -> Void = {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
|
@ -2210,6 +2188,38 @@ public final class WalletWordCheckScreen: ViewController {
|
|||
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
|
||||
})
|
||||
], actionLayout: .vertical), in: .window(.root))
|
||||
}
|
||||
|
||||
let _ = (getServerWalletSalt(network: strongSelf.context.account.network)
|
||||
|> deliverOnMainQueue).start(next: { serverSalt in
|
||||
let _ = (importWallet(postbox: strongSelf.context.account.postbox, tonInstance: strongSelf.tonContext.instance, keychain: strongSelf.tonContext.keychain, wordList: enteredWords, localPassword: serverSalt)
|
||||
|> deliverOnMainQueue).start(next: { walletInfo in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if let navigationController = strongSelf.navigationController as? NavigationController {
|
||||
var controllers = navigationController.viewControllers
|
||||
controllers = controllers.filter { controller in
|
||||
if controller is WalletSplashScreen {
|
||||
return false
|
||||
}
|
||||
if controller is WalletWordDisplayScreen {
|
||||
return false
|
||||
}
|
||||
if controller is WalletWordCheckScreen {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
controllers.append(WalletSplashScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, mode: .success(walletInfo), walletCreatedPreloadState: strongSelf.walletCreatedPreloadState))
|
||||
strongSelf.view.endEditing(true)
|
||||
navigationController.setViewControllers(controllers, animated: true)
|
||||
}
|
||||
}, error: { error in
|
||||
displayError()
|
||||
})
|
||||
}, error: { _ in
|
||||
displayError()
|
||||
})
|
||||
}
|
||||
}, secondaryAction: { [weak self] in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue