ethers.js/packages/hardware-wallets/lib/ledger-transport.js

37 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2020-01-10 03:19:21 -05:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2020-04-25 03:54:54 -04:00
var hidCache = null;
var hidWrapper = Object.freeze({
create: function () {
// Load the library if not loaded
if (hidCache == null) {
hidCache = new Promise(function (resolve, reject) {
try {
var hid = require("@ledgerhq/hw-transport-node-hid");
if (hid.create == null) {
resolve(hid["default"]);
}
resolve(hid);
}
catch (error) {
reject(error);
}
});
/*
hidCache = import("@ledgerhq/hw-transport-node-hid").then((hid) => {
if (hid.create == null) { return hid["default"]; }
return hid;
});
*/
}
return hidCache.then(function (hid) {
console.log(hid, hid.create);
return hid.create();
});
}
});
exports.transports = Object.freeze({
"hid": hidWrapper,
"default": hidWrapper
});