+
+
+
+
+
+
+ );
+}
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx
index 98515aac0..18291a25a 100644
--- a/packages/taler-wallet-webextension/src/wallet/Application.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -65,15 +65,15 @@ import {
WithdrawPageFromParams,
WithdrawPageFromURI,
} from "../cta/Withdraw/index.js";
+import { useIsOnline } from "../hooks/useIsOnline.js";
import { strings } from "../i18n/strings.js";
-import { platform } from "../platform/foreground.js";
import CloseIcon from "../svg/close_24px.inline.svg";
import { AddBackupProviderPage } from "./AddBackupProvider/index.js";
+import { AddExchange } from "./AddExchange/index.js";
import { BackupPage } from "./BackupPage.js";
import { DepositPage } from "./DepositPage/index.js";
import { DestinationSelectionPage } from "./DestinationSelection/index.js";
import { DeveloperPage } from "./DeveloperPage.js";
-import { ExchangeAddPage } from "./ExchangeAddPage.js";
import { HistoryPage } from "./History.js";
import { NotificationsPage } from "./Notifications/index.js";
import { ProviderDetailPage } from "./ProviderDetailPage.js";
@@ -81,7 +81,6 @@ import { QrReaderPage } from "./QrReader.js";
import { SettingsPage } from "./Settings.js";
import { TransactionPage } from "./Transaction.js";
import { WelcomePage } from "./Welcome.js";
-import { useIsOnline } from "../hooks/useIsOnline.js";
export function Application(): VNode {
const { i18n } = useTranslationContext();
@@ -143,7 +142,7 @@ export function Application(): VNode {
path={Pages.settingsExchangeAdd.pattern}
component={() => (
- redirectTo(Pages.balance)} />
+ redirectTo(Pages.balance)} />
)}
/>
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeAddConfirm.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeAddConfirm.tsx
deleted file mode 100644
index 0d4f234b3..000000000
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeAddConfirm.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see
- */
-import { Fragment, h, VNode } from "preact";
-import { useState } from "preact/hooks";
-import { Title } from "../components/styled/index.js";
-import { TermsOfService } from "../components/TermsOfService/index.js";
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
-import { Button } from "../mui/Button.js";
-
-export interface Props {
- url: string;
- onCancel: () => Promise;
- onConfirm: () => Promise;
-}
-
-export function ExchangeAddConfirmPage({
- url,
- onCancel,
- onConfirm,
-}: Props): VNode {
- const { i18n } = useTranslationContext();
-
- const [accepted, setAccepted] = useState(false);
-
- return (
-
-
-
- Review terms of service
-
-
-
-
-
-
-
-
- );
-}
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx
deleted file mode 100644
index 9be12fb28..000000000
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeAddPage.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see
- */
-
-import {
- canonicalizeBaseUrl,
- TalerConfigResponse,
-} from "@gnu-taler/taler-util";
-import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { h, VNode } from "preact";
-import { useState } from "preact/hooks";
-import { useBackendContext } from "../context/backend.js";
-import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
-import { queryToSlashKeys } from "../utils/index.js";
-import { ExchangeAddConfirmPage } from "./ExchangeAddConfirm.js";
-import { ExchangeSetUrlPage } from "./ExchangeSetUrl.js";
-
-interface Props {
- currency?: string;
- onBack: () => Promise;
-}
-
-export function ExchangeAddPage({ currency, onBack }: Props): VNode {
- const [verifying, setVerifying] = useState<
- { url: string; config: TalerConfigResponse } | undefined
- >(undefined);
-
- const api = useBackendContext();
- const knownExchangesResponse = useAsyncAsHook(() =>
- api.wallet.call(WalletApiOperation.ListExchanges, {}),
- );
- const knownExchanges = !knownExchangesResponse
- ? []
- : knownExchangesResponse.hasError
- ? []
- : knownExchangesResponse.response.exchanges;
-
- if (!verifying) {
- return (
- {
- const found =
- knownExchanges.findIndex((e) => e.exchangeBaseUrl === url) !== -1;
-
- if (found) {
- throw Error("This exchange is already known");
- }
- return {
- name: "1",
- version: "15:0:0",
- currency: "ARS",
- };
- }}
- onConfirm={
- async (url) => {
- setVerifying({
- url,
- config: {
- name: "1",
- version: "15:0:0",
- currency: "ARS",
- },
- });
- return undefined;
- }
- // queryToSlashKeys(url)
- // .then((config) => {
- // setVerifying({ url, config });
- // })
- // .catch((e) => e.message)
- }
- />
- );
- }
- return (
- {
- await api.wallet.call(WalletApiOperation.AddExchange, {
- exchangeBaseUrl: canonicalizeBaseUrl(verifying.url),
- forceUpdate: true,
- });
- onBack();
- }}
- />
- );
-}
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx
deleted file mode 100644
index e69268b08..000000000
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see
- */
-
-/**
- *
- * @author Sebastian Javier Marchano (sebasjm)
- */
-
-import * as tests from "@gnu-taler/web-util/testing";
-import { queryToSlashKeys } from "../utils/index.js";
-import { ExchangeSetUrlPage as TestedComponent } from "./ExchangeSetUrl.js";
-
-export default {
- title: "exchange add set url",
-};
-
-export const ExpectedUSD = tests.createExample(TestedComponent, {
- expectedCurrency: "USD",
- onVerify: queryToSlashKeys,
-});
-
-export const ExpectedKUDOS = tests.createExample(TestedComponent, {
- expectedCurrency: "KUDOS",
- onVerify: queryToSlashKeys,
-});
-
-export const InitialState = tests.createExample(TestedComponent, {
- onVerify: queryToSlashKeys,
-});
-
-const knownExchanges = [
- {
- currency: "TESTKUDOS",
- exchangeBaseUrl: "https://exchange.demo.taler.net/",
- tos: {
- currentVersion: "1",
- acceptedVersion: "1",
- content: "content of tos",
- contentType: "text/plain",
- },
- paytoUris: [],
- },
-];
-
-export const WithDemoAsKnownExchange = tests.createExample(TestedComponent, {
- onVerify: async (url) => {
- const found =
- knownExchanges.findIndex((e) => e.exchangeBaseUrl === url) !== -1;
-
- if (found) {
- throw Error("This exchange is already known");
- }
- return queryToSlashKeys(url);
- },
-});
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx
deleted file mode 100644
index 4fea3bc98..000000000
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see
- */
-import {
- canonicalizeBaseUrl,
- TalerConfigResponse,
-} from "@gnu-taler/taler-util";
-import { Fragment, h, VNode } from "preact";
-import { useEffect, useState } from "preact/hooks";
-import { ErrorMessage } from "../components/ErrorMessage.js";
-import {
- Input,
- LightText,
- SubTitle,
- Title,
- WarningBox,
-} from "../components/styled/index.js";
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
-import { Button } from "../mui/Button.js";
-
-export interface Props {
- initialValue?: string;
- expectedCurrency?: string;
- onCancel: () => Promise;
- onVerify: (s: string) => Promise;
- onConfirm: (url: string) => Promise;
- withError?: string;
-}
-
-function useEndpointStatus(
- endpoint: string,
- onVerify: (e: string) => Promise,
-): {
- loading: boolean;
- error?: string;
- endpoint: string;
- result: T | undefined;
- updateEndpoint: (s: string) => void;
-} {
- const [value, setValue] = useState(endpoint);
- const [dirty, setDirty] = useState(false);
- const [loading, setLoading] = useState(false);
- const [result, setResult] = useState(undefined);
- const [error, setError] = useState(undefined);
-
- const [handler, setHandler] = useState(undefined);
-
- useEffect(() => {
- if (!value) return;
- window.clearTimeout(handler);
- const h = window.setTimeout(async () => {
- setDirty(true);
- setLoading(true);
- try {
- const url = canonicalizeBaseUrl(value);
- const result = await onVerify(url);
- setResult(result);
- setError(undefined);
- setLoading(false);
- } catch (e) {
- const errorMessage =
- e instanceof Error ? e.message : `unknown error: ${e}`;
- setError(errorMessage);
- setLoading(false);
- setResult(undefined);
- }
- }, 500);
- setHandler(h);
- }, [value, setHandler, onVerify]);
-
- return {
- error: dirty ? error : undefined,
- loading: loading,
- result: result,
- endpoint: value,
- updateEndpoint: setValue,
- };
-}
-
-export function ExchangeSetUrlPage({
- initialValue,
- expectedCurrency,
- onCancel,
- onVerify,
- onConfirm,
-}: Props): VNode {
- const { i18n } = useTranslationContext();
- const { loading, result, endpoint, updateEndpoint, error } =
- useEndpointStatus(initialValue ?? "", onVerify);
-
- const [confirmationError, setConfirmationError] = useState<
- string | undefined
- >(undefined);
-
- return (
-
-
- {!expectedCurrency ? (
-
- Add new exchange
-
- ) : (
-
- Add exchange for {expectedCurrency}
-
- )}
- {!result && (
-
-
- Enter the URL of an exchange you trust.
-
-
- )}
- {result && (
-
-
- An exchange has been found! Review the information and click next
-
-
- )}
- {result && expectedCurrency && expectedCurrency !== result.currency && (
-
-
- This exchange doesn't match the expected currency
- {expectedCurrency}
-
-
- )}
- {error && (
-
- )}
- {confirmationError && (
-
- )}
-