gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: wallet-core: store changed KY


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: store changed KYC URL on subsequent KYC queries
Date: Wed, 15 Nov 2023 12:07:04 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 1fe13cc8a wallet-core: store changed KYC URL on subsequent KYC queries
1fe13cc8a is described below

commit 1fe13cc8a3f06cf006b826a1a4f5f387b978ee7f
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Nov 15 12:07:03 2023 +0100

    wallet-core: store changed KYC URL on subsequent KYC queries
---
 .../taler-wallet-core/src/operations/withdraw.ts   | 59 +++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index c83993816..9819ae6a9 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -727,6 +727,58 @@ enum AmlStatus {
   fronzen = 2,
 }
 
+/**
+ * Transition a withdrawal transaction with a (new) KYC URL.
+ *
+ * Emit a notification for the (self-)transition.
+ */
+async function transitionKycUrlUpdate(
+  ws: InternalWalletState,
+  withdrawalGroupId: string,
+  kycUrl: string,
+): Promise<void> {
+  let notificationKycUrl: string | undefined = undefined;
+  const transactionId = constructTransactionIdentifier({
+    tag: TransactionType.Withdrawal,
+    withdrawalGroupId,
+  });
+
+  const transitionInfo = await ws.db
+    .mktx((x) => [x.planchets, x.withdrawalGroups])
+    .runReadWrite(async (tx) => {
+      const wg2 = await tx.withdrawalGroups.get(withdrawalGroupId);
+      if (!wg2) {
+        return;
+      }
+      const oldTxState = computeWithdrawalTransactionStatus(wg2);
+      switch (wg2.status) {
+        case WithdrawalGroupStatus.PendingReady: {
+          wg2.kycUrl = kycUrl;
+          notificationKycUrl = kycUrl;
+          await tx.withdrawalGroups.put(wg2);
+          const newTxState = computeWithdrawalTransactionStatus(wg2);
+          return {
+            oldTxState,
+            newTxState,
+          };
+        }
+        default:
+          return undefined;
+      }
+    });
+  if (transitionInfo) {
+    // Always notify, even on self-transition, as the KYC URL might have 
changed.
+    ws.notify({
+      type: NotificationType.TransactionStateTransition,
+      oldTxState: transitionInfo.oldTxState,
+      newTxState: transitionInfo.newTxState,
+      transactionId,
+      experimentalUserData: notificationKycUrl,
+    });
+  }
+  ws.workAvailable.trigger();
+}
+
 async function handleKycRequired(
   ws: InternalWalletState,
   withdrawalGroup: WithdrawalGroupRecord,
@@ -1400,6 +1452,8 @@ async function processWithdrawalGroupPendingKyc(
   );
   url.searchParams.set("timeout_ms", "30000");
 
+  const withdrawalGroupId = withdrawalGroup.withdrawalGroupId;
+
   const retryTag = TaskIdentifiers.forWithdrawal(withdrawalGroup);
   runLongpollAsync(ws, retryTag, async (cancellationToken) => {
     logger.info(`long-polling for withdrawal KYC status via ${url.href}`);
@@ -1421,7 +1475,10 @@ async function processWithdrawalGroupPendingKyc(
     } else if (kycStatusRes.status === HttpStatusCode.Accepted) {
       const kycStatus = await kycStatusRes.json();
       logger.info(`kyc status: ${j2s(kycStatus)}`);
-      // FIXME: do we need to update the KYC url, or does it always stay 
constant?
+      const kycUrl = kycStatus.kyc_url;
+      if (typeof kycUrl === "string") {
+        await transitionKycUrlUpdate(ws, withdrawalGroupId, kycUrl);
+      }
       return { ready: false };
     } else if (
       kycStatusRes.status === HttpStatusCode.UnavailableForLegalReasons

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