Add token immediately upon successful import with universal link

pull/500/head
Hwee-Boon Yar 6 years ago
parent c6ea0b78f2
commit 1798d82bbc
  1. 4
      AlphaWallet/AppCoordinator.swift
  2. 4
      AlphaWallet/AppDelegate.swift
  3. 5
      AlphaWallet/InCoordinator.swift
  4. 9
      AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift
  5. 6
      AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift

@ -124,6 +124,10 @@ class AppCoordinator: NSObject, Coordinator {
}
}
func addImported(contract: String) {
inCoordinator?.addImported(contract: contract)
}
func showInitialWalletCoordinator(entryPoint: WalletEntryPoint) {
let coordinator = InitialWalletCreationCoordinator(
navigationController: navigationController,

@ -108,6 +108,10 @@ extension AppDelegate: UniversalLinkCoordinatorDelegate {
func completed(in coordinator: UniversalLinkCoordinator) {
universalLinkCoordinator = nil
}
func didImported(contract: String, in coordinator: UniversalLinkCoordinator) {
appCoordinator.addImported(contract: contract)
}
}
extension AppDelegate: UniversalLinkInPasteboardCoordinatorDelegate {

@ -569,6 +569,11 @@ extension InCoordinator: TokensCoordinatorDelegate {
}
}
}
func addImported(contract: String) {
let tokensCoordinator = coordinators.first { $0 is TokensCoordinator } as? TokensCoordinator
tokensCoordinator?.addToken(for: contract)
}
}
extension InCoordinator: PaymentCoordinatorDelegate {

@ -11,6 +11,7 @@ protocol UniversalLinkCoordinatorDelegate: class {
func viewControllerForPresenting(in coordinator: UniversalLinkCoordinator) -> UIViewController?
func completed(in coordinator: UniversalLinkCoordinator)
func importPaidSignedOrder(signedOrder: SignedOrder, tokenObject: TokenObject, completion: @escaping (Bool) -> Void)
func didImported(contract: String, in coordinator: UniversalLinkCoordinator)
}
class UniversalLinkCoordinator: Coordinator {
@ -319,6 +320,7 @@ class UniversalLinkCoordinator: Coordinator {
if self.importTicketViewController != nil {
if let vc = self.importTicketViewController, var _ = vc.viewModel {
if successful {
self.delegate?.didImported(contract: signedOrder.order.contractAddress, in: self)
self.showImportSuccessful()
} else {
//TODO Pass in error message
@ -344,6 +346,9 @@ class UniversalLinkCoordinator: Coordinator {
if let response = result.response {
if response.statusCode < 300 {
successful = true
if let contract = parameters["contractAddress"] as? String {
self.delegate?.didImported(contract: contract, in: self)
}
}
}
@ -382,6 +387,10 @@ extension UniversalLinkCoordinator: ImportTicketViewControllerDelegate {
}
func didPressImport(in viewController: ImportTicketViewController) {
if let signedOrder = viewController.signedOrder, let tokenObj = viewController.tokenObject {
self.delegate?.didImported(contract: signedOrder.order.contractAddress, in: self)
}
if let query = viewController.query, let parameters = viewController.parameters {
importUniversalLink(query: query, parameters: parameters)
} else {

@ -139,6 +139,12 @@ class TokensCoordinator: Coordinator {
}
}
func addToken(for contract: String) {
addToken(for: contract) {
self.tokensViewController.fetch()
}
}
func newTokenViewController() -> NewTokenViewController {
let controller = NewTokenViewController()
controller.delegate = self

Loading…
Cancel
Save