aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-01-18 17:50:57 -0300
committerSebastian <sebasjm@gmail.com>2024-01-18 17:50:57 -0300
commite9c6b105d18f142cf4d4b203e734513df1e5021c (patch)
tree8719c58dc144ab4e64694dc00d4dccd563b8a13e
parent421b5c0acfa310fcb7f1893bf81e38f2876e1cbf (diff)
downloadwallet-core-e9c6b105d18f142cf4d4b203e734513df1e5021c.tar.gz
wallet-core-e9c6b105d18f142cf4d4b203e734513df1e5021c.tar.bz2
wallet-core-e9c6b105d18f142cf4d4b203e734513df1e5021c.zip
update config from merchant
-rw-r--r--packages/merchant-backoffice-ui/src/Application.tsx8
-rw-r--r--packages/merchant-backoffice-ui/src/context/config.ts9
-rw-r--r--packages/merchant-backoffice-ui/src/declaration.d.ts40
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 <Loading />;
@@ -159,7 +159,7 @@ function ApplicationStatusRoutes(): VNode {
return (
<div class="has-navbar-fixed-top">
- <ConfigContextProvider value={ctx}>
+ <ConfigContextProvider value={ctx!}>
<ApplicationReadyRoutes />
</ConfigContextProvider>
</div>
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<Type>(null!);
+const Context = createContext<MerchantBackend.VersionResponse>(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.