summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-04-19 12:58:35 -0300
committerSebastian <sebasjm@gmail.com>2023-04-19 12:58:35 -0300
commit45bbe7ba127dc07ae06b420faca591c03402a3f5 (patch)
tree60827bccf32668ccd4d624288b3df00936363c36
parentd483a3f5574355ed9c43eb6ddea59e5734323cf0 (diff)
downloadwallet-core-45bbe7ba127dc07ae06b420faca591c03402a3f5.tar.gz
wallet-core-45bbe7ba127dc07ae06b420faca591c03402a3f5.tar.bz2
wallet-core-45bbe7ba127dc07ae06b420faca591c03402a3f5.zip
add wallet config on the top
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts79
-rw-r--r--packages/taler-wallet-core/src/wallet.ts6
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<string, never>;
/**
* 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<WalletConfig>;
+
+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<T extends object> = {
+type RecursivePartial<T extends object> = {
[P in keyof T]?: T[P] extends Array<infer U extends object>
? Array<RecursivePartial<U>>
: T[P] extends Array<infer J extends Primitives>
@@ -974,38 +1016,3 @@ export type RecursivePartial<T extends object> = {
? RecursivePartial<T[P]>
: T[P];
} & object;
-
-export type WalletConfigParameter = RecursivePartial<WalletConfig>;
-
-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<T extends object>(
- full: T,
- override: RecursivePartial<T>,
-): T {
+function deepMerge<T extends object>(full: T, override: any): T {
const keys = Object.keys(full);
const result = { ...full };
for (const k of keys) {