Wallet improvements

This commit is contained in:
Peter
2019-09-25 00:57:46 +04:00
parent ee9815cff8
commit c64c16b8ee
39 changed files with 4202 additions and 3733 deletions

View File

@@ -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)))
}
}
})