mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-26 02:49:02 +00:00
Fix deallocation of trezor
This commit is contained in:
parent
3b5dd4ec21
commit
e8c3700ab9
@ -3,15 +3,19 @@ import { addHexPrefix, toBuffer } from 'ethereumjs-util';
|
|||||||
import { WalletLib } from 'shared/enclave/types';
|
import { WalletLib } from 'shared/enclave/types';
|
||||||
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
|
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
|
||||||
import LedgerEth from '@ledgerhq/hw-app-eth';
|
import LedgerEth from '@ledgerhq/hw-app-eth';
|
||||||
|
let transport: any;
|
||||||
|
|
||||||
async function getEthApp() {
|
async function getEthApp() {
|
||||||
try {
|
try {
|
||||||
const transport = await TransportNodeHid.create();
|
if (!transport) {
|
||||||
|
transport = await TransportNodeHid.create();
|
||||||
|
transport.on('disconnect', () => (transport = null));
|
||||||
|
}
|
||||||
return new LedgerEth(transport);
|
return new LedgerEth(transport);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err && err.message && err.message.includes('cannot open device with path')) {
|
if (err && err.message && err.message.includes('cannot open device with path')) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Failed to connect with your Ledger. It may be in use with another application. Try plugging the device back in.'
|
'Your Ledger is currently in use with another application. Please wait, or close other wallet applications before trying again.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user