Browse Source

Merge pull request #5 from loeck/next

Add new packages
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
557db5499c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 6
      package.json
  3. 9
      src/main/bridge.js
  4. 26
      src/main/usb.js
  5. 1183
      yarn.lock

2
.gitignore

@ -1,4 +1,6 @@
.DS_Store
/dist/
/node_modules/
/flow-typed/
thumbs.db
*.log

6
package.json

@ -26,14 +26,16 @@
}
},
"dependencies": {
"@ledgerhq/hw-btc": "^1.0.4",
"@ledgerhq/hw-comm": "^1.0.4",
"@ledgerhq/hw-comm-node-hid": "^1.0.4",
"@ledgerhq/hw-eth": "^1.0.4",
"color": "^2.0.1",
"electron": "1.7.10",
"electron-devtools-installer": "^2.2.3",
"history": "^4.7.2",
"i18next": "^10.2.2",
"i18next-node-fs-backend": "^1.0.0",
"ledger-node-js-hid": "github:LedgerHQ/ledger-node-js-hid",
"ledgerco": "^1.2.1",
"object-path": "^0.11.4",
"react": "^16.2.0",
"react-dom": "^16.2.0",

9
src/main/bridge.js

@ -11,17 +11,10 @@ ipcMain.on('msg', (event: any, payload) => {
cwd: resolve(__dirname, './'),
})
const send = (msgType, data) => {
event.sender.send('msg', {
type: msgType,
data,
})
}
compute.send({ type, data })
compute.on('message', payload => {
const { type, data, options = {} } = payload
send(type, data)
event.sender.send('msg', { type, data })
if (options.kill) {
compute.kill()
}

26
src/main/usb.js

@ -1,9 +1,15 @@
process.title = 'ledger-wallet-desktop-usb'
const HID = require('ledger-node-js-hid')
const objectPath = require('object-path')
const { isLedgerDevice } = require('ledgerco/lib/utils')
const ledgerco = require('ledgerco')
const CommNodeHid = require('@ledgerhq/hw-comm-node-hid').default
const listenDevices = require('@ledgerhq/hw-comm-node-hid/lib/listenDevices').default
const getDevices = require('@ledgerhq/hw-comm-node-hid/lib/getDevices').default
const Btc = require('@ledgerhq/hw-btc').default
const isLedgerDevice = device =>
(device.vendorId === 0x2581 && device.productId === 0x3b7c) || device.vendorId === 0x2c97
function send(type, data, options = { kill: true }) {
process.send({ type, data, options })
@ -11,9 +17,9 @@ function send(type, data, options = { kill: true }) {
async function getWalletInfos(path, wallet) {
if (wallet === 'btc') {
const comm = new ledgerco.comm_node(new HID.HID(path), true, 0, false)
const btc = new ledgerco.btc(comm)
const walletInfos = await btc.getWalletPublicKey_async("44'/0'/0'/0")
const comm = new CommNodeHid(path, true, 0, false)
const btc = new Btc(comm)
const walletInfos = await btc.getWalletPublicKey(`44'/0'/0'/0`)
return walletInfos
}
throw new Error('invalid wallet')
@ -33,12 +39,12 @@ const handlers = {
const handleChangeDevice = eventName => device =>
isLedgerDevice(device) && send(eventName, device, { kill: false })
HID.listenDevices.start()
listenDevices.start()
HID.listenDevices.events.on('add', handleChangeDevice('device.add'))
HID.listenDevices.events.on('remove', handleChangeDevice('device.remove'))
listenDevices.events.on('add', handleChangeDevice('device.add'))
listenDevices.events.on('remove', handleChangeDevice('device.remove'))
},
all: () => send('devices.update', HID.devices().filter(isLedgerDevice)),
all: () => send('devices.update', getDevices().filter(isLedgerDevice)),
},
wallet: {
infos: {

1183
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save