add wallet config on the top
This commit is contained in:
parent
d483a3f557
commit
45bbe7ba12
@ -198,6 +198,7 @@ export enum WalletApiOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// group: Initialization
|
// group: Initialization
|
||||||
|
|
||||||
type EmptyObject = Record<string, never>;
|
type EmptyObject = Record<string, never>;
|
||||||
/**
|
/**
|
||||||
* Initialize wallet-core.
|
* Initialize wallet-core.
|
||||||
@ -216,6 +217,47 @@ export type GetVersionOp = {
|
|||||||
response: WalletCoreVersion;
|
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
|
// group: Basic Wallet Information
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -965,7 +1007,7 @@ export interface WalletCoreApiClient {
|
|||||||
|
|
||||||
type Primitives = string | number | boolean;
|
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>
|
[P in keyof T]?: T[P] extends Array<infer U extends object>
|
||||||
? Array<RecursivePartial<U>>
|
? Array<RecursivePartial<U>>
|
||||||
: T[P] extends Array<infer J extends Primitives>
|
: T[P] extends Array<infer J extends Primitives>
|
||||||
@ -974,38 +1016,3 @@ export type RecursivePartial<T extends object> = {
|
|||||||
? RecursivePartial<T[P]>
|
? RecursivePartial<T[P]>
|
||||||
: T[P];
|
: T[P];
|
||||||
} & object;
|
} & 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;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
@ -270,7 +270,6 @@ import {
|
|||||||
WALLET_MERCHANT_PROTOCOL_VERSION,
|
WALLET_MERCHANT_PROTOCOL_VERSION,
|
||||||
} from "./versions.js";
|
} from "./versions.js";
|
||||||
import {
|
import {
|
||||||
RecursivePartial,
|
|
||||||
WalletApiOperation,
|
WalletApiOperation,
|
||||||
WalletConfig,
|
WalletConfig,
|
||||||
WalletConfigParameter,
|
WalletConfigParameter,
|
||||||
@ -1822,10 +1821,7 @@ class InternalWalletStateImpl implements InternalWalletState {
|
|||||||
* @param override
|
* @param override
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function deepMerge<T extends object>(
|
function deepMerge<T extends object>(full: T, override: any): T {
|
||||||
full: T,
|
|
||||||
override: RecursivePartial<T>,
|
|
||||||
): T {
|
|
||||||
const keys = Object.keys(full);
|
const keys = Object.keys(full);
|
||||||
const result = { ...full };
|
const result = { ...full };
|
||||||
for (const k of keys) {
|
for (const k of keys) {
|
||||||
|
Loading…
Reference in New Issue
Block a user