mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Wallet improvements
This commit is contained in:
@@ -1609,16 +1609,33 @@ private func accountContextMenuItems(context: AccountContext, logout: @escaping
|
||||
}
|
||||
|
||||
func openWallet(context: AccountContext, push: @escaping (ViewController) -> Void) {
|
||||
let _ = (availableWallets(postbox: context.account.postbox)
|
||||
|> deliverOnMainQueue).start(next: { wallets in
|
||||
if let tonContext = context.tonContext {
|
||||
if wallets.wallets.isEmpty {
|
||||
guard let tonContext = context.tonContext else {
|
||||
return
|
||||
}
|
||||
let _ = (combineLatest(queue: .mainQueue(),
|
||||
availableWallets(postbox: context.account.postbox),
|
||||
tonContext.keychain.encryptionPublicKey()
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { wallets, currentPublicKey in
|
||||
if wallets.wallets.isEmpty {
|
||||
if let _ = currentPublicKey {
|
||||
push(WalletSplashScreen(context: context, tonContext: tonContext, mode: .intro))
|
||||
} else {
|
||||
let _ = (walletAddress(publicKey: wallets.wallets[0].publicKey, tonInstance: tonContext.instance)
|
||||
|> deliverOnMainQueue).start(next: { address in
|
||||
push(WalletInfoScreen(context: context, tonContext: tonContext, walletInfo: wallets.wallets[0], address: address))
|
||||
})
|
||||
push(WalletSplashScreen(context: context, tonContext: tonContext, mode: .secureStorageNotAvailable))
|
||||
}
|
||||
} else {
|
||||
let walletInfo = wallets.wallets[0].info
|
||||
if let currentPublicKey = currentPublicKey {
|
||||
if currentPublicKey == walletInfo.encryptedSecret.publicKey {
|
||||
let _ = (walletAddress(publicKey: walletInfo.publicKey, tonInstance: tonContext.instance)
|
||||
|> deliverOnMainQueue).start(next: { address in
|
||||
push(WalletInfoScreen(context: context, tonContext: tonContext, walletInfo: walletInfo, address: address))
|
||||
})
|
||||
} else {
|
||||
push(WalletSplashScreen(context: context, tonContext: tonContext, mode: .secureStorageReset(.changed)))
|
||||
}
|
||||
} else {
|
||||
push(WalletSplashScreen(context: context, tonContext: tonContext, mode: .secureStorageReset(.notAvailable)))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user