@exodus/hardware-wallets 1.5.0 → 1.6.0

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,22 @@
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.6.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hardware-wallets@1.5.1...@exodus/hardware-wallets@1.6.0) (2024-10-22)
7
+
8
+ ### Features
9
+
10
+ - support cancelling an action on the ledger device ([#10105](https://github.com/ExodusMovement/exodus-hydra/issues/10105)) ([f1c1fbf](https://github.com/ExodusMovement/exodus-hydra/commit/f1c1fbff6ec70b7ddc68dd700ffb556b673b7a5a))
11
+
12
+ ### Bug Fixes
13
+
14
+ - catch xpub key identifier errrors ([#10124](https://github.com/ExodusMovement/exodus-hydra/issues/10124)) ([7cd681d](https://github.com/ExodusMovement/exodus-hydra/commit/7cd681deec14adfa9c3e7613f276f2745f1df441))
15
+
16
+ ## [1.5.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hardware-wallets@1.5.0...@exodus/hardware-wallets@1.5.1) (2024-10-17)
17
+
18
+ ### Bug Fixes
19
+
20
+ - support cancelling transaction through ui ([#10058](https://github.com/ExodusMovement/exodus-hydra/issues/10058)) ([beb7d2d](https://github.com/ExodusMovement/exodus-hydra/commit/beb7d2d1aafba17678a34febcf2458163d9182d2))
21
+
6
22
  ## [1.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hardware-wallets@1.4.0...@exodus/hardware-wallets@1.5.0) (2024-10-17)
7
23
 
8
24
  ### Features
@@ -37,21 +37,24 @@ export class HardwareWallets {
37
37
  return rpc.callMethod('handle-hardware-wallet', params);
38
38
  };
39
39
  #signGeneric = async ({ baseAssetName, scenario, sign }) => {
40
- let needUserApproval = true;
41
40
  let attempts = 0;
42
41
  const MAX_ATTEMPTS = 50;
43
42
  while (attempts < MAX_ATTEMPTS) {
44
43
  try {
45
- if (needUserApproval) {
46
- this.#requestUserAction({
47
- scenario,
48
- baseAssetName,
49
- });
50
- needUserApproval = false;
51
- }
44
+ const approvePromise = this.#requestUserAction({
45
+ scenario,
46
+ baseAssetName,
47
+ });
52
48
  const { device } = await this.#getSelectedDevice();
53
- await device.ensureApplicationIsOpened(baseAssetName);
54
- const result = await sign({ device });
49
+ const runSign = async () => {
50
+ await device.ensureApplicationIsOpened(baseAssetName);
51
+ return sign({ device });
52
+ };
53
+ const result = await Promise.race([approvePromise, runSign()]);
54
+ if (typeof result === 'object' && result.tryAgain === false) {
55
+ device.cancelAction();
56
+ throw new UserRefusedError(false);
57
+ }
55
58
  this.#requestUserAction({ scenario: 'completed' });
56
59
  return result;
57
60
  }
@@ -62,11 +65,7 @@ export class HardwareWallets {
62
65
  else if (error.name === 'UserRefusedError') {
63
66
  throw error;
64
67
  }
65
- if (error.name === 'DisconnectedDeviceDuringOperation') {
66
- this.#requestUserAction({
67
- scenario,
68
- baseAssetName,
69
- });
68
+ if (['DisconnectedDevice', 'DisconnectedDeviceDuringOperation'].includes(error.name)) {
70
69
  continue;
71
70
  }
72
71
  try {
@@ -185,28 +184,32 @@ export class HardwareWallets {
185
184
  });
186
185
  };
187
186
  #getXPUB = async ({ device, baseAsset, purpose, accountIndex, }) => {
188
- const keyIdentifier = baseAsset.api.getKeyIdentifier({
189
- compatibilityMode: 'ledger',
190
- purpose,
191
- accountIndex,
192
- chainIndex: undefined,
193
- addressIndex: undefined,
194
- });
195
- const { derivationPath } = keyIdentifier;
196
- const xpub = await device
197
- .getXPub({
198
- assetName: baseAsset.name,
199
- derivationPath,
200
- })
201
- .catch((error) => {
202
- if (error.name === 'XPubUnsupportedError') {
203
- this.#logger.warn(`Retrieving XPUBs for ${baseAsset.name} is not supported`, error);
187
+ try {
188
+ const keyIdentifier = baseAsset.api.getKeyIdentifier({
189
+ compatibilityMode: 'ledger',
190
+ purpose,
191
+ accountIndex,
192
+ chainIndex: undefined,
193
+ addressIndex: undefined,
194
+ });
195
+ const { derivationPath } = keyIdentifier;
196
+ const xpub = await device.getXPub({
197
+ assetName: baseAsset.name,
198
+ derivationPath,
199
+ });
200
+ if (xpub) {
201
+ return { keyIdentifier, xpub };
204
202
  }
205
- else {
206
- throw error;
203
+ return null;
204
+ }
205
+ catch (error) {
206
+ if (error.name === 'XPubUnsupportedError' ||
207
+ error.message.includes(`XPUB derivation is not allowed`)) {
208
+ this.#logger.warn(`Retrieving XPUBs for ${baseAsset.name} is not supported`, error);
209
+ return null;
207
210
  }
208
- });
209
- return xpub ? { keyIdentifier, xpub } : null;
211
+ throw error;
212
+ }
210
213
  };
211
214
  #getPublicKey = async ({ device, baseAsset, purpose, accountIndex, }) => {
212
215
  const keyIdentifier = baseAsset.api.getKeyIdentifier({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/hardware-wallets",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
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": {
@@ -28,7 +28,7 @@
28
28
  "prepublishOnly": "yarn run -T build --scope @exodus/hardware-wallets"
29
29
  },
30
30
  "dependencies": {
31
- "@exodus/hw-common": "^3.0.0",
31
+ "@exodus/hw-common": "^3.1.0",
32
32
  "@exodus/models": "^12.0.1",
33
33
  "@exodus/wild-emitter": "^1.1.0",
34
34
  "delay": "^5.0.0",
@@ -41,7 +41,8 @@
41
41
  "@exodus/key-identifier": "^1.3.0",
42
42
  "@exodus/logger": "^1.2.2",
43
43
  "@exodus/public-key-provider": "^3.0.0",
44
- "@types/randombytes": "^2.0.3"
44
+ "@types/randombytes": "^2.0.3",
45
+ "p-defer": "^4.0.1"
45
46
  },
46
- "gitHead": "a4f949331317cbeb49ea2392703722914a67fcac"
47
+ "gitHead": "6a40d50082582568d68206d8926737eea560fa50"
47
48
  }