Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getAddress = async () => {
console.log('Testing Ledger Hardware...');
console.log('supported:', await Transport.isSupported());
console.log('Devices:');
console.log(await Transport.list());
const transport = await Transport.create();
const eth = new AppEth(transport);
// note: this path matches MEWs: m/44'/60'/0'
const result = await eth.getAddress("m/44'/60'/0'/0");
return result;
};
getAddress().then(a => console.log(a));
const getAddress = async () => {
console.log('Testing Ledger Hardware...');
console.log('supported:', await Transport.isSupported());
console.log('Devices:');
console.log(await Transport.list());
const transport = await Transport.create();
const eth = new AppEth(transport);
// note: this path matches MEWs: m/44'/60'/0'
const result = await eth.getAddress("m/44'/60'/0'/0");
return result;
};
getAddress().then(a => console.log(a));
const promiseMethod = new Promise((resolve, reject) => {
const promise = Transport.create(this.timeout, this.timeout);
promise.then((transport) => {
this.transport = transport;
this.methods = [
"getVersion",
"getPublicKeyData",
"checkAddress",
"sendTx",
"getSignatures"
];
this.transport.decorateAppAPIMethods(this, this.methods, "HTR");
resolve(transport);
}, (e) => {
// We have to create a new error because sometimes we receive some errors that
// are not user friendly, e.g. 'Race condition'.
const error = new Error('Error connecting to ledger device.');
reject(error);
const getAddress = async () => {
const transport = await Transport.create();
const xtz = new App(transport);
console.log(xtz)
const result = await xtz.getAddress("44'/1729'/0'/0'/0'", true);
return result.publicKey;
};
/*const signOperation = async () => {
return __awaiter(this, void 0, void 0, function* () {
if (this.transport === null) {
this.transport = yield Transport.create();
}
return this.transport;
});
}
return new Promise(async (resolve, reject) => {
const transport = await Transport.create();
try {
const trx = new AppTrx(transport);
let response = await trx.signTransaction(
this.path,
transaction.hex,
transaction.sha256,
transaction.contractType);
resolve(response);
} catch(e) {
reject(e);
} finally {
transport.close();
}
});
}
const getTransport = () => TransportU2F.create()
const ledger = createLedgerSubprovider(getTransport, options)
sign : async (path, data) => {
const transport = await Transport.create(60 * 1000);
const xtz = new App(transport);
const result = await xtz.signOperation(path, data);
return result;
}
};