From e9c6b105d18f142cf4d4b203e734513df1e5021c Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 18 Jan 2024 17:50:57 -0300 Subject: update config from merchant --- .../merchant-backoffice-ui/src/Application.tsx | 8 ++--- .../merchant-backoffice-ui/src/context/config.ts | 9 ++--- .../merchant-backoffice-ui/src/declaration.d.ts | 40 +++++++++++++++++++++- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/packages/merchant-backoffice-ui/src/Application.tsx b/packages/merchant-backoffice-ui/src/Application.tsx index 0c509ef45..27ae26de5 100644 --- a/packages/merchant-backoffice-ui/src/Application.tsx +++ b/packages/merchant-backoffice-ui/src/Application.tsx @@ -61,10 +61,10 @@ function ApplicationStatusRoutes(): VNode { const result = useBackendConfig(); const { i18n } = useTranslationContext(); - const { currency, version } = result.ok && result.data + const configData = result.ok && result.data ? result.data - : { currency: "unknown", version: "unknown" }; - const ctx = useMemo(() => ({ currency, version }), [currency, version]); + : undefined; + const ctx = useMemo(() => (configData), [configData]); if (!result.ok) { if (result.loading) return ; @@ -159,7 +159,7 @@ function ApplicationStatusRoutes(): VNode { return (
- +
diff --git a/packages/merchant-backoffice-ui/src/context/config.ts b/packages/merchant-backoffice-ui/src/context/config.ts index 040bd0341..9fe655301 100644 --- a/packages/merchant-backoffice-ui/src/context/config.ts +++ b/packages/merchant-backoffice-ui/src/context/config.ts @@ -21,12 +21,9 @@ import { createContext } from "preact"; import { useContext } from "preact/hooks"; +import { MerchantBackend } from "../declaration.js"; -interface Type { - currency: string; - version: string; -} -const Context = createContext(null!); +const Context = createContext(null!); export const ConfigContextProvider = Context.Provider; -export const useConfigContext = (): Type => useContext(Context); +export const useConfigContext = (): MerchantBackend.VersionResponse => useContext(Context); diff --git a/packages/merchant-backoffice-ui/src/declaration.d.ts b/packages/merchant-backoffice-ui/src/declaration.d.ts index f99dd1867..38ab9d254 100644 --- a/packages/merchant-backoffice-ui/src/declaration.d.ts +++ b/packages/merchant-backoffice-ui/src/declaration.d.ts @@ -274,8 +274,46 @@ export namespace MerchantBackend { // Name of the protocol. name: "taler-merchant"; - // Currency supported by this backend. + // Default (!) currency supported by this backend. + // This is the currency that the backend should + // suggest by default to the user when entering + // amounts. See currencies for a list of + // supported currencies and how to render them. currency: string; + + // How services should render currencies supported + // by this backend. Maps + // currency codes (e.g. "EUR" or "KUDOS") to + // the respective currency specification. + // All currencies in this map are supported by + // the backend. Note that the actual currency + // specifications are a *hint* for applications + // that would like *advice* on how to render amounts. + // Applications *may* ignore the currency specification + // if they know how to render currencies that they are + // used with. + currencies: { currency: CurrencySpecification }; + + // Array of exchanges trusted by the merchant. + // Since protocol v6. + exchanges: ExchangeConfigInfo[]; + } + + interface ExchangeConfigInfo { + + // Base URL of the exchange REST API. + base_url: string; + + // Currency for which the merchant is configured + // to trust the exchange. + // May not be the one the exchange actually uses, + // but is the only one we would trust this exchange for. + currency: string; + + // Offline master public key of the exchange. The + // /keys data must be signed with this public + // key for us to trust it. + master_pub: EddsaPublicKey; } interface Location { // Nation with its own government. -- cgit v1.2.3