Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// setListenDevicesDebounce: () => {},
// setListenDevicesPollingSkip: () => {},
// };
// TransportNodeHid.setListenDevicesDebounce(200);
/*
TransportNodeHid.setListenDevicesDebug((msg, ...args) => {
console.log(msg);
console.log({
type: 'listenDevices',
args,
});
});
*/
let busy = false;
TransportNodeHid.setListenDevicesPollingSkip(() => busy);
TransportNodeHid.setListenDevicesDebounce(0);
const getLedgerAccount = (index = 0) => {
const ledgerAccount = new LedgerAccount();
ledgerAccount.coinIndex(SupportedCoin.LISK);
ledgerAccount.account(index);
return ledgerAccount;
};
const createLedgerHWDevice = ({ path, model }) =>
new HWDevice(
Math.floor(Math.random() * 1e5) + 1,
null,
model,
path,
);
const getLiskAccount = async (path) => {
setEnvUnsafe(k, process.env[k])
}
/* eslint-enable guard-for-in */
process.on('message', message => {
if (message.type === 'setEnv') {
const { name, value } = message.env
setEnvUnsafe(name, value)
}
})
let busy = false
TransportNodeHid.setListenDevicesPollingSkip(() => busy)
TransportNodeHid.setListenDevicesDebounce(LISTEN_DEVICES_DEBOUNCE)
const refreshBusyUIState = throttle(() => {
if (process.env.CLI) return
process.send({
type: 'setDeviceBusy',
busy,
})
}, 100)
addAccessHook(() => {
busy = true
refreshBusyUIState()
return () => {
busy = false
refreshBusyUIState()
}