mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Wallet: fixed ton:// links
This commit is contained in:
parent
16928cdb85
commit
5b85b9dffa
@ -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>
|
||||||
|
@ -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>
|
||||||
|
@ -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 "public.file-url" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard" ||
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.vcard" ||
|
||||||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass"
|
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass"
|
||||||
).@count == $extensionItem.attachments.@count
|
).@count == $extensionItem.attachments.@count
|
||||||
).@count > 0</string>
|
).@count > 0</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -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>
|
||||||
|
@ -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>
|
||||||
|
@ -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>
|
||||||
|
@ -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>
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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?
|
||||||
|
@ -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 {
|
||||||
|
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user