@exodus/headless 5.0.0-rc.21 → 5.0.0-rc.23

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,16 @@
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.23](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.22...@exodus/headless@5.0.0-rc.23) (2024-07-17)
7
+
8
+ ### Features
9
+
10
+ - chainable ioc methods to infer types of external features ([#7892](https://github.com/ExodusMovement/exodus-hydra/issues/7892)) ([213e3ab](https://github.com/ExodusMovement/exodus-hydra/commit/213e3ab064cb5796a581b78c590b7c22246b8219))
11
+
12
+ ## [5.0.0-rc.22](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.21...@exodus/headless@5.0.0-rc.22) (2024-07-16)
13
+
14
+ **Note:** Version bump only for package @exodus/headless
15
+
6
16
  ## [5.0.0-rc.21](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@5.0.0-rc.20...@exodus/headless@5.0.0-rc.21) (2024-07-16)
7
17
 
8
18
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "5.0.0-rc.21",
3
+ "version": "5.0.0-rc.23",
4
4
  "description": "The platform-agnostic Exodus wallet SDK",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "main": "src/index.js",
@@ -23,12 +23,13 @@
23
23
  "scripts": {
24
24
  "lint": "run -T eslint . --ignore-path ../../.gitignore",
25
25
  "lint:fix": "yarn lint --fix",
26
- "test": "NODE_OPTIONS=--max-old-space-size=4096 run -T jest"
26
+ "test": "NODE_OPTIONS=--max-old-space-size=4096 run -T jest && yarn test:types",
27
+ "test:types": "run -T tsc --noEmit"
27
28
  },
28
29
  "dependencies": {
29
30
  "@exodus/address-provider": "^11.3.0",
30
31
  "@exodus/application": "^1.2.0",
31
- "@exodus/argo": "^1.3.0",
32
+ "@exodus/argo": "^1.3.1",
32
33
  "@exodus/asset-sources": "^1.1.1",
33
34
  "@exodus/assets-feature": "^5.7.0",
34
35
  "@exodus/atoms": "^7.0.0",
@@ -37,7 +38,7 @@
37
38
  "@exodus/basic-utils": "^2.0.0",
38
39
  "@exodus/blockchain-metadata": "^15.3.0",
39
40
  "@exodus/dependency-injection": "^2.1.2",
40
- "@exodus/dependency-preprocessors": "^5.4.0",
41
+ "@exodus/dependency-preprocessors": "^6.0.0",
41
42
  "@exodus/enabled-assets": "^10.2.0",
42
43
  "@exodus/error-tracking": "^1.1.1",
43
44
  "@exodus/feature-flags": "^6.0.0",
@@ -112,5 +113,5 @@
112
113
  "msw": "^2.0.0",
113
114
  "p-defer": "^4.0.0"
114
115
  },
115
- "gitHead": "7dbd2025af2c73ae13960b1fbaa10998c4a69e98"
116
+ "gitHead": "2530da5fcefc5168e050cd398f9bccf4dee9bf16"
116
117
  }
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import addressProvider from '@exodus/address-provider'
2
- import { Argo, Definition, Feature, InstanceById } from '@exodus/argo'
2
+ import { type Node, Argo, Definition, Feature, InstanceById } from '@exodus/argo'
3
3
  import assetSources from '@exodus/asset-sources'
4
4
  import assets from '@exodus/assets-feature'
5
5
  import availableAssets from '@exodus/available-assets'
@@ -30,6 +30,8 @@ type FeatureFactory = (...args: any[]) => Feature
30
30
 
31
31
  type FeatureApi<F extends FeatureFactory> = Values<InstanceById<ApiDefinitions<ReturnType<F>>>>
32
32
 
33
+ type DefinitionsApi<D extends Definition> = Values<InstanceById<Extract<D, { type: 'api' }>>>
34
+
33
35
  export interface ApplicationWalletApi {
34
36
  addSeed(params: { mnemonic: string; compatibilityMode: string }): Promise<void>
35
37
  start(): Promise<void>
@@ -86,6 +88,16 @@ type Params = {
86
88
  debug?: boolean
87
89
  }
88
90
 
89
- export default function createExodus<D extends Definition>(
91
+ interface ArgoWithApiResolver<D extends Definition>
92
+ extends Omit<Argo<D>, 'use' | 'registerMultiple' | 'register' | 'resolve'> {
93
+ register<N extends Node>(node: N): ArgoWithApiResolver<D | N['definition']>
94
+ registerMultiple<N extends Node>(node: readonly N[]): ArgoWithApiResolver<D | N['definition']>
95
+ use<F extends Feature>(
96
+ feature: F
97
+ ): ArgoWithApiResolver<D | F['definitions'][number]['definition']>
98
+ resolve(): ExodusApi & DefinitionsApi<D>
99
+ }
100
+
101
+ export default function createExodus<D extends Definition = {}>( // eslint-disable-line @typescript-eslint/ban-types
90
102
  params: Params
91
- ): Omit<Argo<D>, 'resolve'> & { resolve: () => ExodusApi }
103
+ ): ArgoWithApiResolver<D>
package/src/index.js CHANGED
@@ -32,6 +32,7 @@ import createApi from './api'
32
32
  import createDependencies from './dependencies'
33
33
  import attachMigrations from './migrations/attach'
34
34
  import attachPlugins from './plugins/attach'
35
+ import { makeChainable } from './utils/ioc'
35
36
 
36
37
  const createExodus = (opts) => {
37
38
  typeforce(
@@ -158,7 +159,7 @@ const createExodus = (opts) => {
158
159
  return createApi({ ioc, port, config, debug, logger: ioc.get('createLogger')('createApi') })
159
160
  }
160
161
 
161
- return { ...ioc, resolve }
162
+ return makeChainable({ ioc, methods: ['use', 'register', 'registerMultiple'], resolve })
162
163
  }
163
164
 
164
165
  export default createExodus
@@ -0,0 +1,17 @@
1
+ export const makeChainable = ({ ioc, methods, resolve }) =>
2
+ new Proxy(ioc, {
3
+ get(target, prop) {
4
+ if (prop === 'resolve') {
5
+ return resolve
6
+ }
7
+
8
+ if (methods.includes(prop)) {
9
+ return (...args) => {
10
+ target[prop](...args)
11
+ return makeChainable({ ioc, methods, resolve })
12
+ }
13
+ }
14
+
15
+ return target[prop]
16
+ },
17
+ })