Add pending transaction on dapp signing

pull/2/head
Michael Scoff 7 years ago
parent 46218ae7ea
commit ff504fdc08
  1. 6
      Trust/Browser/Coordinators/BrowserCoordinator.swift
  2. 13
      Trust/InCoordinator.swift

@ -4,6 +4,10 @@ import Foundation
import UIKit
import BigInt
protocol BrowserCoordinatorDelegate: class {
func didSentTransaction(transaction: SentTransaction, in coordinator: BrowserCoordinator)
}
class BrowserCoordinator: Coordinator {
var coordinators: [Coordinator] = []
let session: WalletSession
@ -14,6 +18,7 @@ class BrowserCoordinator: Coordinator {
controller.delegate = self
return controller
}()
weak var delegate: BrowserCoordinatorDelegate?
init(
navigationController: UINavigationController = NavigationController(),
@ -68,6 +73,7 @@ extension BrowserCoordinator: BrowserViewControllerDelegate {
extension BrowserCoordinator: ConfirmPaymentViewControllerDelegate {
func didCompleted(transaction: SentTransaction, in viewController: ConfirmPaymentViewController) {
delegate?.didSentTransaction(transaction: transaction, in: self)
navigationController.dismiss(animated: true, completion: nil)
rootViewController.notifyFinish(transaction: transaction)
}

@ -105,6 +105,7 @@ class InCoordinator: Coordinator {
if inCoordinatorViewModel.browserAvailable {
let coordinator = BrowserCoordinator(session: session, keystore: keystore)
coordinator.delegate = self
coordinator.start()
coordinator.rootViewController.tabBarItem = UITabBarItem(
title: NSLocalizedString("browser.tabbar.item.title", value: "Browser", comment: ""),
@ -210,6 +211,10 @@ class InCoordinator: Coordinator {
case .watch: break
}
}
private func handlePendingTransaction(transaction: SentTransaction) {
transactionCoordinator?.dataCoordinator.add(transaction: transaction)
}
}
extension InCoordinator: TransactionCoordinatorDelegate {
@ -262,7 +267,7 @@ extension InCoordinator: TokensCoordinatorDelegate {
extension InCoordinator: PaymentCoordinatorDelegate {
func didCreatePendingTransaction(transaction: SentTransaction, in coordinator: PaymentCoordinator) {
transactionCoordinator?.dataCoordinator.add(transaction: transaction)
handlePendingTransaction(transaction: transaction)
}
func didCancel(in coordinator: PaymentCoordinator) {
@ -270,3 +275,9 @@ extension InCoordinator: PaymentCoordinatorDelegate {
removeCoordinator(coordinator)
}
}
extension InCoordinator: BrowserCoordinatorDelegate {
func didSentTransaction(transaction: SentTransaction, in coordinator: BrowserCoordinator) {
handlePendingTransaction(transaction: transaction)
}
}

Loading…
Cancel
Save