Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initialize = async () => {
if (!SignerLedger.allowParallel && SignerLedger.initialized)
throw new Error('another SignerLedger wallet call is already initialized')
this.constructor.initialized = true
const transport = await TransportNodeHid.create()
// const transport = await TransportU2F.create()
// transport.setDebugMode(true);
return {
app: new AppEth(transport),
close: () => {
SignerLedger.initialized = false
transport.close()
},
}
}
async function getInfos(path = "44'/60'/0'/0") {
let transport;
try {
transport = await TransportNodeHid.create();
const eth = new Eth(transport);
eth.getAddress(
path,
true,
true,
).then(function(publicKey) {
console.log(JSON.stringify(publicKey));
}).catch(function(err) {
console.log(err);
});
} catch (e) {
console.log(e);
}
}
getInfos();
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();
}
}
};
async signMessage(path, message) {
let result;
const transport = await TransportNodeHid.create();
if (this.currency === 'stellar') {
const str = new Str(transport);
result = str.signHash(path, message);
result = result.signature;
} else {
const eth = new Eth(transport);
result = await eth.signTransaction(path, message);
}
return result;
}
}
export const createTransport = () => LedgerTransport.create();
const getTransport = () => HWTransportNodeHid.create();
const ledger = Web3SubProvider(getTransport, {