@exodus/hardware-wallets 1.1.0 → 1.1.2

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,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
+ ## [1.1.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hardware-wallets@1.1.1...@exodus/hardware-wallets@1.1.2) (2024-08-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - add require device for ([#8333](https://github.com/ExodusMovement/exodus-hydra/issues/8333)) ([102f065](https://github.com/ExodusMovement/exodus-hydra/commit/102f065d66f00e0501986aeb53d90435f1e51adc))
11
+
12
+ ## [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)
13
+
14
+ ### Bug Fixes
15
+
16
+ - resolve circular dependency temporarily ([#8316](https://github.com/ExodusMovement/exodus-hydra/issues/8316)) ([c4e7570](https://github.com/ExodusMovement/exodus-hydra/commit/c4e75706c5f1e4e4be63d6c46dcaa5f30f71d124))
17
+
6
18
  ## [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
19
 
8
20
  ### 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,5 +1,6 @@
1
1
  import { WalletAccount } from '@exodus/models';
2
- import type { HardwareSignerProvider, CanAccessAssetParams, CreateParams, StoreSyncedKeysParams, ScanParams, SyncParams, EnsureApplicationIsOpenedParams, SignTransactionParams, ScanResult, SyncedKeysId } from './interfaces.js';
2
+ import Emitter from '@exodus/wild-emitter';
3
+ import type { HardwareSignerProvider, CanAccessAssetParams, CreateParams, StoreSyncedKeysParams, ScanParams, SyncParams, EnsureApplicationIsOpenedParams, SignTransactionParams, ScanResult, SyncedKeysId, RequireDeviceForParams } from './interfaces.js';
3
4
  import type { HardwareWalletDiscovery, SignMessageParams } from '@exodus/hw-common';
4
5
  import type { Atom } from '@exodus/atoms';
5
6
  import type { IPublicKeyStore } from '@exodus/public-key-store';
@@ -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>;
@@ -30,11 +32,15 @@ export declare class HardwareWallets implements HardwareSignerProvider {
30
32
  sync: ({ accountIndex }: SyncParams) => Promise<SyncedKeysId>;
31
33
  addPublicKeysToWalletAccount: ({ walletAccountName, syncedKeysId, }: StoreSyncedKeysParams) => Promise<void>;
32
34
  create: ({ syncedKeysId }: CreateParams) => Promise<void>;
35
+ requireDeviceFor: ({ walletAccount }: RequireDeviceForParams) => Promise<{
36
+ signTransaction: ({ baseAssetName, unsignedTx, walletAccount }: SignTransactionParams) => Promise<any>;
37
+ signMessage: ({ assetName, derivationPath, message }: SignMessageParams) => Promise<any>;
38
+ }>;
33
39
  }
34
40
  declare const hardwareWalletsModuleDefinition: {
35
41
  readonly id: "hardwareWallets";
36
42
  readonly type: "module";
37
43
  readonly factory: (opts: Dependencies) => HardwareWallets;
38
- readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts", "txLogMonitors", "restoreProgressTracker"];
44
+ readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"];
39
45
  };
40
46
  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}`);
@@ -308,6 +295,12 @@ export class HardwareWallets {
308
295
  await this.#walletAccounts.setActive(walletAccountName);
309
296
  await this.addPublicKeysToWalletAccount({ walletAccountName, syncedKeysId });
310
297
  };
298
+ requireDeviceFor = async ({ walletAccount }) => {
299
+ return {
300
+ signTransaction: this.signTransaction,
301
+ signMessage: this.signMessage,
302
+ };
303
+ };
311
304
  }
312
305
  const createHardwareWalletsModule = (opts) => new HardwareWallets(opts);
313
306
  const hardwareWalletsModuleDefinition = {
@@ -323,8 +316,6 @@ const hardwareWalletsModuleDefinition = {
323
316
  'wallet',
324
317
  'walletAccountsAtom',
325
318
  'walletAccounts',
326
- 'txLogMonitors',
327
- 'restoreProgressTracker',
328
319
  ],
329
320
  };
330
321
  export default hardwareWalletsModuleDefinition;
@@ -119,4 +119,7 @@ export interface FetchBalanceParams {
119
119
  address: string;
120
120
  }
121
121
  export type FetchBalanceResult = any | null;
122
+ export interface RequireDeviceForParams {
123
+ walletAccount: WalletAccount;
124
+ }
122
125
  export {};
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.2",
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": "007b39adfd80a3f8367b46999f006a6904dfd002"
43
44
  }