@exodus/hardware-wallets 1.1.0 → 1.1.1

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
+ ## [1.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hardware-wallets@1.1.0...@exodus/hardware-wallets@1.1.1) (2024-08-12)
7
+
8
+ ### Bug Fixes
9
+
10
+ - resolve circular dependency temporarily ([#8316](https://github.com/ExodusMovement/exodus-hydra/issues/8316)) ([c4e7570](https://github.com/ExodusMovement/exodus-hydra/commit/c4e75706c5f1e4e4be63d6c46dcaa5f30f71d124))
11
+
6
12
  ## [1.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hardware-wallets@1.0.0...@exodus/hardware-wallets@1.1.0) (2024-08-08)
7
13
 
8
14
  ### Features
@@ -2,8 +2,10 @@ import type { HardwareWallets } from '../module/hardware-wallets.js';
2
2
  declare const hardwareWalletsApiDefinition: {
3
3
  readonly id: "hardwareWalletsApi";
4
4
  readonly type: "api";
5
- readonly factory: ({ hardwareWallets }: {
5
+ readonly factory: ({ hardwareWallets, restoreProgressTracker, txLogMonitors, }: {
6
6
  hardwareWallets: HardwareWallets;
7
+ txLogMonitors: any;
8
+ restoreProgressTracker: any;
7
9
  }) => {
8
10
  hardwareWallets: {
9
11
  isDeviceConnected: () => Promise<boolean>;
@@ -17,6 +19,6 @@ declare const hardwareWalletsApiDefinition: {
17
19
  create: ({ syncedKeysId }: import("../module/interfaces.js").CreateParams) => Promise<void>;
18
20
  };
19
21
  };
20
- readonly dependencies: readonly ["hardwareWallets"];
22
+ readonly dependencies: readonly ["hardwareWallets", "txLogMonitors", "restoreProgressTracker"];
21
23
  };
22
24
  export default hardwareWalletsApiDefinition;
package/lib/api/index.js CHANGED
@@ -1,4 +1,21 @@
1
- const createHardwareWalletsApi = ({ hardwareWallets }) => {
1
+ const createHardwareWalletsApi = ({ hardwareWallets, restoreProgressTracker, txLogMonitors, }) => {
2
+ hardwareWallets.events.subscribe(({ type, payload }) => {
3
+ if (type !== 'syncAssets')
4
+ return;
5
+ const { assetNames } = payload;
6
+ for (const assetName of assetNames) {
7
+ if (assetName === 'ethereum' || assetName === 'matic') {
8
+ restoreProgressTracker.restoreAsset('ethereum');
9
+ restoreProgressTracker.restoreAsset('matic');
10
+ txLogMonitors.update({ assetName: 'ethereum', refresh: true });
11
+ txLogMonitors.update({ assetName: 'matic', refresh: true });
12
+ }
13
+ else {
14
+ restoreProgressTracker.restoreAsset(assetName);
15
+ txLogMonitors.update({ assetName, refresh: true });
16
+ }
17
+ }
18
+ });
2
19
  return {
3
20
  hardwareWallets: {
4
21
  isDeviceConnected: hardwareWallets.isDeviceConnected,
@@ -17,6 +34,6 @@ const hardwareWalletsApiDefinition = {
17
34
  id: 'hardwareWalletsApi',
18
35
  type: 'api',
19
36
  factory: createHardwareWalletsApi,
20
- dependencies: ['hardwareWallets'],
37
+ dependencies: ['hardwareWallets', 'txLogMonitors', 'restoreProgressTracker'],
21
38
  };
22
39
  export default hardwareWalletsApiDefinition;
package/lib/index.d.ts CHANGED
@@ -4,8 +4,10 @@ declare const hardwareWallets: () => {
4
4
  readonly definition: {
5
5
  readonly id: "hardwareWalletsApi";
6
6
  readonly type: "api";
7
- readonly factory: ({ hardwareWallets }: {
7
+ readonly factory: ({ hardwareWallets, restoreProgressTracker, txLogMonitors, }: {
8
8
  hardwareWallets: import("./module/hardware-wallets.js").HardwareWallets;
9
+ txLogMonitors: any;
10
+ restoreProgressTracker: any;
9
11
  }) => {
10
12
  hardwareWallets: {
11
13
  isDeviceConnected: () => Promise<boolean>;
@@ -19,14 +21,14 @@ declare const hardwareWallets: () => {
19
21
  create: ({ syncedKeysId }: import("./module/interfaces.js").CreateParams) => Promise<void>;
20
22
  };
21
23
  };
22
- readonly dependencies: readonly ["hardwareWallets"];
24
+ readonly dependencies: readonly ["hardwareWallets", "txLogMonitors", "restoreProgressTracker"];
23
25
  };
24
26
  }, {
25
27
  readonly definition: {
26
28
  readonly id: "hardwareWallets";
27
29
  readonly type: "module";
28
30
  readonly factory: (opts: import("./module/hardware-wallets.js").Dependencies) => import("./module/hardware-wallets.js").HardwareWallets;
29
- readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts", "txLogMonitors", "restoreProgressTracker"];
31
+ readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"];
30
32
  };
31
33
  }];
32
34
  };
@@ -1,4 +1,5 @@
1
1
  import { WalletAccount } from '@exodus/models';
2
+ import Emitter from '@exodus/wild-emitter';
2
3
  import type { HardwareSignerProvider, CanAccessAssetParams, CreateParams, StoreSyncedKeysParams, ScanParams, SyncParams, EnsureApplicationIsOpenedParams, SignTransactionParams, ScanResult, SyncedKeysId } from './interfaces.js';
3
4
  import type { HardwareWalletDiscovery, SignMessageParams } from '@exodus/hw-common';
4
5
  import type { Atom } from '@exodus/atoms';
@@ -18,7 +19,8 @@ export type Dependencies = {
18
19
  };
19
20
  export declare class HardwareWallets implements HardwareSignerProvider {
20
21
  #private;
21
- constructor({ assetsModule, ledgerDiscovery, logger, userInterface, publicKeyStore, wallet, walletAccountsAtom, walletAccounts, txLogMonitors, restoreProgressTracker, }: Dependencies);
22
+ readonly events: Emitter<string, any>;
23
+ constructor({ assetsModule, ledgerDiscovery, logger, userInterface, publicKeyStore, wallet, walletAccountsAtom, walletAccounts, }: Dependencies);
22
24
  signTransaction: ({ baseAssetName, unsignedTx, walletAccount }: SignTransactionParams) => Promise<any>;
23
25
  signMessage: ({ assetName, derivationPath, message }: SignMessageParams) => Promise<any>;
24
26
  isDeviceConnected: () => Promise<boolean>;
@@ -35,6 +37,6 @@ declare const hardwareWalletsModuleDefinition: {
35
37
  readonly id: "hardwareWallets";
36
38
  readonly type: "module";
37
39
  readonly factory: (opts: Dependencies) => HardwareWallets;
38
- readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts", "txLogMonitors", "restoreProgressTracker"];
40
+ readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"];
39
41
  };
40
42
  export default hardwareWalletsModuleDefinition;
@@ -1,5 +1,6 @@
1
1
  import assert from 'minimalistic-assert';
2
2
  import { WalletAccount } from '@exodus/models';
3
+ import Emitter from '@exodus/wild-emitter';
3
4
  import randomBytes from 'randombytes';
4
5
  import delay from 'delay';
5
6
  import { UserCancelledError } from './errors.js';
@@ -12,10 +13,9 @@ export class HardwareWallets {
12
13
  #wallet;
13
14
  #walletAccountsAtom;
14
15
  #walletAccounts;
15
- #txLogMonitors;
16
- #restoreProgressTracker;
17
16
  #syncedKeysMap = new Map();
18
- constructor({ assetsModule, ledgerDiscovery, logger, userInterface, publicKeyStore, wallet, walletAccountsAtom, walletAccounts, txLogMonitors, restoreProgressTracker, }) {
17
+ events = new Emitter();
18
+ constructor({ assetsModule, ledgerDiscovery, logger, userInterface, publicKeyStore, wallet, walletAccountsAtom, walletAccounts, }) {
19
19
  this.#assetsModule = assetsModule;
20
20
  this.#ledgerDiscovery = ledgerDiscovery;
21
21
  this.#logger = logger;
@@ -24,8 +24,6 @@ export class HardwareWallets {
24
24
  this.#wallet = wallet;
25
25
  this.#walletAccountsAtom = walletAccountsAtom;
26
26
  this.#walletAccounts = walletAccounts;
27
- this.#txLogMonitors = txLogMonitors;
28
- this.#restoreProgressTracker = restoreProgressTracker;
29
27
  }
30
28
  #requestUserAction = async (params) => {
31
29
  const rpc = this.#userInterface.getRPC();
@@ -280,18 +278,7 @@ export class HardwareWallets {
280
278
  const { xpub, publicKey } = keys;
281
279
  await this.#publicKeyStore.add({ walletAccountName, keyIdentifier, xpub, publicKey });
282
280
  }
283
- for (const assetName of assetNames) {
284
- if (assetName === 'ethereum' || assetName === 'matic') {
285
- this.#restoreProgressTracker.restoreAsset('ethereum');
286
- this.#restoreProgressTracker.restoreAsset('matic');
287
- this.#txLogMonitors.update({ assetName: 'ethereum', refresh: true });
288
- this.#txLogMonitors.update({ assetName: 'matic', refresh: true });
289
- }
290
- else {
291
- this.#restoreProgressTracker.restoreAsset(assetName);
292
- this.#txLogMonitors.update({ assetName, refresh: true });
293
- }
294
- }
281
+ this.events.emit('syncAssets', { assetNames });
295
282
  };
296
283
  create = async ({ syncedKeysId }) => {
297
284
  assert(this.#syncedKeysMap.has(syncedKeysId), `no synchronized keys found for id ${syncedKeysId}`);
@@ -323,8 +310,6 @@ const hardwareWalletsModuleDefinition = {
323
310
  'wallet',
324
311
  'walletAccountsAtom',
325
312
  'walletAccounts',
326
- 'txLogMonitors',
327
- 'restoreProgressTracker',
328
313
  ],
329
314
  };
330
315
  export default hardwareWalletsModuleDefinition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/hardware-wallets",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "An Exodus SDK feature that provides a high level abstraction for interacting with hardware wallet devices",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "repository": {
@@ -29,6 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@exodus/models": "^11.7.0",
32
+ "@exodus/wild-emitter": "^1.1.0",
32
33
  "delay": "^5.0.0",
33
34
  "minimalistic-assert": "^1.0.1",
34
35
  "randombytes": "^2.1.0"
@@ -39,5 +40,5 @@
39
40
  "@exodus/logger": "^1.2.2",
40
41
  "@exodus/public-key-store": "^1.2.2"
41
42
  },
42
- "gitHead": "25f3bcf0c26fd9b212c3d8aa8f3149cd139faaae"
43
+ "gitHead": "7b677da738335fdc10685fdfab0084f60d21a828"
43
44
  }