Merge branch 'master' into fix-build-warnings-from-appcode

pull/384/head
James Sangalli 7 years ago committed by GitHub
commit 386458ba60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      Trust/AppCoordinator.swift
  2. 9
      Trust/AppDelegate.swift
  3. 6
      Trust/Market/Coordinators/UniversalLinkCoordinator.swift
  4. 9
      Trust/Wallet/Coordinators/WalletCoordinator.swift

@ -6,7 +6,7 @@ import UIKit
import BigInt
class AppCoordinator: NSObject, Coordinator {
let navigationController: UINavigationController
let navigationController: UINavigationController
lazy var welcomeViewController: WelcomeViewController = {
let controller = WelcomeViewController()
controller.delegate = self
@ -70,6 +70,16 @@ class AppCoordinator: NSObject, Coordinator {
coordinator.start()
addCoordinator(coordinator)
}
func closeWelcomeWindow() {
guard navigationController.viewControllers.contains(welcomeViewController) else {
return
}
navigationController.dismiss(animated: true, completion: nil)
if let wallet = keystore.recentlyUsedWallet {
showTransactions(for: wallet)
}
}
func inializers() {
var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .allDomainsMask, true).flatMap { URL(fileURLWithPath: $0) }
@ -122,6 +132,10 @@ class AppCoordinator: NSObject, Coordinator {
coordinator.start()
addCoordinator(coordinator)
}
func createInitialWallet() {
WalletCoordinator(keystore: keystore).createInitialWallet()
}
}
//Disable creating and importing wallets from welcome screen

@ -61,15 +61,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
appCoordinator.createInitialWallet()
appCoordinator.closeWelcomeWindow()
let url = userActivity.webpageURL
universalLinkCoordinator = UniversalLinkCoordinator()
universalLinkCoordinator = UniversalLinkCoordinator()
universalLinkCoordinator.ethPrice = appCoordinator.ethPrice
universalLinkCoordinator.ethBalance = appCoordinator.ethBalance
universalLinkCoordinator.delegate = self
universalLinkCoordinator.start()
let handled = universalLinkCoordinator.handleUniversalLink(url: url)
//TODO: if we handle other types of URLs, check if handled==false, then we pass the url to another handlers
let handled = universalLinkCoordinator.handleUniversalLink(url: url)
//TODO: if we handle other types of URLs, check if handled==false, then we pass the url to another handlers
return true
}
}

@ -4,6 +4,7 @@ import Foundation
import Alamofire
import BigInt
import Realm
import TrustKeystore
protocol UniversalLinkCoordinatorDelegate: class {
func viewControllerForPresenting(in coordinator: UniversalLinkCoordinator) -> UIViewController?
@ -18,6 +19,7 @@ class UniversalLinkCoordinator: Coordinator {
var ethPrice: Subscribable<Double>?
var ethBalance: Subscribable<BigInt>?
var hasCompleted = false
var addressOfNewWallet: String?
func start() {
preparingToImportUniversalLink()
@ -39,7 +41,7 @@ class UniversalLinkCoordinator: Coordinator {
"v": signature.substring(from: 128),
"r": "0x" + signature.substring(with: Range(uncheckedBounds: (0, 64))),
"s": "0x" + signature.substring(with: Range(uncheckedBounds: (64, 128))),
"networkId": Config.init().chainID.description
"networkId": Config().chainID.description
]
if isForTransfer {
@ -112,12 +114,12 @@ class UniversalLinkCoordinator: Coordinator {
}
//Returns true if handled
func handleUniversalLink(url: URL?) -> Bool {
let matchedPrefix = (url?.description.contains(UniversalLinkHandler().urlPrefix))!
guard matchedPrefix else {
return false
}
let signedOrder = UniversalLinkHandler().parseUniversalLink(url: (url?.absoluteString)!)
getTicketDetailsAndEcRecover(signedOrder: signedOrder) { result in
if let goodResult = result {

@ -14,7 +14,7 @@ class WalletCoordinator: Coordinator {
var navigationController: UINavigationController
weak var delegate: WalletCoordinatorDelegate?
var entryPoint: WalletEntryPoint?
let keystore: Keystore
var keystore: Keystore
var coordinators: [Coordinator] = []
init(
@ -61,6 +61,13 @@ class WalletCoordinator: Coordinator {
controller.delegate = self
navigationController.pushViewController(controller, animated: true)
}
func createInitialWallet() {
if !keystore.hasWallets {
let account = keystore.createAccount(password: PasswordGenerator.generateRandom())
keystore.recentlyUsedWallet = Wallet(type: WalletType.real(account))
}
}
func createInstantWallet() {
navigationController.displayLoading(text: R.string.localizable.walletCreateInProgress(), animated: false)

Loading…
Cancel
Save