Wallet: fixed ton:// links

This commit is contained in:
Ilya Laktyushin 2019-09-27 23:09:41 +03:00
parent 16928cdb85
commit 5b85b9dffa
11 changed files with 31 additions and 25 deletions

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>
@ -31,15 +31,15 @@
SUBQUERY ( SUBQUERY (
$extensionItem.attachments, $extensionItem.attachments,
$attachment, $attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.file-url&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.movie&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.image&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.url&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.text&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.audio&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.data&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;public.vcard&quot; ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass" ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO &quot;com.apple.pkpass&quot;
).@count == $extensionItem.attachments.@count ).@count == $extensionItem.attachments.@count
).@count &gt; 0</string> ).@count &gt; 0</string>
</dict> </dict>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>UIDeviceFamily</key> <key>UIDeviceFamily</key>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.11.1</string> <string>5.12</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>

View File

@ -325,6 +325,7 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
})) }))
dismissInput() dismissInput()
case let .wallet(address, amount, comment): case let .wallet(address, amount, comment):
dismissInput()
context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in
navigationController?.pushViewController(c) navigationController?.pushViewController(c)
} }

View File

@ -451,12 +451,13 @@ private func isValidWalletAddress(_ address: String) -> Bool {
} }
public func parseWalletUrl(_ url: URL) -> ParsedWalletUrl? { public func parseWalletUrl(_ url: URL) -> ParsedWalletUrl? {
guard url.scheme == "ton" else { guard url.scheme == "ton" && url.host == "transfer" else {
return nil return nil
} }
var address: String? var address: String?
if let host = url.host, isValidWalletAddress(host) { let path = url.path.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
address = host if isValidWalletAddress(path) {
address = path
} }
var amount: Int64? var amount: Int64?
var comment: String? var comment: String?

View File

@ -303,18 +303,18 @@ private final class WalletReceiveScreenImpl: ItemListController<WalletReceiveScr
private func invoiceUrl(address: String, state: WalletReceiveScreenState, escapeComment: Bool = true) -> String { private func invoiceUrl(address: String, state: WalletReceiveScreenState, escapeComment: Bool = true) -> String {
var arguments = "" var arguments = ""
if !state.amount.isEmpty { if !state.amount.isEmpty {
arguments += arguments.isEmpty ? "/?" : "&" arguments += arguments.isEmpty ? "?" : "&"
arguments += "amount=\(amountValue(state.amount))" arguments += "amount=\(amountValue(state.amount))"
} }
if !state.comment.isEmpty, let escapedComment = state.comment.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { if !state.comment.isEmpty, let escapedComment = state.comment.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
arguments += arguments.isEmpty ? "/?" : "&" arguments += arguments.isEmpty ? "?" : "&"
if escapeComment { if escapeComment {
arguments += "text=\(escapedComment)" arguments += "text=\(escapedComment)"
} else { } else {
arguments += "text=\(state.comment)" arguments += "text=\(state.comment)"
} }
} }
return "ton://\(address)\(arguments)" return "ton://transfer/\(address)\(arguments)"
} }
func walletReceiveScreen(context: AccountContext, tonContext: TonContext, walletInfo: WalletInfo, address: String) -> ViewController { func walletReceiveScreen(context: AccountContext, tonContext: TonContext, walletInfo: WalletInfo, address: String) -> ViewController {

View File

@ -163,8 +163,10 @@ public final class WalletSplashScreen: ViewController {
} }
var controllers: [UIViewController] = [] var controllers: [UIViewController] = []
for controller in navigationController.viewControllers { for controller in navigationController.viewControllers {
if controller is WalletInfoScreen { if let controller = controller as? 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 = controller.navigationPresentation
controllers.append(infoScreen)
} else { } else {
controllers.append(controller) controllers.append(controller)
} }
@ -300,7 +302,9 @@ public final class WalletSplashScreen: ViewController {
} }
if !controllers.contains(where: { $0 is WalletInfoScreen }) { 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) strongSelf.view.endEditing(true)
navigationController.setViewControllers(controllers, animated: true) navigationController.setViewControllers(controllers, animated: true)