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>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>5.11.1</string>
<string>5.12</string>
<key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string>
<key>NSExtension</key>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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)
}

View File

@ -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?

View File

@ -303,18 +303,18 @@ private final class WalletReceiveScreenImpl: ItemListController<WalletReceiveScr
private func invoiceUrl(address: String, state: WalletReceiveScreenState, escapeComment: Bool = true) -> 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 {

View File

@ -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)