File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ const LedgerConnection = (_LedgerConnection as any).default
40
40
: _LedgerConnection ;
41
41
type LedgerConnection = _LedgerConnection ;
42
42
43
+ const isDeviceAlreadyOpenError = ( error : unknown ) => {
44
+ if ( typeof error !== 'object' ) return false ;
45
+ const innerError = ( error as any ) . innerError ;
46
+ if ( typeof innerError !== 'object' ) return false ;
47
+ return (
48
+ innerError . code === 11 ||
49
+ ( typeof innerError . message === 'string' && innerError . message . includes ( 'cannot open device with path' ) )
50
+ ) ;
51
+ } ;
52
+
43
53
export interface LedgerKeyAgentProps extends Omit < SerializableLedgerKeyAgentData , '__typename' > {
44
54
deviceConnection ?: LedgerConnection ;
45
55
}
@@ -223,7 +233,7 @@ export class LedgerKeyAgent extends KeyAgentBase {
223
233
} ) ;
224
234
return newConnection ;
225
235
} catch ( error : any ) {
226
- if ( error . innerError . message . includes ( 'cannot open device with path' ) ) {
236
+ if ( isDeviceAlreadyOpenError ( error ) ) {
227
237
throw new errors . TransportError ( 'Connection already established' , error ) ;
228
238
}
229
239
// If transport is established we need to close it so we can recover device from previous session
Original file line number Diff line number Diff line change @@ -16,9 +16,12 @@ import {
16
16
util
17
17
} from '@cardano-sdk/key-management' ;
18
18
import { txToTrezor } from './transformers/tx' ;
19
- import TrezorConnectWeb from '@trezor/connect-web' ;
19
+ import _TrezorConnectWeb from '@trezor/connect-web' ;
20
20
21
21
const TrezorConnectNode = Trezor . default ;
22
+ const TrezorConnectWeb = ( _TrezorConnectWeb as any ) . default
23
+ ? ( ( _TrezorConnectWeb as any ) . default as typeof _TrezorConnectWeb )
24
+ : _TrezorConnectWeb ;
22
25
23
26
const transportTypedError = ( error ?: any ) =>
24
27
new errors . AuthenticationError (
You can’t perform that action at this time.
0 commit comments