@exodus/hw-ledger 2.8.1 → 2.9.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,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
+ ## [2.9.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.8.1...@exodus/hw-ledger@2.9.0) (2024-07-16)
7
+
8
+ ### Features
9
+
10
+ - **hw-ledger:** expose bluetooth status to clients ([#7848](https://github.com/ExodusMovement/exodus-hydra/issues/7848)) ([36943b1](https://github.com/ExodusMovement/exodus-hydra/commit/36943b194c286a07c44dd78bd3a1f03324c87ce8))
11
+
6
12
  ## [2.8.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.8.0...@exodus/hw-ledger@2.8.1) (2024-07-10)
7
13
 
8
14
  ### Bug Fixes
@@ -1,5 +1,5 @@
1
- export declare const bluetoothEnabledAtomDefinition: {
2
- readonly id: "bluetoothEnabledAtom";
1
+ export declare const bluetoothStatusAtomDefinition: {
2
+ readonly id: "bluetoothStatusAtom";
3
3
  readonly type: "atom";
4
4
  readonly factory: () => import("@exodus/atoms").Atom<boolean>;
5
5
  readonly dependencies: readonly [];
@@ -1,6 +1,6 @@
1
1
  import { createInMemoryAtom } from '@exodus/atoms';
2
- export const bluetoothEnabledAtomDefinition = {
3
- id: 'bluetoothEnabledAtom',
2
+ export const bluetoothStatusAtomDefinition = {
3
+ id: 'bluetoothStatusAtom',
4
4
  type: 'atom',
5
5
  factory: () => createInMemoryAtom({ defaultValue: false }),
6
6
  dependencies: [],
package/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@ declare const hardwareWalletLedger: ({ bluetoothScannerTimeout, }?: Partial<HwLe
3
3
  readonly id: "hardwareWalletLedger";
4
4
  readonly definitions: readonly [{
5
5
  readonly definition: {
6
- readonly id: "bluetoothEnabledAtom";
6
+ readonly id: "bluetoothStatusAtom";
7
7
  readonly type: "atom";
8
8
  readonly factory: () => import("libraries/atoms/lib").Atom<boolean>;
9
9
  readonly dependencies: readonly [];
@@ -19,10 +19,10 @@ declare const hardwareWalletLedger: ({ bluetoothScannerTimeout, }?: Partial<HwLe
19
19
  readonly definition: {
20
20
  readonly id: "hardwareWalletLedgerPlugin";
21
21
  readonly type: "plugin";
22
- readonly factory: ({ logger, transportsFactories, bluetoothEnabledAtom, bluetoothScanningAtom, port, }: {
22
+ readonly factory: ({ logger, transportsFactories, bluetoothStatusAtom, bluetoothScanningAtom, port, }: {
23
23
  logger: import("./shared/types").Logger;
24
24
  transportsFactories: import("./module/types").TransportFactories;
25
- bluetoothEnabledAtom: import("libraries/atoms/lib").Atom<boolean>;
25
+ bluetoothStatusAtom: import("libraries/atoms/lib").Atom<import("./redux/initial-state").BluetoothStatus>;
26
26
  bluetoothScanningAtom: import("libraries/atoms/lib").Atom<boolean>;
27
27
  port: import("./shared/types").Port;
28
28
  }) => {
@@ -30,7 +30,7 @@ declare const hardwareWalletLedger: ({ bluetoothScannerTimeout, }?: Partial<HwLe
30
30
  onLoad: () => void;
31
31
  onStop: () => void;
32
32
  };
33
- readonly dependencies: readonly ["logger", "transportsFactories", "bluetoothEnabledAtom", "bluetoothScanningAtom", "port"];
33
+ readonly dependencies: readonly ["logger", "transportsFactories", "bluetoothStatusAtom", "bluetoothScanningAtom", "port"];
34
34
  };
35
35
  }, {
36
36
  readonly definition: {
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { bluetoothEnabledAtomDefinition, bluetoothScanningAtomDefinition } from './atoms';
1
+ import { bluetoothStatusAtomDefinition, bluetoothScanningAtomDefinition } from './atoms';
2
2
  import ledgerDiscoveryDefinition from './module';
3
3
  import hardwareWalletLedgerPluginDefinition from './plugin';
4
4
  const hardwareWalletLedger = ({ bluetoothScannerTimeout = 10000, } = {}) => {
@@ -6,7 +6,7 @@ const hardwareWalletLedger = ({ bluetoothScannerTimeout = 10000, } = {}) => {
6
6
  id: 'hardwareWalletLedger',
7
7
  definitions: [
8
8
  {
9
- definition: bluetoothEnabledAtomDefinition,
9
+ definition: bluetoothStatusAtomDefinition,
10
10
  },
11
11
  {
12
12
  definition: bluetoothScanningAtomDefinition,
@@ -1,13 +1,14 @@
1
1
  import type { Atom } from '@exodus/atoms';
2
2
  import type { TransportFactories } from '../module/types';
3
3
  import type { Logger, Port } from '../shared/types';
4
+ import { BluetoothStatus } from '../redux/initial-state';
4
5
  declare const hardwareWalletLedgerPluginDefinition: {
5
6
  readonly id: "hardwareWalletLedgerPlugin";
6
7
  readonly type: "plugin";
7
- readonly factory: ({ logger, transportsFactories, bluetoothEnabledAtom, bluetoothScanningAtom, port, }: {
8
+ readonly factory: ({ logger, transportsFactories, bluetoothStatusAtom, bluetoothScanningAtom, port, }: {
8
9
  logger: Logger;
9
10
  transportsFactories: TransportFactories;
10
- bluetoothEnabledAtom: Atom<boolean>;
11
+ bluetoothStatusAtom: Atom<BluetoothStatus>;
11
12
  bluetoothScanningAtom: Atom<boolean>;
12
13
  port: Port;
13
14
  }) => {
@@ -15,6 +16,6 @@ declare const hardwareWalletLedgerPluginDefinition: {
15
16
  onLoad: () => void;
16
17
  onStop: () => void;
17
18
  };
18
- readonly dependencies: readonly ["logger", "transportsFactories", "bluetoothEnabledAtom", "bluetoothScanningAtom", "port"];
19
+ readonly dependencies: readonly ["logger", "transportsFactories", "bluetoothStatusAtom", "bluetoothScanningAtom", "port"];
19
20
  };
20
21
  export default hardwareWalletLedgerPluginDefinition;
@@ -1,8 +1,8 @@
1
1
  import { createAtomObserver } from '@exodus/atoms';
2
- const createHardwareWalletLedgerPlugin = ({ logger, transportsFactories, bluetoothEnabledAtom, bluetoothScanningAtom, port, }) => {
2
+ const createHardwareWalletLedgerPlugin = ({ logger, transportsFactories, bluetoothStatusAtom, bluetoothScanningAtom, port, }) => {
3
3
  let subscription;
4
4
  const observers = [
5
- createAtomObserver({ atom: bluetoothEnabledAtom, port, event: 'bluetoothEnabled' }),
5
+ createAtomObserver({ atom: bluetoothStatusAtom, port, event: 'bluetoothStatus' }),
6
6
  createAtomObserver({ atom: bluetoothScanningAtom, port, event: 'bluetoothScanning' }),
7
7
  ];
8
8
  observers.forEach((observer) => observer.register());
@@ -13,17 +13,13 @@ const createHardwareWalletLedgerPlugin = ({ logger, transportsFactories, bluetoo
13
13
  return;
14
14
  if (transportsFactories.bluetooth.observeState) {
15
15
  subscription = transportsFactories.bluetooth.observeState({
16
- next: (e) => {
17
- bluetoothEnabledAtom.set(!!e.available);
18
- },
16
+ next: ({ type, available }) => bluetoothStatusAtom.set({ type, available }),
19
17
  error: (error) => logger.error(error),
20
18
  });
21
19
  }
22
20
  else if (transportsFactories.bluetooth.observeAvailability) {
23
21
  subscription = transportsFactories.bluetooth.observeAvailability({
24
- next: (available) => {
25
- bluetoothEnabledAtom.set(available);
26
- },
22
+ next: (available) => bluetoothStatusAtom.set({ type: 'Unknown', available }),
27
23
  error: (error) => logger.error(error),
28
24
  });
29
25
  }
@@ -51,7 +47,7 @@ const hardwareWalletLedgerPluginDefinition = {
51
47
  dependencies: [
52
48
  'logger',
53
49
  'transportsFactories',
54
- 'bluetoothEnabledAtom',
50
+ 'bluetoothStatusAtom',
55
51
  'bluetoothScanningAtom',
56
52
  'port',
57
53
  ],
@@ -4,18 +4,18 @@ declare const exchangeReduxDefinition: {
4
4
  readonly type: "redux-module";
5
5
  readonly initialState: LedgerHardwareWalletState;
6
6
  readonly eventReducers: {
7
- readonly bluetoothEnabled: (state: LedgerHardwareWalletState, payload: boolean) => {
8
- bluetoothEnabled: boolean;
7
+ readonly bluetoothStatus: (state: LedgerHardwareWalletState, payload: boolean) => {
8
+ bluetoothStatus: boolean;
9
9
  bluetoothScanning: boolean;
10
10
  };
11
11
  readonly bluetoothScanning: (state: LedgerHardwareWalletState, payload: boolean) => {
12
12
  bluetoothScanning: boolean;
13
- bluetoothEnabled: boolean;
13
+ bluetoothStatus: import("./initial-state").BluetoothStatus;
14
14
  };
15
15
  };
16
16
  readonly selectorDefinitions: ({
17
- readonly id: "bluetoothEnabled";
18
- readonly resultFunction: (state: LedgerHardwareWalletState) => boolean;
17
+ readonly id: "bluetoothStatus";
18
+ readonly resultFunction: (state: LedgerHardwareWalletState) => import("./initial-state").BluetoothStatus;
19
19
  readonly dependencies: readonly [{
20
20
  readonly selector: string;
21
21
  }];
@@ -6,9 +6,9 @@ const exchangeReduxDefinition = {
6
6
  type: 'redux-module',
7
7
  initialState,
8
8
  eventReducers: {
9
- bluetoothEnabled: (state, payload) => ({
9
+ bluetoothStatus: (state, payload) => ({
10
10
  ...state,
11
- bluetoothEnabled: payload,
11
+ bluetoothStatus: payload,
12
12
  }),
13
13
  bluetoothScanning: (state, payload) => ({
14
14
  ...state,
@@ -1,5 +1,9 @@
1
+ export type BluetoothStatus = {
2
+ type: 'Unknown' | 'Resetting' | 'Unsupported' | 'Unauthorized' | 'PoweredOff' | 'PoweredOn';
3
+ available: boolean;
4
+ };
1
5
  export type LedgerHardwareWalletState = {
2
- bluetoothEnabled: boolean;
6
+ bluetoothStatus: BluetoothStatus;
3
7
  bluetoothScanning: boolean;
4
8
  };
5
9
  declare const initialState: LedgerHardwareWalletState;
@@ -1,5 +1,5 @@
1
1
  const initialState = {
2
- bluetoothEnabled: false,
2
+ bluetoothStatus: { type: 'Unknown', available: false },
3
3
  bluetoothScanning: false,
4
4
  };
5
5
  export default initialState;
@@ -1,9 +1,9 @@
1
1
  import type { LedgerHardwareWalletState } from '../initial-state';
2
- declare const bluetoothEnabledSelectorDefinition: {
3
- readonly id: "bluetoothEnabled";
4
- readonly resultFunction: (state: LedgerHardwareWalletState) => boolean;
2
+ declare const bluetoothStatusSelectorDefinition: {
3
+ readonly id: "bluetoothStatus";
4
+ readonly resultFunction: (state: LedgerHardwareWalletState) => import("../initial-state").BluetoothStatus;
5
5
  readonly dependencies: readonly [{
6
6
  readonly selector: string;
7
7
  }];
8
8
  };
9
- export default bluetoothEnabledSelectorDefinition;
9
+ export default bluetoothStatusSelectorDefinition;
@@ -0,0 +1,8 @@
1
+ import { MY_STATE } from '@exodus/redux-dependency-injection';
2
+ const resultFunction = (state) => state.bluetoothStatus;
3
+ const bluetoothStatusSelectorDefinition = {
4
+ id: 'bluetoothStatus',
5
+ resultFunction,
6
+ dependencies: [{ selector: MY_STATE }],
7
+ };
8
+ export default bluetoothStatusSelectorDefinition;
@@ -1,6 +1,6 @@
1
1
  declare const ledgerSelectors: ({
2
- readonly id: "bluetoothEnabled";
3
- readonly resultFunction: (state: import("../initial-state").LedgerHardwareWalletState) => boolean;
2
+ readonly id: "bluetoothStatus";
3
+ readonly resultFunction: (state: import("../initial-state").LedgerHardwareWalletState) => import("../initial-state").BluetoothStatus;
4
4
  readonly dependencies: readonly [{
5
5
  readonly selector: string;
6
6
  }];
@@ -1,4 +1,4 @@
1
- import bluetoothEnabledSelectorDefinition from './bluetoothEnabled';
1
+ import bluetoothStatusSelectorDefinition from './bluetoothStatus';
2
2
  import bluetoothScanningSelectorDefinition from './bluetoothScanning';
3
- const ledgerSelectors = [bluetoothEnabledSelectorDefinition, bluetoothScanningSelectorDefinition];
3
+ const ledgerSelectors = [bluetoothStatusSelectorDefinition, bluetoothScanningSelectorDefinition];
4
4
  export default ledgerSelectors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/hw-ledger",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "description": "The ledger module",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "repository": {
@@ -72,5 +72,5 @@
72
72
  "ts-jest": "^29.0.3",
73
73
  "typescript": "^4.7.3"
74
74
  },
75
- "gitHead": "53b2dc8a2362537c92f3be5b23c6f71e13980d81"
75
+ "gitHead": "03f1666538fa7d596c729b77a380f891f7e747e4"
76
76
  }
@@ -1,8 +0,0 @@
1
- import { MY_STATE } from '@exodus/redux-dependency-injection';
2
- const resultFunction = (state) => state.bluetoothEnabled;
3
- const bluetoothEnabledSelectorDefinition = {
4
- id: 'bluetoothEnabled',
5
- resultFunction,
6
- dependencies: [{ selector: MY_STATE }],
7
- };
8
- export default bluetoothEnabledSelectorDefinition;