@exodus/hardware-wallets 1.0.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 +16 -0
- package/lib/api/index.d.ts +5 -2
- package/lib/api/index.js +20 -2
- package/lib/index.d.ts +6 -3
- package/lib/module/hardware-wallets.d.ts +5 -2
- package/lib/module/hardware-wallets.js +8 -19
- package/lib/module/interfaces.d.ts +1 -0
- package/package.json +4 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
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
|
+
|
|
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)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- add scan device support ([#8249](https://github.com/ExodusMovement/exodus-hydra/issues/8249)) ([e6393bf](https://github.com/ExodusMovement/exodus-hydra/commit/e6393bf91235a9b0d719097d855e1808efc48a33))
|
package/lib/api/index.d.ts
CHANGED
|
@@ -2,12 +2,15 @@ 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>;
|
|
10
12
|
listUseableAssetNames: () => Promise<string[]>;
|
|
13
|
+
scanForDevices: () => Promise<void>;
|
|
11
14
|
canAccessAsset: ({ assetName }: import("../module/interfaces.js").CanAccessAssetParams) => Promise<boolean>;
|
|
12
15
|
ensureApplicationIsOpened: ({ assetName }: import("../module/interfaces.js").EnsureApplicationIsOpenedParams) => Promise<void>;
|
|
13
16
|
scan: ({ assetName, accountIndexes, addressLimit, addressOffset, }: import("../module/interfaces.js").ScanParams) => Promise<import("../module/interfaces.js").ScanResult>;
|
|
@@ -16,6 +19,6 @@ declare const hardwareWalletsApiDefinition: {
|
|
|
16
19
|
create: ({ syncedKeysId }: import("../module/interfaces.js").CreateParams) => Promise<void>;
|
|
17
20
|
};
|
|
18
21
|
};
|
|
19
|
-
readonly dependencies: readonly ["hardwareWallets"];
|
|
22
|
+
readonly dependencies: readonly ["hardwareWallets", "txLogMonitors", "restoreProgressTracker"];
|
|
20
23
|
};
|
|
21
24
|
export default hardwareWalletsApiDefinition;
|
package/lib/api/index.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
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,
|
|
5
22
|
listUseableAssetNames: hardwareWallets.listUseableAssetNames,
|
|
23
|
+
scanForDevices: hardwareWallets.scanForDevices,
|
|
6
24
|
canAccessAsset: hardwareWallets.canAccessAsset,
|
|
7
25
|
ensureApplicationIsOpened: hardwareWallets.ensureApplicationIsOpened,
|
|
8
26
|
scan: hardwareWallets.scan,
|
|
@@ -16,6 +34,6 @@ const hardwareWalletsApiDefinition = {
|
|
|
16
34
|
id: 'hardwareWalletsApi',
|
|
17
35
|
type: 'api',
|
|
18
36
|
factory: createHardwareWalletsApi,
|
|
19
|
-
dependencies: ['hardwareWallets'],
|
|
37
|
+
dependencies: ['hardwareWallets', 'txLogMonitors', 'restoreProgressTracker'],
|
|
20
38
|
};
|
|
21
39
|
export default hardwareWalletsApiDefinition;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ 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>;
|
|
12
14
|
listUseableAssetNames: () => Promise<string[]>;
|
|
15
|
+
scanForDevices: () => Promise<void>;
|
|
13
16
|
canAccessAsset: ({ assetName }: import("./module/interfaces.js").CanAccessAssetParams) => Promise<boolean>;
|
|
14
17
|
ensureApplicationIsOpened: ({ assetName }: import("./module/interfaces.js").EnsureApplicationIsOpenedParams) => Promise<void>;
|
|
15
18
|
scan: ({ assetName, accountIndexes, addressLimit, addressOffset, }: import("./module/interfaces.js").ScanParams) => Promise<import("./module/interfaces.js").ScanResult>;
|
|
@@ -18,14 +21,14 @@ declare const hardwareWallets: () => {
|
|
|
18
21
|
create: ({ syncedKeysId }: import("./module/interfaces.js").CreateParams) => Promise<void>;
|
|
19
22
|
};
|
|
20
23
|
};
|
|
21
|
-
readonly dependencies: readonly ["hardwareWallets"];
|
|
24
|
+
readonly dependencies: readonly ["hardwareWallets", "txLogMonitors", "restoreProgressTracker"];
|
|
22
25
|
};
|
|
23
26
|
}, {
|
|
24
27
|
readonly definition: {
|
|
25
28
|
readonly id: "hardwareWallets";
|
|
26
29
|
readonly type: "module";
|
|
27
30
|
readonly factory: (opts: import("./module/hardware-wallets.js").Dependencies) => import("./module/hardware-wallets.js").HardwareWallets;
|
|
28
|
-
readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"
|
|
31
|
+
readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"];
|
|
29
32
|
};
|
|
30
33
|
}];
|
|
31
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,10 +19,12 @@ export type Dependencies = {
|
|
|
18
19
|
};
|
|
19
20
|
export declare class HardwareWallets implements HardwareSignerProvider {
|
|
20
21
|
#private;
|
|
21
|
-
|
|
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>;
|
|
27
|
+
scanForDevices: () => Promise<void>;
|
|
25
28
|
canAccessAsset: ({ assetName }: CanAccessAssetParams) => Promise<boolean>;
|
|
26
29
|
listUseableAssetNames: () => Promise<string[]>;
|
|
27
30
|
ensureApplicationIsOpened: ({ assetName }: EnsureApplicationIsOpenedParams) => Promise<void>;
|
|
@@ -34,6 +37,6 @@ declare const hardwareWalletsModuleDefinition: {
|
|
|
34
37
|
readonly id: "hardwareWallets";
|
|
35
38
|
readonly type: "module";
|
|
36
39
|
readonly factory: (opts: Dependencies) => HardwareWallets;
|
|
37
|
-
readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"
|
|
40
|
+
readonly dependencies: readonly ["assetsModule", "logger", "ledgerDiscovery", "userInterface", "publicKeyStore", "wallet", "walletAccountsAtom", "walletAccounts"];
|
|
38
41
|
};
|
|
39
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
|
-
|
|
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();
|
|
@@ -116,6 +114,10 @@ export class HardwareWallets {
|
|
|
116
114
|
return false;
|
|
117
115
|
}
|
|
118
116
|
};
|
|
117
|
+
scanForDevices = async () => {
|
|
118
|
+
this.#ledgerDiscovery.stopScan(true);
|
|
119
|
+
return this.#ledgerDiscovery.scan();
|
|
120
|
+
};
|
|
119
121
|
canAccessAsset = async ({ assetName }) => {
|
|
120
122
|
const asset = this.#assetsModule.getAsset(assetName);
|
|
121
123
|
const device = await this.#ledgerDiscovery.getFirstDevice();
|
|
@@ -276,18 +278,7 @@ export class HardwareWallets {
|
|
|
276
278
|
const { xpub, publicKey } = keys;
|
|
277
279
|
await this.#publicKeyStore.add({ walletAccountName, keyIdentifier, xpub, publicKey });
|
|
278
280
|
}
|
|
279
|
-
|
|
280
|
-
if (assetName === 'ethereum' || assetName === 'matic') {
|
|
281
|
-
this.#restoreProgressTracker.restoreAsset('ethereum');
|
|
282
|
-
this.#restoreProgressTracker.restoreAsset('matic');
|
|
283
|
-
this.#txLogMonitors.update({ assetName: 'ethereum', refresh: true });
|
|
284
|
-
this.#txLogMonitors.update({ assetName: 'matic', refresh: true });
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
this.#restoreProgressTracker.restoreAsset(assetName);
|
|
288
|
-
this.#txLogMonitors.update({ assetName, refresh: true });
|
|
289
|
-
}
|
|
290
|
-
}
|
|
281
|
+
this.events.emit('syncAssets', { assetNames });
|
|
291
282
|
};
|
|
292
283
|
create = async ({ syncedKeysId }) => {
|
|
293
284
|
assert(this.#syncedKeysMap.has(syncedKeysId), `no synchronized keys found for id ${syncedKeysId}`);
|
|
@@ -319,8 +310,6 @@ const hardwareWalletsModuleDefinition = {
|
|
|
319
310
|
'wallet',
|
|
320
311
|
'walletAccountsAtom',
|
|
321
312
|
'walletAccounts',
|
|
322
|
-
'txLogMonitors',
|
|
323
|
-
'restoreProgressTracker',
|
|
324
313
|
],
|
|
325
314
|
};
|
|
326
315
|
export default hardwareWalletsModuleDefinition;
|
|
@@ -3,6 +3,7 @@ import type { HardwareWalletDevice, SignMessageParams } from '@exodus/hw-common'
|
|
|
3
3
|
import type KeyIdentifier from '@exodus/key-identifier';
|
|
4
4
|
export interface HardwareSignerProvider {
|
|
5
5
|
isDeviceConnected: () => Promise<boolean>;
|
|
6
|
+
scanForDevices: () => Promise<void>;
|
|
6
7
|
canAccessAsset: ({ assetName }: CanAccessAssetParams) => Promise<boolean>;
|
|
7
8
|
listUseableAssetNames: () => Promise<string[]>;
|
|
8
9
|
ensureApplicationIsOpened: ({ assetName }: EnsureApplicationIsOpenedParams) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/hardware-wallets",
|
|
3
|
-
"version": "1.
|
|
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,15 +29,16 @@
|
|
|
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"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@exodus/atoms": "^8.0.0",
|
|
38
|
-
"@exodus/hw-common": "^2.
|
|
39
|
+
"@exodus/hw-common": "^2.3.0",
|
|
39
40
|
"@exodus/logger": "^1.2.2",
|
|
40
41
|
"@exodus/public-key-store": "^1.2.2"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "7b677da738335fdc10685fdfab0084f60d21a828"
|
|
43
44
|
}
|