@exodus/headless 2.0.0-alpha.18 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -126
- package/README.md +20 -146
- package/package.json +12 -35
- package/src/api.js +3 -55
- package/src/application.js +40 -50
- package/src/dependencies/atoms.js +1 -108
- package/src/dependencies/index.js +0 -15
- package/src/dependencies/modules.js +6 -40
- package/src/index.js +4 -77
- package/src/ioc.js +1 -15
- package/src/atoms/attach.js +0 -40
- package/src/constants.js +0 -10
- package/src/dependencies/atom-collections.js +0 -25
- package/src/dependencies/monitors.js +0 -33
- package/src/dependencies/plugins.js +0 -7
- package/src/plugins/attach.js +0 -19
- package/src/plugins/index.js +0 -3
- package/src/plugins/log-lifecycle.js +0 -25
- package/src/unlock-encrypted-storage.js +0 -19
- package/src/utils/blockchain-metadata.js +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,132 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [2.0.0-alpha.18](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.17...@exodus/headless@2.0.0-alpha.18) (2023-05-05)
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
- announce that featureFlags writes to featureFlagAtoms ([#1548](https://github.com/ExodusMovement/exodus-hydra/issues/1548)) ([fefac86](https://github.com/ExodusMovement/exodus-hydra/commit/fefac86970ab11e85d530d8424ca9f3de86fed91))
|
|
11
|
-
|
|
12
|
-
## [2.0.0-alpha.17](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.16...@exodus/headless@2.0.0-alpha.17) (2023-05-05)
|
|
13
|
-
|
|
14
|
-
### ⚠ BREAKING CHANGES
|
|
15
|
-
|
|
16
|
-
- don't serialize port payloads (#1458)
|
|
17
|
-
|
|
18
|
-
### Features
|
|
19
|
-
|
|
20
|
-
- add feature-flags to headless ([#1516](https://github.com/ExodusMovement/exodus-hydra/issues/1516)) ([9d2da89](https://github.com/ExodusMovement/exodus-hydra/commit/9d2da895d4f58d34674b19d42fe3fd621d439f73))
|
|
21
|
-
|
|
22
|
-
### Code Refactoring
|
|
23
|
-
|
|
24
|
-
- don't serialize port payloads ([#1458](https://github.com/ExodusMovement/exodus-hydra/issues/1458)) ([9b98a28](https://github.com/ExodusMovement/exodus-hydra/commit/9b98a28b091146ad0dee631a236629f25a16b3e2))
|
|
25
|
-
|
|
26
|
-
## [2.0.0-alpha.16](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.15...@exodus/headless@2.0.0-alpha.16) (2023-05-04)
|
|
27
|
-
|
|
28
|
-
### Bug Fixes
|
|
29
|
-
|
|
30
|
-
- bump atoms in headless ([#1523](https://github.com/ExodusMovement/exodus-hydra/issues/1523)) ([7b6ca0b](https://github.com/ExodusMovement/exodus-hydra/commit/7b6ca0b19ccad9e33c9c0f0aac03feddad9d4cac))
|
|
31
|
-
|
|
32
|
-
## [2.0.0-alpha.15](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.14...@exodus/headless@2.0.0-alpha.15) (2023-05-04)
|
|
33
|
-
|
|
34
|
-
### ⚠ BREAKING CHANGES
|
|
35
|
-
|
|
36
|
-
- use readOnlyAtoms dependency processor (#1497)
|
|
37
|
-
|
|
38
|
-
### Features
|
|
39
|
-
|
|
40
|
-
- add geolocation to headless ([#1514](https://github.com/ExodusMovement/exodus-hydra/issues/1514)) ([44a8620](https://github.com/ExodusMovement/exodus-hydra/commit/44a8620249f8de2147dc073098b68f0562fb7287))
|
|
41
|
-
- use readOnlyAtoms dependency processor ([#1497](https://github.com/ExodusMovement/exodus-hydra/issues/1497)) ([b3b4866](https://github.com/ExodusMovement/exodus-hydra/commit/b3b4866084428496aeff30dcb14ec583d6f4d64f))
|
|
42
|
-
|
|
43
|
-
### Bug Fixes
|
|
44
|
-
|
|
45
|
-
- enabledAssets storage access ([#1519](https://github.com/ExodusMovement/exodus-hydra/issues/1519)) ([c4d9463](https://github.com/ExodusMovement/exodus-hydra/commit/c4d9463829b0015e70ce617e11940b1fea5bfbe6))
|
|
46
|
-
|
|
47
|
-
## [2.0.0-alpha.14](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.13...@exodus/headless@2.0.0-alpha.14) (2023-05-03)
|
|
48
|
-
|
|
49
|
-
**Note:** Version bump only for package @exodus/headless
|
|
50
|
-
|
|
51
|
-
## [2.0.0-alpha.13](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.12...@exodus/headless@2.0.0-alpha.13) (2023-05-02)
|
|
52
|
-
|
|
53
|
-
### Features
|
|
54
|
-
|
|
55
|
-
- add rates monitor to headless ([#1470](https://github.com/ExodusMovement/exodus-hydra/issues/1470)) ([d214b9a](https://github.com/ExodusMovement/exodus-hydra/commit/d214b9a22ca0649bbd79e2c8f6d9592733c802d2))
|
|
56
|
-
|
|
57
|
-
### Bug Fixes
|
|
58
|
-
|
|
59
|
-
- get assetsModule from 'adapters' ([#1491](https://github.com/ExodusMovement/exodus-hydra/issues/1491)) ([b010cbd](https://github.com/ExodusMovement/exodus-hydra/commit/b010cbd319ffcd02d18a7492dc20e2d7ba7fe1c4))
|
|
60
|
-
|
|
61
|
-
## [2.0.0-alpha.12](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.11...@exodus/headless@2.0.0-alpha.12) (2023-05-02)
|
|
62
|
-
|
|
63
|
-
### Features
|
|
64
|
-
|
|
65
|
-
- add balances to headless ([#1379](https://github.com/ExodusMovement/exodus-hydra/issues/1379)) ([b5d6846](https://github.com/ExodusMovement/exodus-hydra/commit/b5d6846d86b9d83463ece51a2ef14c4fd898d438))
|
|
66
|
-
|
|
67
|
-
## [2.0.0-alpha.11](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.10...@exodus/headless@2.0.0-alpha.11) (2023-05-02)
|
|
68
|
-
|
|
69
|
-
### Features
|
|
70
|
-
|
|
71
|
-
- migrate locales atoms ([#1457](https://github.com/ExodusMovement/exodus-hydra/issues/1457)) ([e6f3a7f](https://github.com/ExodusMovement/exodus-hydra/commit/e6f3a7feb4319d8aa44032e27df746343fdb66eb))
|
|
72
|
-
- migrate market history module ([#1456](https://github.com/ExodusMovement/exodus-hydra/issues/1456)) ([3e64532](https://github.com/ExodusMovement/exodus-hydra/commit/3e64532b739ea802f0df841b7c030c2c912d57e8))
|
|
73
|
-
|
|
74
|
-
## [2.0.0-alpha.10](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.9...@exodus/headless@2.0.0-alpha.10) (2023-04-30)
|
|
75
|
-
|
|
76
|
-
### Features
|
|
77
|
-
|
|
78
|
-
- add pricingClient to headless ([#1439](https://github.com/ExodusMovement/exodus-hydra/issues/1439)) ([2a82a4c](https://github.com/ExodusMovement/exodus-hydra/commit/2a82a4c663b542178580908aaaff840524d55369))
|
|
79
|
-
- attach wallet account atoms ([#1437](https://github.com/ExodusMovement/exodus-hydra/issues/1437)) ([2648699](https://github.com/ExodusMovement/exodus-hydra/commit/264869986c175091e6bc7c48e852946bd60911d6))
|
|
80
|
-
|
|
81
|
-
## [2.0.0-alpha.9](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.8...@exodus/headless@2.0.0-alpha.9) (2023-04-26)
|
|
82
|
-
|
|
83
|
-
### Features
|
|
84
|
-
|
|
85
|
-
- add available-assets to headless ([#1361](https://github.com/ExodusMovement/exodus-hydra/issues/1361)) ([900d142](https://github.com/ExodusMovement/exodus-hydra/commit/900d142018ff112f36ef0f7ef53cf5020020e3ca))
|
|
86
|
-
|
|
87
|
-
## [2.0.0-alpha.8](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.7...@exodus/headless@2.0.0-alpha.8) (2023-04-25)
|
|
88
|
-
|
|
89
|
-
### Features
|
|
90
|
-
|
|
91
|
-
- add enabled-assets to headless ([#1235](https://github.com/ExodusMovement/exodus-hydra/issues/1235)) ([a808b75](https://github.com/ExodusMovement/exodus-hydra/commit/a808b750bd911c33241ae710fbf8d8ba7e2073a6))
|
|
92
|
-
- add lifecycle docs ([#1313](https://github.com/ExodusMovement/exodus-hydra/issues/1313)) ([df18faa](https://github.com/ExodusMovement/exodus-hydra/commit/df18faa9c341404c2feaadf51ec46236c54e2f15))
|
|
93
|
-
- add remoteConfig module ([#1370](https://github.com/ExodusMovement/exodus-hydra/issues/1370)) ([ebc888d](https://github.com/ExodusMovement/exodus-hydra/commit/ebc888d6440c509a19dd6c9c600033fd41128ad7))
|
|
94
|
-
- add support for plugins ([#1351](https://github.com/ExodusMovement/exodus-hydra/issues/1351)) ([fac0e2a](https://github.com/ExodusMovement/exodus-hydra/commit/fac0e2a727b0e71ad5f0619b8457c7e80612f707))
|
|
95
|
-
|
|
96
|
-
## [2.0.0-alpha.7](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.6...@exodus/headless@2.0.0-alpha.7) (2023-04-24)
|
|
97
|
-
|
|
98
|
-
### ⚠ BREAKING CHANGES
|
|
99
|
-
|
|
100
|
-
- pass compatibility modes config to wallet (#1223)
|
|
101
|
-
|
|
102
|
-
### Features
|
|
103
|
-
|
|
104
|
-
- add blockchain metadata to headless ([#1293](https://github.com/ExodusMovement/exodus-hydra/issues/1293)) ([04390a7](https://github.com/ExodusMovement/exodus-hydra/commit/04390a71cb01744cd427f470735fa0748b9157ca))
|
|
105
|
-
- add namespaceStorage preprocessor ([#1322](https://github.com/ExodusMovement/exodus-hydra/issues/1322)) ([95f403e](https://github.com/ExodusMovement/exodus-hydra/commit/95f403e59c87f90901247619c727496ebac0a399))
|
|
106
|
-
- pass compatibility modes config to wallet ([#1223](https://github.com/ExodusMovement/exodus-hydra/issues/1223)) ([b49b640](https://github.com/ExodusMovement/exodus-hydra/commit/b49b64097af7969e210e5ecf5395ee7f40a13eac))
|
|
107
|
-
|
|
108
|
-
## [2.0.0-alpha.6](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.5...@exodus/headless@2.0.0-alpha.6) (2023-04-20)
|
|
109
|
-
|
|
110
|
-
### Features
|
|
111
|
-
|
|
112
|
-
- add walletAccounts in headless ([#1184](https://github.com/ExodusMovement/exodus-hydra/issues/1184)) ([8d9c93d](https://github.com/ExodusMovement/exodus-hydra/commit/8d9c93d86173476211d596e883a72b51b645e866))
|
|
113
|
-
|
|
114
|
-
## [2.0.0-alpha.5](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.4...@exodus/headless@2.0.0-alpha.5) (2023-04-20)
|
|
115
|
-
|
|
116
|
-
### Features
|
|
117
|
-
|
|
118
|
-
- force restart on import ([#1297](https://github.com/ExodusMovement/exodus-hydra/issues/1297)) ([3900196](https://github.com/ExodusMovement/exodus-hydra/commit/39001966ce7d962ddde9df8aa3b93619053569f8))
|
|
119
|
-
- **headless:** clear storage when seed not present ([#1300](https://github.com/ExodusMovement/exodus-hydra/issues/1300)) ([c3c76f5](https://github.com/ExodusMovement/exodus-hydra/commit/c3c76f5953d91e5ef308b129f1bb2fec0dc41500))
|
|
120
|
-
- unlock encrypted storage on wallet unlock ([#1304](https://github.com/ExodusMovement/exodus-hydra/issues/1304)) ([09ea5f2](https://github.com/ExodusMovement/exodus-hydra/commit/09ea5f20ff9547557f59d4c416cee3291f348fdf))
|
|
121
|
-
|
|
122
|
-
## [2.0.0-alpha.4](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.3...@exodus/headless@2.0.0-alpha.4) (2023-04-13)
|
|
123
|
-
|
|
124
|
-
**Note:** Version bump only for package @exodus/headless
|
|
125
|
-
|
|
126
|
-
## [2.0.0-alpha.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.2...@exodus/headless@2.0.0-alpha.3) (2023-04-11)
|
|
127
|
-
|
|
128
|
-
### Features
|
|
129
|
-
|
|
130
|
-
- export subscribe/unsubscribe ([#1161](https://github.com/ExodusMovement/exodus-hydra/issues/1161)) ([7da465f](https://github.com/ExodusMovement/exodus-hydra/commit/7da465fc1734fd0818a55ff740704adb8c6ae222))
|
|
131
|
-
|
|
132
6
|
## [2.0.0-alpha.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.1...@exodus/headless@2.0.0-alpha.2) (2023-04-10)
|
|
133
7
|
|
|
134
8
|
### Features
|
package/README.md
CHANGED
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The headless Exodus wallet SDK
|
|
4
4
|
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Quick Start](#quick-start)
|
|
8
|
-
- [Lifecycle](#lifecycle)
|
|
9
|
-
- [Port](#port)
|
|
10
|
-
- [Adapters](#adapters)
|
|
11
|
-
- [Config](#config)
|
|
12
|
-
- [Headless API](#headless-api)
|
|
13
|
-
|
|
14
5
|
## Quick Start
|
|
15
6
|
|
|
16
7
|
```js
|
|
@@ -43,74 +34,15 @@ const exodus = container.resolve()
|
|
|
43
34
|
await exodus.wallet.create({ passphrase: 'my-super-secure-passphrase' })
|
|
44
35
|
```
|
|
45
36
|
|
|
46
|
-
## Lifecycle
|
|
47
|
-
|
|
48
|
-
The headless wallet instance transitions through different states during his life. When moving from one another, there are two things that are triggered:
|
|
49
|
-
|
|
50
|
-
- Fires hook call: Allows modules to subscribe and halt transition until listener resolves.
|
|
51
|
-
- Fires event call: Emitted after all hooks had been executed and resolved.
|
|
52
|
-
|
|
53
|
-
Below you can find a state diagram that visualize what hooks are triggered between state transitions:
|
|
54
|
-
|
|
55
|
-
```mermaid
|
|
56
|
-
stateDiagram-v2
|
|
57
|
-
direction LR
|
|
58
|
-
[*] --> Starting
|
|
59
|
-
|
|
60
|
-
state Starting {
|
|
61
|
-
direction LR
|
|
62
|
-
|
|
63
|
-
state "Needs clear storage?*" as NeedsClear
|
|
64
|
-
state "Is importing?" as IsImporting
|
|
65
|
-
|
|
66
|
-
NeedsClear --> Clearing : CLEAR
|
|
67
|
-
Clearing --> IsImporting
|
|
68
|
-
IsImporting --> Importing : IMPORT
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
Starting --> Started : START
|
|
72
|
-
|
|
73
|
-
state Started {
|
|
74
|
-
direction LR
|
|
75
|
-
|
|
76
|
-
state "Has seed?" as HasSeed
|
|
77
|
-
|
|
78
|
-
HasSeed --> Empty : No
|
|
79
|
-
HasSeed --> Locked : Yes
|
|
80
|
-
|
|
81
|
-
Empty --> Locked : CREATE \n---or---\nIMPORT
|
|
82
|
-
|
|
83
|
-
Locked --> Migrating : MIGRATE
|
|
84
|
-
Migrating --> Unlocked : UNLOCK
|
|
85
|
-
Unlocked --> Locked : LOCK
|
|
86
|
-
|
|
87
|
-
Unlocked --> Restarting : DELETE
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
Restarting --> [*] : RESTART
|
|
93
|
-
|
|
94
|
-
Started --> Started : LOAD
|
|
95
|
-
|
|
96
|
-
classDef conditional fill:#ededed,stroke:#c2c2c2,color:#a6a6a6,stroke-width:2;
|
|
97
|
-
|
|
98
|
-
class NeedsClear conditional
|
|
99
|
-
class IsImporting conditional
|
|
100
|
-
class HasSeed conditional
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
\* Wallet needs to clear storage if seed is not present or is restoring a new wallet
|
|
104
|
-
|
|
105
37
|
## Port
|
|
106
38
|
|
|
107
39
|
Event bus between headless wallet and client
|
|
108
40
|
|
|
109
|
-
| Method
|
|
110
|
-
|
|
|
111
|
-
| subscribe
|
|
112
|
-
| unsubscribe | `({ type: string, payload: any }) => void` | Unsubscribe handler from receiving events. |
|
|
113
|
-
| emit
|
|
41
|
+
| Method | Type | Description |
|
|
42
|
+
| -------------------- | ------------------------------------------ | ------------------------------------------ |
|
|
43
|
+
| subscribe | `({ type: string, payload: any }) => void` | Subscribe to receive events. |
|
|
44
|
+
| unsubscribe(handler) | `({ type: string, payload: any }) => void` | Unsubscribe handler from receiving events. |
|
|
45
|
+
| emit | `(type: string, payload: any) => void` | Emit an event. |
|
|
114
46
|
|
|
115
47
|
## Adapters
|
|
116
48
|
|
|
@@ -189,21 +121,21 @@ Currently not used.
|
|
|
189
121
|
|
|
190
122
|
> Type: object
|
|
191
123
|
|
|
192
|
-
| Method | Type
|
|
193
|
-
| ------------------------ |
|
|
194
|
-
| exists | `async () => boolean`
|
|
195
|
-
| create | `async ({ passphrase?: string }) => void`
|
|
196
|
-
| import | `async ({ mnemonic: string, passphrase?: string
|
|
197
|
-
| delete | `async ({ passphrase?: string }) => void`
|
|
198
|
-
| lock | `async () => void`
|
|
199
|
-
| unlock | `async ({ passphrase?: string }) => void`
|
|
200
|
-
| isLocked | `async () => boolean`
|
|
201
|
-
| getMnemonic | `async () => void`
|
|
202
|
-
| changePassphrase | `async ({ currentPassphrase?: string. newPassphrase: string }) => void`
|
|
203
|
-
| restoreFromCurrentPhrase | `async ({ passphrase?: string }) => void`
|
|
204
|
-
| load | `async () => void`
|
|
205
|
-
| unload | `async () => void`
|
|
206
|
-
| changeLockTimer | `async ({ ttl: number }) => void`
|
|
124
|
+
| Method | Type | Description |
|
|
125
|
+
| ------------------------ | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
126
|
+
| exists | `async () => boolean` | Checks if a wallet exists on the device. |
|
|
127
|
+
| create | `async ({ passphrase?: string }) => void` | Creates new wallet |
|
|
128
|
+
| import | `async ({ mnemonic: string, passphrase?: string }) => void` | Imports existing wallet |
|
|
129
|
+
| delete | `async ({ passphrase?: string }) => void` | Deletes wallet. Passphrase is mandatory if wallet was created with one |
|
|
130
|
+
| lock | `async () => void` | Locks wallet |
|
|
131
|
+
| unlock | `async ({ passphrase?: string }) => void` | Unlocks wallet. Passphrase is mandatory if wallet was created with one |
|
|
132
|
+
| isLocked | `async () => boolean` | Checks if wallet is locked |
|
|
133
|
+
| getMnemonic | `async () => void` | Sets wallet as backed up |
|
|
134
|
+
| changePassphrase | `async ({ currentPassphrase?: string. newPassphrase: string }) => void` | Change passphrase. Current passphrase is mandatory if wallet was created with one |
|
|
135
|
+
| restoreFromCurrentPhrase | `async ({ passphrase?: string }) => void` | Restore current wallet. Passphrase is mandatory if wallet was created with one |
|
|
136
|
+
| load | `async () => void` | Loads UI by rehydratating data through port (`BE Only`) |
|
|
137
|
+
| unload | `async () => void` | Unloads UI by rehydratating data through port (`BE Only`) |
|
|
138
|
+
| changeLockTimer | `async ({ ttl: number }) => void` | Change auto unlock ttl (`BE Only`) |
|
|
207
139
|
|
|
208
140
|
## isMnemonicValid
|
|
209
141
|
|
|
@@ -215,61 +147,3 @@ Currently not used.
|
|
|
215
147
|
| wordlist | `string[]` | Words list to check against. |
|
|
216
148
|
|
|
217
149
|
**Returns**: `boolean`
|
|
218
|
-
|
|
219
|
-
## walletAccounts
|
|
220
|
-
|
|
221
|
-
> Type: object
|
|
222
|
-
|
|
223
|
-
| Method | Type | Description |
|
|
224
|
-
| ---------- | ------------------------------------------- | -------------------------------------------------------------- |
|
|
225
|
-
| create | `async (walletAccountFields) => void` | Creates a new WalletAccount with the provided fields. |
|
|
226
|
-
| update | `async (name, walletAccountFields) => void` | Updates an existing WalletAccount with the provided fields. |
|
|
227
|
-
| enable | `async (name) => void` | Enables an existing WalletAccount. |
|
|
228
|
-
| disable | `async (name) => void` | Disables an existing WalletAccount. |
|
|
229
|
-
| getEnabled | `async () => object` | Returns enabled walletAccounts as `{ [name]: WalletAccount }`. |
|
|
230
|
-
|
|
231
|
-
## blockchainMetadata
|
|
232
|
-
|
|
233
|
-
> Type: object
|
|
234
|
-
|
|
235
|
-
| Method | Type | Description |
|
|
236
|
-
| ---------------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
237
|
-
| getTxLog | `async ({ assetName, walletAccount }) => TxSet` | Get the TxSet for the provided `assetName`/`walletAccount` combination (AssetSource) |
|
|
238
|
-
| getLoadedTxLogs | `async () => object` | Get the all loaded `TxSet`s as a `{ [walletAccount]: { [assetName]: TxSet } } object` |
|
|
239
|
-
| updateTxs | `async ({ assetName: string, walletAccount: string, txs: object[] }) => void` | Add or update txs with updates provided in `txs` |
|
|
240
|
-
| overwriteTxs | `async ({ assetName: string, walletAccount: string, txs: object[], notifyReceivedTxs: ?boolean }) => void` | Overwrite specified txs. |
|
|
241
|
-
| clearTxs | `async ({ assetName: string, walletAccount: string }) => void` | Remove txs for AssetSource. |
|
|
242
|
-
| removeTxs | `async ({ assetName: string, walletAccount: string, txs: object[] }) => void` | Remove provided txs. |
|
|
243
|
-
| getAccountState | `async ({ assetName, walletAccount }) => AccountState` | Get the AccountState for the provided AssetSource |
|
|
244
|
-
| getLoadedAccountStates | `async () => object` | Get the all loaded `AccountState`s as a `{ [walletAccount]: { [assetName]: AccountState } } object` |
|
|
245
|
-
| updateAccountState | `async ({ assetName: string, walletAccount: string, newData: object }) => void` | Update accountState for AssetSource. |
|
|
246
|
-
| removeAccountState | `async ({ assetName: string, walletAccount: string }) => void` | Remove accountState for AssetSource. |
|
|
247
|
-
| batch | `() => Batch` | Create a batch of updates. See [blockchainMetadata](../blockchain-metadata) README for batching details. |
|
|
248
|
-
|
|
249
|
-
## assets
|
|
250
|
-
|
|
251
|
-
> Type: object
|
|
252
|
-
|
|
253
|
-
| Method | Type | Description |
|
|
254
|
-
| ----------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
255
|
-
| enable | `async (assetNames: string[]) => void` | Enables assets. |
|
|
256
|
-
| disable | `async (assetNames: string[]) => void` | Disables assets. |
|
|
257
|
-
| addAndEnableToken | `async (assetId: string, baseAssetName: string) => string` | Adds and enables a custom token. Returns the created `asset`'s `.name` |
|
|
258
|
-
|
|
259
|
-
## locale
|
|
260
|
-
|
|
261
|
-
> Type: object
|
|
262
|
-
|
|
263
|
-
| Method | Type | Description |
|
|
264
|
-
| ----------- | ---------------------------------- | ------------------------- |
|
|
265
|
-
| setCurrency | `async (currency: string) => void` | Changes current currency. |
|
|
266
|
-
| setLanguage | `async (language: string) => void` | Changes current language. |
|
|
267
|
-
|
|
268
|
-
## subscribe
|
|
269
|
-
|
|
270
|
-
> Type: function
|
|
271
|
-
|
|
272
|
-
| Argument | Type | Description |
|
|
273
|
-
| ----------- | ------------------------------------------ | ------------------------------------------ |
|
|
274
|
-
| subscribe | `({ type: string, payload: any }) => void` | Subscribe to receive events. |
|
|
275
|
-
| unsubscribe | `({ type: string, payload: any }) => void` | Unsubscribe handler from receiving events. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/headless",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"description": "The headless Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement Inc",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -26,50 +26,27 @@
|
|
|
26
26
|
"test": "jest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@exodus/atoms": "^
|
|
30
|
-
"@exodus/available-assets": "^2.0.0",
|
|
31
|
-
"@exodus/balances": "^6.0.0",
|
|
32
|
-
"@exodus/basic-utils": "^2.0.0",
|
|
33
|
-
"@exodus/blockchain-metadata": "^8.0.1",
|
|
34
|
-
"@exodus/config": "^7.0.0",
|
|
29
|
+
"@exodus/atoms": "^2.9.0",
|
|
35
30
|
"@exodus/dependency-injection": "^1.2.0",
|
|
36
|
-
"@exodus/dependency-preprocessors": "^2.
|
|
37
|
-
"@exodus/enabled-assets": "^6.0.0",
|
|
38
|
-
"@exodus/exodus-pricing-client": "^1.1.0",
|
|
39
|
-
"@exodus/feature-flags": "^2.0.0",
|
|
31
|
+
"@exodus/dependency-preprocessors": "^2.0.2",
|
|
40
32
|
"@exodus/fetch": "^1.2.1",
|
|
41
|
-
"@exodus/
|
|
42
|
-
"@exodus/
|
|
43
|
-
"@exodus/keychain": "^4.0.0",
|
|
44
|
-
"@exodus/market-history": "^3.1.0",
|
|
33
|
+
"@exodus/key-identifier-provider": "^1.1.1",
|
|
34
|
+
"@exodus/keychain": "^3.2.1",
|
|
45
35
|
"@exodus/module": "^1.0.0",
|
|
46
|
-
"@exodus/
|
|
47
|
-
"@exodus/wallet": "
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"bip39": "^2.6.0",
|
|
51
|
-
"events": "^3.3.0",
|
|
52
|
-
"lodash": "npm:@exodus/lodash@^4.17.21-exodus.2",
|
|
36
|
+
"@exodus/wallet": "^5.0.0",
|
|
37
|
+
"@exodus/wallet-compatibility-modes": "1.0.2",
|
|
38
|
+
"bip39": "2.6.0",
|
|
39
|
+
"lodash": "https://registry.yarnpkg.com/@exodus/lodash/-/lodash-4.17.21-exodus.2.tgz",
|
|
53
40
|
"minimalistic-assert": "^1.0.1"
|
|
54
41
|
},
|
|
55
42
|
"devDependencies": {
|
|
56
|
-
"@exodus/bitcoin-meta": "^1.0.0",
|
|
57
|
-
"@exodus/currency": "^2.2.0",
|
|
58
43
|
"@exodus/ethereum-lib": "^2.22.2",
|
|
59
|
-
"@exodus/ethereum-meta": "^1.0.23",
|
|
60
|
-
"@exodus/models": "^8.11.1",
|
|
61
44
|
"@exodus/solana-lib": "^1.3.11",
|
|
62
|
-
"@exodus/
|
|
63
|
-
"@exodus/storage-encrypted": "^1.1.2",
|
|
64
|
-
"@exodus/storage-memory": "^2.0.0",
|
|
45
|
+
"@exodus/storage-memory": "^1.1.0",
|
|
65
46
|
"@exodus/wild-emitter": "^1.0.0",
|
|
66
47
|
"buffer-json": "^2.0.0",
|
|
67
|
-
"deepmerge": "^4.2.2",
|
|
68
48
|
"eslint": "^8.33.0",
|
|
69
|
-
"
|
|
70
|
-
"jest": "^29.1.2",
|
|
71
|
-
"nock": "^13.3.1",
|
|
72
|
-
"p-defer": "^4.0.0"
|
|
49
|
+
"jest": "^29.1.2"
|
|
73
50
|
},
|
|
74
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "58929429bb5b339e14fd422ed9955d9765b3394c"
|
|
75
52
|
}
|
package/src/api.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { validateMnemonic as isMnemonicValid } from 'bip39'
|
|
2
2
|
|
|
3
|
-
const createApi = ({ ioc
|
|
4
|
-
const {
|
|
3
|
+
const createApi = ({ ioc }) => {
|
|
4
|
+
const { passphraseCache } = ioc.getByType('adapter')
|
|
5
5
|
|
|
6
|
-
const { application,
|
|
7
|
-
ioc.getByType('module')
|
|
8
|
-
|
|
9
|
-
const { ratesMonitor } = ioc.getByType('monitor')
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
// ...
|
|
13
|
-
currencyAtom,
|
|
14
|
-
enabledWalletAccountsAtom,
|
|
15
|
-
languageAtom,
|
|
16
|
-
} = ioc.getByType('atom')
|
|
6
|
+
const { application, wallet } = ioc.getByType('module')
|
|
17
7
|
|
|
18
8
|
return {
|
|
19
9
|
wallet: {
|
|
@@ -37,49 +27,7 @@ const createApi = ({ ioc, port }) => {
|
|
|
37
27
|
changeLockTimer: application.changeLockTimer,
|
|
38
28
|
isLocked: () => wallet.isLocked(),
|
|
39
29
|
},
|
|
40
|
-
walletAccounts: {
|
|
41
|
-
create: walletAccounts.create,
|
|
42
|
-
update: walletAccounts.update,
|
|
43
|
-
disable: walletAccounts.disable,
|
|
44
|
-
enable: walletAccounts.enable,
|
|
45
|
-
getEnabled: enabledWalletAccountsAtom.get,
|
|
46
|
-
},
|
|
47
|
-
blockchainMetadata: {
|
|
48
|
-
getTxLog: blockchainMetadata.getTxLog,
|
|
49
|
-
getLoadedTxLogs: blockchainMetadata.getLoadedTxLogs,
|
|
50
|
-
updateTxs: blockchainMetadata.updateTxs,
|
|
51
|
-
overwriteTxs: blockchainMetadata.overwriteTxs,
|
|
52
|
-
clearTxs: blockchainMetadata.clearTxs,
|
|
53
|
-
removeTxs: blockchainMetadata.removeTxs,
|
|
54
|
-
getAccountState: blockchainMetadata.getAccountState,
|
|
55
|
-
getLoadedAccountStates: blockchainMetadata.getLoadedAccountStates,
|
|
56
|
-
updateAccountState: blockchainMetadata.updateAccountState,
|
|
57
|
-
removeAccountState: blockchainMetadata.removeAccountState,
|
|
58
|
-
batch: blockchainMetadata.batch,
|
|
59
|
-
},
|
|
60
|
-
assets: {
|
|
61
|
-
enable: enabledAssets.enable,
|
|
62
|
-
disable: enabledAssets.disable,
|
|
63
|
-
addAndEnableToken: async (...args) => {
|
|
64
|
-
const asset = await assetsModule.addToken(...args)
|
|
65
|
-
await enabledAssets.enable([asset.name])
|
|
66
|
-
return asset.name
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
remoteConfig: {
|
|
70
|
-
get: remoteConfig.get,
|
|
71
|
-
getAll: remoteConfig.getAll,
|
|
72
|
-
},
|
|
73
|
-
locale: {
|
|
74
|
-
setLanguage: (value) => languageAtom.set(value),
|
|
75
|
-
setCurrency: (value) => currencyAtom.set(value),
|
|
76
|
-
},
|
|
77
|
-
rates: {
|
|
78
|
-
refresh: () => ratesMonitor.update(),
|
|
79
|
-
},
|
|
80
30
|
isMnemonicValid,
|
|
81
|
-
subscribe: port.subscribe.bind(port),
|
|
82
|
-
unsubscribe: port.unsubscribe.bind(port),
|
|
83
31
|
}
|
|
84
32
|
}
|
|
85
33
|
|
package/src/application.js
CHANGED
|
@@ -17,25 +17,23 @@ const IMPORT_FLAG = 'importFlag'
|
|
|
17
17
|
// Set as true on import method is called, and set to false after restore is completed
|
|
18
18
|
const RESTORE_FLAG = 'restoreFlag'
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const HOOKS = Object.freeze({
|
|
21
|
+
lock: 'lock',
|
|
22
|
+
unlock: 'unlock',
|
|
23
|
+
clear: 'clear',
|
|
24
|
+
import: 'import',
|
|
25
|
+
migrate: 'migrate',
|
|
26
|
+
start: 'start',
|
|
27
|
+
load: 'load',
|
|
28
|
+
unload: 'unload',
|
|
29
|
+
create: 'create',
|
|
30
|
+
backup: 'backup',
|
|
31
|
+
restore: 'restore',
|
|
32
|
+
'restore-completed': 'restore-completed',
|
|
33
|
+
'assets-synced': 'assets-synced',
|
|
34
|
+
'change-passphrase': 'change-passphrase',
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
-
const HOOKS = new Set(Object.values(Hook))
|
|
38
|
-
|
|
39
37
|
class Application extends ExodusModule {
|
|
40
38
|
#hooks = {}
|
|
41
39
|
#wallet = null
|
|
@@ -52,7 +50,6 @@ class Application extends ExodusModule {
|
|
|
52
50
|
this.#storage = unsafeStorage.namespace('flags')
|
|
53
51
|
|
|
54
52
|
this.#applicationStarted = new Promise((resolve) => (this.#resolveStart = resolve))
|
|
55
|
-
this.setMaxListeners(Number.POSITIVE_INFINITY)
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
start = async () => {
|
|
@@ -66,17 +63,12 @@ class Application extends ExodusModule {
|
|
|
66
63
|
if (isDeleting || isImporting) {
|
|
67
64
|
await this.#storage.batchDelete([DELETE_FLAG, IMPORT_FLAG])
|
|
68
65
|
await this.#passphraseCache.clear()
|
|
66
|
+
await this.fire(HOOKS.clear)
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (isImporting || !walletExists) {
|
|
74
|
-
await this.fire(Hook.Clear)
|
|
75
|
-
}
|
|
69
|
+
if (isImporting) await this.fire(HOOKS.import)
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await this.fire(Hook.Start)
|
|
71
|
+
await this.fire(HOOKS.start)
|
|
80
72
|
await this.#autoUnlock()
|
|
81
73
|
|
|
82
74
|
const locked = await this.#wallet.isLocked()
|
|
@@ -96,7 +88,7 @@ class Application extends ExodusModule {
|
|
|
96
88
|
this.isRestoring(),
|
|
97
89
|
])
|
|
98
90
|
|
|
99
|
-
await this.fire(
|
|
91
|
+
await this.fire(HOOKS.load, {
|
|
100
92
|
walletExists,
|
|
101
93
|
hasPassphraseSet,
|
|
102
94
|
isLocked,
|
|
@@ -107,11 +99,11 @@ class Application extends ExodusModule {
|
|
|
107
99
|
unload = async () => {
|
|
108
100
|
await this.#applicationStarted
|
|
109
101
|
await this.#passphraseCache.scheduleClear()
|
|
110
|
-
await this.fire(
|
|
102
|
+
await this.fire(HOOKS.unload)
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
hook = (hookName, listener) => {
|
|
114
|
-
assert(HOOKS
|
|
106
|
+
assert(HOOKS[hookName], `no such hook: ${hookName}`)
|
|
115
107
|
|
|
116
108
|
if (!this.#hooks[hookName]) {
|
|
117
109
|
this.#hooks[hookName] = []
|
|
@@ -121,7 +113,7 @@ class Application extends ExodusModule {
|
|
|
121
113
|
}
|
|
122
114
|
|
|
123
115
|
fire = async (hookName, params) => {
|
|
124
|
-
assert(HOOKS
|
|
116
|
+
assert(HOOKS[hookName], `no such hook: ${hookName}`)
|
|
125
117
|
this._logger.debug('firing hooks', hookName)
|
|
126
118
|
|
|
127
119
|
const hooks = this.#hooks[hookName] || []
|
|
@@ -139,7 +131,7 @@ class Application extends ExodusModule {
|
|
|
139
131
|
await this.#applicationStarted
|
|
140
132
|
await this.#wallet.create(opts)
|
|
141
133
|
|
|
142
|
-
await this.fire(
|
|
134
|
+
await this.fire(HOOKS.create, { hasPassphraseSet: !!opts?.passphrase })
|
|
143
135
|
}
|
|
144
136
|
|
|
145
137
|
import = async (opts) => {
|
|
@@ -149,28 +141,26 @@ class Application extends ExodusModule {
|
|
|
149
141
|
|
|
150
142
|
await this.#applicationStarted
|
|
151
143
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const { forceRestart, ...wallet } = opts
|
|
155
|
-
|
|
156
|
-
await this.#wallet.import(wallet)
|
|
157
|
-
|
|
158
|
-
if (forceRestart || walletExists) {
|
|
144
|
+
if (await this.#wallet.exists()) {
|
|
145
|
+
await this.#wallet.import(opts)
|
|
159
146
|
await this.#storage.set(IMPORT_FLAG, true)
|
|
160
147
|
|
|
161
148
|
this.emit('restart', { reason: 'import' })
|
|
162
|
-
} else {
|
|
163
|
-
await this.fire(Hook.Import)
|
|
164
149
|
|
|
165
|
-
|
|
150
|
+
return
|
|
166
151
|
}
|
|
152
|
+
|
|
153
|
+
await this.#wallet.import(opts)
|
|
154
|
+
await this.fire(HOOKS.import)
|
|
155
|
+
|
|
156
|
+
this._logger.log('wallet imported')
|
|
167
157
|
}
|
|
168
158
|
|
|
169
159
|
getMnemonic = async (opts) => this.#wallet.getMnemonic(opts)
|
|
170
160
|
|
|
171
161
|
setBackedUp = async () => {
|
|
172
162
|
await this.#wallet.setBackedUp()
|
|
173
|
-
await this.fire(
|
|
163
|
+
await this.fire(HOOKS.backup)
|
|
174
164
|
}
|
|
175
165
|
|
|
176
166
|
lock = async (opts) => {
|
|
@@ -179,7 +169,7 @@ class Application extends ExodusModule {
|
|
|
179
169
|
await this.#applicationStarted
|
|
180
170
|
await this.#wallet.lock(opts)
|
|
181
171
|
await this.#passphraseCache.clear()
|
|
182
|
-
await this.fire(
|
|
172
|
+
await this.fire(HOOKS.lock)
|
|
183
173
|
|
|
184
174
|
this._logger.log('locked')
|
|
185
175
|
}
|
|
@@ -188,13 +178,13 @@ class Application extends ExodusModule {
|
|
|
188
178
|
const isRestoring = await this.isRestoring()
|
|
189
179
|
|
|
190
180
|
if (isRestoring) {
|
|
191
|
-
await this.fire(
|
|
181
|
+
await this.fire(HOOKS.restore)
|
|
192
182
|
await this.#storage.delete(RESTORE_FLAG)
|
|
193
183
|
await this.setBackedUp()
|
|
194
|
-
await this.fire(
|
|
184
|
+
await this.fire(HOOKS['restore-completed'])
|
|
195
185
|
}
|
|
196
186
|
|
|
197
|
-
this.fire(
|
|
187
|
+
this.fire(HOOKS['assets-synced'])
|
|
198
188
|
}
|
|
199
189
|
|
|
200
190
|
#autoUnlock = async () => {
|
|
@@ -207,7 +197,7 @@ class Application extends ExodusModule {
|
|
|
207
197
|
this._logger.log('unlocking with cache')
|
|
208
198
|
|
|
209
199
|
await this.#wallet.unlock({ passphrase })
|
|
210
|
-
await this.fire(
|
|
200
|
+
await this.fire(HOOKS.unlock)
|
|
211
201
|
|
|
212
202
|
this.#restoreIfNeeded()
|
|
213
203
|
|
|
@@ -223,8 +213,8 @@ class Application extends ExodusModule {
|
|
|
223
213
|
await this.#applicationStarted
|
|
224
214
|
await this.#wallet.unlock({ passphrase })
|
|
225
215
|
|
|
226
|
-
await this.fire(
|
|
227
|
-
await this.fire(
|
|
216
|
+
await this.fire(HOOKS.migrate)
|
|
217
|
+
await this.fire(HOOKS.unlock)
|
|
228
218
|
|
|
229
219
|
this.#restoreIfNeeded()
|
|
230
220
|
|
|
@@ -239,7 +229,7 @@ class Application extends ExodusModule {
|
|
|
239
229
|
await this.#applicationStarted
|
|
240
230
|
await this.#wallet.changePassphrase({ currentPassphrase, newPassphrase })
|
|
241
231
|
await this.#passphraseCache.set(newPassphrase)
|
|
242
|
-
await this.fire(
|
|
232
|
+
await this.fire(HOOKS['change-passphrase'])
|
|
243
233
|
|
|
244
234
|
this._logger.log('passphrase changed')
|
|
245
235
|
}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createInMemoryAtom,
|
|
3
|
-
createRemoteConfigAtomFactory,
|
|
4
|
-
createStorageAtomFactory,
|
|
5
|
-
createFusionAtomFactory,
|
|
6
|
-
} from '@exodus/atoms'
|
|
7
|
-
import {
|
|
8
|
-
walletAccountsAtomDefinition,
|
|
9
|
-
enabledWalletAccountsAtomDefinition,
|
|
10
|
-
} from '@exodus/wallet-accounts/atoms'
|
|
11
|
-
import {
|
|
12
|
-
enabledAndDisabledAssetsAtomDefinition,
|
|
13
|
-
enabledAssetsAtomDefinition,
|
|
14
|
-
} from '@exodus/enabled-assets/atoms'
|
|
15
|
-
import { availableAssetNamesAtomDefinition } from '@exodus/available-assets/atoms'
|
|
16
|
-
import { ratesAtomDefinition } from '@exodus/rates-monitor/atoms'
|
|
17
|
-
import { balancesAtomDefinition } from '@exodus/balances/atoms'
|
|
18
|
-
import createGeolocationAtom from '@exodus/geolocation'
|
|
19
|
-
import { featureFlagsAtomDefinition } from '@exodus/feature-flags/atoms'
|
|
20
|
-
|
|
1
|
+
import { createInMemoryAtom } from '@exodus/atoms'
|
|
21
2
|
import { withType } from './utils'
|
|
22
3
|
|
|
23
4
|
const createAtomDependencies = () =>
|
|
@@ -29,94 +10,6 @@ const createAtomDependencies = () =>
|
|
|
29
10
|
dependencies: [],
|
|
30
11
|
},
|
|
31
12
|
},
|
|
32
|
-
{
|
|
33
|
-
definition: walletAccountsAtomDefinition,
|
|
34
|
-
storage: { namespace: 'walletAccounts' },
|
|
35
|
-
},
|
|
36
|
-
{ definition: enabledWalletAccountsAtomDefinition },
|
|
37
|
-
{
|
|
38
|
-
definition: enabledAndDisabledAssetsAtomDefinition,
|
|
39
|
-
storage: { namespace: 'enabledAssets' },
|
|
40
|
-
},
|
|
41
|
-
{ definition: enabledAssetsAtomDefinition },
|
|
42
|
-
{ definition: availableAssetNamesAtomDefinition },
|
|
43
|
-
{
|
|
44
|
-
definition: {
|
|
45
|
-
id: 'pricingServerUrlAtom',
|
|
46
|
-
factory: ({ config, remoteConfig }) =>
|
|
47
|
-
createRemoteConfigAtomFactory({ remoteConfig })({
|
|
48
|
-
path: config.pricingServerPath,
|
|
49
|
-
defaultValue: config.defaultPricingServerUrl,
|
|
50
|
-
}),
|
|
51
|
-
dependencies: ['config', 'remoteConfig'],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
definition: {
|
|
56
|
-
id: 'languageAtom',
|
|
57
|
-
factory: ({ storage, config }) =>
|
|
58
|
-
createStorageAtomFactory({ storage })({
|
|
59
|
-
key: 'language',
|
|
60
|
-
defaultValue: config.defaultValue,
|
|
61
|
-
isSoleWriter: true,
|
|
62
|
-
}),
|
|
63
|
-
dependencies: ['storage', 'config'],
|
|
64
|
-
},
|
|
65
|
-
aliases: [
|
|
66
|
-
{
|
|
67
|
-
implementationId: 'unsafeStorage',
|
|
68
|
-
interfaceId: 'storage',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
storage: { namespace: 'locale' },
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
definition: {
|
|
75
|
-
id: 'currencyAtom',
|
|
76
|
-
factory: ({ fusion, config }) =>
|
|
77
|
-
createFusionAtomFactory({ fusion })({
|
|
78
|
-
path: `private.currency`,
|
|
79
|
-
defaultValue: config.defaultValue,
|
|
80
|
-
}),
|
|
81
|
-
dependencies: ['fusion', 'config'],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
// TODO: move to @exodus/market-history
|
|
85
|
-
{
|
|
86
|
-
definition: {
|
|
87
|
-
id: 'marketHistoryClearCacheAtom',
|
|
88
|
-
factory: ({ config }) => createInMemoryAtom(config),
|
|
89
|
-
dependencies: ['config'],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
// TODO: move to @exodus/market-history
|
|
93
|
-
{
|
|
94
|
-
definition: {
|
|
95
|
-
id: 'remoteConfigClearMarketHistoryCacheAtom',
|
|
96
|
-
factory: ({ config, remoteConfig }) =>
|
|
97
|
-
createRemoteConfigAtomFactory({ remoteConfig })(config),
|
|
98
|
-
dependencies: ['config', 'remoteConfig'],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
// TODO: move to @exodus/market-history
|
|
102
|
-
{
|
|
103
|
-
definition: {
|
|
104
|
-
id: 'marketHistoryRefreshIntervalAtom',
|
|
105
|
-
factory: ({ config, remoteConfig }) =>
|
|
106
|
-
createRemoteConfigAtomFactory({ remoteConfig })(config),
|
|
107
|
-
dependencies: ['config', 'remoteConfig'],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
{ definition: balancesAtomDefinition },
|
|
111
|
-
{ definition: ratesAtomDefinition },
|
|
112
|
-
{
|
|
113
|
-
definition: {
|
|
114
|
-
id: 'geolocationAtom',
|
|
115
|
-
factory: createGeolocationAtom,
|
|
116
|
-
dependencies: ['config'],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{ definition: featureFlagsAtomDefinition },
|
|
120
13
|
].map(withType('atom'))
|
|
121
14
|
|
|
122
15
|
export default createAtomDependencies
|
|
@@ -6,11 +6,8 @@ import assert from 'minimalistic-assert'
|
|
|
6
6
|
import createConfigDependencies from './configs'
|
|
7
7
|
import createAdapterDependencies from './adapters'
|
|
8
8
|
import createAtomDependencies from './atoms'
|
|
9
|
-
import createAtomCollectionDependencies from './atom-collections'
|
|
10
9
|
import createModuleDependencies from './modules'
|
|
11
|
-
import createMonitorDependencies from './monitors'
|
|
12
10
|
import { wrapConstant } from './utils'
|
|
13
|
-
import createPluginDependencies from './plugins'
|
|
14
11
|
|
|
15
12
|
const adapterKeys = [
|
|
16
13
|
// ...
|
|
@@ -19,9 +16,6 @@ const adapterKeys = [
|
|
|
19
16
|
'legacyPrivToPub',
|
|
20
17
|
'seedStorage',
|
|
21
18
|
'unsafeStorage',
|
|
22
|
-
'fusion',
|
|
23
|
-
'fetch',
|
|
24
|
-
'freeze',
|
|
25
19
|
]
|
|
26
20
|
|
|
27
21
|
const createDependencies = ({ adapters, config }) => {
|
|
@@ -35,24 +29,15 @@ const createDependencies = ({ adapters, config }) => {
|
|
|
35
29
|
|
|
36
30
|
const modules = createModuleDependencies({ adapters, config })
|
|
37
31
|
|
|
38
|
-
const monitors = createMonitorDependencies({ adapters, config })
|
|
39
|
-
|
|
40
32
|
const atoms = createAtomDependencies({ adapters, config })
|
|
41
33
|
|
|
42
|
-
const atomCollections = createAtomCollectionDependencies({ adapters, config })
|
|
43
|
-
|
|
44
34
|
const adaptersTree = createAdapterDependencies({ adapters, config })
|
|
45
35
|
|
|
46
|
-
const plugins = createPluginDependencies()
|
|
47
|
-
|
|
48
36
|
return []
|
|
49
37
|
.concat(adaptersTree)
|
|
50
38
|
.concat(configs)
|
|
51
39
|
.concat(modules)
|
|
52
|
-
.concat(monitors)
|
|
53
40
|
.concat(atoms)
|
|
54
|
-
.concat(atomCollections)
|
|
55
|
-
.concat(plugins)
|
|
56
41
|
.concat(wrapConstant({ id: 'logger', type: 'module', value: logger }))
|
|
57
42
|
}
|
|
58
43
|
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import createRemoteConfig from '@exodus/config/remote'
|
|
3
|
-
import keychainDefinition from '@exodus/keychain/module'
|
|
1
|
+
import { createKeychain } from '@exodus/keychain'
|
|
4
2
|
import walletDefinition from '@exodus/wallet/module'
|
|
5
|
-
import walletAccountsDefinition from '@exodus/wallet-accounts/module'
|
|
6
|
-
import blockchainMetadataDefinition from '@exodus/blockchain-metadata/module'
|
|
7
|
-
import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
|
|
8
|
-
import availableAssetsModuleDefinition from '@exodus/available-assets/module'
|
|
9
3
|
import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
|
|
10
4
|
import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
|
|
11
|
-
import balancesDefinition from '@exodus/balances/module'
|
|
12
|
-
import featureFlagsDefinition from '@exodus/feature-flags/module'
|
|
13
5
|
|
|
14
6
|
import createApplication from '../application'
|
|
15
7
|
import { withType } from './utils'
|
|
16
|
-
import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
|
|
17
|
-
import createExodusPricingClient from '@exodus/exodus-pricing-client'
|
|
18
8
|
|
|
19
9
|
const createModuleDependencies = () =>
|
|
20
10
|
[
|
|
@@ -33,42 +23,18 @@ const createModuleDependencies = () =>
|
|
|
33
23
|
},
|
|
34
24
|
},
|
|
35
25
|
{
|
|
36
|
-
definition:
|
|
26
|
+
definition: {
|
|
27
|
+
id: 'keychain',
|
|
28
|
+
factory: createKeychain,
|
|
29
|
+
dependencies: ['legacyPrivToPub'],
|
|
30
|
+
},
|
|
37
31
|
},
|
|
38
32
|
{
|
|
39
33
|
definition: walletDefinition,
|
|
40
|
-
writesAtoms: ['lockedAtom'],
|
|
41
34
|
},
|
|
42
35
|
{
|
|
43
36
|
definition: walletCompatibilityModesDefinition,
|
|
44
37
|
},
|
|
45
|
-
{ definition: unlockEncryptedStorageDefinition },
|
|
46
|
-
{ definition: walletAccountsDefinition, writesAtoms: ['walletAccountsAtom'] },
|
|
47
|
-
{
|
|
48
|
-
definition: blockchainMetadataDefinition,
|
|
49
|
-
storage: { namespace: ['blockchain', 'v1'] },
|
|
50
|
-
},
|
|
51
|
-
{ definition: enabledAssetsModuleDefinition, writesAtoms: ['enabledAndDisabledAssetsAtom'] },
|
|
52
|
-
{
|
|
53
|
-
definition: {
|
|
54
|
-
id: 'remoteConfig',
|
|
55
|
-
factory: (deps) => {
|
|
56
|
-
const eventEmitter = new EventEmitter().setMaxListeners(Number.POSITIVE_INFINITY)
|
|
57
|
-
return createRemoteConfig({ eventEmitter, ...deps })
|
|
58
|
-
},
|
|
59
|
-
dependencies: ['fetch', 'freeze', 'config', 'logger'],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{ definition: availableAssetsModuleDefinition, writesAtoms: ['availableAssetNamesAtom'] },
|
|
63
|
-
{
|
|
64
|
-
definition: {
|
|
65
|
-
id: 'pricingClient',
|
|
66
|
-
factory: createExodusPricingClient,
|
|
67
|
-
dependencies: ['fetch', 'pricingServerUrlAtom'],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{ definition: balancesDefinition, writesAtoms: ['balancesAtom'] },
|
|
71
|
-
{ definition: featureFlagsDefinition, writesAtoms: ['featureFlagAtoms'] },
|
|
72
38
|
].map(withType('module'))
|
|
73
39
|
|
|
74
40
|
export default createModuleDependencies
|
package/src/index.js
CHANGED
|
@@ -1,108 +1,35 @@
|
|
|
1
|
-
import { pick } from '@exodus/basic-utils'
|
|
2
1
|
import createIOC from './ioc'
|
|
3
2
|
import createApi from './api'
|
|
4
|
-
import { createLoadWalletAccountsHandler } from './utils/blockchain-metadata'
|
|
5
|
-
|
|
6
|
-
import attachPlugins from './plugins/attach'
|
|
7
|
-
import attachAtoms from './atoms/attach'
|
|
8
|
-
import { atomsToAttach } from './constants'
|
|
9
3
|
|
|
10
4
|
const createExodus = ({ adapters, config, port }) => {
|
|
11
5
|
const ioc = createIOC({ adapters, config })
|
|
12
|
-
const { headless: headlessConfig } = config
|
|
13
6
|
|
|
14
7
|
const resolve = () => {
|
|
15
8
|
ioc.resolve()
|
|
16
9
|
|
|
17
|
-
const { assetsModule
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
application,
|
|
21
|
-
blockchainMetadata,
|
|
22
|
-
enabledAssets,
|
|
23
|
-
featureFlags,
|
|
24
|
-
remoteConfig,
|
|
25
|
-
unlockEncryptedStorage,
|
|
26
|
-
walletAccounts,
|
|
27
|
-
} = ioc.getByType('module')
|
|
28
|
-
|
|
29
|
-
const { marketHistory, ratesMonitor } = ioc.getByType('monitor')
|
|
30
|
-
|
|
31
|
-
const handleLoadWalletAccounts = createLoadWalletAccountsHandler({
|
|
32
|
-
blockchainMetadata,
|
|
33
|
-
port,
|
|
34
|
-
})
|
|
10
|
+
const { assetsModule } = ioc.getByType('adapter')
|
|
35
11
|
|
|
36
|
-
|
|
37
|
-
blockchainMetadata.on('tx-logs-update', (payload) => port.emit('tx-logs-update', payload))
|
|
38
|
-
blockchainMetadata.on('account-states-update', (payload) =>
|
|
39
|
-
port.emit('account-states-update', payload)
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
remoteConfig.on('sync', ({ current }) => port.emit('remote-config', current))
|
|
43
|
-
|
|
44
|
-
// TODO: migrate to marketHistoryAtom. Will be easier once it's on headless
|
|
45
|
-
marketHistory.on('market-history', (payload) => port.emit('market-history', payload))
|
|
46
|
-
|
|
47
|
-
// TODO: migrate to ratesAtom. Will be easier once it's on headless
|
|
48
|
-
ratesMonitor.on('rates', (payload) => port.emit('rates', payload))
|
|
12
|
+
const { application } = ioc.getByType('module')
|
|
49
13
|
|
|
50
14
|
application.hook('start', () => {
|
|
51
|
-
remoteConfig.load()
|
|
52
|
-
featureFlags.load()
|
|
53
|
-
|
|
54
15
|
port.emit('start')
|
|
55
16
|
})
|
|
56
17
|
|
|
57
18
|
application.hook('unlock', async () => {
|
|
58
|
-
if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
|
|
59
|
-
|
|
60
|
-
remoteConfig.sync()
|
|
61
|
-
marketHistory.start()
|
|
62
|
-
ratesMonitor.start()
|
|
63
|
-
|
|
64
19
|
await assetsModule.load()
|
|
65
|
-
await walletAccounts.load()
|
|
66
|
-
await Promise.all([
|
|
67
|
-
//
|
|
68
|
-
blockchainMetadata.load(),
|
|
69
|
-
enabledAssets.load(),
|
|
70
|
-
])
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
application.on('unlock', () => {
|
|
74
|
-
port.emit('unlock')
|
|
75
20
|
})
|
|
76
21
|
|
|
77
22
|
application.hook('clear', async () => {
|
|
78
|
-
await Promise.all([
|
|
79
|
-
//
|
|
80
|
-
assetsModule.clear(),
|
|
81
|
-
walletAccounts.clear(),
|
|
82
|
-
blockchainMetadata.clear(),
|
|
83
|
-
enabledAssets.clear(),
|
|
84
|
-
])
|
|
85
|
-
|
|
86
|
-
port.emit('clear')
|
|
23
|
+
await Promise.all([assetsModule.clear()])
|
|
87
24
|
})
|
|
88
25
|
|
|
89
26
|
application.on('restart', (payload) => {
|
|
90
27
|
port.emit('restart', payload)
|
|
91
28
|
})
|
|
92
29
|
|
|
93
|
-
attachAtoms({
|
|
94
|
-
port,
|
|
95
|
-
application,
|
|
96
|
-
logger: ioc.get('createLogger')('attachAtoms'),
|
|
97
|
-
atoms: pick(ioc.getByType('atom'), atomsToAttach),
|
|
98
|
-
lifecycleEvents: headlessConfig?.attachAtomsLifecycleEvents,
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
attachPlugins({ application, plugins: ioc.getByType('plugin') })
|
|
102
|
-
|
|
103
30
|
application.start()
|
|
104
31
|
|
|
105
|
-
return createApi({ ioc
|
|
32
|
+
return createApi({ ioc })
|
|
106
33
|
}
|
|
107
34
|
|
|
108
35
|
return { ...ioc, resolve }
|
package/src/ioc.js
CHANGED
|
@@ -3,29 +3,15 @@ import preprocess from '@exodus/dependency-preprocessors'
|
|
|
3
3
|
import alias from '@exodus/dependency-preprocessors/src/preprocessors/alias'
|
|
4
4
|
import logify from '@exodus/dependency-preprocessors/src/preprocessors/logify'
|
|
5
5
|
import namespaceConfig from '@exodus/dependency-preprocessors/src/preprocessors/namespace-config'
|
|
6
|
-
import namespaceStorage from '@exodus/dependency-preprocessors/src/preprocessors/namespace-storage'
|
|
7
|
-
import readOnlyAtoms from '@exodus/dependency-preprocessors/src/preprocessors/read-only-atoms'
|
|
8
6
|
|
|
9
7
|
import createDependencies from './dependencies'
|
|
10
8
|
|
|
11
9
|
const createIOC = ({ adapters, config }) => {
|
|
12
10
|
const { createLogger } = adapters
|
|
13
|
-
const { readOnlyAtoms: readOnlyAtomsConfig } = config.ioc ?? {}
|
|
14
11
|
|
|
15
12
|
const logger = createLogger('exodus:ioc')
|
|
16
13
|
const dependencies = createDependencies({ adapters, config })
|
|
17
|
-
const preprocessors = [
|
|
18
|
-
logify({ createLogger }),
|
|
19
|
-
namespaceConfig(),
|
|
20
|
-
alias(),
|
|
21
|
-
// NOTE: order matters, this should come after `alias`
|
|
22
|
-
namespaceStorage(),
|
|
23
|
-
readOnlyAtoms({
|
|
24
|
-
logger: createLogger('exodus:read-only-atoms'),
|
|
25
|
-
warn: true,
|
|
26
|
-
...readOnlyAtomsConfig,
|
|
27
|
-
}),
|
|
28
|
-
]
|
|
14
|
+
const preprocessors = [logify({ createLogger }), namespaceConfig(), alias()]
|
|
29
15
|
const definitions = preprocess({ dependencies, preprocessors })
|
|
30
16
|
const ioc = createIocContainer({ logger })
|
|
31
17
|
|
package/src/atoms/attach.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const emitAtomValue = async (opts) => {
|
|
2
|
-
const { port, atomId, atom } = opts
|
|
3
|
-
const value = 'value' in opts ? opts.value : await atom.get()
|
|
4
|
-
port.emit(atomId, value)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const emitFromAtoms = ({ atoms, port }) =>
|
|
8
|
-
Object.entries(atoms).forEach(async ([atomId, atom]) => emitAtomValue({ port, atomId, atom }))
|
|
9
|
-
|
|
10
|
-
const attachAtom = ({ port, application, logger, atom, atomId, lifecycleEvents }) => {
|
|
11
|
-
let loaded = false
|
|
12
|
-
|
|
13
|
-
lifecycleEvents.forEach((event) =>
|
|
14
|
-
application.on(event, async () => {
|
|
15
|
-
loaded = true
|
|
16
|
-
await emitAtomValue({ port, atomId, atom })
|
|
17
|
-
})
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
application.on('clear', async () => {
|
|
21
|
-
try {
|
|
22
|
-
await atom?.set(undefined)
|
|
23
|
-
} catch (error) {
|
|
24
|
-
logger.debug('failed to clear atom', error)
|
|
25
|
-
// noop. atom might not support set
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
atom.observe((value) => {
|
|
30
|
-
if (loaded) emitAtomValue({ port, atomId, atom, value })
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const attachAtoms = ({ port, application, logger, atoms, lifecycleEvents = ['start'] }) => {
|
|
35
|
-
for (const [atomId, atom] of Object.entries(atoms)) {
|
|
36
|
-
attachAtom({ port, application, logger, atom, atomId, lifecycleEvents })
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default attachAtoms
|
package/src/constants.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
featureFlagAtomsDefinition,
|
|
3
|
-
remoteConfigFeatureFlagAtomsDefinition,
|
|
4
|
-
} from '@exodus/feature-flags/atoms'
|
|
5
|
-
|
|
6
|
-
import { withType } from './utils'
|
|
7
|
-
|
|
8
|
-
const createAtomCollectionDependencies = () =>
|
|
9
|
-
[
|
|
10
|
-
{
|
|
11
|
-
definition: remoteConfigFeatureFlagAtomsDefinition,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
definition: featureFlagAtomsDefinition,
|
|
15
|
-
storage: { namespace: 'featureFlags' },
|
|
16
|
-
aliases: [
|
|
17
|
-
{
|
|
18
|
-
implementationId: 'unsafeStorage',
|
|
19
|
-
interfaceId: 'storage',
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
].map(withType('atom-collection'))
|
|
24
|
-
|
|
25
|
-
export default createAtomCollectionDependencies
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import marketHistoryMonitorDefinition from '@exodus/market-history/module'
|
|
2
|
-
import ratesMonitorDefinition from '@exodus/rates-monitor/module'
|
|
3
|
-
|
|
4
|
-
import { withType } from './utils'
|
|
5
|
-
|
|
6
|
-
const createModuleDependencies = () =>
|
|
7
|
-
[
|
|
8
|
-
{
|
|
9
|
-
definition: marketHistoryMonitorDefinition,
|
|
10
|
-
storage: { namespace: 'marketHistory' },
|
|
11
|
-
aliases: [
|
|
12
|
-
{
|
|
13
|
-
implementationId: 'unsafeStorage',
|
|
14
|
-
interfaceId: 'storage',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
implementationId: 'marketHistoryClearCacheAtom',
|
|
18
|
-
interfaceId: 'clearCacheAtom',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
implementationId: 'remoteConfigClearMarketHistoryCacheAtom',
|
|
22
|
-
interfaceId: 'remoteConfigClearCacheAtom',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
implementationId: 'marketHistoryRefreshIntervalAtom',
|
|
26
|
-
interfaceId: 'remoteConfigRefreshIntervalAtom',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
{ definition: ratesMonitorDefinition, writesAtoms: ['ratesAtom'] },
|
|
31
|
-
].map(withType('monitor'))
|
|
32
|
-
|
|
33
|
-
export default createModuleDependencies
|
package/src/plugins/attach.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { kebabCase, memoize } from 'lodash'
|
|
2
|
-
|
|
3
|
-
// e.g. onUnlock -> unlock -> onUnlock, onChangePassphrase -> change-passphrase
|
|
4
|
-
const getApplicationHookName = memoize((lifecycleMethod) =>
|
|
5
|
-
kebabCase(lifecycleMethod.replace(/^on/, ''))
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
const attachPlugins = ({ plugins, application }) => {
|
|
9
|
-
Object.entries(plugins).forEach(([name, lifecycleMethods]) => {
|
|
10
|
-
const entries = Object.entries(lifecycleMethods || {})
|
|
11
|
-
|
|
12
|
-
for (const [lifecycleMethod, fn] of entries) {
|
|
13
|
-
const hookName = getApplicationHookName(lifecycleMethod)
|
|
14
|
-
application.hook(hookName, fn)
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default attachPlugins
|
package/src/plugins/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const logLifecycle = {
|
|
2
|
-
id: 'logLifecyclePlugin',
|
|
3
|
-
type: 'plugin',
|
|
4
|
-
factory: ({ logger }) => {
|
|
5
|
-
return {
|
|
6
|
-
onLock: () => logger.debug('onLock'),
|
|
7
|
-
onUnlock: () => logger.debug('onUnlock'),
|
|
8
|
-
onClear: () => logger.debug('onClear'),
|
|
9
|
-
onImport: () => logger.debug('onImport'),
|
|
10
|
-
onMigrate: () => logger.debug('onMigrate'),
|
|
11
|
-
onStart: () => logger.debug('onStart'),
|
|
12
|
-
onLoad: () => logger.debug('onLoad'),
|
|
13
|
-
onUnload: () => logger.debug('onUnload'),
|
|
14
|
-
onCreate: () => logger.debug('onCreate'),
|
|
15
|
-
onBackup: () => logger.debug('onBackup'),
|
|
16
|
-
onRestore: () => logger.debug('onRestore'),
|
|
17
|
-
onRestoreCompleted: () => logger.debug('onRestoreCompleted'),
|
|
18
|
-
onAssetsSynced: () => logger.debug('onAssetsSynced'),
|
|
19
|
-
onChangePassphrase: () => logger.debug('onChangePassphrase'),
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
dependencies: ['logger'],
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default logLifecycle
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EXODUS_KEY_IDS } from '@exodus/keychain/module'
|
|
2
|
-
|
|
3
|
-
const createUnlockEncryptedStorage = ({ keychain }) => {
|
|
4
|
-
return async (encryptedStorage) => {
|
|
5
|
-
// should the key id be part of a `config` dep?
|
|
6
|
-
const sodiumEncryptor = keychain.createSodiumEncryptor(EXODUS_KEY_IDS.WALLET_INFO)
|
|
7
|
-
|
|
8
|
-
await encryptedStorage.unlock({
|
|
9
|
-
encrypt: (data) => sodiumEncryptor.encryptSecretBox({ data }),
|
|
10
|
-
decrypt: (data) => sodiumEncryptor.decryptSecretBox({ data }),
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
id: 'unlockEncryptedStorage',
|
|
17
|
-
factory: createUnlockEncryptedStorage,
|
|
18
|
-
dependencies: ['keychain'],
|
|
19
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function createLoadWalletAccountsHandler({ port, blockchainMetadata }) {
|
|
2
|
-
return async () => {
|
|
3
|
-
const [txLogs, accountStates] = await Promise.all([
|
|
4
|
-
blockchainMetadata.getLoadedTxLogs(),
|
|
5
|
-
blockchainMetadata.getLoadedAccountStates(),
|
|
6
|
-
])
|
|
7
|
-
|
|
8
|
-
port.emit('tx-logs', txLogs)
|
|
9
|
-
port.emit('account-states', accountStates)
|
|
10
|
-
}
|
|
11
|
-
}
|