mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix wallet url decoding and opening in peer info
This commit is contained in:
parent
a6791dcbd3
commit
0d5326959c
@ -330,6 +330,6 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
|
||||
dismissInput()
|
||||
context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in
|
||||
navigationController?.pushViewController(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,10 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate
|
||||
controller.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: { peerId in
|
||||
openResolvedPeerImpl(peerId, .chat(textInputState: nil, subject: nil))
|
||||
}), in: .window(.root))
|
||||
case let .wallet(address, amount, comment):
|
||||
context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in
|
||||
(controller.navigationController as? NavigationController)?.pushViewController(c)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -18,14 +18,16 @@ public func parseWalletUrl(_ url: URL) -> ParsedWalletUrl? {
|
||||
guard url.scheme == "ton" && url.host == "transfer" else {
|
||||
return nil
|
||||
}
|
||||
let updatedUrl = URL(string: url.absoluteString.replacingOccurrences(of: "+", with: "%20"), relativeTo: nil) ?? url
|
||||
|
||||
var address: String?
|
||||
let path = url.path.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
|
||||
let path = updatedUrl.path.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
|
||||
if isValidWalletAddress(path) {
|
||||
address = path
|
||||
}
|
||||
var amount: Int64?
|
||||
var comment: String?
|
||||
if let query = url.query, let components = URLComponents(string: "/?" + query), let queryItems = components.queryItems {
|
||||
if let query = updatedUrl.query, let components = URLComponents(string: "/?" + query), let queryItems = components.queryItems {
|
||||
for queryItem in queryItems {
|
||||
if let value = queryItem.value {
|
||||
if queryItem.name == "amount", !value.isEmpty, let amountValue = Int64(value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user