Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const executeLedgerCommand = (device, command) =>
TransportNodeHid.open(device.path)
// eslint-disable-next-line max-statements
.then(async (transport) => {
busy = true;
try {
const liskLedger = new DposLedger(transport);
const ledgerAccount = getLedgerAccount(command.data.index);
let res;
if (command.action === 'GET_PUBLICKEY') {
res = await liskLedger.getPubKey(ledgerAccount, command.data.showOnDevice);
res = res.publicKey;
}
if (command.action === 'GET_ADDRESS') {
res = await liskLedger.getPubKey(ledgerAccount, command.data.showOnDevice);
res = res.address;
async open() {
try {
// this.device = await retry(() => LedgerNode.open(this.path));
this.device = await LedgerNode.open(this.path);
return this;
} catch (err) {
throw evalTransportError(err);
}
}
() =>
getEnv('EXPERIMENTAL_USB')
? TransportNodeHidSingleton.open()
: TransportNodeHid.open(devicePath),
{ maxRetry: 4 },
const createEthTransportActivity = async (descriptor, activityFn) => {
let transport;
try {
if (process.platform === 'win32') {
transport = await LedgerTransport.create();
} else {
transport = await LedgerTransport.open(descriptor);
}
const ethTransport = new Eth(transport);
const result = await activityFn(ethTransport);
return result;
} finally {
if (transport) {
await transport.close();
}
}
};
const t = await retry(() => TransportNodeHid.open(devicePath), { maxRetry: 2 }).catch(
mapError,
export const createEthTransportActivity = async (descriptor, activityFn) => {
let transport;
try {
transport = await LedgerTransport.open(descriptor);
const ethTransport = new Eth(transport);
const result = await activityFn(ethTransport);
return result;
} finally {
if (transport) {
await transport.close();
}
}
};
const transport = await retry(async (): Promise => {
try {
return await TransportNodeHid.open(devicePath);
} catch (e) {
lastTransportOpenError = e;
return undefined;
}
}, 14);
async open (): Promise {
try {
this.device = await LedgerNode.open(this.path)
return this
} catch (err) {
throw evalTransportError(err)
}
}
const getLiskAccount = async (path) => {
let transport;
try {
transport = await TransportNodeHid.open(path);
const liskLedger = new DposLedger(transport);
const ledgerAccount = getLedgerAccount(0);
const liskAccount = await liskLedger.getPubKey(ledgerAccount);
transport.close();
return liskAccount;
} catch (e) {
if (transport) transport.close();
return null;
}
};