@exodus/headless 2.0.0-alpha.46 → 2.0.0-alpha.48
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 +12 -0
- package/README.md +12 -3
- package/package.json +3 -2
- package/src/api.js +1 -26
- package/src/dependencies/atoms.js +1 -14
- package/src/dependencies/modules.js +0 -5
- package/src/index.js +2 -0
- package/src/modules/ab-testing/index.js +1 -1
- package/src/modules/locale/index.js +6 -4
- package/src/modules/nfts/index.js +1 -1
- package/src/modules/personal-notes/index.js +4 -1
- package/src/modules/wallet/api.js +34 -0
- package/src/modules/wallet/index.js +24 -0
- package/src/modules/wallet/locked-atom.js +10 -0
- package/src/{plugins/restore.js → modules/wallet/restore-plugin.js} +1 -0
- package/src/plugins/index.js +1 -2
- /package/src/{atoms/restore.js → modules/wallet/restore-atom.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.48](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.47...@exodus/headless@2.0.0-alpha.48) (2023-06-20)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- declare atoms in writesAtoms ([#2006](https://github.com/ExodusMovement/exodus-hydra/issues/2006)) ([02b7227](https://github.com/ExodusMovement/exodus-hydra/commit/02b72271116b4e3b034b7f889b0dc333fda17413))
|
|
11
|
+
|
|
12
|
+
## [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)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- use(wallet) ([#1994](https://github.com/ExodusMovement/exodus-hydra/issues/1994)) ([6686257](https://github.com/ExodusMovement/exodus-hydra/commit/668625744087ee77068fc64671ce80ea0c3c62a4))
|
|
17
|
+
|
|
6
18
|
## [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
19
|
|
|
8
20
|
### Features
|
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ The headless Exodus wallet SDK
|
|
|
15
15
|
|
|
16
16
|
```js
|
|
17
17
|
import createExodus from '@exodus/headless'
|
|
18
|
+
import referrals from '@exodus/headless/src/modules/referrals'
|
|
18
19
|
import Emitter from '@exodus/wild-emitter'
|
|
19
20
|
|
|
20
21
|
// 1. Create port. Acts as an event bus between headless wallet and client
|
|
@@ -25,10 +26,10 @@ const adapters = {}
|
|
|
25
26
|
const config = {}
|
|
26
27
|
|
|
27
28
|
// 3. Create Exodus container
|
|
28
|
-
const
|
|
29
|
+
const exodusContainer = createExodus({ port, adapters, config })
|
|
29
30
|
|
|
30
31
|
// 4. Register external modules. Does not support overriding modules at the moment.
|
|
31
|
-
|
|
32
|
+
exodusContainer.register({
|
|
32
33
|
definition: {
|
|
33
34
|
id: 'remoteConfig',
|
|
34
35
|
factory: createRemoteConfig,
|
|
@@ -36,14 +37,22 @@ container.register({
|
|
|
36
37
|
},
|
|
37
38
|
})
|
|
38
39
|
|
|
40
|
+
// see an example feature definition:
|
|
41
|
+
// https://github.com/ExodusMovement/exodus-hydra/blob/2e8d63426421ffcbec84a9b6fbc83eb913b47eba/modules/headless/src/modules/geolocation/index.js
|
|
42
|
+
exodusContainer.use(referrals())
|
|
43
|
+
exodusContainer.use(myCustomFeature({ id: 'myCustomFeature', ... }))
|
|
44
|
+
|
|
39
45
|
// 5. Resolve exodus instance
|
|
40
|
-
const exodus =
|
|
46
|
+
const exodus = exodusContainer.resolve()
|
|
41
47
|
|
|
42
48
|
// 6. Start exodus instance
|
|
43
49
|
await exodus.wallet.start()
|
|
44
50
|
|
|
45
51
|
// 7. Use it!
|
|
46
52
|
await exodus.wallet.create({ passphrase: 'my-super-secure-passphrase' })
|
|
53
|
+
|
|
54
|
+
// 8. Use your custom feature API, if any
|
|
55
|
+
exodus.myCustomFeature.doThatThingYouDo()
|
|
47
56
|
```
|
|
48
57
|
|
|
49
58
|
## Lifecycle
|
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.48",
|
|
4
4
|
"description": "The headless Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement Inc",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@exodus/feature-flags": "^2.1.0",
|
|
46
46
|
"@exodus/fee-monitors": "^1.0.0",
|
|
47
47
|
"@exodus/fetch": "^1.2.1",
|
|
48
|
+
"@exodus/fusion": "^5.0.0",
|
|
48
49
|
"@exodus/geolocation": "^2.0.0",
|
|
49
50
|
"@exodus/key-identifier-provider": "^1.1.3",
|
|
50
51
|
"@exodus/keychain": "^4.0.0",
|
|
@@ -88,5 +89,5 @@
|
|
|
88
89
|
"nock": "^13.3.1",
|
|
89
90
|
"p-defer": "^4.0.0"
|
|
90
91
|
},
|
|
91
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "a8a419acb6f13d21b294f346e1c00f10a5b3a90b"
|
|
92
93
|
}
|
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 {
|
|
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())
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
2
|
+
import { fusionAtomFactory } from '@exodus/fusion/atoms'
|
|
2
3
|
|
|
3
4
|
import localeApiDefinition from './api'
|
|
4
5
|
import localePluginDefinition from './plugin'
|
|
@@ -12,7 +13,8 @@ const locale = () => {
|
|
|
12
13
|
id: 'currencyAtom',
|
|
13
14
|
type: 'atom',
|
|
14
15
|
factory: ({ fusion, config }) =>
|
|
15
|
-
|
|
16
|
+
fusionAtomFactory({
|
|
17
|
+
fusion,
|
|
16
18
|
path: `private.currency`,
|
|
17
19
|
defaultValue: config.defaultValue,
|
|
18
20
|
}),
|
|
@@ -39,8 +41,8 @@ const locale = () => {
|
|
|
39
41
|
],
|
|
40
42
|
storage: { namespace: 'locale' },
|
|
41
43
|
},
|
|
42
|
-
{ definition: localePluginDefinition },
|
|
43
|
-
{ definition: localeApiDefinition },
|
|
44
|
+
{ definition: localePluginDefinition, writesAtoms: ['languageAtom'] },
|
|
45
|
+
{ definition: localeApiDefinition, writesAtoms: ['languageAtom', 'currencyAtom'] },
|
|
44
46
|
],
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -23,7 +23,7 @@ const nfts = () => {
|
|
|
23
23
|
definition: { type: 'monitor', ...nftsMonitorDefinition },
|
|
24
24
|
writesAtoms: ['nftsCacheAtom'],
|
|
25
25
|
},
|
|
26
|
-
{ definition: nftsModuleDefinition },
|
|
26
|
+
{ definition: nftsModuleDefinition, writesAtoms: ['nftsCacheAtom', 'nftsConfigAtom'] },
|
|
27
27
|
{ definition: nftsPluginDefinition },
|
|
28
28
|
{ definition: nftsApiDefinition },
|
|
29
29
|
],
|
|
@@ -18,7 +18,10 @@ const personalNotes = () => {
|
|
|
18
18
|
},
|
|
19
19
|
],
|
|
20
20
|
},
|
|
21
|
-
{
|
|
21
|
+
{
|
|
22
|
+
definition: { type: 'module', ...personalNotesDefinition },
|
|
23
|
+
writesAtoms: ['personalNotesAtom'],
|
|
24
|
+
},
|
|
22
25
|
{ definition: personalNotesPluginDefinition },
|
|
23
26
|
{ definition: personalNotesApiDefinition },
|
|
24
27
|
],
|
|
@@ -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, writesAtoms: ['restoreAtom'] },
|
|
19
|
+
{ definition: walletApi },
|
|
20
|
+
],
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default wallet
|
package/src/plugins/index.js
CHANGED
|
@@ -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,
|
|
5
|
+
export default [logLifecyclePlugin, autoEnableAssetsPlugin]
|
|
File without changes
|