gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (1e5abb5b2 -> 66e1529f0)


From: gnunet
Subject: [taler-wallet-core] branch master updated (1e5abb5b2 -> 66e1529f0)
Date: Fri, 01 Dec 2023 16:18:52 +0100

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

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

    from 1e5abb5b2 exchange account info
     new dbfa3b78b also query for the currency spec
     new 66e1529f0 show conversion service in withdrawal details

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:
 .../taler-wallet-core/src/operations/withdraw.ts   |  11 ++
 .../src/components/BankDetailsByPaytoType.tsx      | 121 ++++++++++++++-------
 .../src/wallet/Transaction.stories.tsx             |   6 +
 3 files changed, 97 insertions(+), 41 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 868ac3adc..24e8d3f8f 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -29,6 +29,7 @@ import {
   BankWithdrawDetails,
   CancellationToken,
   CoinStatus,
+  CurrencySpecification,
   DenomKeyType,
   DenomSelectionState,
   Duration,
@@ -61,6 +62,7 @@ import {
   canonicalizeBaseUrl,
   codecForBankWithdrawalOperationPostResponse,
   codecForCashinConversionResponse,
+  codecForConversionBankConfig,
   codecForExchangeWithdrawBatchResponse,
   codecForIntegrationBankConfig,
   codecForReserveStatus,
@@ -2600,6 +2602,7 @@ async function fetchWithdrawalAccountInfo(
   for (let acct of exchangeDetails.wireInfo.accounts) {
     let paytoUri: string;
     let transferAmount: AmountString | undefined = undefined;
+    let currencySpecification: CurrencySpecification | undefined = undefined;
     if (acct.conversion_url != null) {
       const reqUrl = new URL("cashin-rate", acct.conversion_url);
       reqUrl.searchParams.set(
@@ -2613,6 +2616,13 @@ async function fetchWithdrawalAccountInfo(
       );
       paytoUri = acct.payto_uri;
       transferAmount = resp.amount_debit;
+      const configUrl = new URL("config", acct.conversion_url);
+      const configResp = await ws.http.fetch(configUrl.href);
+      const configParsed = await readSuccessResponseJsonOrThrow(
+        configResp,
+        codecForConversionBankConfig(),
+      );
+      currencySpecification = configParsed.fiat_currency_specification
       if (req.reservePub) {
       }
     } else {
@@ -2630,6 +2640,7 @@ async function fetchWithdrawalAccountInfo(
     const acctInfo: WithdrawalExchangeAccountDetails = {
       paytoUri,
       transferAmount,
+      currencySpecification,
       creditRestrictions: acct.credit_restrictions,
     };
     if (transferAmount != null) {
diff --git 
a/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx 
b/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
index a28c34987..9fd117b08 100644
--- 
a/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
+++ 
b/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
@@ -26,11 +26,12 @@ import {
 import {
   useTranslationContext
 } from "@gnu-taler/web-util/browser";
-import { Fragment, h, VNode } from "preact";
+import { ComponentChildren, Fragment, h, VNode } from "preact";
 import { useEffect, useRef, useState } from "preact/hooks";
 import { CopiedIcon, CopyIcon } from "../svg/index.js";
 import { Amount } from "./Amount.js";
 import { ButtonBox, TooltipLeft, WarningBox } from "./styled/index.js";
+import { Button } from "../mui/Button.js";
 
 export interface BankDetailsProps {
   subject: string;
@@ -44,19 +45,68 @@ export function BankDetailsByPaytoType({
   accounts,
 }: BankDetailsProps): VNode {
   const { i18n } = useTranslationContext();
-
+  const [index, setIndex] = useState(0)
+  const [currency, setCurrency] = useState(amount.currency)
   if (!accounts.length) {
-    return <div>exchange doesn't have accounts to wire </div>
+    return <div>the exchange account list is empty</div>
   }
-  const [index, setIndex] = useState(0)
-  const fisrtAccount = accounts[index];
+  const selectedAccount = accounts[index];
+  const altCurrency = selectedAccount.currencySpecification?.name
 
-  const payto = parsePaytoUri(fisrtAccount.paytoUri);
+  const payto = parsePaytoUri(selectedAccount.paytoUri);
 
   if (!payto) return <Fragment />;
-  payto.params["amount"] = Amounts.stringify(amount);
+  payto.params["amount"] = currency === altCurrency ? 
selectedAccount.transferAmount! :Amounts.stringify(amount) ;
   payto.params["message"] = subject;
 
+
+  function Frame({ title, children }: { title: TranslatedString, children: 
ComponentChildren }): VNode {
+    return <section
+      style={{
+        textAlign: "left",
+        border: "solid 1px black",
+        padding: 8,
+        borderRadius: 4,
+      }}
+    >
+      <div style={{ display: "flex", width: "100%", justifyContent: 
"space-between" }}>
+        <p style={{ marginTop: 0 }}>
+          {title}
+        </p>
+        {accounts.length > 1 ?
+          <Button variant="contained"
+            onClick={async () => {
+              setIndex((index + 1) % accounts.length)
+            }}
+          >
+            <i18n.Translate>Next</i18n.Translate>
+          </Button>
+          : undefined}
+      </div>
+
+      {children}
+
+      {altCurrency ?
+        <Fragment>
+          <Button variant={currency === amount.currency ? "contained" : 
"outlined"}
+            onClick={async () => {
+              setCurrency(amount.currency)
+            }}
+          >
+            <i18n.Translate>{amount.currency}</i18n.Translate>
+          </Button>
+          <Button variant={currency === altCurrency ? "contained" : "outlined"}
+            onClick={async () => {
+              setCurrency(altCurrency)
+            }}
+          >
+            <i18n.Translate>{altCurrency}</i18n.Translate>
+          </Button>
+        </Fragment>
+        : undefined}
+    </section>
+  }
+
   if (payto.isKnown && payto.targetType === "bitcoin") {
     const min = segwitMinAmount(amount.currency);
     const addrs = payto.segwitAddrs.map(
@@ -65,17 +115,7 @@ export function BankDetailsByPaytoType({
     addrs.unshift(`${payto.targetPath} ${Amounts.stringifyValue(amount)}`);
     const copyContent = addrs.join("\n");
     return (
-      <section
-        style={{
-          textAlign: "left",
-          border: "solid 1px black",
-          padding: 8,
-          borderRadius: 4,
-        }}
-      >
-        <p style={{ marginTop: 0 }}>
-          <i18n.Translate>Bitcoin transfer details</i18n.Translate>
-        </p>
+      <Frame title={i18n.str`Bitcoin transfer details`}>
         <p>
           <i18n.Translate>
             The exchange need a transaction with 3 output, one output is the
@@ -115,7 +155,7 @@ export function BankDetailsByPaytoType({
             BTC, else you have to change the base unit to BTC
           </i18n.Translate>
         </p>
-      </section>
+      </Frame>
     );
   }
 
@@ -137,31 +177,30 @@ export function BankDetailsByPaytoType({
 
   const receiver = payto.params["receiver"] || undefined;
   return (
-    <section>
+    <Frame title={i18n.str`Bank transfer details`}>
+      <table>
+        {accountPart}
+        {currency === altCurrency ? <Fragment>
+          <Row
+            name={i18n.str`Amount`}
+            value={<Amount value={selectedAccount.transferAmount!} />}
+          />
+          <Row
+            name={i18n.str`Converted`}
+            value={<Amount value={amount} />}
+          />
 
-      <div
-        style={{
-          textAlign: "left",
-          border: "solid 1px black",
-          padding: 8,
-          borderRadius: 4,
-        }}
-      >
-        <p style={{ marginTop: 0 }}>
-          <i18n.Translate>Bank transfer details</i18n.Translate>
-        </p>
-        <table>
-          {accountPart}
+        </Fragment> :
           <Row
             name={i18n.str`Amount`}
-            value={<Amount value={amount} hideCurrency />}
+            value={<Amount value={amount} />}
           />
-          <Row name={i18n.str`Subject`} value={subject} literal />
-          {receiver ? (
-            <Row name={i18n.str`Receiver name`} value={receiver} />
-          ) : undefined}
-        </table>
-      </div>
+        }
+        <Row name={i18n.str`Subject`} value={subject} literal />
+        {receiver ? (
+          <Row name={i18n.str`Receiver name`} value={receiver} />
+        ) : undefined}
+      </table>
       <table>
         <tbody>
           <tr>
@@ -196,7 +235,7 @@ export function BankDetailsByPaytoType({
           </i18n.Translate>
         </WarningBox>
       </p>
-    </section>
+    </Frame>
   );
 }
 
diff --git 
a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx 
b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
index 09f7c4dc1..c17d15b01 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
@@ -293,6 +293,12 @@ export const WithdrawPendingManual = tests.createExample(
         type: WithdrawalType.ManualTransfer,
         exchangePaytoUris: ["payto://iban/ES8877998399652238"],
         reservePub: "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG",
+        exchangeCreditAccountDetails: [{
+          paytoUri: "payto://IBAN/1231231231",
+        },
+        {
+          paytoUri: "payto://IBAN/2342342342",
+        }],
       } as WithdrawalDetails,
       txState: {
         major: TransactionMajorState.Pending,

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