-
Notifications
You must be signed in to change notification settings - Fork 293
/
api.js
340 lines (299 loc) · 11.8 KB
/
api.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
// @flow
import type {
BugReportRequestHttpOptions,
BugReportRequestPayload,
} from '../types/bug-report-request.types';
import type { GenerateFileMetaParams } from '../types/file-meta-request.types';
import type { GeneratePaperWalletParams } from '../types/paper-wallet-request.types';
import type {
FileDialogRequestParams,
OpenFileDialogResponseParams,
SaveFileDialogResponseParams,
} from '../types/file-dialog.types';
import type { GenerateAddressPDFParams } from '../types/address-pdf-request.types';
import type { GenerateRewardsCsvParams } from '../types/rewards-csv-request.types';
import type {
CardanoNodeState,
CardanoStatus,
FaultInjectionIpcRequest,
TlsConfig,
} from '../types/cardano-node.types';
import type { CheckDiskSpaceResponse } from '../types/no-disk-space.types';
import type { LogFiles } from '../../renderer/app/types/LogTypes';
import type { GpuStatus } from '../../renderer/app/types/gpuStatus';
import type { ExportedByronWallet } from '../../renderer/app/types/walletExportTypes';
import type {
StateSnapshotLogParams,
WalletMigrationReportData,
} from '../types/logging.types';
import type { Locale } from '../types/locales.types';
import type {
DownloadLocalDataRequest,
DownloadLocalDataResponse,
DownloadsLocalDataRequest,
DownloadsLocalDataResponse,
DownloadRequest,
DownloadResponse,
ResumeDownloadRequest,
ResumeDownloadResponse,
} from '../types/downloadManager.types';
import type { StoreMessage } from '../types/electron-store.types';
import type {
IntrospectAddressRequest,
IntrospectAddressResponse,
} from '../types/address-introspection.types';
/**
* ======================= IPC CHANNELS API =========================
* This is the ipc-api contract between main and renderer process
* which defines channel names and their possible message types.
* Complex types are referenced from common/types to keep this api readable.
* ==================================================================
*/
export const GET_LOGS_CHANNEL = 'GET_LOGS_CHANNEL';
export type GetLogsRendererRequest = void;
export type GetLogsMainResponse = LogFiles;
export const COMPRESS_LOGS_CHANNEL = 'COMPRESS_LOGS_CHANNEL';
export type CompressLogsRendererRequest = {
logs: LogFiles,
compressedFileName: string,
};
export type CompressLogsMainResponse = string;
export const DOWNLOAD_LOGS_CHANNEL = 'DOWNLOAD_LOGS_CHANNEL';
export type DownloadLogsRendererRequest = {
compressedLogsFilePath: string,
destinationPath: string,
};
export type DownloadLogsMainResponse = void;
export const GET_GPU_STATUS_CHANNEL = 'GET_GPU_STATUS_CHANNEL';
export type GetGPUStatusRendererRequest = void;
export type GetGPUStatusMainResponse = GpuStatus;
/**
* Channel for showing ui parts specified via constants
*/
export const SHOW_UI_PART_CHANNEL = 'SHOW_UI_PART_CHANNEL';
export type ShowUiPartMainRequest = string;
export type ShowUiPartRendererResponse = void;
/**
* Channel for toggling ui parts specified via constants
*/
export const TOGGLE_UI_PART_CHANNEL = 'TOGGLE_UI_PART_CHANNEL';
export type ToggleUiPartMainRequest = string;
export type ToggleUiPartRendererResponse = void;
/**
* Channel for checking the disk space available
*/
export const GET_DISK_SPACE_STATUS_CHANNEL = 'GetDiskSpaceStatusChannel';
export type GetDiskSpaceStatusRendererRequest = number | any;
export type GetDiskSpaceStatusMainResponse = CheckDiskSpaceResponse;
/**
* Channel for checking the state directory path
*/
export const GET_STATE_DIRECTORY_PATH_CHANNEL = 'GetStateDirectoryPathChannel';
export type GetStateDirectoryPathRendererRequest = string | any;
export type GetStateDirectoryPathMainResponse = any;
/**
* Channel for checking the desktop directory path
*/
export const GET_DESKTOP_DIRECTORY_PATH_CHANNEL =
'GetDesktopDirectoryPathChannel';
export type GetDesktopDirectoryPathRendererRequest = void;
export type GetDesktopDirectoryPathMainResponse = string;
/**
* Channel for checking the system locale
*/
export const GET_SYSTEM_LOCALE_CHANNEL = 'GetSystemLocaleChannel';
export type GetSystemLocaleRendererRequest = void;
export type GetSystemLocaleMainResponse = Locale;
/**
* Channel for setting log state snapshot
*/
export const SET_STATE_SNAPSHOT_LOG_CHANNEL = 'SetStateSnapshotLogChannel';
export type SetStateSnapshotLogRendererRequest = StateSnapshotLogParams | any;
export type SetStateSnapshotLogMainResponse = StateSnapshotLogParams | any;
/**
* Channel for loading a base64 encoded asset from within the `source/renderer` folder
*/
export const LOAD_ASSET_CHANNEL = 'LoadAssetChannel';
export type LoadAssetRendererRequest = { fileName: string };
export type LoadAssetMainResponse = string;
/**
* Channel for opening an external url in the default browser
*/
export const OPEN_EXTERNAL_URL_CHANNEL = 'OPEN_EXTERNAL_URL_CHANNEL';
export type OpenExternalUrlRendererRequest = string;
export type OpenExternalUrlMainResponse = void;
/**
* Channel for opening a local directory in the default desktop explorer
*/
export const OPEN_LOCAL_DIRECTORY_CHANNEL = 'OpenLocalDirectoryChannel';
export type OpenLocalDirectoryRendererRequest = string;
export type OpenLocalDirectoryMainResponse = void;
/**
* Channel to send bug report requests
*/
export const SUBMIT_BUG_REPORT_REQUEST_CHANNEL =
'SUBMIT_BUG_REPORT_REQUEST_CHANNEL';
export type SubmitBugReportRendererRequest = {
httpOptions: BugReportRequestHttpOptions,
requestPayload?: BugReportRequestPayload,
};
export type SubmitBugReportRequestMainResponse = void;
/**
* Channel to rebuild the electron application menu after the language setting changes
*/
export const REBUILD_APP_MENU_CHANNEL = 'REBUILD_APP_MENU_CHANNEL';
export type RebuildAppMenuRendererRequest = { isUpdateAvailable: boolean };
export type RebuildAppMenuMainResponse = void;
/**
* Channel to generate file blob
*/
export const GENERATE_FILE_META_CHANNEL = 'GENERATE_FILE_META_CHANNEL';
export type GenerateFileMetaRendererRequest = GenerateFileMetaParams;
export type GenerateFileMetaMainResponse = any;
/**
* Channel to generate and save a paper wallet certificate
*/
export const GENERATE_PAPER_WALLET_CHANNEL = 'GENERATE_PAPER_WALLET_CHANNEL';
export type GeneratePaperWalletRendererRequest = GeneratePaperWalletParams;
export type GeneratePaperWalletMainResponse = void;
/**
* Channel to generate and save a share address PDF
*/
export const GENERATE_ADDRESS_PDF_CHANNEL = 'GENERATE_ADDRESS_PDF_CHANNEL';
export type GenerateAddressPDFRendererRequest = GenerateAddressPDFParams;
export type GenerateAddressPDFMainResponse = void;
/**
* Channel to generate and save a rewards csv
*/
export const GENERATE_REWARDS_CSV_CHANNEL = 'GENERATE_REWARDS_CSV_CHANNEL';
export type GenerateRewardsCsvRendererRequest = GenerateRewardsCsvParams;
export type GenerateRewardsCsvMainResponse = void;
/**
* ====================== CARDANO IPC CHANNELS ======================
* This is the ipc-api contract between main & renderer process
* to communicate with the cardano-node manager code.
* ==================================================================
*/
/**
* Channel to indicate that cardano-node will exit for updating
*/
export const CARDANO_AWAIT_UPDATE_CHANNEL = 'CARDANO_AWAIT_UPDATE_CHANNEL';
export type CardanoAwaitUpdateRendererRequest = void;
export type CardanoAwaitUpdateMainResponse = void;
/**
* Channel where main process tells the renderer about cardano-node state updates
*/
export const CARDANO_STATE_CHANNEL = 'CARDANO_STATE_CHANNEL';
export type CardanoStateRendererRequest = void;
export type CardanoStateRendererResponse = CardanoNodeState;
/**
* Channel to exchange tls config between main and renderer process
*/
export const CARDANO_TLS_CONFIG_CHANNEL = 'CARDANO_TLS_CONFIG_CHANNEL';
export type CardanoTlsConfigRendererRequest = void;
export type CardanoTlsConfigMainResponse = ?TlsConfig;
/**
* Channel where renderer can request a cardano-node restart
*/
export const CARDANO_RESTART_CHANNEL = 'CARDANO_RESTART_CHANNEL';
export type CardanoRestartRendererRequest = void;
export type CardanoRestartMainResponse = void;
/**
* Channel where render process can toggle cardano-node fault injections
*/
export const CARDANO_FAULT_INJECTION_CHANNEL =
'CARDANO_FAULT_INJECTION_CHANNEL';
export type CardanoFaultInjectionRendererRequest = FaultInjectionIpcRequest;
export type CardanoFaultInjectionMainResponse = void;
/**
* Channel where renderer can ask for the last cached cardano-node status
*/
export const GET_CACHED_CARDANO_STATUS_CHANNEL =
'GET_CACHED_CARDANO_STATUS_CHANNEL';
export type GetCachedCardanoStatusRendererRequest = void;
export type GetCachedCardanoStatusMainResponse = ?CardanoStatus;
/**
* Channel where renderer and main process can exchange cardano-node status info
*/
export const SET_CACHED_CARDANO_STATUS_CHANNEL =
'SET_CACHED_CARDANO_STATUS_CHANNEL';
export type SetCachedCardanoStatusRendererRequest = ?CardanoStatus;
export type SetCachedCardanoStatusMainResponse = void;
/**
* Channel where renderer can ask main process to export wallets
*/
export const EXPORT_WALLETS_CHANNEL = 'EXPORT_WALLETS_CHANNEL';
export type ExportWalletsRendererRequest = {
exportSourcePath: string,
locale: string,
};
export type ExportWalletsMainResponse = {
wallets: Array<ExportedByronWallet>,
errors: string,
};
/**
* Channel for generating wallet migration report
*/
export const GENERATE_WALLET_MIGRATION_REPORT_CHANNEL =
'GENERATE_WALLET_MIGRATION_REPORT_CHANNEL';
export type GenerateWalletMigrationReportRendererRequest = WalletMigrationReportData;
export type GenerateWalletMigrationReportMainResponse = void;
/**
* Channel for generating wallet migration report
*/
export const GET_WASM_BINARY_CHANNEL = 'GET_WASM_BINARY_CHANNEL';
export type getRecoveryWalletIdRendererRequest = Array<string>;
export type getRecoveryWalletIdMainResponse = string;
/**
* Channel for showing open dialog
*/
export const SHOW_OPEN_DIALOG_CHANNEL = 'SHOW_OPEN_DIALOG_CHANNEL';
export type ShowOpenDialogRendererRequest = FileDialogRequestParams;
export type ShowOpenDialogMainResponse = OpenFileDialogResponseParams;
/**
* Channel for showing save dialog
*/
export const SHOW_SAVE_DIALOG_CHANNEL = 'SHOW_SAVE_DIALOG_CHANNEL';
export type ShowSaveDialogRendererRequest = FileDialogRequestParams;
export type ShowSaveDialogMainResponse = SaveFileDialogResponseParams;
/**
* Channel for electron-store
*/
export const ELECTRON_STORE_CHANNEL = 'ELECTRON_STORE_CHANNEL';
export type ElectronStoreMessage = StoreMessage;
/**
* Channel for initiating the download manager
*/
export const GET_DOWNLOAD_LOCAL_DATA = 'GET_DOWNLOAD_LOCAL_DATA';
export type DownloadLocalDataRendererRequest = DownloadLocalDataRequest;
export type DownloadLocalDataMainResponse = DownloadLocalDataResponse;
/**
* Channel for initiating the download manager
*/
export const GET_DOWNLOADS_LOCAL_DATA = 'GET_DOWNLOADS_LOCAL_DATA';
export type DownloadsLocalDataRendererRequest = DownloadsLocalDataRequest | void;
export type DownloadsLocalDataMainResponse = DownloadsLocalDataResponse | void;
/**
* Channel for requesting a new download
*/
export const REQUEST_DOWNLOAD = 'REQUEST_DOWNLOAD';
export type DownloadRendererRequest = DownloadRequest;
export type DownloadMainResponse = DownloadResponse;
/**
* Channel for requesting a new download
*/
export const RESUME_DOWNLOAD = 'RESUME_DOWNLOAD';
export type ResumeDownloadRendererRequest = ResumeDownloadRequest;
export type ResumeDownloadMainResponse = ResumeDownloadResponse | void;
/**
* Channel for introspecting an address
*/
export const INTROSPECT_ADDRESS_CHANNEL = 'INTROSPECT_ADDRESS_CHANNEL';
export type IntrospectAddressRendererRequest = IntrospectAddressRequest;
export type IntrospectAddressMainResponse = IntrospectAddressResponse;
/**
* Channel for checking block replay progress
*/
export const GET_BLOCK_REPLAY_STATUS_CHANNEL = 'GetBlockReplayProgressChannel';
export type GetBlockReplayProgressRendererRequest = void;
export type GetBlockReplayProgressMainResponse = number;