gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 07/36: Amount(currency:cent:)


From: gnunet
Subject: [taler-taler-ios] 07/36: Amount(currency:cent:)
Date: Mon, 13 Nov 2023 21:27:12 +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 93bdf944d63ad9c26c05ddded2feecb62c02c218
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sun Nov 12 08:53:31 2023 +0100

    Amount(currency:cent:)
---
 TalerWallet1/Views/Balances/BalanceRowView.swift        |  4 ++--
 TalerWallet1/Views/Balances/BalancesSectionView.swift   |  2 +-
 TalerWallet1/Views/Balances/PendingRowView.swift        |  4 ++--
 TalerWallet1/Views/Exchange/ExchangeRowView.swift       |  2 +-
 TalerWallet1/Views/Exchange/ExchangeSectionView.swift   |  2 +-
 TalerWallet1/Views/Exchange/ManualWithdraw.swift        |  4 ++--
 TalerWallet1/Views/HelperViews/AmountRowV.swift         |  4 ++--
 TalerWallet1/Views/Peer2peer/SendDoneV.swift            |  2 +-
 TalerWallet1/Views/Sheets/Payment/PaymentView.swift     | 10 +++++-----
 TalerWallet1/Views/Transactions/ManualDetailsV.swift    |  4 ++--
 TalerWallet1/Views/Transactions/ThreeAmountsV.swift     |  4 ++--
 .../Views/Transactions/TransactionDetailView.swift      |  2 +-
 .../Views/Transactions/TransactionRowView.swift         | 17 +++++------------
 13 files changed, 27 insertions(+), 34 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift 
b/TalerWallet1/Views/Balances/BalanceRowView.swift
index 2fb15ae..1ce34c8 100644
--- a/TalerWallet1/Views/Balances/BalanceRowView.swift
+++ b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -103,8 +103,8 @@ struct SomeBalanceRows: View {
     var body: some View {
         let testInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 0)
         let demoInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 2)
-        let test = try! Amount(fromString: TESTCURRENCY + ":1.23")
-        let demo = try! Amount(fromString: DEMOCURRENCY + ":123.12")
+        let test = Amount(currency: TESTCURRENCY, cent: 123)
+        let demo = Amount(currency: DEMOCURRENCY, cent: 123456)
 //        let testStr = test.string(testInfo)
 //        let demoStr = demo.string(demoInfo)
 
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift 
b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index 611d3b5..ab7f088 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -292,7 +292,7 @@ fileprivate struct BindingViewContainer: View {
 
     var body: some View {
         let scopeInfo = ScopeInfo(type: ScopeInfo.ScopeInfoType.exchange, url: 
DEMOEXCHANGE, currency: LONGCURRENCY)
-        let balance = Balance(available: try! Amount(fromString: LONGCURRENCY 
+ ":0.1"),
+        let balance = Balance(available: Amount(currency: LONGCURRENCY, 
cent:1),
                               scopeInfo: scopeInfo,
                       requiresUserInput: false,
                  hasPendingTransactions: true)
diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift 
b/TalerWallet1/Views/Balances/PendingRowView.swift
index c312006..ec06e05 100644
--- a/TalerWallet1/Views/Balances/PendingRowView.swift
+++ b/TalerWallet1/Views/Balances/PendingRowView.swift
@@ -127,8 +127,8 @@ struct PendingRowView_Previews: PreviewProvider {
     static var previews: some View {
         let testInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 0)
         let demoInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 2)
-        let test = try! Amount(fromString: TESTCURRENCY + ":1.23")
-        let demo = try! Amount(fromString: DEMOCURRENCY + ":1234.56")
+        let test = Amount(currency: TESTCURRENCY, cent: 123)
+        let demo = Amount(currency: DEMOCURRENCY, cent: 123456)
         List {
             PendingRowView(amount: test, currencyInfo: testInfo, incoming: 
true)
             PendingRowView(amount: demo, currencyInfo: demoInfo, incoming: 
false)
diff --git a/TalerWallet1/Views/Exchange/ExchangeRowView.swift 
b/TalerWallet1/Views/Exchange/ExchangeRowView.swift
index 0ed21cb..7343ad3 100644
--- a/TalerWallet1/Views/Exchange/ExchangeRowView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeRowView.swift
@@ -107,7 +107,7 @@ struct ExchangeRowView: View {
 fileprivate struct ExchangeRow_Container : View {
     @State private var centsToTransfer: UInt64 = 100
 
-//    let amount = try! Amount(fromString: LONGCURRENCY + ":1234.56")
+//    let amount = Amount(currency: LONGCURRENCY, cent: 123456)
     var body: some View {
         let exchange1 = Exchange(exchangeBaseUrl: ARS_AGE_EXCHANGE,
                                         currency: LONGCURRENCY,
diff --git a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift 
b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
index 6e2afab..10ad252 100644
--- a/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeSectionView.swift
@@ -38,7 +38,7 @@ struct ExchangeSectionView: View {
 fileprivate struct ExchangeRow_Container : View {
     @State private var centsToTransfer: UInt64 = 100
 
-//    let amount = try! Amount(fromString: LONGCURRENCY + ":1234.56")
+//    let amount = Amount(currency: LONGCURRENCY, cent: 123456)
     var body: some View {
         let exchange1 = Exchange(exchangeBaseUrl: ARS_AGE_EXCHANGE,
                                         currency: LONGCURRENCY,
diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift 
b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
index dc98268..7fba4e9 100644
--- a/TalerWallet1/Views/Exchange/ManualWithdraw.swift
+++ b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
@@ -99,8 +99,8 @@ struct ManualWithdraw: View {
 struct ManualWithdraw_Container : View {
     @State private var centsToTransfer: UInt64 = 510
     @State private var details = WithdrawalAmountDetails(tosAccepted: false,
-                                                           amountRaw: try! 
Amount(fromString: LONGCURRENCY + ":5.1"),
-                                                     amountEffective: try! 
Amount(fromString: LONGCURRENCY + ":5.0"),
+                                                           amountRaw: 
Amount(currency: LONGCURRENCY, cent: 510),
+                                                     amountEffective: 
Amount(currency: LONGCURRENCY, cent: 500),
                                                            paytoUris: [],
                                                ageRestrictionOptions: [],
                                                             numCoins: 6)
diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift 
b/TalerWallet1/Views/HelperViews/AmountRowV.swift
index ac741f9..eda77f1 100644
--- a/TalerWallet1/Views/HelperViews/AmountRowV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountRowV.swift
@@ -54,8 +54,8 @@ struct SectionWithAmountRow: View {
     var body: some View {
         let testInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 0)
         let demoInfo = PreviewCurrencyInfo(DEMOCURRENCY, digits: 2)
-        let test = try! Amount(fromString: TESTCURRENCY + ":1.23")
-        let demo = try! Amount(fromString: DEMOCURRENCY + ":1234.12")
+        let test = Amount(currency: TESTCURRENCY, cent: 123)
+        let demo = Amount(currency: DEMOCURRENCY, cent: 123456)
         let testStr = test.string(testInfo)
         let demoStr = demo.string(demoInfo)
         List {
diff --git a/TalerWallet1/Views/Peer2peer/SendDoneV.swift 
b/TalerWallet1/Views/Peer2peer/SendDoneV.swift
index 84b31ee..7584b3f 100644
--- a/TalerWallet1/Views/Peer2peer/SendDoneV.swift
+++ b/TalerWallet1/Views/Peer2peer/SendDoneV.swift
@@ -97,7 +97,7 @@ struct SendDoneV: View {
 //    static var previews: some View {
 //        Group {
 //            SendDoneV(stack: CallStack("Preview"),
-//              amountToSend: try! Amount(fromString: LONGCURRENCY + ":4.8"),
+//               amountToSend: Amount(currency: LONGCURRENCY, cent: 480),
 //           amountToReceive: nil,
 //                   summary: "some subject/purpose",
 //                expireDays: 0)
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index 27557b7..ebb8943 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -123,9 +123,9 @@ struct PaymentURIView_Previews: PreviewProvider {
                                           summary: "summary",
                                             summaryI18n: nil,
                                           nonce: "nonce",
-                                          amount: try! Amount(fromString: 
LONGCURRENCY + ":2.2"),
+                                          amount: Amount(currency: 
LONGCURRENCY, cent: 220),
                                           payDeadline: Timestamp.tomorrow(),
-                                          maxFee: try! Amount(fromString: 
LONGCURRENCY + ":0.2"),
+                                          maxFee: Amount(currency: 
LONGCURRENCY, cent: 20),
                                           merchant: merchant,
                                           merchantPub: "merchantPub",
                                             deliveryDate: nil,
@@ -142,7 +142,7 @@ struct PaymentURIView_Previews: PreviewProvider {
                                             fulfillmentMessage: nil,
                                             fulfillmentMessageI18n: nil,
                                           wireFeeAmortization: 0,
-                                          maxWireFee: try! Amount(fromString: 
LONGCURRENCY + ":0.2"),
+                                          maxWireFee: Amount(currency: 
LONGCURRENCY, cent: 20),
                                           minimumAge: nil
 //                                          extra: extra,
 //                                          auditors: [],
@@ -152,8 +152,8 @@ struct PaymentURIView_Previews: PreviewProvider {
             transactionId: "txn:payment:012345",
             contractTerms: terms,
             contractTermsHash: "termsHash",
-            amountRaw: try! Amount(fromString: LONGCURRENCY + ":2.2"),
-            amountEffective: try! Amount(fromString: LONGCURRENCY + ":2.4"),
+            amountRaw: Amount(currency: LONGCURRENCY, cent: 220),
+            amountEffective: Amount(currency: LONGCURRENCY, cent: 240),
             balanceDetails: nil,
             paid: nil
 //        ,   talerUri: "talerURI"
diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift 
b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
index 3adceaf..44fc7cf 100644
--- a/TalerWallet1/Views/Transactions/ManualDetailsV.swift
+++ b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
@@ -85,8 +85,8 @@ struct ManualDetails_Previews: PreviewProvider {
     static var previews: some View {
         let common = TransactionCommon(type: .withdrawal,
                                     txState: TransactionState(major: .done),
-                            amountEffective: try! Amount(fromString: 
LONGCURRENCY + ":1.1"),
-                                  amountRaw: try! Amount(fromString: 
LONGCURRENCY + ":2.2"),
+                            amountEffective: Amount(currency: LONGCURRENCY, 
cent: 110),
+                                  amountRaw: Amount(currency: LONGCURRENCY, 
cent: 220),
                               transactionId: "someTxID",
                                   timestamp: Timestamp(from: 
1_666_666_000_000),
                                   txActions: [])
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift 
b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
index 2579b94..0ff8f06 100644
--- a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
+++ b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
@@ -114,8 +114,8 @@ struct ThreeAmounts_Previews: PreviewProvider {
     static var previews: some View {
         let common = TransactionCommon(type: .withdrawal,
                                     txState: TransactionState(major: .done),
-                            amountEffective: try! Amount(fromString: 
LONGCURRENCY + ":0.1"),
-                                  amountRaw: try! Amount(fromString: 
LONGCURRENCY + ":0.2"),
+                            amountEffective: Amount(currency: LONGCURRENCY, 
cent: 10),
+                                  amountRaw: Amount(currency: LONGCURRENCY, 
cent: 20),
                               transactionId: "someTxID",
                                   timestamp: Timestamp(from: 
1_666_666_000_000),
                                   txActions: [])
diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift 
b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
index aca9ae8..31e8780 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
@@ -8,7 +8,7 @@ import SymLog
 
 extension Transaction {             // for Dummys
     init(dummyCurrency: String) {
-        let amount = try! Amount(fromString: "\(dummyCurrency):0")
+        let amount = Amount.zero(currency: dummyCurrency)
         let now = Timestamp.now()
         let common = TransactionCommon(type: .dummy,
                                        txState: TransactionState(major: 
.pending),
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift 
b/TalerWallet1/Views/Transactions/TransactionRowView.swift
index f51e1c6..28925c2 100644
--- a/TalerWallet1/Views/Transactions/TransactionRowView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -116,8 +116,6 @@ struct TransactionRow_Previews: PreviewProvider {
     static var previews: some View {
         let testInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 0)
         let demoInfo = PreviewCurrencyInfo(TESTCURRENCY, digits: 2)
-        let test = try! Amount(fromString: TESTCURRENCY + ":1.23")
-        let demo = try! Amount(fromString: DEMOCURRENCY + ":1234.56")
         List {
             TransactionRowView(transaction: withdrawal, currencyInfo: testInfo)
             TransactionRowView(transaction: payment, currencyInfo: demoInfo)
@@ -127,17 +125,12 @@ struct TransactionRow_Previews: PreviewProvider {
 // MARK: -
 extension Transaction {             // for PreViews
     init(incoming: Bool, pending: Bool, id: String, time: Timestamp) {
-        let currency = LONGCURRENCY
-        let raw = currency + ":5"
-        let effective = currency + (incoming ? ":4.8"
-                                             : ":5.2")
-        let refRaw = currency + ":3"
-        let refEff = currency + ":2.8"
+        let effective = incoming ? 480 : 520
         let common = TransactionCommon(type: incoming ? .withdrawal : .payment,
                                     txState: TransactionState(major: pending ? 
TransactionMajorState.pending
                                                                              : 
TransactionMajorState.done),
-                            amountEffective: try! Amount(fromString: 
effective),
-                                  amountRaw: try! Amount(fromString: raw),
+                            amountEffective: Amount(currency: LONGCURRENCY, 
cent: UInt64(effective)),
+                                  amountRaw: Amount(currency: LONGCURRENCY, 
cent: 5),
                               transactionId: id,
                                   timestamp: time,
                                   txActions: [.abort])
@@ -159,8 +152,8 @@ extension Transaction {             // for PreViews
                                       summary: "some product summary",
                                      products: [])
             let pDetails = PaymentTransactionDetails(proposalId: "some 
proposal ID",
-                                                 totalRefundRaw: try! 
Amount(fromString: refRaw),
-                                           totalRefundEffective: try! 
Amount(fromString: refEff),
+                                                 totalRefundRaw: 
Amount(currency: LONGCURRENCY, cent: 300),
+                                           totalRefundEffective: 
Amount(currency: LONGCURRENCY, cent: 280),
                                                            info: info)
             self = .payment(PaymentTransaction(common: common, details: 
pDetails))
         }

-- 
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]