-
Notifications
You must be signed in to change notification settings - Fork 293
/
config.js
135 lines (124 loc) · 4.79 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// @flow
import path from 'path';
import { app, dialog } from 'electron';
import { readLauncherConfig } from './utils/config';
import { environment } from './environment';
const { isTest, isProduction, isBlankScreenFixActive } = environment;
// Make sure Daedalus is started with required configuration
const { LAUNCHER_CONFIG } = process.env;
const isStartedByLauncher = !!LAUNCHER_CONFIG;
const isWindows = process.platform === 'win32';
if (!isStartedByLauncher) {
const dialogTitle = 'Daedalus improperly started!';
let dialogMessage;
if (isProduction) {
dialogMessage = isWindows
? 'Please start Daedalus using the icon in the Windows start menu or using Daedalus icon on your desktop.'
: 'Daedalus was launched without needed configuration. Please start Daedalus using the shortcut provided by the installer.';
} else {
dialogMessage =
'Daedalus should be started using nix-shell. Find more details here: https://github.com/input-output-hk/daedalus/blob/develop/README.md';
}
try {
// app may not be available at this moment so we need to use try-catch
dialog.showErrorBox(dialogTitle, dialogMessage);
app.exit(1);
} catch (e) {
throw new Error(`${dialogTitle}\n\n${dialogMessage}\n`);
}
}
/**
* The shape of the config params, usually provided to the cadano-node launcher
*/
export type LauncherConfig = {
frontendOnlyMode: boolean,
stateDir: string,
walletBin: string,
walletArgs: Array<string>,
nodeBin: string,
cliBin: string,
nodeImplementation: 'jormungandr' | 'cardano-node',
nodeArgs: Array<string>,
tlsPath: string,
nodeDbPath: string,
workingDir: string,
logsPrefix: string,
nodeLogConfig: string,
nodeTimeoutSec: number,
configuration: {
filePath: string,
key: string,
systemStart: string,
seed: string,
},
};
type WindowOptionsType = {
show: boolean,
width: number,
height: number,
webPreferences: {
nodeIntegration: boolean,
webviewTag: boolean,
enableRemoteModule: boolean,
preload: string,
},
icon?: string,
};
export const WINDOW_WIDTH = 1150;
export const WINDOW_HEIGHT = 870;
export const MIN_WINDOW_CONTENT_WIDTH = 905;
export const MIN_WINDOW_CONTENT_HEIGHT = 600;
export const windowOptions: WindowOptionsType = {
show: false,
width: WINDOW_WIDTH,
height: WINDOW_HEIGHT,
webPreferences: {
nodeIntegration: isTest,
webviewTag: false,
enableRemoteModule: isTest,
preload: path.join(__dirname, './preload.js'),
additionalArguments: isBlankScreenFixActive ? ['--safe-mode'] : [],
},
useContentSize: true,
};
export const APP_NAME = 'Daedalus';
export const launcherConfig: LauncherConfig = readLauncherConfig(
LAUNCHER_CONFIG
);
export const appLogsFolderPath = launcherConfig.logsPrefix;
export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub');
export const appFolderPath = launcherConfig.workingDir;
export const { nodeDbPath } = launcherConfig;
export const stateDirectoryPath = launcherConfig.stateDir;
export const stateDrive = isWindows ? stateDirectoryPath.slice(0, 2) : '/';
export const ALLOWED_LOGS = [
'Daedalus.json',
'System-info.json',
'Daedalus-versions.json',
'State-snapshot.json',
'node.log',
];
export const ALLOWED_NODE_LOGS = new RegExp(/(node.log-)(\d{14}$)/);
export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/);
export const MAX_NODE_LOGS_ALLOWED = 3;
export const MAX_LAUNCHER_LOGS_ALLOWED = 3;
// We need to invert 'frontendOnlyMode' value received from the launcherConfig
// as this variable has an opposite meaning from the launcher's perspective.
// Launcher treats the 'frontendOnlyMode' set to 'true' as the case where Daedalus
// takes the responsiblity for launching and managing the cardano-node.
export const frontendOnlyMode = !launcherConfig.frontendOnlyMode;
// CardanoNode config
export const NODE_STARTUP_TIMEOUT = 5000;
export const NODE_STARTUP_MAX_RETRIES = 5;
export const NODE_SHUTDOWN_TIMEOUT = isTest ? 5000 : 10000;
export const NODE_KILL_TIMEOUT = isTest ? 5000 : 10000;
export const NODE_UPDATE_TIMEOUT = isTest ? 10000 : 60000;
export const DISK_SPACE_REQUIRED = 2 * 1073741274; // 2 GB | unit: bytes
export const DISK_SPACE_REQUIRED_MARGIN_PERCENTAGE = 10; // 10% of the available disk space
export const DISK_SPACE_CHECK_LONG_INTERVAL = 10 * 60 * 1000; // 10 minutes | unit: milliseconds
export const DISK_SPACE_CHECK_MEDIUM_INTERVAL = 60 * 1000; // 1 minute | unit: milliseconds
export const DISK_SPACE_CHECK_SHORT_INTERVAL = isTest ? 2000 : 10 * 1000; // 10 seconds | unit: milliseconds
export const DISK_SPACE_RECOMMENDED_PERCENTAGE = 15; // 15% of the total disk space
// CardanoWallet config
export const CARDANO_WALLET_STAKE_POOL_REGISTRY_URL =
'https://github.com/input-output-hk/cardano-wallet/raw/master/lib/jormungandr/test/data/jormungandr/stake_pools/registry/test-integration-registry.zip';