gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (e759684f -> 5e7812d6)


From: gnunet
Subject: [taler-wallet-core] branch master updated (e759684f -> 5e7812d6)
Date: Thu, 01 Sep 2022 13:42:56 +0200

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

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

    from e759684f invoice and transfer details
     new 94eeab8a more information about p2p:
     new 5e7812d6 show sharing action when the tx is not completed

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/transactionsTypes.ts       | 10 +++
 packages/taler-wallet-core/src/db.ts               | 28 +++++----
 .../src/operations/peer-to-peer.ts                 |  5 +-
 .../src/operations/transactions.ts                 | 73 ++++++++++++++++++++--
 .../src/wallet/History.stories.tsx                 |  5 +-
 .../src/wallet/Transaction.stories.tsx             | 49 ++++++++++++++-
 .../src/wallet/Transaction.tsx                     | 69 ++++++++++++++++----
 7 files changed, 206 insertions(+), 33 deletions(-)

diff --git a/packages/taler-util/src/transactionsTypes.ts 
b/packages/taler-util/src/transactionsTypes.ts
index 79c62cbc..e4b1faf2 100644
--- a/packages/taler-util/src/transactionsTypes.ts
+++ b/packages/taler-util/src/transactionsTypes.ts
@@ -187,12 +187,19 @@ export interface TransactionWithdrawal extends 
TransactionCommon {
   withdrawalDetails: WithdrawalDetails;
 }
 
+export interface PeerInfoShort {
+  expiration: TalerProtocolTimestamp | undefined;
+  summary: string | undefined;
+  completed: boolean;
+}
+
 /**
  * Credit because we were paid for a P2P invoice we created.
  */
 export interface TransactionPeerPullCredit extends TransactionCommon {
   type: TransactionType.PeerPullCredit;
 
+  info: PeerInfoShort;
   /**
    * Exchange used.
    */
@@ -220,6 +227,7 @@ export interface TransactionPeerPullCredit extends 
TransactionCommon {
 export interface TransactionPeerPullDebit extends TransactionCommon {
   type: TransactionType.PeerPullDebit;
 
+  info: PeerInfoShort;
   /**
    * Exchange used.
    */
@@ -236,6 +244,7 @@ export interface TransactionPeerPullDebit extends 
TransactionCommon {
 export interface TransactionPeerPushDebit extends TransactionCommon {
   type: TransactionType.PeerPushDebit;
 
+  info: PeerInfoShort;
   /**
    * Exchange used.
    */
@@ -263,6 +272,7 @@ export interface TransactionPeerPushDebit extends 
TransactionCommon {
 export interface TransactionPeerPushCredit extends TransactionCommon {
   type: TransactionType.PeerPushCredit;
 
+  info: PeerInfoShort;
   /**
    * Exchange used.
    */
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index 3f97be04..903dfa47 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1180,9 +1180,9 @@ export const WALLET_BACKUP_STATE_KEY = 
"walletBackupState";
  */
 export type ConfigRecord =
   | {
-      key: typeof WALLET_BACKUP_STATE_KEY;
-      value: WalletBackupConfState;
-    }
+    key: typeof WALLET_BACKUP_STATE_KEY;
+    value: WalletBackupConfState;
+  }
   | { key: "currencyDefaultsApplied"; value: boolean };
 
 export interface WalletBackupConfState {
@@ -1243,6 +1243,7 @@ export interface WgInfoBankManual {
 export interface WgInfoBankPeerPull {
   withdrawalType: WithdrawalRecordType.PeerPullCredit;
 
+  contractTerms: any;
   /**
    * Needed to quickly construct the taler:// URI for the counterparty
    * without a join.
@@ -1252,6 +1253,8 @@ export interface WgInfoBankPeerPull {
 
 export interface WgInfoBankPeerPush {
   withdrawalType: WithdrawalRecordType.PeerPushCredit;
+
+  contractTerms: any;
 }
 
 export interface WgInfoBankRecoup {
@@ -1445,17 +1448,17 @@ export enum BackupProviderStateTag {
 
 export type BackupProviderState =
   | {
-      tag: BackupProviderStateTag.Provisional;
-    }
+    tag: BackupProviderStateTag.Provisional;
+  }
   | {
-      tag: BackupProviderStateTag.Ready;
-      nextBackupTimestamp: TalerProtocolTimestamp;
-    }
+    tag: BackupProviderStateTag.Ready;
+    nextBackupTimestamp: TalerProtocolTimestamp;
+  }
   | {
-      tag: BackupProviderStateTag.Retrying;
-      retryInfo: RetryInfo;
-      lastError?: TalerErrorDetail;
-    };
+    tag: BackupProviderStateTag.Retrying;
+    retryInfo: RetryInfo;
+    lastError?: TalerErrorDetail;
+  };
 
 export interface BackupProviderTerms {
   supportedProtocolVersion: string;
@@ -1630,6 +1633,7 @@ export interface PeerPushPaymentInitiationRecord {
 
   amount: AmountString;
 
+  contractTerms: any;
   /**
    * Purse public key.  Used as the primary key to look
    * up this record.
diff --git a/packages/taler-wallet-core/src/operations/peer-to-peer.ts 
b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
index 88bfecd3..27525808 100644
--- a/packages/taler-wallet-core/src/operations/peer-to-peer.ts
+++ b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
@@ -263,6 +263,7 @@ export async function initiatePeerToPeerPush(
       await tx.peerPushPaymentInitiations.add({
         amount: Amounts.stringify(instructedAmount),
         contractPriv: econtractResp.contractPriv,
+        contractTerms,
         exchangeBaseUrl: sel.exchangeBaseUrl,
         mergePriv: mergePair.priv,
         mergePub: mergePair.pub,
@@ -536,6 +537,7 @@ export async function acceptPeerPushPayment(
     amount,
     wgInfo: {
       withdrawalType: WithdrawalRecordType.PeerPushCredit,
+      contractTerms: peerInc.contractTerms,
     },
     exchangeBaseUrl: peerInc.exchangeBaseUrl,
     reserveStatus: ReserveRecordStatus.QueryingStatus,
@@ -552,7 +554,7 @@ export async function acceptPeerPushPayment(
 export async function acceptPeerPullPayment(
   ws: InternalWalletState,
   req: AcceptPeerPullPaymentRequest,
-) {
+): Promise<void> {
   const peerPullInc = await ws.db
     .mktx((x) => ({ peerPullPaymentIncoming: x.peerPullPaymentIncoming }))
     .runReadOnly(async (tx) => {
@@ -808,6 +810,7 @@ export async function initiatePeerRequestForPay(
     amount: Amounts.parseOrThrow(req.amount),
     wgInfo: {
       withdrawalType: WithdrawalRecordType.PeerPullCredit,
+      contractTerms,
       contractPriv: econtractResp.contractPriv,
     },
     exchangeBaseUrl: req.exchangeBaseUrl,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 8eff945c..11f47d8a 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -59,6 +59,8 @@ export enum TombstoneTag {
   DeleteRefreshGroup = "delete-refresh-group",
   DeleteDepositGroup = "delete-deposit-group",
   DeleteRefund = "delete-refund",
+  DeletePeerPullDebit = "delete-peer-pull-debit",
+  DeletePeerPushDebit = "delete-peer-push-debit",
 }
 
 /**
@@ -144,6 +146,7 @@ export async function getTransactions(
     .runReadOnly(async (tx) => {
       tx.peerPushPaymentInitiations.iter().forEachAsync(async (pi) => {
         const amount = Amounts.parseOrThrow(pi.amount);
+
         if (shouldSkipCurrency(transactionsRequest, amount.currency)) {
           return;
         }
@@ -155,6 +158,11 @@ export async function getTransactions(
           amountEffective: pi.amount,
           amountRaw: pi.amount,
           exchangeBaseUrl: pi.exchangeBaseUrl,
+          info: {
+            expiration: pi.contractTerms.purse_expiration,
+            summary: pi.contractTerms.summary,
+            completed: Amounts.isZero(amount),
+          },
           frozen: false,
           pending: !pi.purseCreated,
           timestamp: pi.timestampCreated,
@@ -180,6 +188,7 @@ export async function getTransactions(
         if (!pi.accepted) {
           return;
         }
+
         transactions.push({
           type: TransactionType.PeerPullDebit,
           amountEffective: Amounts.stringify(amount),
@@ -187,10 +196,15 @@ export async function getTransactions(
           exchangeBaseUrl: pi.exchangeBaseUrl,
           frozen: false,
           pending: false,
+          info: {
+            expiration: pi.contractTerms.purse_expiration,
+            summary: pi.contractTerms.summary,
+            completed: pi.paid
+          },
           timestamp: pi.timestampCreated,
           transactionId: makeEventId(
             TransactionType.PeerPullDebit,
-            pi.pursePub,
+            pi.peerPullPaymentIncomingId,
           ),
         });
       });
@@ -217,6 +231,11 @@ export async function getTransactions(
             exchangeBaseUrl: wsr.exchangeBaseUrl,
             pending: !wsr.timestampFinish,
             timestamp: wsr.timestampStart,
+            info: {
+              expiration: wsr.wgInfo.contractTerms.purse_expiration,
+              summary: wsr.wgInfo.contractTerms.summary,
+              completed: !!wsr.timestampFinish
+            },
             talerUri: constructPayPullUri({
               exchangeBaseUrl: wsr.exchangeBaseUrl,
               contractPriv: wsr.wgInfo.contractPriv,
@@ -237,6 +256,11 @@ export async function getTransactions(
             amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
             amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount),
             exchangeBaseUrl: wsr.exchangeBaseUrl,
+            info: {
+              expiration: wsr.wgInfo.contractTerms.purse_expiration,
+              summary: wsr.wgInfo.contractTerms.summary,
+              completed: !!wsr.timestampFinish,
+            },
             pending: !wsr.timestampFinish,
             timestamp: wsr.timestampStart,
             transactionId: makeEventId(
@@ -567,9 +591,9 @@ export async function deleteTransaction(
   ws: InternalWalletState,
   transactionId: string,
 ): Promise<void> {
-  const [type, ...rest] = transactionId.split(":");
-
-  if (type === TransactionType.Withdrawal) {
+  const [typeStr, ...rest] = transactionId.split(":");
+  const type = typeStr as TransactionType;
+  if (type === TransactionType.Withdrawal || type === 
TransactionType.PeerPullCredit || type === TransactionType.PeerPushCredit) {
     const withdrawalGroupId = rest[0];
     await ws.db
       .mktx((x) => ({
@@ -686,7 +710,46 @@ export async function deleteTransaction(
           });
         }
       });
+  } else if (type === TransactionType.PeerPullDebit) {
+    const peerPullPaymentIncomingId = rest[0];
+    await ws.db
+      .mktx((x) => ({
+        peerPullPaymentIncoming: x.peerPullPaymentIncoming,
+        tombstones: x.tombstones,
+      }))
+      .runReadWrite(async (tx) => {
+        const debit = await 
tx.peerPullPaymentIncoming.get(peerPullPaymentIncomingId);
+        if (debit) {
+          await tx.peerPullPaymentIncoming.delete(peerPullPaymentIncomingId);
+          await tx.tombstones.put({
+            id: makeEventId(
+              TombstoneTag.DeletePeerPullDebit,
+              peerPullPaymentIncomingId,
+            ),
+          });
+        }
+      });
+  } else if (type === TransactionType.PeerPushDebit) {
+    const pursePub = rest[0];
+    await ws.db
+      .mktx((x) => ({
+        peerPushPaymentInitiations: x.peerPushPaymentInitiations,
+        tombstones: x.tombstones,
+      }))
+      .runReadWrite(async (tx) => {
+        const debit = await tx.peerPushPaymentInitiations.get(pursePub);
+        if (debit) {
+          await tx.peerPushPaymentInitiations.delete(pursePub);
+          await tx.tombstones.put({
+            id: makeEventId(
+              TombstoneTag.DeletePeerPushDebit,
+              pursePub,
+            ),
+          });
+        }
+      });
   } else {
-    throw Error(`can't delete a '${type}' transaction`);
+    const unknownTxType: never = type;
+    throw Error(`can't delete a '${unknownTxType}' transaction`);
   }
 }
diff --git a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx 
b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
index 335d5ea9..e37711b8 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
@@ -51,9 +51,9 @@ const commonTransaction = (): TransactionCommon =>
     amountEffective: "USD:9",
     pending: false,
     timestamp: TalerProtocolTimestamp.fromSeconds(
-      new Date().getTime() - count++ * 60 * 60 * 7,
+      new Date().getTime() / 1000 - count++ * 60 * 60 * 7,
     ),
-    transactionId: "12",
+    transactionId: String(count),
   } as TransactionCommon);
 
 const exampleData = {
@@ -145,6 +145,7 @@ const exampleData = {
   pull_debit: {
     ...commonTransaction(),
     type: TransactionType.PeerPullDebit,
+
     exchangeBaseUrl: "https://exchange.taler.net";,
   } as TransactionPeerPullDebit,
 };
diff --git 
a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx 
b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
index 6c591611..acb50642 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
@@ -20,6 +20,7 @@
  */
 
 import {
+  AbsoluteTime,
   PaymentStatus,
   TalerProtocolTimestamp,
   TransactionCommon,
@@ -146,6 +147,13 @@ const exampleData = {
   push_credit: {
     ...commonTransaction,
     type: TransactionType.PeerPushCredit,
+    info: {
+      expiration: {
+        t_s: new Date().getTime() / 1000 + 2 * 60 * 60,
+      },
+      summary: "take this money",
+      completed: true,
+    },
     exchangeBaseUrl: "https://exchange.taler.net";,
   } as TransactionPeerPushCredit,
   push_debit: {
@@ -153,6 +161,13 @@ const exampleData = {
     type: TransactionType.PeerPushDebit,
     talerUri:
       
"taler://pay-push/exchange.taler.ar/HS585JK0QCXHJ8Z8QWZA3EBAY5WY7XNC1RR2MHJXSH2Z4WP0YPJ0",
+    info: {
+      expiration: {
+        t_s: new Date().getTime() / 1000 + 2 * 60 * 60,
+      },
+      summary: "take this money",
+      completed: true,
+    },
     exchangeBaseUrl: "https://exchange.taler.net";,
   } as TransactionPeerPushDebit,
   pull_credit: {
@@ -160,11 +175,25 @@ const exampleData = {
     type: TransactionType.PeerPullCredit,
     talerUri:
       
"taler://pay-push/exchange.taler.ar/HS585JK0QCXHJ8Z8QWZA3EBAY5WY7XNC1RR2MHJXSH2Z4WP0YPJ0",
+    info: {
+      expiration: {
+        t_s: new Date().getTime() / 1000 + 2 * 60 * 60,
+      },
+      summary: "pay me, please?",
+      completed: true,
+    },
     exchangeBaseUrl: "https://exchange.taler.net";,
   } as TransactionPeerPullCredit,
   pull_debit: {
     ...commonTransaction,
     type: TransactionType.PeerPullDebit,
+    info: {
+      expiration: {
+        t_s: new Date().getTime() / 1000 + 2 * 60 * 60,
+      },
+      summary: "pay me, please?",
+      completed: true,
+    },
     exchangeBaseUrl: "https://exchange.taler.net";,
   } as TransactionPeerPullDebit,
 };
@@ -527,10 +556,17 @@ export const RefundPending = 
createExample(TestedComponent, {
   transaction: { ...exampleData.refund, pending: true },
 });
 
-export const InvoiceCredit = createExample(TestedComponent, {
+export const InvoiceCreditComplete = createExample(TestedComponent, {
   transaction: { ...exampleData.pull_credit },
 });
 
+export const InvoiceCreditIncomplete = createExample(TestedComponent, {
+  transaction: {
+    ...exampleData.pull_credit,
+    info: { ...exampleData.pull_credit.info, completed: false },
+  },
+});
+
 export const InvoiceDebit = createExample(TestedComponent, {
   transaction: { ...exampleData.pull_debit },
 });
@@ -539,6 +575,15 @@ export const TransferCredit = 
createExample(TestedComponent, {
   transaction: { ...exampleData.push_credit },
 });
 
-export const TransferDebit = createExample(TestedComponent, {
+export const TransferDebitComplete = createExample(TestedComponent, {
   transaction: { ...exampleData.push_debit },
 });
+export const TransferDebitIncomplete = createExample(TestedComponent, {
+  transaction: {
+    ...exampleData.push_debit,
+    info: {
+      ...exampleData.push_debit.info,
+      completed: false,
+    },
+  },
+});
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx 
b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
index c8c4e3ae..44543c2c 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -115,6 +115,9 @@ export function TransactionPage({ tid, goToWalletHistory }: 
Props): VNode {
   return (
     <TransactionView
       transaction={state.response}
+      onSend={async () => {
+        null;
+      }}
       onDelete={() =>
         wxApi.deleteTransaction(tid).then(() => goToWalletHistory(currency))
       }
@@ -129,6 +132,7 @@ export function TransactionPage({ tid, goToWalletHistory }: 
Props): VNode {
 
 export interface WalletTransactionProps {
   transaction: Transaction;
+  onSend: () => Promise<void>;
   onDelete: () => Promise<void>;
   onRetry: () => Promise<void>;
   onRefund: (id: string) => Promise<void>;
@@ -147,6 +151,7 @@ export function TransactionView({
   transaction,
   onDelete,
   onRetry,
+  onSend,
   onRefund,
 }: WalletTransactionProps): VNode {
   const [confirmBeforeForget, setConfirmBeforeForget] = useState(false);
@@ -169,6 +174,10 @@ export function TransactionView({
   }: {
     children: ComponentChildren;
   }): VNode {
+    const showSend =
+      (transaction.type === TransactionType.PeerPullCredit ||
+        transaction.type === TransactionType.PeerPushDebit) &&
+      !transaction.info.completed;
     const showRetry =
       transaction.error !== undefined ||
       transaction.timestamp.t_s === "never" ||
@@ -194,7 +203,13 @@ export function TransactionView({
         </section>
         <section>{children}</section>
         <footer>
-          <div />
+          <div>
+            {showSend ? (
+              <Button variant="contained" onClick={onSend}>
+                <i18n.Translate>Send</i18n.Translate>
+              </Button>
+            ) : null}
+          </div>
           <div>
             {showRetry ? (
               <Button variant="contained" onClick={onRetry}>
@@ -597,16 +612,25 @@ export function TransactionView({
           Invoice
         </Header>
 
+        {transaction.info.summary ? (
+          <Part
+            title={<i18n.Translate>Subject</i18n.Translate>}
+            text={transaction.info.summary}
+            kind="neutral"
+          />
+        ) : undefined}
         <Part
           title={<i18n.Translate>Exchange</i18n.Translate>}
           text={transaction.exchangeBaseUrl}
           kind="neutral"
         />
-        <Part
-          title={<i18n.Translate>URI</i18n.Translate>}
-          text={<ShowQrWithCopy text={transaction.talerUri} />}
-          kind="neutral"
-        />
+        {!transaction.info.completed && (
+          <Part
+            title={<i18n.Translate>URI</i18n.Translate>}
+            text={<ShowQrWithCopy text={transaction.talerUri} />}
+            kind="neutral"
+          />
+        )}
         <Part
           title={<i18n.Translate>Details</i18n.Translate>}
           text={
@@ -635,6 +659,13 @@ export function TransactionView({
           Invoice
         </Header>
 
+        {transaction.info.summary ? (
+          <Part
+            title={<i18n.Translate>Subject</i18n.Translate>}
+            text={transaction.info.summary}
+            kind="neutral"
+          />
+        ) : undefined}
         <Part
           title={<i18n.Translate>Exchange</i18n.Translate>}
           text={transaction.exchangeBaseUrl}
@@ -667,16 +698,25 @@ export function TransactionView({
           Transfer
         </Header>
 
+        {transaction.info.summary ? (
+          <Part
+            title={<i18n.Translate>Subject</i18n.Translate>}
+            text={transaction.info.summary}
+            kind="neutral"
+          />
+        ) : undefined}
         <Part
           title={<i18n.Translate>Exchange</i18n.Translate>}
           text={transaction.exchangeBaseUrl}
           kind="neutral"
         />
-        <Part
-          title={<i18n.Translate>URI</i18n.Translate>}
-          text={<QR text={transaction.talerUri} />}
-          kind="neutral"
-        />
+        {!transaction.info.completed && (
+          <Part
+            title={<i18n.Translate>URI</i18n.Translate>}
+            text={<ShowQrWithCopy text={transaction.talerUri} />}
+            kind="neutral"
+          />
+        )}
         <Part
           title={<i18n.Translate>Details</i18n.Translate>}
           text={
@@ -705,6 +745,13 @@ export function TransactionView({
           Transfer
         </Header>
 
+        {transaction.info.summary ? (
+          <Part
+            title={<i18n.Translate>Subject</i18n.Translate>}
+            text={transaction.info.summary}
+            kind="neutral"
+          />
+        ) : undefined}
         <Part
           title={<i18n.Translate>Exchange</i18n.Translate>}
           text={transaction.exchangeBaseUrl}

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