Handle showing error for only watch accounts

pull/2/head
Michael Scoff 7 years ago
parent 7ad15191c5
commit dfd7eb3d43
  1. 4
      Trust.xcodeproj/project.pbxproj
  2. 22
      Trust/InCoordinator.swift
  3. 14
      Trust/Transfer/Coordinators/PaymentCoordinator.swift
  4. 15
      Trust/Transfer/Types/InCoordinatorError.swift

@ -286,6 +286,7 @@
29FF13081F75F0AE00AFD326 /* AppCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF13071F75F0AE00AFD326 /* AppCoordinatorTests.swift */; };
29FF130A1F75F67200AFD326 /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF13091F75F67200AFD326 /* Address.swift */; };
29FF130D1F7626E800AFD326 /* FakeNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF130C1F7626E800AFD326 /* FakeNavigationController.swift */; };
29FF6D6B2011D2AF00A3011C /* InCoordinatorError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D6A2011D2AF00A3011C /* InCoordinatorError.swift */; };
3CDDD1E2CD1B0180754B7992 /* Pods_Trust.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 646C8C822C986358D7388602 /* Pods_Trust.framework */; };
613D04891FDE15F8008DE72E /* COMODO ECC Domain Validation Secure Server CA 2.cer in Resources */ = {isa = PBXBuildFile; fileRef = 613D04881FDE15F8008DE72E /* COMODO ECC Domain Validation Secure Server CA 2.cer */; };
613D048B1FDE162B008DE72E /* TrustProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 613D048A1FDE162B008DE72E /* TrustProvider.swift */; };
@ -622,6 +623,7 @@
29FF13071F75F0AE00AFD326 /* AppCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCoordinatorTests.swift; sourceTree = "<group>"; };
29FF13091F75F67200AFD326 /* Address.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Address.swift; sourceTree = "<group>"; };
29FF130C1F7626E800AFD326 /* FakeNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeNavigationController.swift; sourceTree = "<group>"; };
29FF6D6A2011D2AF00A3011C /* InCoordinatorError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InCoordinatorError.swift; sourceTree = "<group>"; };
477899BEAA4489DA423E8857 /* Pods-TrustUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrustUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TrustUITests/Pods-TrustUITests.debug.xcconfig"; sourceTree = "<group>"; };
4DB8204016307EAFC079EA48 /* Pods-Trust.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Trust.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Trust/Pods-Trust.debug.xcconfig"; sourceTree = "<group>"; };
613D04881FDE15F8008DE72E /* COMODO ECC Domain Validation Secure Server CA 2.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "COMODO ECC Domain Validation Secure Server CA 2.cer"; sourceTree = "<group>"; };
@ -1557,6 +1559,7 @@
299B5E481FD2C8900051361C /* ConfigureTransaction.swift */,
29BDF1971FEE4DB00023A45F /* GasPriceConfiguration.swift */,
29BDF1A01FEE51A80023A45F /* GasLimitConfiguration.swift */,
29FF6D6A2011D2AF00A3011C /* InCoordinatorError.swift */,
);
path = Types;
sourceTree = "<group>";
@ -2389,6 +2392,7 @@
771AA94E1FF971CD00D25403 /* DappAction.swift in Sources */,
29F1C8471FEB6664003780D8 /* EditTokenTableViewCell.swift in Sources */,
296106C21F76403A0006164B /* TokenViewCell.swift in Sources */,
29FF6D6B2011D2AF00A3011C /* InCoordinatorError.swift in Sources */,
29F114F01FA6D53700114A29 /* ImportSelectionType.swift in Sources */,
29850D251F6B27A800791A49 /* R.generated.swift in Sources */,
296105931FA2AA2100292494 /* SignTransaction.swift in Sources */,

@ -10,18 +10,6 @@ protocol InCoordinatorDelegate: class {
func didUpdateAccounts(in coordinator: InCoordinator)
}
enum InCoordinatorError: LocalizedError {
case onlyWatchAccount
var errorDescription: String? {
return NSLocalizedString(
"InCoordinatorError.onlyWatchAccount",
value: "This wallet could be only used for watching. Import Private Key/Keystore to sign transactions",
comment: ""
)
}
}
class InCoordinator: Coordinator {
let navigationController: UINavigationController
@ -197,20 +185,20 @@ class InCoordinator: Coordinator {
let session = transactionCoordinator.session
let tokenStorage = transactionCoordinator.tokensStorage
switch session.account.type {
case .real(let account):
switch (type, session.account.type) {
case (.send, .real), (.request, _):
let coordinator = PaymentCoordinator(
flow: type,
session: session,
keystore: keystore,
storage: tokenStorage,
account: account
storage: tokenStorage
)
coordinator.delegate = self
navigationController.present(coordinator.navigationController, animated: true, completion: nil)
coordinator.start()
addCoordinator(coordinator)
case .watch: break
case (_, _):
navigationController.displayError(error: InCoordinatorError.onlyWatchAccount)
}
}

@ -19,7 +19,6 @@ class PaymentCoordinator: Coordinator {
let navigationController: UINavigationController
let keystore: Keystore
let storage: TokensDataStore
let account: Account
lazy var transferType: TransferType = {
switch self.flow {
@ -35,21 +34,19 @@ class PaymentCoordinator: Coordinator {
flow: PaymentFlow,
session: WalletSession,
keystore: Keystore,
storage: TokensDataStore,
account: Account
storage: TokensDataStore
) {
self.navigationController = navigationController
self.navigationController.modalPresentationStyle = .formSheet
self.session = session
self.account = account
self.flow = flow
self.keystore = keystore
self.storage = storage
}
func start() {
switch flow {
case .send(let type):
switch (flow, session.account.type) {
case (.send(let type), .real(let account)):
let coordinator = SendCoordinator(
transferType: type,
navigationController: navigationController,
@ -61,7 +58,7 @@ class PaymentCoordinator: Coordinator {
coordinator.delegate = self
coordinator.start()
addCoordinator(coordinator)
case .request:
case (.request, _):
let coordinator = RequestCoordinator(
navigationController: navigationController,
session: session
@ -69,6 +66,9 @@ class PaymentCoordinator: Coordinator {
coordinator.delegate = self
coordinator.start()
addCoordinator(coordinator)
case (.send, .watch):
// This case should be returning an error inCoordinator. Improve this logic into single piece.
break
}
}

@ -0,0 +1,15 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
enum InCoordinatorError: LocalizedError {
case onlyWatchAccount
var errorDescription: String? {
return NSLocalizedString(
"InCoordinatorError.onlyWatchAccount",
value: "This wallet could be only used for watching. Import Private Key/Keystore to sign transactions",
comment: ""
)
}
}
Loading…
Cancel
Save