gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 114/204: Pay


From: gnunet
Subject: [taler-taler-ios] 114/204: Pay
Date: Thu, 05 Dec 2024 23:51:22 +0100

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit 36e1f7903b6cc8409208b1e5f1c6df52e55ba03e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Nov 8 21:52:20 2024 +0100

    Pay
---
 TalerWallet1/Model/Model+Payment.swift             | 34 ++++++++++++----------
 .../Views/Sheets/Payment/PayTemplateV.swift        |  8 +++--
 .../Views/Sheets/Payment/PaymentDone.swift         |  2 +-
 .../Views/Sheets/Payment/PaymentView.swift         |  8 ++---
 4 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/TalerWallet1/Model/Model+Payment.swift 
b/TalerWallet1/Model/Model+Payment.swift
index a1c29c0..7904889 100644
--- a/TalerWallet1/Model/Model+Payment.swift
+++ b/TalerWallet1/Model/Model+Payment.swift
@@ -137,13 +137,18 @@ struct ExchangeFeeGapEstimate: Codable {
     let maxEffectiveSpendAmount: Amount
 }
 
+struct PerScopeDetails: Codable {
+    let scopeInfo: ScopeInfo
+}
 /// The result from PreparePayForUri
 struct PreparePayResult: Codable {
     let status: PreparePayResultType
     let transactionId: String
     let contractTerms: MerchantContractTerms
     let scopes: [ScopeInfo]
+//  let detailsPerScope: [ScopeInfo : PreparePayDetails]
     let amountRaw: Amount
+
     let amountEffective: Amount?                                // only if 
status != insufficientBalance
     let paid: Bool?                                             // only if 
status == alreadyConfirmed
     let talerUri: String?
@@ -234,7 +239,7 @@ struct ConfirmPayResult: Decodable {
     var transactionId: String
 }
 /// A request to get an exchange's payment details.
-fileprivate struct confirmPayForUri: WalletBackendFormattedRequest {
+fileprivate struct ConfirmPayForUri: WalletBackendFormattedRequest {
     typealias Response = ConfirmPayResult
     func operation() -> String { "confirmPay" }
     func args() -> Args { Args(transactionId: transactionId) }
@@ -247,32 +252,31 @@ fileprivate struct confirmPayForUri: 
WalletBackendFormattedRequest {
 // MARK: -
 extension WalletModel {
     /// load payment details. Networking involved
-    @MainActor
-    func preparePayForUriM(_ talerPayUri: String, viewHandles: Bool = false)   
    // M for MainActor
-      async throws -> PreparePayResult {
-          let request = PreparePayForUri(talerPayUri: talerPayUri)
-          let response = try await sendRequest(request, ASYNCDELAY, 
viewHandles: viewHandles)
-          return response
-    }
-    @MainActor
-    func checkPayForTemplateM(_ talerPayTemplateUri: String, viewHandles: Bool 
= false)       // M for MainActor
+    nonisolated func checkPayForTemplate(_ talerPayTemplateUri: String, 
viewHandles: Bool = false)
       async throws -> WalletTemplateDetails {
         let request = CheckPayForTemplate(talerPayTemplateUri: 
talerPayTemplateUri)
         let response = try await sendRequest(request, ASYNCDELAY, viewHandles: 
viewHandles)
         return response
     }
-    @MainActor
-    func preparePayForTemplateM(_ talerPayTemplateUri: String, amount: 
Amount?, summary: String?, viewHandles: Bool = false)       // M for MainActor
+
+    nonisolated func preparePayForTemplate(_ talerPayTemplateUri: String, 
amount: Amount?, summary: String?, viewHandles: Bool = false)
       async throws -> PreparePayResult {
         let templateParams = TemplateParams(amount: amount, summary: summary)
         let request = PreparePayForTemplateRequest(talerPayTemplateUri: 
talerPayTemplateUri, templateParams: templateParams)
         let response = try await sendRequest(request, ASYNCDELAY, viewHandles: 
viewHandles)
         return response
     }
-    @MainActor
-    func confirmPayM(_ transactionId: String, viewHandles: Bool = false)       
       // M for MainActor
+
+    nonisolated func preparePayForUri(_ talerPayUri: String, viewHandles: Bool 
= false)
+      async throws -> PreparePayResult {
+        let request = PreparePayForUri(talerPayUri: talerPayUri)
+        let response = try await sendRequest(request, ASYNCDELAY, viewHandles: 
viewHandles)
+        return response
+    }
+
+    nonisolated func confirmPay(_ transactionId: String, viewHandles: Bool = 
false)
       async throws -> ConfirmPayResult {
-        let request = confirmPayForUri(transactionId: transactionId)
+        let request = ConfirmPayForUri(transactionId: transactionId)
         let response = try await sendRequest(request, ASYNCDELAY, viewHandles: 
viewHandles)
         return response
     }
diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift 
b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
index e296e61..e6d246d 100644
--- a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
@@ -54,10 +54,12 @@ struct PayTemplateV: View {
     private func buttonAction2() {
         buttonSelected2 = true
     }
+
+    @MainActor
     func acceptAction(preparePayResult: PreparePayResult) {
         Task { // runs on MainActor
-            if let confirmPayResult = try? await 
model.confirmPayM(preparePayResult.transactionId) {
-                //                symLog.log(confirmPayResult as Any)
+            if let confirmPayResult = try? await 
model.confirmPay(preparePayResult.transactionId) {
+//                symLog.log(confirmPayResult as Any)
                 if confirmPayResult.type != "done" {
                     controller.playSound(0)
                     // TODO: show error
@@ -82,7 +84,7 @@ struct PayTemplateV: View {
 
     @MainActor
     private func viewDidLoad() async {
-        if let response = try? await 
model.checkPayForTemplateM(url.absoluteString) {
+        if let response = try? await 
model.checkPayForTemplate(url.absoluteString) {
             let details = response.templateDetails
             let defaults = details.editableDefaults     // might be nil, or 
its fields might be nil
                                                         // TODO: let the user 
choose a currency from supportedCurrencies[]
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
index 1fc8da1..5dcc6f0 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
@@ -25,7 +25,7 @@ struct PaymentDone: View {
 
     @MainActor
     private func viewDidLoad() async {
-        if let confirmPayResult = try? await model.confirmPayM(transactionId) {
+        if let confirmPayResult = try? await model.confirmPay(transactionId) {
 //          symLog.log(confirmPayResult as Any)
             if confirmPayResult.type == "done" {
                 paymentDone = true
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index 8534d52..69a36b5 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -115,14 +115,14 @@ struct PaymentView: View, Sendable {
     private func viewDidLoad() async {
 //        symLog.log(".task")
         if template {
-            if let templateResponse = try? await 
model.preparePayForTemplateM(url.absoluteString,
-                                                                     amount: 
amountIsEditable ? amountToTransfer : nil,
-                                                                    summary: 
summaryIsEditable ? summary : nil) {
+            if let templateResponse = try? await 
model.preparePayForTemplate(url.absoluteString,
+                                                   amount: amountIsEditable ? 
amountToTransfer : nil,
+                                                 summary: summaryIsEditable ? 
summary : nil) {
                 await checkCurrencyInfo(for: templateResponse)
                 preparePayResult = templateResponse
             }
         } else {
-            if let payResponse = try? await 
model.preparePayForUriM(url.absoluteString) {
+            if let payResponse = try? await 
model.preparePayForUri(url.absoluteString) {
                 amountToTransfer = payResponse.amountRaw
                 await checkCurrencyInfo(for: payResponse)
                 preparePayResult = payResponse

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]