@exodus/headless 2.0.0-alpha.46 → 2.0.0-alpha.47

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,12 @@
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.47](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.46...@exodus/headless@2.0.0-alpha.47) (2023-06-18)
7
+
8
+ ### Features
9
+
10
+ - use(wallet) ([#1994](https://github.com/ExodusMovement/exodus-hydra/issues/1994)) ([6686257](https://github.com/ExodusMovement/exodus-hydra/commit/668625744087ee77068fc64671ce80ea0c3c62a4))
11
+
6
12
  ## [2.0.0-alpha.46](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.45...@exodus/headless@2.0.0-alpha.46) (2023-06-18)
7
13
 
8
14
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "2.0.0-alpha.46",
3
+ "version": "2.0.0-alpha.47",
4
4
  "description": "The headless Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc",
6
6
  "main": "src/index.js",
@@ -88,5 +88,5 @@
88
88
  "nock": "^13.3.1",
89
89
  "p-defer": "^4.0.0"
90
90
  },
91
- "gitHead": "9946e9d678eb80b4cb7de96fb76c804ae5e31fc9"
91
+ "gitHead": "003665277a4a7ee772af60ab555f5692b1f840f6"
92
92
  }
package/src/api.js CHANGED
@@ -5,13 +5,10 @@ const createApi = ({ ioc, port }) => {
5
5
 
6
6
  const { assetsModule } = ioc.getByType('adapter')
7
7
 
8
- const { application, enabledAssets, remoteConfig, wallet } = ioc.getByType('module')
8
+ const { enabledAssets, remoteConfig } = ioc.getByType('module')
9
9
 
10
10
  const { feeMonitors, nftsMonitor } = ioc.getByType('monitor')
11
11
 
12
- // TODO: decide where this belongs
13
- const { passphraseCache } = ioc.getAll()
14
-
15
12
  // TODO: do this on 'unload'
16
13
  const stop = () => {
17
14
  remoteConfig.stop()
@@ -21,28 +18,6 @@ const createApi = ({ ioc, port }) => {
21
18
 
22
19
  return {
23
20
  ...Object.assign({}, ...Object.values(apis)),
24
- wallet: {
25
- exists: () => wallet.exists(),
26
- start: application.start,
27
- load: application.load,
28
- unload: application.unload,
29
- create: application.create,
30
- lock: application.lock,
31
- unlock: application.unlock,
32
- import: application.import,
33
- delete: application.delete,
34
- getMnemonic: application.getMnemonic,
35
- setBackedUp: application.setBackedUp,
36
- changePassphrase: application.changePassphrase,
37
- restoreFromCurrentPhrase: async ({ passphrase } = {}) => {
38
- if (!passphrase) passphrase = await passphraseCache.get()
39
- const mnemonic = await application.getMnemonic({ passphrase })
40
-
41
- await application.import({ passphrase, mnemonic })
42
- },
43
- changeLockTimer: application.changeLockTimer,
44
- isLocked: () => wallet.isLocked(),
45
- },
46
21
  assets: {
47
22
  enable: enabledAssets.enable,
48
23
  disable: enabledAssets.disable,
@@ -1,8 +1,4 @@
1
- import {
2
- createInMemoryAtom,
3
- createRemoteConfigAtomFactory,
4
- createStorageAtomFactory,
5
- } from '@exodus/atoms'
1
+ import { createRemoteConfigAtomFactory, createStorageAtomFactory } from '@exodus/atoms'
6
2
  import { availableAssetNamesAtomDefinition } from '@exodus/available-assets/atoms'
7
3
  import { balancesAtomDefinition } from '@exodus/balances/atoms'
8
4
  import {
@@ -12,18 +8,10 @@ import {
12
8
 
13
9
  import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
14
10
  import nonDustBalanceAssetNamesAtomDefinition from '../atoms/non-dust-balance-asset-names-atom'
15
- import restoreAtomDefinition from '../atoms/restore'
16
11
  import { withType } from './utils'
17
12
 
18
13
  const createAtomDependencies = () =>
19
14
  [
20
- {
21
- definition: {
22
- id: 'lockedAtom',
23
- factory: () => createInMemoryAtom({ defaultValue: true }),
24
- dependencies: [],
25
- },
26
- },
27
15
  {
28
16
  definition: enabledAndDisabledAssetsAtomDefinition,
29
17
  storage: { namespace: 'enabledAssets' },
@@ -65,7 +53,6 @@ const createAtomDependencies = () =>
65
53
  },
66
54
  { definition: balancesAtomDefinition },
67
55
  { definition: baseAssetNamesToMonitorAtomDefinition },
68
- { definition: restoreAtomDefinition },
69
56
  ].map(withType('atom'))
70
57
 
71
58
  export default createAtomDependencies
@@ -4,7 +4,6 @@ import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
4
4
  import createExodusPricingClient from '@exodus/exodus-pricing-client'
5
5
  import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
6
6
  import keychainDefinition from '@exodus/keychain/module'
7
- import walletDefinition from '@exodus/wallet/module'
8
7
  import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
9
8
 
10
9
  import createApplication from '../application'
@@ -30,10 +29,6 @@ const createModuleDependencies = ({ config }) =>
30
29
  {
31
30
  definition: keychainDefinition,
32
31
  },
33
- {
34
- definition: walletDefinition,
35
- writesAtoms: ['lockedAtom'],
36
- },
37
32
  {
38
33
  definition: walletCompatibilityModesDefinition,
39
34
  },
package/src/index.js CHANGED
@@ -22,6 +22,7 @@ import rates from './modules/rates'
22
22
  import referrals from './modules/referrals'
23
23
  import remoteConfig from './modules/remote-config'
24
24
  import topMovers from './modules/top-movers'
25
+ import wallet from './modules/wallet'
25
26
  import walletAccounts from './modules/wallet-accounts'
26
27
  import attachPlugins from './plugins/attach'
27
28
 
@@ -29,6 +30,7 @@ const createExodus = ({ adapters, config, port }) => {
29
30
  const ioc = createIOC({ adapters, config })
30
31
  const { headless: headlessConfig, topMoversMonitor } = config
31
32
 
33
+ ioc.use(wallet())
32
34
  ioc.use(walletAccounts())
33
35
  ioc.use(blockchainMetadata())
34
36
  ioc.use(remoteConfig())
@@ -0,0 +1,34 @@
1
+ const createWalletApi = ({ wallet, application, passphraseCache }) => {
2
+ const restoreFromCurrentPhrase = async ({ passphrase } = {}) => {
3
+ if (!passphrase) passphrase = await passphraseCache.get()
4
+ const mnemonic = await application.getMnemonic({ passphrase })
5
+ await application.import({ passphrase, mnemonic })
6
+ }
7
+
8
+ return {
9
+ wallet: {
10
+ exists: () => wallet.exists(),
11
+ start: application.start,
12
+ load: application.load,
13
+ unload: application.unload,
14
+ create: application.create,
15
+ lock: application.lock,
16
+ unlock: application.unlock,
17
+ import: application.import,
18
+ delete: application.delete,
19
+ getMnemonic: application.getMnemonic,
20
+ setBackedUp: application.setBackedUp,
21
+ changePassphrase: application.changePassphrase,
22
+ changeLockTimer: application.changeLockTimer,
23
+ restoreFromCurrentPhrase,
24
+ isLocked: () => wallet.isLocked(),
25
+ },
26
+ }
27
+ }
28
+
29
+ export default {
30
+ id: 'walletApi',
31
+ type: 'api',
32
+ factory: createWalletApi,
33
+ dependencies: ['wallet', 'application', 'passphraseCache'],
34
+ }
@@ -0,0 +1,24 @@
1
+ import walletDefinition from '@exodus/wallet/module'
2
+
3
+ import walletApi from './api'
4
+ import lockedAtomDefinition from './locked-atom'
5
+ import restoreAtomDefinition from './restore-atom'
6
+ import restorePluginDefinition from './restore-plugin'
7
+
8
+ const wallet = () => {
9
+ return {
10
+ id: 'wallet',
11
+ definitions: [
12
+ {
13
+ definition: { type: 'module', ...walletDefinition },
14
+ writesAtoms: ['lockedAtom'],
15
+ },
16
+ { definition: lockedAtomDefinition },
17
+ { definition: restoreAtomDefinition },
18
+ { definition: restorePluginDefinition },
19
+ { definition: walletApi },
20
+ ],
21
+ }
22
+ }
23
+
24
+ export default wallet
@@ -0,0 +1,10 @@
1
+ import { createInMemoryAtom } from '@exodus/atoms'
2
+
3
+ const lockedAtomDefinition = {
4
+ id: 'lockedAtom',
5
+ type: 'atom',
6
+ factory: () => createInMemoryAtom({ defaultValue: true }),
7
+ dependencies: [],
8
+ }
9
+
10
+ export default lockedAtomDefinition
@@ -11,6 +11,7 @@ const restorePlugin = ({ restoreAtom }) => {
11
11
 
12
12
  export default {
13
13
  id: 'restorePlugin',
14
+ type: 'plugin',
14
15
  factory: restorePlugin,
15
16
  dependencies: ['restoreAtom'],
16
17
  }
@@ -1,6 +1,5 @@
1
1
  import autoEnableAssetsPlugin from '@exodus/auto-enable-assets-plugin'
2
2
 
3
3
  import logLifecyclePlugin from './log-lifecycle'
4
- import restorePlugin from './restore'
5
4
 
6
- export default [logLifecyclePlugin, restorePlugin, autoEnableAssetsPlugin]
5
+ export default [logLifecyclePlugin, autoEnableAssetsPlugin]