@exodus/headless 5.0.0-rc.33 → 5.0.0-rc.35

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,26 @@
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
+ ## [5.0.0-rc.35](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.34...@exodus/headless@5.0.0-rc.35) (2024-09-23)
7
+
8
+ ### Features
9
+
10
+ - add ability to ignore all sunset asset monitors ([#8875](https://github.com/ExodusMovement/exodus-hydra/issues/8875)) ([e7fafa4](https://github.com/ExodusMovement/exodus-hydra/commit/e7fafa437a17edd1aca2f430ce8cecfcd6088a72))
11
+ - allow supplying the wallet sdk as adapter to headless ([#9317](https://github.com/ExodusMovement/exodus-hydra/issues/9317)) ([de4dcca](https://github.com/ExodusMovement/exodus-hydra/commit/de4dccabd0126e28e5de08c946e60056eb9d149a))
12
+ - type dependency injection container ([#9398](https://github.com/ExodusMovement/exodus-hydra/issues/9398)) ([e347bfa](https://github.com/ExodusMovement/exodus-hydra/commit/e347bfaf210751fcfb62600f276402eb7fdce46d))
13
+
14
+ ### Bug Fixes
15
+
16
+ - **headless:** bump @exodus/application ([#9230](https://github.com/ExodusMovement/exodus-hydra/issues/9230)) ([819597b](https://github.com/ExodusMovement/exodus-hydra/commit/819597b2042c5677651bf81f16d04b806bcfadec))
17
+
18
+ ## [5.0.0-rc.34](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.32...@exodus/headless@5.0.0-rc.34) (2024-09-09)
19
+
20
+ ### Features
21
+
22
+ - **headless:** move headless-ui plugin alongside others ([#8971](https://github.com/ExodusMovement/exodus-hydra/issues/8971)) ([4a5c72c](https://github.com/ExodusMovement/exodus-hydra/commit/4a5c72cd2271e835080e84be14d3a49364e43f3a))
23
+ - **headless:** clear headless-ui storage ([#8964](https://github.com/ExodusMovement/exodus-hydra/issues/8964)) ([5840128](https://github.com/ExodusMovement/exodus-hydra/commit/5840128c8d626278db51c4d06da33315603f3dc0))
24
+ - implement headless redux IOC ([#8857](https://github.com/ExodusMovement/exodus-hydra/issues/8857)) ([8520a07](https://github.com/ExodusMovement/exodus-hydra/commit/8520a07ba7d83db12051ad713fafbe00ad14ee13))
25
+
6
26
  ## [5.0.0-rc.33](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.32...@exodus/headless@5.0.0-rc.33) (2024-09-09)
7
27
 
8
28
  ### Features
package/README.md CHANGED
@@ -62,57 +62,7 @@ The headless wallet instance transitions through different states during his lif
62
62
  - Fires hook call: Allows modules to subscribe and halt transition until listener resolves.
63
63
  - Fires event call: Emitted after all hooks had been executed and resolved.
64
64
 
65
- Below you can find a state diagram that visualize what hooks are triggered between state transitions:
66
-
67
- ```mermaid
68
- stateDiagram-v2
69
- direction LR
70
- [*] --> Starting
71
-
72
- state Starting {
73
- direction LR
74
-
75
- state "Needs clear storage?*" as NeedsClear
76
- state "Is importing?" as IsImporting
77
-
78
- NeedsClear --> Clearing : CLEAR
79
- Clearing --> IsImporting
80
- IsImporting --> Importing : IMPORT
81
- }
82
-
83
- Starting --> Started : START
84
-
85
- state Started {
86
- direction LR
87
-
88
- state "Has seed?" as HasSeed
89
-
90
- HasSeed --> Empty : No
91
- HasSeed --> Locked : Yes
92
-
93
- Empty --> Locked : CREATE \n---or---\nIMPORT
94
-
95
- Locked --> Migrating : MIGRATE
96
- Migrating --> Unlocked : UNLOCK
97
- Unlocked --> Locked : LOCK
98
-
99
- Unlocked --> Restarting : DELETE
100
-
101
-
102
- }
103
-
104
- Restarting --> [*] : RESTART
105
-
106
- Started --> Started : LOAD
107
-
108
- classDef conditional fill:#ededed,stroke:#c2c2c2,color:#a6a6a6,stroke-width:2;
109
-
110
- class NeedsClear conditional
111
- class IsImporting conditional
112
- class HasSeed conditional
113
- ```
114
-
115
- \* Wallet needs to clear storage if seed is not present or is restoring a new wallet
65
+ For more information about lifecycle hooks, please refer to the [application feature documentation](../../features/application/README.md#lifecycle-hooks).
116
66
 
117
67
  ## Port
118
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "5.0.0-rc.33",
3
+ "version": "5.0.0-rc.35",
4
4
  "description": "The platform-agnostic Exodus wallet SDK",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "main": "src/index.js",
@@ -24,13 +24,15 @@
24
24
  "scripts": {
25
25
  "lint": "run -T eslint .",
26
26
  "lint:fix": "yarn lint --fix",
27
- "test": "yarn test:types && NODE_OPTIONS=--max-old-space-size=4096 run -T jest",
27
+ "test": "yarn test:types && yarn test:single-process && yarn test:multi-process",
28
+ "test:single-process": "NODE_OPTIONS=--max-old-space-size=4096 run -T jest",
29
+ "test:multi-process": "MULTI_PROCESS=1 NODE_OPTIONS=--max-old-space-size=4096 run -T jest",
28
30
  "test:types": "run -T tsc --noEmit"
29
31
  },
30
32
  "dependencies": {
31
33
  "@exodus/address-provider": "^12.0.1",
32
- "@exodus/application": "^1.5.0",
33
- "@exodus/argo": "^2.1.0",
34
+ "@exodus/application": "^2.1.0",
35
+ "@exodus/argo": "^2.2.0",
34
36
  "@exodus/asset-sources": "^1.4.1",
35
37
  "@exodus/assets-feature": "^5.11.3",
36
38
  "@exodus/atoms": "^8.1.1",
@@ -38,6 +40,7 @@
38
40
  "@exodus/balances": "^13.3.1",
39
41
  "@exodus/basic-utils": "^3.0.1",
40
42
  "@exodus/blockchain-metadata": "^15.3.5",
43
+ "@exodus/browser-extension-rpc": "^2.1.2",
41
44
  "@exodus/dependency-injection": "^2.1.2",
42
45
  "@exodus/dependency-preprocessors": "^6.0.5",
43
46
  "@exodus/enabled-assets": "^10.5.1",
@@ -51,13 +54,12 @@
51
54
  "@exodus/hd-key-slip-10": "^2.0.0",
52
55
  "@exodus/key-ids": "^1.2.3",
53
56
  "@exodus/key-viewer": "^1.1.2",
54
- "@exodus/keychain": "^6.10.0",
57
+ "@exodus/keychain": "^7.1.0",
55
58
  "@exodus/locale": "^2.2.2",
56
59
  "@exodus/message-signer": "^1.3.4",
57
60
  "@exodus/module": "^1.2.2",
58
61
  "@exodus/pricing": "^1.3.2",
59
62
  "@exodus/public-key-provider": "^2.4.1",
60
- "@exodus/public-key-store": "^1.2.2",
61
63
  "@exodus/rates-monitor": "^4.4.1",
62
64
  "@exodus/remote-config": "^2.7.2",
63
65
  "@exodus/restore-progress-tracker": "^3.5.1",
@@ -78,7 +80,7 @@
78
80
  "@exodus/ab-testing": "^7.6.1",
79
81
  "@exodus/algorand-lib": "^2.0.1",
80
82
  "@exodus/algorand-meta": "^1.1.4",
81
- "@exodus/analytics": "^14.4.1",
83
+ "@exodus/analytics": "^14.4.2",
82
84
  "@exodus/announcements": "^3.0.0",
83
85
  "@exodus/apy-rates": "^3.5.0",
84
86
  "@exodus/assets-feature": "workspace:^",
@@ -86,8 +88,9 @@
86
88
  "@exodus/bitcoin-plugin": "^1.0.14",
87
89
  "@exodus/connected-origins": "^3.4.0",
88
90
  "@exodus/crypto-news-monitor": "^5.0.2",
89
- "@exodus/currency": "^5.0.2",
91
+ "@exodus/currency": "^6.0.0",
90
92
  "@exodus/deferring-storage": "^1.0.1",
93
+ "@exodus/domain-serialization": "^1.3.1",
91
94
  "@exodus/ethereum-lib": "^5.0.0",
92
95
  "@exodus/ethereum-meta": "^1.1.0",
93
96
  "@exodus/exodus-pricing-client": "^1.3.1",
@@ -98,7 +101,7 @@
98
101
  "@exodus/litecoin-meta": "^1.0.0",
99
102
  "@exodus/market-history": "^9.0.5",
100
103
  "@exodus/models": "^12.0.1",
101
- "@exodus/nfts": "^9.3.6",
104
+ "@exodus/nfts": "^9.3.7",
102
105
  "@exodus/personal-notes": "^3.6.3",
103
106
  "@exodus/referrals": "^8.8.0",
104
107
  "@exodus/solana-lib": "^2.0.0",
@@ -106,7 +109,8 @@
106
109
  "@exodus/storage-encrypted": "^1.4.1",
107
110
  "@exodus/storage-memory": "^2.2.0",
108
111
  "@exodus/top-movers-monitor": "^4.2.3",
109
- "@exodus/ui-config": "^3.10.1",
112
+ "@exodus/ui-config": "^3.11.0",
113
+ "@exodus/wallet-sdk": "^1.0.0",
110
114
  "@exodus/wild-emitter": "^1.0.0",
111
115
  "buffer-json": "^2.0.0",
112
116
  "deepmerge": "^4.2.2",
@@ -116,5 +120,5 @@
116
120
  "msw": "^2.0.0",
117
121
  "p-defer": "^4.0.0"
118
122
  },
119
- "gitHead": "d64de7579b06afe91fbded3d1f7eb29950f82e5a"
123
+ "gitHead": "1ff5cf831e8154730887aaaa3ac3bf0e3020a386"
120
124
  }
package/src/api/index.js CHANGED
@@ -36,8 +36,7 @@ const createApi = ({ ioc, port, config, debug, logger }) => {
36
36
  }
37
37
  }
38
38
 
39
- featureApis.wallet = {
40
- ...featureApis.wallet,
39
+ const applicationWalletApi = {
41
40
  addSeed: application.addSeed,
42
41
  start: deprecated(application.start),
43
42
  stop: deprecated(application.stop),
@@ -56,6 +55,17 @@ const createApi = ({ ioc, port, config, debug, logger }) => {
56
55
  restoreFromCurrentPhrase: deprecated(application.restoreFromCurrentPhrase),
57
56
  }
58
57
 
58
+ // featureApis.wallet is a proxy when the wallet sdk is used from a separate process, do not spread!
59
+ featureApis.wallet = new Proxy(featureApis.wallet, {
60
+ get(target, prop) {
61
+ if (prop in applicationWalletApi) {
62
+ return applicationWalletApi[prop]
63
+ }
64
+
65
+ return target[prop]
66
+ },
67
+ })
68
+
59
69
  const debugApi = createDebug({ ioc, port, debug })
60
70
  const reportingApi = createReporting({ ioc, config })
61
71
 
@@ -13,10 +13,15 @@ const createBaseAssetNamesToMonitorAtom = ({
13
13
  enabledAssetsAtom,
14
14
  restoreAtom,
15
15
  availableAssetNamesAtom,
16
+ config: { ignoreAssetNames = [] } = Object.create(null),
16
17
  }) => {
18
+ const ignoreAssetNamesSet = new Set(ignoreAssetNames)
19
+
17
20
  const selector = ({ isRestore, enabledAssets, availableAssetNames }) => {
18
21
  const assetNames = isRestore ? availableAssetNames : Object.keys(enabledAssets)
19
- return getNetworks(assetNames, assetsModule.getAssets())
22
+ return getNetworks(assetNames, assetsModule.getAssets()).filter(
23
+ (assetName) => !ignoreAssetNamesSet.has(assetName)
24
+ )
20
25
  }
21
26
 
22
27
  return dedupe(
@@ -36,6 +41,12 @@ export default {
36
41
  id: 'baseAssetNamesToMonitorAtom',
37
42
  type: 'atom',
38
43
  factory: createBaseAssetNamesToMonitorAtom,
39
- dependencies: ['assetsModule', 'availableAssetNamesAtom', 'enabledAssetsAtom', 'restoreAtom'],
44
+ dependencies: [
45
+ 'assetsModule',
46
+ 'availableAssetNamesAtom',
47
+ 'enabledAssetsAtom',
48
+ 'restoreAtom',
49
+ 'config?',
50
+ ],
40
51
  public: true,
41
52
  }
@@ -1,5 +1,10 @@
1
1
  import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
2
2
 
3
- const createAtomDependencies = () => [{ definition: baseAssetNamesToMonitorAtomDefinition }]
3
+ const createAtomDependencies = ({ config }) => [
4
+ {
5
+ definition: baseAssetNamesToMonitorAtomDefinition,
6
+ config: { ignoreAssetNames: config.ignoreAssetNamesToMonitor },
7
+ },
8
+ ]
4
9
 
5
10
  export default createAtomDependencies
@@ -10,14 +10,7 @@ import createModuleDependencies from './modules'
10
10
  import createPluginDependencies from './plugins'
11
11
  import { wrapConstant } from './utils'
12
12
 
13
- const adapterKeys = [
14
- 'createLogger',
15
- 'legacyPrivToPub',
16
- 'seedStorage',
17
- 'unsafeStorage',
18
- 'fetch',
19
- 'freeze',
20
- ]
13
+ const adapterKeys = ['createLogger', 'legacyPrivToPub', 'unsafeStorage', 'fetch', 'freeze']
21
14
 
22
15
  const createDependencies = ({ adapters, config }) => {
23
16
  assert(config, 'expected config object')
@@ -1,8 +1,10 @@
1
1
  import headlessAnalyticsPluginDefinition from '../plugins/analytics'
2
+ import headlessUiLifecyclePluginDefinition from '../plugins/headless-ui'
2
3
  import logLifecyclePluginDefinition from '../plugins/log-lifecycle'
3
4
 
4
5
  const createPluginDependencies = () => [
5
6
  { definition: logLifecyclePluginDefinition },
7
+ { definition: headlessUiLifecyclePluginDefinition },
6
8
  {
7
9
  if: { registered: ['analytics'] },
8
10
  definition: headlessAnalyticsPluginDefinition,
@@ -0,0 +1,5 @@
1
+ import { createRpcFeature } from '../../utils/ioc'
2
+
3
+ const keychainRpc = (api) => createRpcFeature('keychain', api)
4
+
5
+ export default keychainRpc
@@ -0,0 +1,55 @@
1
+ import { createInMemoryAtom } from '@exodus/atoms'
2
+
3
+ const walletRpc = (api) => {
4
+ const id = 'wallet'
5
+
6
+ const createSeedIngestingProxy = (primarySeedIdAtom) =>
7
+ new Proxy(api, {
8
+ get(target, prop) {
9
+ if (prop === 'unlock') {
10
+ return async (...args) => {
11
+ const { primarySeedId } = await target[prop](...args)
12
+ await primarySeedIdAtom.set(primarySeedId)
13
+ return primarySeedId
14
+ }
15
+ }
16
+
17
+ return target[prop]
18
+ },
19
+ })
20
+
21
+ return {
22
+ id,
23
+ definitions: [
24
+ {
25
+ definition: {
26
+ id: 'primarySeedIdAtom',
27
+ type: 'atom',
28
+ factory: () => createInMemoryAtom(), // eslint-disable-line @exodus/hydra/in-memory-atom-default-value
29
+ public: true,
30
+ },
31
+ },
32
+ {
33
+ definition: {
34
+ id,
35
+ type: 'module',
36
+ public: true,
37
+ factory: ({ primarySeedIdAtom }) => createSeedIngestingProxy(primarySeedIdAtom),
38
+ dependencies: ['primarySeedIdAtom'],
39
+ },
40
+ },
41
+ {
42
+ definition: {
43
+ id: `${id}Api`,
44
+ type: 'api',
45
+ factory: ({ primarySeedIdAtom }) => ({
46
+ [id]: createSeedIngestingProxy(primarySeedIdAtom),
47
+ }),
48
+ dependencies: ['primarySeedIdAtom'],
49
+ },
50
+ },
51
+ ],
52
+ }
53
+ }
54
+
55
+ export default walletRpc
package/src/index.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- import addressProvider from '@exodus/address-provider'
2
- import { type Node, Argo, Definition, Feature, InstanceById } from '@exodus/argo'
3
- import assetSources from '@exodus/asset-sources'
4
- import assets from '@exodus/assets-feature'
5
- import availableAssets from '@exodus/available-assets'
6
- import blockchainMetadata from '@exodus/blockchain-metadata'
7
- import enabledAssets from '@exodus/enabled-assets'
8
- import featureFlags from '@exodus/feature-flags'
9
- import fees from '@exodus/fee-data-monitors'
10
- import keyViewer from '@exodus/key-viewer'
11
- import keychain from '@exodus/keychain'
12
- import locale from '@exodus/locale'
13
- import messageSigner from '@exodus/message-signer'
14
- import pricing from '@exodus/pricing'
15
- import publicKeyProvider from '@exodus/public-key-provider'
16
- import rates from '@exodus/rates-monitor'
17
- import remoteConfig from '@exodus/remote-config'
18
- import txSigner from '@exodus/tx-signer'
19
- import wallet from '@exodus/wallet'
20
- import walletAccounts from '@exodus/wallet-accounts'
1
+ import type addressProvider from '@exodus/address-provider'
2
+ import type { type Node, Argo, Definition, Feature, InstanceById } from '@exodus/argo'
3
+ import type assetSources from '@exodus/asset-sources'
4
+ import type assets from '@exodus/assets-feature'
5
+ import type availableAssets from '@exodus/available-assets'
6
+ import type blockchainMetadata from '@exodus/blockchain-metadata'
7
+ import type enabledAssets from '@exodus/enabled-assets'
8
+ import type featureFlags from '@exodus/feature-flags'
9
+ import type fees from '@exodus/fee-data-monitors'
10
+ import type keyViewer from '@exodus/key-viewer'
11
+ import type keychain from '@exodus/keychain'
12
+ import type locale from '@exodus/locale'
13
+ import type messageSigner from '@exodus/message-signer'
14
+ import type pricing from '@exodus/pricing'
15
+ import type publicKeyProvider from '@exodus/public-key-provider'
16
+ import type rates from '@exodus/rates-monitor'
17
+ import type remoteConfig from '@exodus/remote-config'
18
+ import type txSigner from '@exodus/tx-signer'
19
+ import type wallet from '@exodus/wallet'
20
+ import type walletAccounts from '@exodus/wallet-accounts'
21
21
 
22
22
  type ApiDefinitions<F extends Feature> = Extract<
23
23
  F['definitions'][number]['definition'],
package/src/index.js CHANGED
@@ -18,7 +18,6 @@ import locale from '@exodus/locale'
18
18
  import messageSigner from '@exodus/message-signer'
19
19
  import pricing from '@exodus/pricing'
20
20
  import publicKeyProvider from '@exodus/public-key-provider'
21
- import publicKeyStore from '@exodus/public-key-store'
22
21
  import rates from '@exodus/rates-monitor'
23
22
  import remoteConfig from '@exodus/remote-config'
24
23
  import restoreProgressTracker from '@exodus/restore-progress-tracker'
@@ -32,7 +31,8 @@ import ms from 'ms'
32
31
 
33
32
  import createApi from './api'
34
33
  import createDependencies from './dependencies'
35
- import headlessUi from './headless-ui'
34
+ import keychainRpc from './features/keychain-rpc'
35
+ import walletRpc from './features/wallet-rpc'
36
36
  import attachMigrations from './migrations/attach'
37
37
  import attachPlugins from './plugins/attach'
38
38
  import { makeChainable } from './utils/ioc'
@@ -64,22 +64,28 @@ const createExodus = (opts) => {
64
64
  ioc.use(fees(config.fees))
65
65
  ioc.use(filesystem(config.filesystem))
66
66
  ioc.use(geolocation(config.geolocation))
67
- ioc.use(keychain(config.keychain))
68
67
  ioc.use(keyViewer(config.keyViewer))
69
68
  ioc.use(locale(config.locale))
70
69
  ioc.use(messageSigner(config.messageSigner))
71
70
  ioc.use(pricing(config.pricing))
72
71
  ioc.use(publicKeyProvider(config.publicKeyProvider))
73
- ioc.use(publicKeyStore(config.publicKeyStore))
74
72
  ioc.use(rates(config.rates))
75
73
  ioc.use(remoteConfig(config.remoteConfig))
76
74
  ioc.use(restoreProgressTracker(config.restoreProgressTracker))
77
75
  ioc.use(startupCounter(config.startupCounter))
78
76
  ioc.use(transactionSigner(config.transactionSigner))
79
77
  ioc.use(txLogMonitors(config.txLogMonitors))
80
- ioc.use(wallet(config.wallet))
81
78
  ioc.use(walletAccounts(config.walletAccounts))
82
- ioc.use(headlessUi())
79
+
80
+ const { walletSdk } = adapters
81
+
82
+ if (walletSdk) {
83
+ ioc.use(keychainRpc(walletSdk.keychain))
84
+ ioc.use(walletRpc(walletSdk.wallet))
85
+ } else {
86
+ ioc.use(keychain(config.keychain))
87
+ ioc.use(wallet(config.wallet))
88
+ }
83
89
 
84
90
  ioc.registerMultiple(createDependencies({ adapters, config }))
85
91
 
@@ -13,8 +13,4 @@ const headlessUiLifecyclePluginDefinition = {
13
13
  dependencies: ['storage'],
14
14
  }
15
15
 
16
- const headlessUiFeatureDefinition = () => ({
17
- definitions: [{ definition: headlessUiLifecyclePluginDefinition }],
18
- })
19
-
20
- export default headlessUiFeatureDefinition
16
+ export default headlessUiLifecyclePluginDefinition
package/src/utils/ioc.js CHANGED
@@ -15,3 +15,31 @@ export const makeChainable = ({ ioc, methods, resolve }) =>
15
15
  return target[prop]
16
16
  },
17
17
  })
18
+
19
+ /**
20
+ * @returns {import('@exodus/dependency-types').Feature}
21
+ */
22
+ export const createRpcFeature = (id, api) => ({
23
+ id,
24
+ definitions: [
25
+ {
26
+ // export module to IOC for consumption via dependencies
27
+ definition: {
28
+ id,
29
+ type: 'module',
30
+ public: true,
31
+ factory: () => api,
32
+ },
33
+ },
34
+ {
35
+ // export API to SDK surface
36
+ definition: {
37
+ id: `${id}Api`,
38
+ type: 'api',
39
+ factory: () => ({
40
+ [id]: api,
41
+ }),
42
+ },
43
+ },
44
+ ],
45
+ })