From 45bbe7ba127dc07ae06b420faca591c03402a3f5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 19 Apr 2023 12:58:35 -0300 Subject: [PATCH] add wallet config on the top --- .../taler-wallet-core/src/wallet-api-types.ts | 79 ++++++++++--------- packages/taler-wallet-core/src/wallet.ts | 6 +- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 94348f095..e85c6ffc3 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -198,6 +198,7 @@ export enum WalletApiOperation { } // group: Initialization + type EmptyObject = Record; /** * Initialize wallet-core. @@ -216,6 +217,47 @@ export type GetVersionOp = { response: WalletCoreVersion; }; +/** + * Configurations options for the Wallet + * + * All missing values of the config will be replaced with default values + * Default values are defined by Wallet.getDefaultConfig() + */ +export type WalletConfigParameter = RecursivePartial; + +export interface WalletConfig { + /** + * Initialization values useful for a complete startup. + * + * These are values may be overridden by different wallets + */ + builtin: { + exchanges: string[]; + auditors: AuditorTrustRecord[]; + }; + + /** + * Unsafe options which it should only be used to create + * testing environment. + */ + testing: { + /** + * Allow withdrawal of denominations even though they are about to expire. + */ + denomselAllowLate: boolean; + devModeActive: boolean; + insecureTrustExchange: boolean; + }; + + /** + * Configurations values that may be safe to show to the user + */ + features: { + batchWithdrawal: boolean; + allowHttp: boolean; + }; +} + // group: Basic Wallet Information /** @@ -965,7 +1007,7 @@ export interface WalletCoreApiClient { type Primitives = string | number | boolean; -export type RecursivePartial = { +type RecursivePartial = { [P in keyof T]?: T[P] extends Array ? Array> : T[P] extends Array @@ -974,38 +1016,3 @@ export type RecursivePartial = { ? RecursivePartial : T[P]; } & object; - -export type WalletConfigParameter = RecursivePartial; - -export interface WalletConfig { - /** - * Initialization values useful for a complete startup. - * - * These are values may be overridden by different wallets - */ - builtin: { - exchanges: string[]; - auditors: AuditorTrustRecord[]; - }; - - /** - * Unsafe options which it should only be used to create - * testing environment. - */ - testing: { - /** - * Allow withdrawal of denominations even though they are about to expire. - */ - denomselAllowLate: boolean; - devModeActive: boolean; - insecureTrustExchange: boolean; - }; - - /** - * Configurations values that may be safe to show to the user - */ - features: { - batchWithdrawal: boolean; - allowHttp: boolean; - }; -} diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 45b33ce45..d554e5b83 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -270,7 +270,6 @@ import { WALLET_MERCHANT_PROTOCOL_VERSION, } from "./versions.js"; import { - RecursivePartial, WalletApiOperation, WalletConfig, WalletConfigParameter, @@ -1822,10 +1821,7 @@ class InternalWalletStateImpl implements InternalWalletState { * @param override * @returns */ -function deepMerge( - full: T, - override: RecursivePartial, -): T { +function deepMerge(full: T, override: any): T { const keys = Object.keys(full); const result = { ...full }; for (const k of keys) {