gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (f94d7bc15 -> 0425b92dd)


From: gnunet
Subject: [taler-wallet-core] branch master updated (f94d7bc15 -> 0425b92dd)
Date: Tue, 25 Apr 2023 23:58:20 +0200

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

dold pushed a change to branch master
in repository wallet-core.

    from f94d7bc15 adding user_Type validation when updating instances
     new fd86791e4 -DD37 wip
     new 0425b92dd wallet-core: adjust to breaking merchant API change

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-util/src/transactions-types.ts      |  6 ++
 packages/taler-wallet-core/src/db.ts               | 12 ++++
 .../src/operations/pay-merchant.ts                 | 12 +++-
 .../src/operations/transactions.ts                 | 35 ++++++------
 .../taler-wallet-core/src/operations/withdraw.ts   | 64 +++++++++++++++++++++-
 5 files changed, 111 insertions(+), 18 deletions(-)

diff --git a/packages/taler-util/src/transactions-types.ts 
b/packages/taler-util/src/transactions-types.ts
index 017e54e0a..a5fc6c070 100644
--- a/packages/taler-util/src/transactions-types.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -89,6 +89,7 @@ export enum TransactionMajorState {
   Aborting = "aborting",
   Aborted = "aborted",
   Suspended = "suspended",
+  SuspendedAborting = "suspended-aborting",
   Failed = "failed",
   // Only used for the notification, never in the transaction history
   Deleted = "deleted",
@@ -105,6 +106,11 @@ export enum TransactionMinorState {
   Refresh = "refresh",
   Pickup = "pickup",
   User = "user",
+  Bank = "bank",
+  BankRegisterReserve = "bank-register-reserve",
+  BankConfirmTransfer = "bank-confirm-transfer",
+  WithdrawCoins = "withdraw-coins",
+  ExchangeWaitReserve = "exchange-wait-reserve",
 }
 
 export interface TransactionsResponse {
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index 9b250cede..cff874508 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -165,6 +165,12 @@ export enum WithdrawalGroupStatus {
    */
   Ready = 13,
 
+  /**
+   * We are telling the bank that we don't want to complete
+   * the withdrawal!
+   */
+  AbortingBank = 14,
+
   /**
    * The corresponding withdraw record has been created.
    * No further processing is done, unless explicitly requested
@@ -176,6 +182,12 @@ export enum WithdrawalGroupStatus {
    * The bank aborted the withdrawal.
    */
   BankAborted = 51,
+
+  SuspendedRegisteringBank = 52,
+  SuspendedWaitConfirmBank = 53,
+  SuspendedQueryingStatus = 54,
+  SuspendedReady = 55,
+  SuspendedAbortingBank = 55,
 }
 
 /**
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts 
b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index e79314416..e6ade08aa 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -71,6 +71,7 @@ import {
   TalerErrorDetail,
   TalerProtocolTimestamp,
   TalerProtocolViolationError,
+  TransactionState,
   TransactionType,
   URL,
 } from "@gnu-taler/taler-util";
@@ -1552,7 +1553,10 @@ export async function processPurchasePay(
       ws.http.postJson(payAgainUrl, reqBody),
     );
     logger.trace(`/paid response status: ${resp.status}`);
-    if (resp.status !== 204) {
+    if (
+      resp.status !== HttpStatusCode.NoContent &&
+      resp.status != HttpStatusCode.Ok
+    ) {
       throw TalerError.fromDetail(
         TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,
         getHttpResponseErrorDetails(resp),
@@ -2472,3 +2476,9 @@ export async function abortPay(
     });
   });
 }
+
+export function computeWithdrawalTransactionStatus(
+  purchaseRecord: PurchaseRecord,
+): TransactionState {
+  throw Error("not implemented");
+}
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 674d4959c..cacc179f2 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -95,6 +95,7 @@ import { processRefreshGroup } from "./refresh.js";
 import { computeTipTransactionStatus, processTip } from "./tip.js";
 import {
   augmentPaytoUrisForWithdrawal,
+  computeWithdrawalTransactionStatus,
   processWithdrawalGroup,
 } from "./withdraw.js";
 
@@ -643,35 +644,35 @@ function buildTransactionForPeerPushCredit(
 }
 
 function buildTransactionForBankIntegratedWithdraw(
-  wsr: WithdrawalGroupRecord,
+  wgRecord: WithdrawalGroupRecord,
   ort?: OperationRetryRecord,
 ): Transaction {
-  if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated)
+  if (wgRecord.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated)
     throw Error("");
 
   return {
     type: TransactionType.Withdrawal,
-    txState: mkTxStateUnknown(),
-    amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
-    amountRaw: Amounts.stringify(wsr.instructedAmount),
+    txState: computeWithdrawalTransactionStatus(wgRecord),
+    amountEffective: Amounts.stringify(wgRecord.denomsSel.totalCoinValue),
+    amountRaw: Amounts.stringify(wgRecord.instructedAmount),
     withdrawalDetails: {
       type: WithdrawalType.TalerBankIntegrationApi,
-      confirmed: wsr.wgInfo.bankInfo.timestampBankConfirmed ? true : false,
-      reservePub: wsr.reservePub,
-      bankConfirmationUrl: wsr.wgInfo.bankInfo.confirmUrl,
+      confirmed: wgRecord.wgInfo.bankInfo.timestampBankConfirmed ? true : 
false,
+      reservePub: wgRecord.reservePub,
+      bankConfirmationUrl: wgRecord.wgInfo.bankInfo.confirmUrl,
       reserveIsReady:
-        wsr.status === WithdrawalGroupStatus.Finished ||
-        wsr.status === WithdrawalGroupStatus.Ready,
+        wgRecord.status === WithdrawalGroupStatus.Finished ||
+        wgRecord.status === WithdrawalGroupStatus.Ready,
     },
-    exchangeBaseUrl: wsr.exchangeBaseUrl,
-    extendedStatus: wsr.timestampFinish
+    exchangeBaseUrl: wgRecord.exchangeBaseUrl,
+    extendedStatus: wgRecord.timestampFinish
       ? ExtendedStatus.Done
       : ExtendedStatus.Pending,
-    pending: !wsr.timestampFinish,
-    timestamp: wsr.timestampStart,
+    pending: !wgRecord.timestampFinish,
+    timestamp: wgRecord.timestampStart,
     transactionId: makeTransactionId(
       TransactionType.Withdrawal,
-      wsr.withdrawalGroupId,
+      wgRecord.withdrawalGroupId,
     ),
     frozen: false,
     ...(ort?.lastError ? { error: ort.lastError } : {}),
@@ -697,7 +698,7 @@ function buildTransactionForManualWithdraw(
 
   return {
     type: TransactionType.Withdrawal,
-    txState: mkTxStateUnknown(),
+    txState: computeWithdrawalTransactionStatus(withdrawalGroup),
     amountEffective: Amounts.stringify(
       withdrawalGroup.denomsSel.totalCoinValue,
     ),
@@ -1238,10 +1239,12 @@ export async function getTransactions(
           case WithdrawalRecordType.PeerPullCredit:
             // Will be reported by the corresponding p2p transaction.
             // FIXME: If this is an orphan withdrawal, still report it as a 
withdrawal!
+            // FIXME: Still report if requested with verbose option?
             return;
           case WithdrawalRecordType.PeerPushCredit:
             // Will be reported by the corresponding p2p transaction.
             // FIXME: If this is an orphan withdrawal, still report it as a 
withdrawal!
+            // FIXME: Still report if requested with verbose option?
             return;
           case WithdrawalRecordType.BankIntegrated:
             transactions.push(
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 23c3e6713..6d5644b06 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -40,7 +40,6 @@ import {
   DenomKeyType,
   DenomSelectionState,
   Duration,
-  durationFromSpec,
   encodeCrock,
   ExchangeListItem,
   ExchangeWithdrawalDetails,
@@ -64,6 +63,9 @@ import {
   WithdrawUriInfoResponse,
   ExchangeBatchWithdrawRequest,
   WalletNotification,
+  TransactionState,
+  TransactionMajorState,
+  TransactionMinorState,
 } from "@gnu-taler/taler-util";
 import { EddsaKeypair } from "../crypto/cryptoImplementation.js";
 import {
@@ -133,6 +135,66 @@ import { isWithdrawableDenom } from "../index.js";
  */
 const logger = new Logger("operations/withdraw.ts");
 
+export function computeWithdrawalTransactionStatus(
+  wgRecord: WithdrawalGroupRecord,
+): TransactionState {
+  switch (wgRecord.status) {
+    case WithdrawalGroupStatus.BankAborted:
+      return {
+        major: TransactionMajorState.Aborted,
+      };
+    case WithdrawalGroupStatus.Finished:
+      return {
+        major: TransactionMajorState.Done,
+      };
+    case WithdrawalGroupStatus.RegisteringBank:
+      return {
+        major: TransactionMajorState.Pending,
+        minor: TransactionMinorState.BankRegisterReserve,
+      };
+    case WithdrawalGroupStatus.Ready:
+      return {
+        major: TransactionMajorState.Pending,
+        minor: TransactionMinorState.WithdrawCoins,
+      };
+    case WithdrawalGroupStatus.QueryingStatus:
+      return {
+        major: TransactionMajorState.Pending,
+        minor: TransactionMinorState.ExchangeWaitReserve,
+      };
+    case WithdrawalGroupStatus.WaitConfirmBank:
+      return {
+        major: TransactionMajorState.Pending,
+        minor: TransactionMinorState.BankConfirmTransfer,
+      };
+    case WithdrawalGroupStatus.AbortingBank:
+      return {
+        major: TransactionMajorState.Aborting,
+        minor: TransactionMinorState.Bank,
+      };
+    case WithdrawalGroupStatus.SuspendedAbortingBank:
+      return {
+        major: TransactionMajorState.SuspendedAborting,
+        minor: TransactionMinorState.Bank,
+      };
+    case WithdrawalGroupStatus.SuspendedQueryingStatus:
+      return {
+        major: TransactionMajorState.Suspended,
+        minor: TransactionMinorState.ExchangeWaitReserve,
+      };
+    case WithdrawalGroupStatus.SuspendedRegisteringBank:
+      return {
+        major: TransactionMajorState.Suspended,
+        minor: TransactionMinorState.BankRegisterReserve,
+      };
+    case WithdrawalGroupStatus.SuspendedWaitConfirmBank:
+      return {
+        major: TransactionMajorState.Suspended,
+        minor: TransactionMinorState.BankConfirmTransfer,
+      };
+  }
+}
+
 /**
  * Get information about a withdrawal from
  * a taler://withdraw URI by asking the bank.

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