gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (eca75bbeb -> 7b62d04f2)


From: gnunet
Subject: [taler-wallet-core] branch master updated (eca75bbeb -> 7b62d04f2)
Date: Thu, 30 Nov 2023 15:09:02 +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 eca75bbeb fix createTestingReserve to use correct URL
     new d5a46a3bc check conversion URL
     new 7b62d04f2 alt currency WIP

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/codec.ts                   | 33 ++++++++++++++++++++++
 packages/taler-util/src/taler-types.ts             |  3 +-
 .../src/cta/Withdraw/index.ts                      |  2 ++
 .../src/cta/Withdraw/state.ts                      |  6 ++--
 .../src/cta/Withdraw/stories.tsx                   | 33 ++++++++++++++++++++++
 .../src/cta/Withdraw/views.tsx                     | 18 +++++++++++-
 6 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/packages/taler-util/src/codec.ts b/packages/taler-util/src/codec.ts
index 695f3c147..670111b75 100644
--- a/packages/taler-util/src/codec.ts
+++ b/packages/taler-util/src/codec.ts
@@ -321,6 +321,39 @@ export function codecForString(): Codec<string> {
   };
 }
 
+/**
+ * Return a codec for a value that must be a string.
+ */
+export function codecForStringURL(shouldEndWithSlash?: boolean): Codec<string> 
{
+  return {
+    decode(x: any, c?: Context): string {
+      if (typeof x !== "string") {
+        throw new DecodingError(
+          `expected string at ${renderContext(c)} but got ${typeof x}`,
+        );
+      }
+      if (shouldEndWithSlash && !x.endsWith("/")) {
+        throw new DecodingError(
+          `expected URL string that ends with slash at ${renderContext(c)} but 
got ${x}`,
+        );
+      }
+      try {
+        const url = new URL(x)
+        return x;
+      } catch(e) {
+        if (e instanceof Error) {
+          throw new DecodingError(e.message)  
+        } else {
+          throw new DecodingError(
+            `expected an URL string at ${renderContext(c)} but got "${x}"`,
+          );
+        }
+
+      }
+    },
+  };
+}
+
 /**
  * Codec that allows any value.
  */
diff --git a/packages/taler-util/src/taler-types.ts 
b/packages/taler-util/src/taler-types.ts
index e32c5a99d..3b96c52fe 100644
--- a/packages/taler-util/src/taler-types.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -38,6 +38,7 @@ import {
   codecForMap,
   codecForNumber,
   codecForString,
+  codecForStringURL,
   codecOptional,
 } from "./codec.js";
 import { strcmp } from "./helpers.js";
@@ -2372,7 +2373,7 @@ export interface ExchangeWireAccount {
 
 export const codecForExchangeWireAccount = (): Codec<ExchangeWireAccount> =>
   buildCodecForObject<ExchangeWireAccount>()
-    .property("conversion_url", codecOptional(codecForString()))
+    .property("conversion_url", codecOptional(codecForStringURL()))
     .property("credit_restrictions", codecForList(codecForAny()))
     .property("debit_restrictions", codecForList(codecForAny()))
     .property("master_sig", codecForString())
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts 
b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts
index f80e5a648..3dc2b7f3d 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts
@@ -18,6 +18,7 @@ import {
   AmountJson,
   AmountString,
   ExchangeListItem,
+  WithdrawalExchangeAccountDetails,
 } from "@gnu-taler/taler-util";
 import { Loading } from "../../components/Loading.js";
 import { State as SelectExchangeState } from 
"../../hooks/useSelectedExchange.js";
@@ -91,6 +92,7 @@ export namespace State {
 
     doWithdrawal: ButtonHandler;
     doSelectExchange: ButtonHandler;
+    accounts: WithdrawalExchangeAccountDetails[];
 
     ageRestriction?: SelectFieldHandler;
 
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts 
b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
index a3855c2f4..46d221766 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -324,10 +324,11 @@ function exchangeSelectionState(
         raw: Amounts.parseOrThrow(info.amountRaw),
         effective: Amounts.parseOrThrow(info.amountEffective),
       };
-
+      
       return {
         amount: withdrawAmount,
         ageRestrictionOptions: info.ageRestrictionOptions,
+        accounts: info.withdrawalAccountList
       };
     }, []);
 
@@ -335,7 +336,7 @@ function exchangeSelectionState(
       undefined,
     );
     const [doingWithdraw, setDoingWithdraw] = useState<boolean>(false);
-
+    
     async function doWithdrawAndCheckError(): Promise<void> {
       try {
         setDoingWithdraw(true);
@@ -406,6 +407,7 @@ function exchangeSelectionState(
       doSelectExchange: selectedExchange.doSelect,
       currentExchange,
       toBeReceived,
+      accounts: amountHook.response.accounts,
       withdrawalFee,
       chosenAmount,
       talerWithdrawUri,
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx 
b/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx
index 29f7e0a30..df70a5c95 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx
@@ -64,6 +64,7 @@ export const TermsOfServiceNotYetLoaded = 
tests.createExample(SuccessView, {
     fraction: 0,
     value: 1,
   },
+  accounts: [],
 });
 
 export const WithSomeFee = tests.createExample(SuccessView, {
@@ -90,6 +91,7 @@ export const WithSomeFee = tests.createExample(SuccessView, {
     value: 1,
   },
   doSelectExchange: {},
+  accounts: [],
 });
 
 export const WithoutFee = tests.createExample(SuccessView, {
@@ -116,6 +118,7 @@ export const WithoutFee = tests.createExample(SuccessView, {
     fraction: 0,
     value: 2,
   },
+  accounts: [],
 });
 
 export const EditExchangeUntouched = tests.createExample(SuccessView, {
@@ -142,6 +145,7 @@ export const EditExchangeUntouched = 
tests.createExample(SuccessView, {
     fraction: 0,
     value: 2,
   },
+  accounts: [],
 });
 
 export const EditExchangeModified = tests.createExample(SuccessView, {
@@ -168,6 +172,7 @@ export const EditExchangeModified = 
tests.createExample(SuccessView, {
     fraction: 0,
     value: 2,
   },
+  accounts: [],
 });
 
 export const WithAgeRestriction = tests.createExample(SuccessView, {
@@ -195,4 +200,32 @@ export const WithAgeRestriction = 
tests.createExample(SuccessView, {
     fraction: 0,
     value: 2,
   },
+  accounts: [],
+});
+
+export const WithAlternateCurrencies = tests.createExample(SuccessView, {
+  error: undefined,
+  status: "success",
+  chosenAmount: {
+    currency: "USD",
+    value: 2,
+    fraction: 10000000,
+  },
+  accounts: [],
+  doWithdrawal: { onClick: nullFunction },
+  currentExchange: {
+    exchangeBaseUrl: "https://exchange.demo.taler.net";,
+    tos: {},
+  } as Partial<ExchangeListItem> as any,
+  withdrawalFee: {
+    currency: "USD",
+    fraction: 10000000,
+    value: 1,
+  },
+  doSelectExchange: {},
+  toBeReceived: {
+    currency: "USD",
+    fraction: 0,
+    value: 1,
+  },
 });
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx 
b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
index 8a01edaaf..aa8b58707 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
@@ -39,7 +39,8 @@ export function SuccessView(state: State.Success): VNode {
   const { i18n } = useTranslationContext();
   const currentTosVersionIsAccepted =
     state.currentExchange.tosStatus === ExchangeTosStatus.Accepted;
-  return (
+    const altCurrencies = state.accounts.filter(a => 
!!a.currencySpecification).map(a => a.currencySpecification!.name)
+    return (
     <Fragment>
       <section style={{ textAlign: "left" }}>
         <Part
@@ -66,6 +67,21 @@ export function SuccessView(state: State.Success): VNode {
           kind="neutral"
           big
         />
+        <p>
+          This exchange allows alternative currency
+        </p>
+        <p>
+            <Button
+              variant="outlined"
+            >
+              EUR
+            </Button>
+            <Button
+              variant="outlined"
+            >
+              ARS
+            </Button>
+          </p>
         <Part
           title={i18n.str`Details`}
           text={

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