commit 61a0f3a0f4663ec40015ab7fbb90dfaba23f2e2a
parent 4fb024aa33aabaa135de25ab1e69eeea6213f6e7
Author: Sebastian <sebasjm@gmail.com>
Date: Thu, 29 May 2025 16:24:39 -0300
fix #9536
Diffstat:
5 files changed, 37 insertions(+), 42 deletions(-)
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -75,7 +75,9 @@ export function useComponentStateFromParams({
const exchanges = await api.wallet.call(
WalletApiOperation.ListExchanges,
- {},
+ {
+ filterByScope: scope
+ },
);
const chosenAmount =
diff --git a/packages/taler-wallet-webextension/src/hooks/useSelectedExchange.ts b/packages/taler-wallet-webextension/src/hooks/useSelectedExchange.ts
@@ -14,7 +14,10 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { ExchangeListItem, ScopeInfo, ScopeType, stringifyScopeInfoShort } from "@gnu-taler/taler-util";
+import {
+ ExchangeListItem,
+ ScopeInfo
+} from "@gnu-taler/taler-util";
import { useState } from "preact/hooks";
import { useAlertContext } from "../context/alert.js";
import { ButtonHandler } from "../mui/handlers.js";
@@ -25,7 +28,7 @@ export namespace State {
export interface NoExchangeFound {
status: "no-exchange-found";
error: undefined;
- scope: ScopeInfo;
+ currency: string;
defaultExchange: string | undefined;
}
export interface Ready {
@@ -39,7 +42,7 @@ export namespace State {
onSelection: (url: string) => Promise<void>;
onCancel: () => Promise<void>;
list: ExchangeListItem[];
- scope: ScopeInfo;
+ // scope: ScopeInfo;
initialValue: string;
}
}
@@ -67,19 +70,8 @@ export function useSelectedExchange({
return {
status: "no-exchange-found",
error: undefined,
- scope,
- defaultExchange,
- };
- }
-
- const scopeStr = stringifyScopeInfoShort(scope)
- const exchangesWithThisScope = list.filter((e) => stringifyScopeInfoShort(e.scopeInfo) === scopeStr);
- if (!exchangesWithThisScope.length) {
- // there should be at least one exchange for this currency
- return {
- status: "no-exchange-found",
- error: undefined,
- scope,
+ // scope,
+ currency: scope.currency,
defaultExchange,
};
}
@@ -88,12 +80,12 @@ export function useSelectedExchange({
const currentExchange =
selectedExchange ??
defaultExchange ??
- exchangesWithThisScope[0].exchangeBaseUrl;
+ list[0].exchangeBaseUrl;
return {
status: "selecting-exchange",
error: undefined,
- list: exchangesWithThisScope,
- scope,
+ list: list,
+ // scope,
initialValue: currentExchange,
onSelection: async (exchangeBaseUrl: string) => {
setIsSelecting(false);
@@ -137,6 +129,6 @@ export function useSelectedExchange({
doSelect: {
onClick: pushAlertOnError(async () => setIsSelecting(true)),
},
- selected: exchangesWithThisScope[0],
+ selected: list[0],
};
}
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx
@@ -28,10 +28,10 @@ export default {
};
export const NoExchangeFound = tests.createExample(NoExchangesView, {
- scope: {
- currency: "USD",
- type: ScopeType.Global,
- },
+ // scope: {
+ // currency: "USD",
+ // type: ScopeType.Global,
+ // },
defaultExchange: "https://exchange.taler.ar",
});
@@ -257,7 +257,7 @@ function timelineExample() {
},
},
],
- refresh: [
+ refresh: [
{
group: "0.1",
from: {
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx
@@ -144,7 +144,8 @@ export function TosContentView({
export function NoExchangesView({
defaultExchange,
- scope,
+ currency,
+ // scope,
}: SelectExchangeState.NoExchangeFound): VNode {
const { i18n } = useTranslationContext();
return (
@@ -153,7 +154,7 @@ export function NoExchangesView({
<AlertView
alert={{
type: "error",
- message: i18n.str`There is no exchange available for currency ${scope.currency}`,
+ message: i18n.str`There is no exchange available for currency ${currency}`,
description: i18n.str`You can add more exchanges from the settings.`,
cause: undefined,
context: undefined,
diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx
@@ -272,10 +272,21 @@ export function HistoryView({
>
{balances.map((entry, si) => {
const st = stringifyScopeInfoShort(entry.scopeInfo);
+ const sc = entry.scopeInfo;
+ if (sc.type === ScopeType.Global) {
+ return (
+ <option value={st} key={st}>
+ <b>{sc.currency}</b>
+ </option>
+ );
+ }
+
return (
- <option value={st} key={st}>
- <BalanceLabel sc={entry.scopeInfo} />
- </option>
+ <optgroup label={sc.currency}>
+ <option value={st} key={st}>
+ {new URL(sc.url).hostname}
+ </option>
+ </optgroup>
);
})}
</select>
@@ -397,14 +408,3 @@ export function FilteredHistoryView({
</Fragment>
);
}
-function BalanceLabel({ sc }: { sc: ScopeInfo }): VNode {
- if (sc.type === ScopeType.Global) {
- return <b>{sc.currency}</b>;
- }
-
- return (
- <Fragment>
- {sc.currency} {new URL(sc.url).hostname}
- </Fragment>
- );
-}