From 5b85b9dffa9d63ffaa35f448e3903bcd7b9f2156 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 27 Sep 2019 23:09:41 +0300 Subject: [PATCH] Wallet: fixed ton:// links --- NotificationContent/Info.plist | 2 +- NotificationService/Info.plist | 2 +- Share/Info.plist | 20 +++++++++---------- SiriIntents/Info.plist | 2 +- Watch/App/Info.plist | 2 +- Watch/Extension/Info.plist | 2 +- Widget/Info.plist | 2 +- .../TelegramUI/OpenResolvedUrl.swift | 1 + .../UrlHandling/Sources/UrlHandling.swift | 7 ++++--- .../Sources/WalletReceiveScreen.swift | 6 +++--- .../WalletUI/Sources/WalletSplashScreen.swift | 10 +++++++--- 11 files changed, 31 insertions(+), 25 deletions(-) diff --git a/NotificationContent/Info.plist b/NotificationContent/Info.plist index 8794b5e261..f982785438 100644 --- a/NotificationContent/Info.plist +++ b/NotificationContent/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/NotificationService/Info.plist b/NotificationService/Info.plist index b4beea254f..b9f2e746f9 100644 --- a/NotificationService/Info.plist +++ b/NotificationService/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Share/Info.plist b/Share/Info.plist index ac2fd93455..d4b1dd7082 100644 --- a/Share/Info.plist +++ b/Share/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} NSExtension @@ -31,15 +31,15 @@ SUBQUERY ( $extensionItem.attachments, $attachment, - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard" || - ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass" + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard" || + ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass" ).@count == $extensionItem.attachments.@count ).@count > 0 diff --git a/SiriIntents/Info.plist b/SiriIntents/Info.plist index 2806e7beb8..d6b99942eb 100644 --- a/SiriIntents/Info.plist +++ b/SiriIntents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Watch/App/Info.plist b/Watch/App/Info.plist index 4e459a905e..70f8f1258b 100644 --- a/Watch/App/Info.plist +++ b/Watch/App/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} UIDeviceFamily diff --git a/Watch/Extension/Info.plist b/Watch/Extension/Info.plist index 976d51af4a..963171e6e6 100644 --- a/Watch/Extension/Info.plist +++ b/Watch/Extension/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Widget/Info.plist b/Widget/Info.plist index c4dbc30710..103bb1a25a 100644 --- a/Widget/Info.plist +++ b/Widget/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.11.1 + 5.12 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift b/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift index d89cea8b96..610e73f0d1 100644 --- a/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift @@ -325,6 +325,7 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur })) dismissInput() case let .wallet(address, amount, comment): + dismissInput() context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in navigationController?.pushViewController(c) } diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index cf64372a36..0b0270935f 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -451,12 +451,13 @@ private func isValidWalletAddress(_ address: String) -> Bool { } public func parseWalletUrl(_ url: URL) -> ParsedWalletUrl? { - guard url.scheme == "ton" else { + guard url.scheme == "ton" && url.host == "transfer" else { return nil } var address: String? - if let host = url.host, isValidWalletAddress(host) { - address = host + let path = url.path.trimmingCharacters(in: CharacterSet(charactersIn: "/")) + if isValidWalletAddress(path) { + address = path } var amount: Int64? var comment: String? diff --git a/submodules/WalletUI/Sources/WalletReceiveScreen.swift b/submodules/WalletUI/Sources/WalletReceiveScreen.swift index e8d741f6af..becdf73fe5 100644 --- a/submodules/WalletUI/Sources/WalletReceiveScreen.swift +++ b/submodules/WalletUI/Sources/WalletReceiveScreen.swift @@ -303,18 +303,18 @@ private final class WalletReceiveScreenImpl: ItemListController String { var arguments = "" if !state.amount.isEmpty { - arguments += arguments.isEmpty ? "/?" : "&" + arguments += arguments.isEmpty ? "?" : "&" arguments += "amount=\(amountValue(state.amount))" } if !state.comment.isEmpty, let escapedComment = state.comment.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { - arguments += arguments.isEmpty ? "/?" : "&" + arguments += arguments.isEmpty ? "?" : "&" if escapeComment { arguments += "text=\(escapedComment)" } else { arguments += "text=\(state.comment)" } } - return "ton://\(address)\(arguments)" + return "ton://transfer/\(address)\(arguments)" } func walletReceiveScreen(context: AccountContext, tonContext: TonContext, walletInfo: WalletInfo, address: String) -> ViewController { diff --git a/submodules/WalletUI/Sources/WalletSplashScreen.swift b/submodules/WalletUI/Sources/WalletSplashScreen.swift index 5028313810..11992ecfb0 100644 --- a/submodules/WalletUI/Sources/WalletSplashScreen.swift +++ b/submodules/WalletUI/Sources/WalletSplashScreen.swift @@ -163,8 +163,10 @@ public final class WalletSplashScreen: ViewController { } var controllers: [UIViewController] = [] for controller in navigationController.viewControllers { - if controller is WalletInfoScreen { - controllers.append(WalletInfoScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, walletInfo: walletInfo, address: address)) + if let controller = controller as? WalletInfoScreen { + let infoScreen = WalletInfoScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, walletInfo: walletInfo, address: address) + infoScreen.navigationPresentation = controller.navigationPresentation + controllers.append(infoScreen) } else { controllers.append(controller) } @@ -300,7 +302,9 @@ public final class WalletSplashScreen: ViewController { } if !controllers.contains(where: { $0 is WalletInfoScreen }) { - controllers.append(WalletInfoScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, walletInfo: walletInfo, address: address)) + let infoScreen = WalletInfoScreen(context: strongSelf.context, tonContext: strongSelf.tonContext, walletInfo: walletInfo, address: address) + infoScreen.navigationPresentation = .modal + controllers.append(infoScreen) } strongSelf.view.endEditing(true) navigationController.setViewControllers(controllers, animated: true)