From 91d05ad9a4bb7f679f1dbe3c04415e77f113438b Mon Sep 17 00:00:00 2001 From: Simon McLoughlin Date: Mon, 22 Jan 2024 16:41:00 +0000 Subject: [PATCH] - bug fix: scan view controller blocking main thread on paste - add loading spinner to pairing on WC2 - add timer to auto fail after 10 seconds --- .../xcshareddata/swiftpm/Package.resolved | 2 +- Kukai Mobile/Controls/ScanViewController.swift | 1 - Kukai Mobile/Services/TransactionService.swift | 18 +++++++++++------- .../Services/WalletConnectService.swift | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f458e087..4bef8cd4 100644 --- a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -69,7 +69,7 @@ "location" : "https://github.com/kukai-wallet/kukai-core-swift", "state" : { "branch" : "develop", - "revision" : "9af31bf32f291f9dd51cdfb2e774c5c1c8e552d5" + "revision" : "6a7d1f937117de5d88b9a936e74c64084a56be2b" } }, { diff --git a/Kukai Mobile/Controls/ScanViewController.swift b/Kukai Mobile/Controls/ScanViewController.swift index 6fbf5fcf..4770469e 100644 --- a/Kukai Mobile/Controls/ScanViewController.swift +++ b/Kukai Mobile/Controls/ScanViewController.swift @@ -344,7 +344,6 @@ class ScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelega self.textfield.text = "" } else { - captureSession.stopRunning() found(code: stringToCheck) } } diff --git a/Kukai Mobile/Services/TransactionService.swift b/Kukai Mobile/Services/TransactionService.swift index a16cb49b..51f7a278 100644 --- a/Kukai Mobile/Services/TransactionService.swift +++ b/Kukai Mobile/Services/TransactionService.swift @@ -336,22 +336,26 @@ public class TransactionService { let imageSize = TransactionService.sizeForWalletIcon(walletIconSize: size) let currentNetwork = DependencyManager.shared.currentNetworkType - // Early exit if tezos domain - if metadata.hasDomain(onNetwork: currentNetwork) { - let image = UIImage(named: "Social_TZDomain_Color")?.resizedImage(size: imageSize) ?? UIImage() - return (image: image, title: metadata.primaryDomain(onNetwork: currentNetwork)?.domain.name ?? "", subtitle: metadata.address.truncateTezosAddress()) - } - - // Second Early exit if non-social wallet without domain if metadata.type != .social { let image = UIImage(named: "Social_TZ_1color")?.resizedImage(size: imageSize)?.withTintColor(.colorNamed("BGB4")) ?? UIImage() var title = "" var subtitle: String? = "" if let nickname = metadata.walletNickname { + + // If non social, check for nicknames first title = nickname subtitle = metadata.address.truncateTezosAddress() + + } else if metadata.hasDomain(onNetwork: currentNetwork) { + + // If no nicknames, check for tezos domains + let image = UIImage(named: "Social_TZDomain_Color")?.resizedImage(size: imageSize) ?? UIImage() + return (image: image, title: metadata.primaryDomain(onNetwork: currentNetwork)?.domain.name ?? "", subtitle: metadata.address.truncateTezosAddress()) + } else { + + // Use address title = metadata.address.truncateTezosAddress() subtitle = nil } diff --git a/Kukai Mobile/Services/WalletConnectService.swift b/Kukai Mobile/Services/WalletConnectService.swift index dab0fa0c..155b479e 100644 --- a/Kukai Mobile/Services/WalletConnectService.swift +++ b/Kukai Mobile/Services/WalletConnectService.swift @@ -69,6 +69,8 @@ public class WalletConnectService { icons: ["https://wallet.kukai.app/assets/img/header-logo.svg"], redirect: AppMetadata.Redirect(native: "kukai://", universal: nil)) + private var pairingTimer: Timer? = nil + @Published public var requestDidComplete: Bool = false @Published public var pairsAndSessionsUpdated: Bool = false @@ -155,6 +157,11 @@ public class WalletConnectService { .sink { [weak self] incomingProposalObj in Logger.app.info("WC sessionProposalPublisher") self?.sessionActionRequiredPublisherSubject.send((action: incomingProposalObj.proposal, context: incomingProposalObj.context)) + + self?.delegate?.processingIncomingDone() + self?.pairingTimer?.invalidate() + self?.pairingTimer = nil + }.store(in: &bag) Sign.instance.sessionRequestPublisher @@ -266,6 +273,12 @@ public class WalletConnectService { return Future() { [weak self] promise in Logger.app.info("WC pairing to \(uri.absoluteString)") + self?.delegate?.processingIncomingOperations() + self?.pairingTimer = Timer.scheduledTimer(withTimeInterval: 10, repeats: false, block: { [weak self] timer in + self?.delegateErrorOnMain(message: "No response from application. Please refresh the webpage, and try to connect again", error: nil) + self?.delegate?.processingIncomingDone() + }) + Task { [weak self] in do { try await Pair.instance.pair(uri: uri) @@ -274,6 +287,9 @@ public class WalletConnectService { } catch { Logger.app.error("WC Pairing connect error: \(error)") self?.delegateErrorOnMain(message: "Unable to connect to Pair with dApp, due to: \(error)", error: error) + self?.delegate?.processingIncomingDone() + self?.pairingTimer?.invalidate() + self?.pairingTimer = nil promise(.success(false)) }