forked from LedgerHQ/ledger-live-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.js
107 lines (96 loc) · 2.72 KB
/
types.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
// @flow
import type { DeviceModel, DeviceModelId } from "@ledgerhq/devices";
import type { Observable, Subject } from "rxjs";
import type { CryptoCurrency } from "../types/currencies";
import type { App, DeviceInfo, FinalFirmware } from "../types/manager";
export type Exec = (
appOp: AppOp,
targetId: string | number,
app: App
) => Observable<{ progress: number }>;
export type InstalledItem = {
name: string,
updated: boolean,
hash: string,
blocks: number,
version: string,
availableVersion: string
};
export type ListAppsEvent =
| { type: "device-permission-requested", wording: string }
| { type: "device-permission-granted" }
| { type: "result", result: ListAppsResult };
export type ListAppsResult = {
appByName: { [_: string]: App },
appsListNames: string[],
installedAvailable: boolean,
installed: InstalledItem[],
deviceInfo: DeviceInfo,
deviceModelId: DeviceModelId,
firmware: ?FinalFirmware
};
export type State = {
deviceInfo: DeviceInfo,
deviceModel: DeviceModel,
firmware: ?FinalFirmware,
appByName: { [_: string]: App },
apps: App[],
installedAvailable: boolean,
installed: InstalledItem[],
recentlyInstalledApps: string[],
installQueue: string[],
uninstallQueue: string[],
// queue saved at the time of a "updateAll" action
updateAllQueue: string[],
currentAppOp: ?AppOp,
currentProgressSubject: ?Subject<number>,
currentError: ?{
error: Error,
appOp: AppOp
}
};
export type AppOp =
| { type: "install", name: string }
| { type: "uninstall", name: string };
export type Action =
// recover from an error
| { type: "recover" }
// wipe will remove all apps of the device
| { type: "wipe" }
// uninstall a specific app by name
| { type: "uninstall", name: string, force?: boolean }
// install or update a specific app by name
| { type: "install", name: string }
// update all
| { type: "updateAll" }
// action to run after an update was done on the device (uninstall/install)
| { type: "onRunnerEvent", event: RunnerEvent };
export type RunnerEvent =
| { type: "runStart", appOp: AppOp }
| { type: "runProgress", appOp: AppOp, progress: number }
| { type: "runError", appOp: AppOp, error: Error }
| { type: "runSuccess", appOp: AppOp };
export type AppData = {
currency: ?CryptoCurrency,
name: string,
blocks: number,
bytes: number
};
export type UnrecognizedAppData = {
name: string,
hash: string
};
export type AppsDistribution = {
totalBlocks: number,
totalBytes: number,
osBlocks: number,
osBytes: number,
apps: Array<AppData>,
appsSpaceBlocks: number,
appsSpaceBytes: number,
totalAppsBlocks: number,
totalAppsBytes: number,
freeSpaceBlocks: number,
freeSpaceBytes: number,
shouldWarnMemory: boolean
};