diff options
author | Sebastian <sebasjm@gmail.com> | 2024-02-12 16:58:30 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-02-12 16:58:30 -0300 |
commit | c166f98aeb744a31cb0ae8d6d7d294fc2eae0b1f (patch) | |
tree | c1c82a8a4ab8d80750870c00388bbdd18f48b636 | |
parent | 86194c61457f2e2e534cd05071bde9633e205ad3 (diff) | |
download | wallet-core-c166f98aeb744a31cb0ae8d6d7d294fc2eae0b1f.tar.xz |
fixes #8228
4 files changed, 50 insertions, 12 deletions
diff --git a/packages/taler-wallet-webextension/src/components/BalanceTable.tsx b/packages/taler-wallet-webextension/src/components/BalanceTable.tsx index d3733e6cc..b8bcaa391 100644 --- a/packages/taler-wallet-webextension/src/components/BalanceTable.tsx +++ b/packages/taler-wallet-webextension/src/components/BalanceTable.tsx @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { Amounts, WalletBalance } from "@gnu-taler/taler-util"; +import { Amounts, ScopeType, WalletBalance } from "@gnu-taler/taler-util"; import { VNode, h } from "preact"; import { TableWithRoundRows as TableWithRoundedRows } from "./styled/index.js"; @@ -45,6 +45,9 @@ export function BalanceTable({ }} > {Amounts.stringifyValue(av, 2)} + <div style={{ fontSize: "small", color: "grey" }}> + {entry.scopeInfo.type === ScopeType.Exchange || entry.scopeInfo.type === ScopeType.Auditor ? entry.scopeInfo.url : undefined} + </div> </td> </tr> ); diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index 23614e290..513b37642 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -153,7 +153,10 @@ export function BalanceView(state: State.Balances): VNode { const { i18n } = useTranslationContext(); const currencyWithNonZeroAmount = state.balances .filter((b) => !Amounts.isZero(b.available)) - .map((b) => b.available.split(":")[0]); + .map((b) => { + b.flags + return b.available.split(":")[0] + }); if (state.balances.length === 0) { return ( diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index d12ae864b..5230d830f 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -170,6 +170,7 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { ); const [tagName, setTagName] = useState(""); + const [exchangeURL, setExchangeURL] = useState(""); const [logLevel, setLogLevel] = useState("info"); return ( <div> @@ -397,6 +398,34 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { Set log level </Button> </Paper> + <Paper style={{ padding: 10, margin: 10 }}> + <h3>Exchange</h3> + <div> + <TextField + label="Exchange URL" + placeholder="exchange.demo.taler.net" + variant="filled" + // error={subject.error} + required + value={exchangeURL} + onChange={setExchangeURL} + /> + </div> + <Button + variant="contained" + onClick={async () => { + const resp = await fetch(new URL("/keys", exchangeURL).href) + const j = await resp.json() + api.wallet.call(WalletApiOperation.AddGlobalCurrencyExchange, { + currency: j.currency, + exchangeBaseUrl: j.base_url, + exchangeMasterPub: j.master_public_key, + }); + }} + > + Set exchange as Global + </Button> + </Paper> { downloadedDatabase && ( <div> diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx index dcc3c43e3..41b03424c 100644 --- a/packages/taler-wallet-webextension/src/wallet/History.tsx +++ b/packages/taler-wallet-webextension/src/wallet/History.tsx @@ -18,6 +18,7 @@ import { AbsoluteTime, Amounts, NotificationType, + ScopeType, Transaction, WalletBalance, } from "@gnu-taler/taler-util"; @@ -132,11 +133,10 @@ export function HistoryView({ (transactionByCurrency[av.currency] && transactionByCurrency[av.currency].length > 0) ); - }) - .map((b) => b.available.split(":")[0]); + }); const defaultCurrencyIndex = currencies.findIndex( - (c) => c === defaultCurrency, + (c) => c.scopeInfo.currency === defaultCurrency, ); const [currencyIndex, setCurrencyIndex] = useState( defaultCurrencyIndex === -1 ? 0 : defaultCurrencyIndex, @@ -151,7 +151,7 @@ export function HistoryView({ const ts = selectedCurrency === undefined ? [] - : transactionByCurrency[selectedCurrency] ?? []; + : transactionByCurrency[selectedCurrency.scopeInfo.currency] ?? []; const datesWithTransaction: string[] = []; const byDate = ts.reduce((rv, x) => { @@ -199,7 +199,7 @@ export function HistoryView({ {selectedCurrency} </CenteredText> ) : ( - <NiceSelect> + <NiceSelect style={{ flexDirection: "column" }}> <select style={{ fontSize: "x-large", @@ -209,14 +209,17 @@ export function HistoryView({ setCurrencyIndex(Number(e.currentTarget.value)); }} > - {currencies.map((currency, index) => { + {currencies.map((entry, index) => { return ( - <option value={index} key={currency}> - {currency} + <option value={index} key={entry.scopeInfo.currency}> + {entry.scopeInfo.currency} </option> ); })} </select> + <div style={{ fontSize: "small", color: "grey" }}> + {selectedCurrency.scopeInfo.type === ScopeType.Exchange || selectedCurrency.scopeInfo.type === ScopeType.Auditor ? selectedCurrency.scopeInfo.url : undefined} + </div> </NiceSelect> )} {currencyAmount && ( @@ -236,7 +239,7 @@ export function HistoryView({ tooltip="Transfer money to the wallet" startIcon={DownloadIcon} variant="contained" - onClick={() => goToWalletManualWithdraw(selectedCurrency)} + onClick={() => goToWalletManualWithdraw(selectedCurrency.scopeInfo.currency)} > <i18n.Translate>Add</i18n.Translate> </Button> @@ -246,7 +249,7 @@ export function HistoryView({ startIcon={UploadIcon} variant="outlined" color="primary" - onClick={() => goToWalletDeposit(selectedCurrency)} + onClick={() => goToWalletDeposit(selectedCurrency.scopeInfo.currency)} > <i18n.Translate>Send</i18n.Translate> </Button> |