@@ -20,7 +20,7 @@ enum PublicPaykitError: LocalizedError {
2020}
2121
2222enum PublicPaykitPaymentLaunchResult {
23- case opened
23+ case opened( paymentRequest : String )
2424 case noEndpoint
2525 case notOpened
2626
@@ -176,13 +176,8 @@ enum PublicPaykitService {
176176 return payableEndpoints
177177 }
178178
179- @MainActor
180179 static func beginPayment(
181- to publicKey: String ,
182- app: AppViewModel ,
183- currency: CurrencyViewModel ,
184- settings: SettingsViewModel ,
185- sheets: SheetViewModel
180+ to publicKey: String
186181 ) async throws -> PublicPaykitPaymentLaunchResult {
187182 let endpoints = try await fetchPublicEndpoints ( publicKey: publicKey)
188183 let payableEndpoints = await payableEndpoints ( from: endpoints)
@@ -191,16 +186,7 @@ enum PublicPaykitService {
191186 return endpoints. isEmpty ? . noEndpoint : . notOpened
192187 }
193188
194- try await app. handleScannedData ( paymentRequest ( from: payableEndpoints) )
195-
196- guard let route = contactPaymentRoute ( app: app, currency: currency, settings: settings) else {
197- return . notOpened
198- }
199-
200- app. contactPaymentContext = ContactPaymentContext ( publicKey: publicKey)
201- sheets. showSheet ( . send, data: SendConfig ( view: route) )
202-
203- return . opened
189+ return . opened( paymentRequest: paymentRequest ( from: payableEndpoints) )
204190 }
205191
206192 static func paymentRequest( from endpoints: [ Endpoint ] ) -> String {
@@ -213,37 +199,6 @@ enum PublicPaykitService {
213199 return " bitcoin: \( onchainEndpoint. paymentRequest) ?lightning= \( bolt11Endpoint. paymentRequest) "
214200 }
215201
216- @MainActor
217- private static func contactPaymentRoute(
218- app: AppViewModel ,
219- currency: CurrencyViewModel ,
220- settings: SettingsViewModel
221- ) -> SendRoute ? {
222- guard let route = PaymentNavigationHelper . appropriateSendRoute ( app: app, currency: currency, settings: settings) else {
223- return nil
224- }
225-
226- switch route {
227- case . quickpay:
228- if app. lnurlPayData != nil {
229- return . lnurlPayAmount
230- }
231-
232- if app. scannedLightningInvoice != nil || app. scannedOnchainInvoice != nil {
233- return . amount
234- }
235-
236- return route
237- case . confirm:
238- if app. scannedLightningInvoice != nil || app. scannedOnchainInvoice != nil {
239- return . amount
240- }
241- return route
242- default :
243- return route
244- }
245- }
246-
247202 static func onchainMethodId( for address: String ) -> MethodId {
248203 let normalizedAddress = address. trimmingCharacters ( in: . whitespacesAndNewlines) . lowercased ( )
249204
0 commit comments