-
Notifications
You must be signed in to change notification settings - Fork 293
/
config.js
174 lines (161 loc) · 5.22 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// @flow
import path from 'path';
import { app, dialog } from 'electron';
import { environment } from './environment';
import { readLauncherConfig } from './utils/config';
import { getBuildLabel } from '../common/utils/environmentCheckers';
import type { CardanoNodeImplementations } from '../common/types/cardano-node.types';
const {
isTest,
isProduction,
isBlankScreenFixActive,
current,
build,
network,
version,
} = 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`);
}
}
export type NodeConfig = {
configurationDir: string,
delegationCertificate?: string,
kind: 'byron' | 'shelley',
network: {
configFile: string,
genesisFile: string,
genesisHash: string,
topologyFile: string,
},
signingKey?: string,
};
/**
* The shape of the config params, usually provided to the cardano-node launcher
*/
export type LauncherConfig = {
stateDir: string,
nodeImplementation: CardanoNodeImplementations,
nodeConfig: NodeConfig,
tlsPath: string,
logsPrefix: string,
cluster: string,
block0Path: string,
block0Hash: string,
secretPath: string,
configPath: string,
syncTolerance: string,
cliBin: string,
exportWalletsBin: string,
legacyStateDir: string,
legacySecretKey: string,
legacyWalletDB: string,
isFlight: boolean,
isStaging: boolean,
};
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 = 700;
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 launcherConfig: LauncherConfig = readLauncherConfig(
LAUNCHER_CONFIG
);
export const {
cluster,
nodeImplementation,
stateDir,
legacyStateDir,
logsPrefix,
isFlight,
} = launcherConfig;
export const appLogsFolderPath = logsPrefix;
export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub');
export const stateDirectoryPath = stateDir;
export const stateDrive = isWindows ? stateDirectoryPath.slice(0, 2) : '/';
export const buildLabel = getBuildLabel(
build,
network,
current,
isFlight,
version
);
// Logging config
export const ALLOWED_LOGS = [
'Daedalus.json',
'System-info.json',
'Daedalus-versions.json',
'State-snapshot.json',
'Wallet-migration-report.json',
'cardano-wallet.log',
'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;
// 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
export const BLOCK_REPLAY_PROGRESS_CHECK_INTERVAL = 1 * 1000; // 1 seconds | unit: milliseconds
// CardanoWallet config
export const STAKE_POOL_REGISTRY_URL = {
itn_selfnode:
'https://github.com/input-output-hk/daedalus/raw/selfnode/test-integration-registry.zip',
nightly:
'https://github.com/piotr-iohk/incentivized-testnet-stakepool-registry/archive/master.zip',
qa:
'https://explorer.qa.jormungandr-testnet.iohkdev.io/stakepool-registry/registry.zip',
};