@exodus/headless 2.0.0-alpha.2 → 2.0.0-alpha.20

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 CHANGED
@@ -3,6 +3,158 @@
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.20](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.19...@exodus/headless@2.0.0-alpha.20) (2023-05-12)
7
+
8
+ ### Features
9
+
10
+ - stop timers on remoteConfig.stop(), kyc.stop(), referrals.stop() ([#1593](https://github.com/ExodusMovement/exodus-hydra/issues/1593)) ([0f73363](https://github.com/ExodusMovement/exodus-hydra/commit/0f7336362cdc5a6f878109e6353ac241795e4fc6))
11
+
12
+ ### Bug Fixes
13
+
14
+ - kyc tests ([#1619](https://github.com/ExodusMovement/exodus-hydra/issues/1619)) ([20da423](https://github.com/ExodusMovement/exodus-hydra/commit/20da423b98aa3b950e197b4a2290898c731c59b2))
15
+ - kyc tests (again) ([#1626](https://github.com/ExodusMovement/exodus-hydra/issues/1626)) ([0f12f89](https://github.com/ExodusMovement/exodus-hydra/commit/0f12f898691504aefffeaca0db2fd3dbe9740ff6))
16
+
17
+ ## [2.0.0-alpha.19](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.18...@exodus/headless@2.0.0-alpha.19) (2023-05-08)
18
+
19
+ ### ⚠ BREAKING CHANGES
20
+
21
+ - use revamped geolocation (#1559)
22
+
23
+ ### Features
24
+
25
+ - add addressesProvider to headless ([#1540](https://github.com/ExodusMovement/exodus-hydra/issues/1540)) ([90e963a](https://github.com/ExodusMovement/exodus-hydra/commit/90e963aafa0bb855d8c857902feac37514985d4a))
26
+ - add kyc and referrals modules to headless ([#1539](https://github.com/ExodusMovement/exodus-hydra/issues/1539)) ([1a0cf7c](https://github.com/ExodusMovement/exodus-hydra/commit/1a0cf7c18cbbfc5f2b92d9720d9cbf17cd850214))
27
+
28
+ ### Code Refactoring
29
+
30
+ - use revamped geolocation ([#1559](https://github.com/ExodusMovement/exodus-hydra/issues/1559)) ([4378d13](https://github.com/ExodusMovement/exodus-hydra/commit/4378d137a67e4836a45c72e6bfc79590d4b7ab20))
31
+
32
+ ## [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)
33
+
34
+ ### Bug Fixes
35
+
36
+ - announce that featureFlags writes to featureFlagAtoms ([#1548](https://github.com/ExodusMovement/exodus-hydra/issues/1548)) ([fefac86](https://github.com/ExodusMovement/exodus-hydra/commit/fefac86970ab11e85d530d8424ca9f3de86fed91))
37
+
38
+ ## [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)
39
+
40
+ ### ⚠ BREAKING CHANGES
41
+
42
+ - don't serialize port payloads (#1458)
43
+
44
+ ### Features
45
+
46
+ - add feature-flags to headless ([#1516](https://github.com/ExodusMovement/exodus-hydra/issues/1516)) ([9d2da89](https://github.com/ExodusMovement/exodus-hydra/commit/9d2da895d4f58d34674b19d42fe3fd621d439f73))
47
+
48
+ ### Code Refactoring
49
+
50
+ - don't serialize port payloads ([#1458](https://github.com/ExodusMovement/exodus-hydra/issues/1458)) ([9b98a28](https://github.com/ExodusMovement/exodus-hydra/commit/9b98a28b091146ad0dee631a236629f25a16b3e2))
51
+
52
+ ## [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)
53
+
54
+ ### Bug Fixes
55
+
56
+ - bump atoms in headless ([#1523](https://github.com/ExodusMovement/exodus-hydra/issues/1523)) ([7b6ca0b](https://github.com/ExodusMovement/exodus-hydra/commit/7b6ca0b19ccad9e33c9c0f0aac03feddad9d4cac))
57
+
58
+ ## [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)
59
+
60
+ ### ⚠ BREAKING CHANGES
61
+
62
+ - use readOnlyAtoms dependency processor (#1497)
63
+
64
+ ### Features
65
+
66
+ - add geolocation to headless ([#1514](https://github.com/ExodusMovement/exodus-hydra/issues/1514)) ([44a8620](https://github.com/ExodusMovement/exodus-hydra/commit/44a8620249f8de2147dc073098b68f0562fb7287))
67
+ - use readOnlyAtoms dependency processor ([#1497](https://github.com/ExodusMovement/exodus-hydra/issues/1497)) ([b3b4866](https://github.com/ExodusMovement/exodus-hydra/commit/b3b4866084428496aeff30dcb14ec583d6f4d64f))
68
+
69
+ ### Bug Fixes
70
+
71
+ - enabledAssets storage access ([#1519](https://github.com/ExodusMovement/exodus-hydra/issues/1519)) ([c4d9463](https://github.com/ExodusMovement/exodus-hydra/commit/c4d9463829b0015e70ce617e11940b1fea5bfbe6))
72
+
73
+ ## [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)
74
+
75
+ **Note:** Version bump only for package @exodus/headless
76
+
77
+ ## [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)
78
+
79
+ ### Features
80
+
81
+ - add rates monitor to headless ([#1470](https://github.com/ExodusMovement/exodus-hydra/issues/1470)) ([d214b9a](https://github.com/ExodusMovement/exodus-hydra/commit/d214b9a22ca0649bbd79e2c8f6d9592733c802d2))
82
+
83
+ ### Bug Fixes
84
+
85
+ - get assetsModule from 'adapters' ([#1491](https://github.com/ExodusMovement/exodus-hydra/issues/1491)) ([b010cbd](https://github.com/ExodusMovement/exodus-hydra/commit/b010cbd319ffcd02d18a7492dc20e2d7ba7fe1c4))
86
+
87
+ ## [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)
88
+
89
+ ### Features
90
+
91
+ - add balances to headless ([#1379](https://github.com/ExodusMovement/exodus-hydra/issues/1379)) ([b5d6846](https://github.com/ExodusMovement/exodus-hydra/commit/b5d6846d86b9d83463ece51a2ef14c4fd898d438))
92
+
93
+ ## [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)
94
+
95
+ ### Features
96
+
97
+ - migrate locales atoms ([#1457](https://github.com/ExodusMovement/exodus-hydra/issues/1457)) ([e6f3a7f](https://github.com/ExodusMovement/exodus-hydra/commit/e6f3a7feb4319d8aa44032e27df746343fdb66eb))
98
+ - migrate market history module ([#1456](https://github.com/ExodusMovement/exodus-hydra/issues/1456)) ([3e64532](https://github.com/ExodusMovement/exodus-hydra/commit/3e64532b739ea802f0df841b7c030c2c912d57e8))
99
+
100
+ ## [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)
101
+
102
+ ### Features
103
+
104
+ - add pricingClient to headless ([#1439](https://github.com/ExodusMovement/exodus-hydra/issues/1439)) ([2a82a4c](https://github.com/ExodusMovement/exodus-hydra/commit/2a82a4c663b542178580908aaaff840524d55369))
105
+ - attach wallet account atoms ([#1437](https://github.com/ExodusMovement/exodus-hydra/issues/1437)) ([2648699](https://github.com/ExodusMovement/exodus-hydra/commit/264869986c175091e6bc7c48e852946bd60911d6))
106
+
107
+ ## [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)
108
+
109
+ ### Features
110
+
111
+ - add available-assets to headless ([#1361](https://github.com/ExodusMovement/exodus-hydra/issues/1361)) ([900d142](https://github.com/ExodusMovement/exodus-hydra/commit/900d142018ff112f36ef0f7ef53cf5020020e3ca))
112
+
113
+ ## [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)
114
+
115
+ ### Features
116
+
117
+ - add enabled-assets to headless ([#1235](https://github.com/ExodusMovement/exodus-hydra/issues/1235)) ([a808b75](https://github.com/ExodusMovement/exodus-hydra/commit/a808b750bd911c33241ae710fbf8d8ba7e2073a6))
118
+ - add lifecycle docs ([#1313](https://github.com/ExodusMovement/exodus-hydra/issues/1313)) ([df18faa](https://github.com/ExodusMovement/exodus-hydra/commit/df18faa9c341404c2feaadf51ec46236c54e2f15))
119
+ - add remoteConfig module ([#1370](https://github.com/ExodusMovement/exodus-hydra/issues/1370)) ([ebc888d](https://github.com/ExodusMovement/exodus-hydra/commit/ebc888d6440c509a19dd6c9c600033fd41128ad7))
120
+ - add support for plugins ([#1351](https://github.com/ExodusMovement/exodus-hydra/issues/1351)) ([fac0e2a](https://github.com/ExodusMovement/exodus-hydra/commit/fac0e2a727b0e71ad5f0619b8457c7e80612f707))
121
+
122
+ ## [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)
123
+
124
+ ### ⚠ BREAKING CHANGES
125
+
126
+ - pass compatibility modes config to wallet (#1223)
127
+
128
+ ### Features
129
+
130
+ - add blockchain metadata to headless ([#1293](https://github.com/ExodusMovement/exodus-hydra/issues/1293)) ([04390a7](https://github.com/ExodusMovement/exodus-hydra/commit/04390a71cb01744cd427f470735fa0748b9157ca))
131
+ - add namespaceStorage preprocessor ([#1322](https://github.com/ExodusMovement/exodus-hydra/issues/1322)) ([95f403e](https://github.com/ExodusMovement/exodus-hydra/commit/95f403e59c87f90901247619c727496ebac0a399))
132
+ - pass compatibility modes config to wallet ([#1223](https://github.com/ExodusMovement/exodus-hydra/issues/1223)) ([b49b640](https://github.com/ExodusMovement/exodus-hydra/commit/b49b64097af7969e210e5ecf5395ee7f40a13eac))
133
+
134
+ ## [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)
135
+
136
+ ### Features
137
+
138
+ - add walletAccounts in headless ([#1184](https://github.com/ExodusMovement/exodus-hydra/issues/1184)) ([8d9c93d](https://github.com/ExodusMovement/exodus-hydra/commit/8d9c93d86173476211d596e883a72b51b645e866))
139
+
140
+ ## [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)
141
+
142
+ ### Features
143
+
144
+ - force restart on import ([#1297](https://github.com/ExodusMovement/exodus-hydra/issues/1297)) ([3900196](https://github.com/ExodusMovement/exodus-hydra/commit/39001966ce7d962ddde9df8aa3b93619053569f8))
145
+ - **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))
146
+ - unlock encrypted storage on wallet unlock ([#1304](https://github.com/ExodusMovement/exodus-hydra/issues/1304)) ([09ea5f2](https://github.com/ExodusMovement/exodus-hydra/commit/09ea5f20ff9547557f59d4c416cee3291f348fdf))
147
+
148
+ ## [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)
149
+
150
+ **Note:** Version bump only for package @exodus/headless
151
+
152
+ ## [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)
153
+
154
+ ### Features
155
+
156
+ - export subscribe/unsubscribe ([#1161](https://github.com/ExodusMovement/exodus-hydra/issues/1161)) ([7da465f](https://github.com/ExodusMovement/exodus-hydra/commit/7da465fc1734fd0818a55ff740704adb8c6ae222))
157
+
6
158
  ## [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)
7
159
 
8
160
  ### Features
package/README.md CHANGED
@@ -2,6 +2,15 @@
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
+
5
14
  ## Quick Start
6
15
 
7
16
  ```js
@@ -34,15 +43,74 @@ const exodus = container.resolve()
34
43
  await exodus.wallet.create({ passphrase: 'my-super-secure-passphrase' })
35
44
  ```
36
45
 
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
+
37
105
  ## Port
38
106
 
39
107
  Event bus between headless wallet and client
40
108
 
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. |
109
+ | Method | Type | Description |
110
+ | ----------- | ------------------------------------------ | ------------------------------------------ |
111
+ | subscribe | `({ type: string, payload: any }) => void` | Subscribe to receive events. |
112
+ | unsubscribe | `({ type: string, payload: any }) => void` | Unsubscribe handler from receiving events. |
113
+ | emit | `(type: string, payload: any) => void` | Emit an event. |
46
114
 
47
115
  ## Adapters
48
116
 
@@ -121,21 +189,21 @@ Currently not used.
121
189
 
122
190
  > Type: object
123
191
 
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`) |
192
+ | Method | Type | Description |
193
+ | ------------------------ | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
194
+ | exists | `async () => boolean` | Checks if a wallet exists on the device. |
195
+ | create | `async ({ passphrase?: string }) => void` | Creates new wallet |
196
+ | import | `async ({ mnemonic: string, passphrase?: string, forceRestart?: boolean }) => void` | Imports existing wallet |
197
+ | delete | `async ({ passphrase?: string }) => void` | Deletes wallet. Passphrase is mandatory if wallet was created with one |
198
+ | lock | `async () => void` | Locks wallet |
199
+ | unlock | `async ({ passphrase?: string }) => void` | Unlocks wallet. Passphrase is mandatory if wallet was created with one |
200
+ | isLocked | `async () => boolean` | Checks if wallet is locked |
201
+ | getMnemonic | `async () => void` | Sets wallet as backed up |
202
+ | changePassphrase | `async ({ currentPassphrase?: string. newPassphrase: string }) => void` | Change passphrase. Current passphrase is mandatory if wallet was created with one |
203
+ | restoreFromCurrentPhrase | `async ({ passphrase?: string }) => void` | Restore current wallet. Passphrase is mandatory if wallet was created with one |
204
+ | load | `async () => void` | Loads UI by rehydratating data through port (`BE Only`) |
205
+ | unload | `async () => void` | Unloads UI by rehydratating data through port (`BE Only`) |
206
+ | changeLockTimer | `async ({ ttl: number }) => void` | Change auto unlock ttl (`BE Only`) |
139
207
 
140
208
  ## isMnemonicValid
141
209
 
@@ -147,3 +215,61 @@ Currently not used.
147
215
  | wordlist | `string[]` | Words list to check against. |
148
216
 
149
217
  **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.2",
3
+ "version": "2.0.0-alpha.20",
4
4
  "description": "The headless Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc",
6
6
  "main": "src/index.js",
@@ -23,30 +23,58 @@
23
23
  "scripts": {
24
24
  "lint": "eslint . --ignore-path ../../.gitignore",
25
25
  "lint:fix": "yarn lint --fix",
26
- "test": "jest"
26
+ "test": "jest --runInBand"
27
27
  },
28
28
  "dependencies": {
29
- "@exodus/atoms": "^2.9.0",
29
+ "@exodus/addresses-provider": "^3.0.2",
30
+ "@exodus/atoms": "^3.5.2",
31
+ "@exodus/available-assets": "^2.0.0",
32
+ "@exodus/balances": "^6.0.0",
33
+ "@exodus/basic-utils": "^2.0.0",
34
+ "@exodus/blockchain-metadata": "^8.0.1",
35
+ "@exodus/config": "^7.0.0",
30
36
  "@exodus/dependency-injection": "^1.2.0",
31
- "@exodus/dependency-preprocessors": "^2.0.2",
37
+ "@exodus/dependency-preprocessors": "^2.4.0",
38
+ "@exodus/enabled-assets": "^6.0.0",
39
+ "@exodus/exodus-pricing-client": "^1.1.0",
40
+ "@exodus/feature-flags": "^2.0.0",
32
41
  "@exodus/fetch": "^1.2.1",
33
- "@exodus/key-identifier-provider": "^1.1.1",
34
- "@exodus/keychain": "^3.2.1",
42
+ "@exodus/geolocation": "^1.1.0",
43
+ "@exodus/key-identifier-provider": "^1.1.3",
44
+ "@exodus/keychain": "^4.0.0",
45
+ "@exodus/kyc": "^3.4.0",
46
+ "@exodus/market-history": "^3.1.0",
35
47
  "@exodus/module": "^1.0.0",
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",
48
+ "@exodus/rates-monitor": "^2.0.0",
49
+ "@exodus/referrals": "^5.2.0",
50
+ "@exodus/wallet": "^6.0.1",
51
+ "@exodus/wallet-accounts": "^8.0.1",
52
+ "@exodus/wallet-compatibility-modes": "^2.0.0",
53
+ "bip39": "^2.6.0",
54
+ "events": "^3.3.0",
55
+ "lodash": "npm:@exodus/lodash@^4.17.21-exodus.2",
40
56
  "minimalistic-assert": "^1.0.1"
41
57
  },
42
58
  "devDependencies": {
59
+ "@exodus/algorand-lib": "^2.0.1",
60
+ "@exodus/algorand-meta": "^1.1.4",
61
+ "@exodus/bitcoin-meta": "^1.0.0",
62
+ "@exodus/currency": "^2.2.0",
43
63
  "@exodus/ethereum-lib": "^2.22.2",
64
+ "@exodus/ethereum-meta": "^1.0.23",
65
+ "@exodus/models": "^8.11.1",
44
66
  "@exodus/solana-lib": "^1.3.11",
45
- "@exodus/storage-memory": "^1.1.0",
67
+ "@exodus/solana-meta": "^1.0.2",
68
+ "@exodus/storage-encrypted": "^1.1.2",
69
+ "@exodus/storage-memory": "^2.1.0",
46
70
  "@exodus/wild-emitter": "^1.0.0",
47
71
  "buffer-json": "^2.0.0",
72
+ "deepmerge": "^4.2.2",
48
73
  "eslint": "^8.33.0",
49
- "jest": "^29.1.2"
74
+ "events": "^3.3.0",
75
+ "jest": "^29.1.2",
76
+ "nock": "^13.3.1",
77
+ "p-defer": "^4.0.0"
50
78
  },
51
- "gitHead": "58929429bb5b339e14fd422ed9955d9765b3394c"
79
+ "gitHead": "97af2cc1155b12a20858cf026a2fee25fff37483"
52
80
  }
package/src/api.js CHANGED
@@ -1,9 +1,35 @@
1
1
  import { validateMnemonic as isMnemonicValid } from 'bip39'
2
2
 
3
- const createApi = ({ ioc }) => {
4
- const { passphraseCache } = ioc.getByType('adapter')
3
+ const createApi = ({ ioc, port }) => {
4
+ const { assetsModule, passphraseCache } = ioc.getByType('adapter')
5
5
 
6
- const { application, wallet } = ioc.getByType('module')
6
+ const {
7
+ addressesProvider,
8
+ application,
9
+ blockchainMetadata,
10
+ enabledAssets,
11
+ kyc,
12
+ referrals,
13
+ remoteConfig,
14
+ wallet,
15
+ walletAccounts,
16
+ } = ioc.getByType('module')
17
+
18
+ const { ratesMonitor } = ioc.getByType('monitor')
19
+
20
+ const {
21
+ // ...
22
+ currencyAtom,
23
+ enabledWalletAccountsAtom,
24
+ languageAtom,
25
+ } = ioc.getByType('atom')
26
+
27
+ // TODO: do this on 'unload'
28
+ const stop = () => {
29
+ kyc.stop()
30
+ referrals.stop()
31
+ remoteConfig.stop()
32
+ }
7
33
 
8
34
  return {
9
35
  wallet: {
@@ -27,7 +53,64 @@ const createApi = ({ ioc }) => {
27
53
  changeLockTimer: application.changeLockTimer,
28
54
  isLocked: () => wallet.isLocked(),
29
55
  },
56
+ walletAccounts: {
57
+ create: walletAccounts.create,
58
+ update: walletAccounts.update,
59
+ disable: walletAccounts.disable,
60
+ enable: walletAccounts.enable,
61
+ getEnabled: enabledWalletAccountsAtom.get,
62
+ },
63
+ blockchainMetadata: {
64
+ getTxLog: blockchainMetadata.getTxLog,
65
+ getLoadedTxLogs: blockchainMetadata.getLoadedTxLogs,
66
+ updateTxs: blockchainMetadata.updateTxs,
67
+ overwriteTxs: blockchainMetadata.overwriteTxs,
68
+ clearTxs: blockchainMetadata.clearTxs,
69
+ removeTxs: blockchainMetadata.removeTxs,
70
+ getAccountState: blockchainMetadata.getAccountState,
71
+ getLoadedAccountStates: blockchainMetadata.getLoadedAccountStates,
72
+ updateAccountState: blockchainMetadata.updateAccountState,
73
+ removeAccountState: blockchainMetadata.removeAccountState,
74
+ batch: blockchainMetadata.batch,
75
+ },
76
+ assets: {
77
+ enable: enabledAssets.enable,
78
+ disable: enabledAssets.disable,
79
+ addAndEnableToken: async (...args) => {
80
+ const asset = await assetsModule.addToken(...args)
81
+ await enabledAssets.enable([asset.name])
82
+ return asset.name
83
+ },
84
+ },
85
+ remoteConfig: {
86
+ get: remoteConfig.get,
87
+ getAll: remoteConfig.getAll,
88
+ },
89
+ locale: {
90
+ setLanguage: (value) => languageAtom.set(value),
91
+ setCurrency: (value) => currencyAtom.set(value),
92
+ },
93
+ rates: {
94
+ refresh: () => ratesMonitor.update(),
95
+ },
96
+ addressesProvider: {
97
+ getAddress: addressesProvider.getAddress.bind(addressesProvider),
98
+ getSupportedPurposes: addressesProvider.getSupportedPurposes.bind(addressesProvider),
99
+ getReceiveAddress: addressesProvider.getReceiveAddress.bind(addressesProvider),
100
+ },
101
+ kyc: {
102
+ start: kyc.start,
103
+ sync: kyc.sync,
104
+ requestKycToken: kyc.requestKycToken,
105
+ },
106
+ referrals: {
107
+ setReferredBy: referrals.setReferredBy,
108
+ referralCodeExists: referrals.referralCodeExists,
109
+ },
30
110
  isMnemonicValid,
111
+ subscribe: port.subscribe.bind(port),
112
+ unsubscribe: port.unsubscribe.bind(port),
113
+ stop,
31
114
  }
32
115
  }
33
116