diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-24 12:53:20 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-24 12:53:20 -0300 |
commit | 205d7364ed74d90068ae2a1cc402e77ac2f0bbad (patch) | |
tree | a6fba8791c77a891bee2d64ffc4d8cf0c97f76ee /packages/taler-wallet-core/src/wallet.ts | |
parent | 3004ece1f8153fdf8ddb283e5d767dd5b5c2e179 (diff) |
wallet effective config
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 435a4e241..7f78be23a 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1564,7 +1564,7 @@ export class Wallet { http, timer, cryptoWorkerFactory, - config ?? {}, + Wallet.getEffectiveConfig(config), ); } @@ -1587,8 +1587,33 @@ export class Wallet { return w; } - static getDefaultConfig(): Readonly<WalletConfig> { - return InternalWalletStateImpl.defaultConfig; + public static defaultConfig: Readonly<WalletConfig> = { + builtin: { + exchanges: ["https://exchange.demo.taler.net/"], + auditors: [ + { + currency: "KUDOS", + auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0", + auditorBaseUrl: "https://auditor.demo.taler.net/", + uids: ["5P25XF8TVQP9AW6VYGY2KV47WT5Y3ZXFSJAA570GJPX5SVJXKBVG"], + }, + ], + }, + features: { + batchWithdrawal: false, + allowHttp: false, + }, + testing: { + devModeActive: false, + insecureTrustExchange: false, + denomselAllowLate: false, + }, + }; + + static getEffectiveConfig( + param?: WalletConfigParameter, + ): Readonly<WalletConfig> { + return deepMerge(Wallet.defaultConfig, param ?? {}); } addNotificationListener(f: (n: WalletNotification) => void): void { @@ -1674,29 +1699,6 @@ class InternalWalletStateImpl implements InternalWalletState { config: Readonly<WalletConfig>; - public static defaultConfig: Readonly<WalletConfig> = { - builtin: { - exchanges: ["https://exchange.demo.taler.net/"], - auditors: [ - { - currency: "KUDOS", - auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0", - auditorBaseUrl: "https://auditor.demo.taler.net/", - uids: ["5P25XF8TVQP9AW6VYGY2KV47WT5Y3ZXFSJAA570GJPX5SVJXKBVG"], - }, - ], - }, - features: { - batchWithdrawal: false, - allowHttp: false, - }, - testing: { - devModeActive: false, - insecureTrustExchange: false, - denomselAllowLate: false, - }, - }; - constructor( // FIXME: Make this a getter and make // the actual value nullable. @@ -1706,12 +1708,12 @@ class InternalWalletStateImpl implements InternalWalletState { public http: HttpRequestLibrary, public timer: TimerAPI, cryptoWorkerFactory: CryptoWorkerFactory, - config: WalletConfigParameter, + configParam: WalletConfig, ) { this.cryptoDispatcher = new CryptoDispatcher(cryptoWorkerFactory); this.cryptoApi = this.cryptoDispatcher.cryptoApi; this.timerGroup = new TimerGroup(timer); - this.config = deepMerge(InternalWalletStateImpl.defaultConfig, config); + this.config = configParam; if (this.config.testing.devModeActive) { this.http = new DevExperimentHttpLib(this.http); } @@ -1823,7 +1825,7 @@ class InternalWalletStateImpl implements InternalWalletState { * @param override * @returns */ -function deepMerge<T extends object>(full: T, override: any): T { +function deepMerge<T extends object>(full: T, override: object): T { const keys = Object.keys(full); const result = { ...full }; for (const k of keys) { |