Check in keepkey progress
This commit is contained in:
parent
7d6fb98627
commit
f008ed86b4
|
@ -63,7 +63,7 @@ class KeepKeyDecryptClass extends PureComponent<Props, State> {
|
||||||
Unlocking...
|
Unlocking...
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
translate('ADD_TREZOR_SCAN')
|
translate('ADD_KEEPKEY_SCAN')
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
"X_TREZOR": "TREZOR ",
|
"X_TREZOR": "TREZOR ",
|
||||||
"ADD_TREZOR_SCAN": "Connect to TREZOR ",
|
"ADD_TREZOR_SCAN": "Connect to TREZOR ",
|
||||||
"X_KEEPKEY": "KeepKey",
|
"X_KEEPKEY": "KeepKey",
|
||||||
|
"ADD_KEEPKEY_SCAN": "Connect to KeepKey ",
|
||||||
"X_PARITYSIGNER": "Parity Signer ",
|
"X_PARITYSIGNER": "Parity Signer ",
|
||||||
"ADD_PARITY_DESC": "Connect & sign via your Parity Signer mobile app ",
|
"ADD_PARITY_DESC": "Connect & sign via your Parity Signer mobile app ",
|
||||||
"ADD_PARITY_1": "Transaction canceled ",
|
"ADD_PARITY_1": "Transaction canceled ",
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"bip39": "2.5.0",
|
"bip39": "2.5.0",
|
||||||
"bn.js": "4.11.8",
|
"bn.js": "4.11.8",
|
||||||
"bootstrap-sass": "3.3.7",
|
"bootstrap-sass": "3.3.7",
|
||||||
|
"bytebuffer": "5.0.1",
|
||||||
"classnames": "2.2.5",
|
"classnames": "2.2.5",
|
||||||
"electron-updater": "2.21.4",
|
"electron-updater": "2.21.4",
|
||||||
"ethereum-blockies-base64": "1.0.1",
|
"ethereum-blockies-base64": "1.0.1",
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { DeviceClientManager } from '@keepkey/device-client/dist/device-client-manager';
|
||||||
|
import { HidHelper } from '@keepkey/device-client/dist/hid-helper';
|
||||||
|
import HID from 'node-hid';
|
||||||
|
import NodeHidTransport from './NodeHidTransport';
|
||||||
|
|
||||||
|
const dcm = new DeviceClientManager();
|
||||||
|
|
||||||
|
export default class NodeHidHelper implements HidHelper {
|
||||||
|
public async getActiveClient() {
|
||||||
|
const devices = HID.devices();
|
||||||
|
const device = devices.find(d => d.vendorId === 11044 && d.product === 'KeepKey');
|
||||||
|
|
||||||
|
if (!device) {
|
||||||
|
throw new Error('No KeepKey device found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return dcm.factory(new NodeHidTransport(device));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
import { Transport } from '@keepkey/device-client/dist/transport';
|
||||||
|
import HID from 'node-hid';
|
||||||
|
import ByteBuffer from 'bytebuffer';
|
||||||
|
|
||||||
|
export default class NodeHidTransport extends Transport {
|
||||||
|
private device: HID.HID | null;
|
||||||
|
|
||||||
|
constructor(deviceData: HID.Device) {
|
||||||
|
super(deviceData);
|
||||||
|
|
||||||
|
this.device = new HID.HID(deviceData.vendorId, deviceData.productId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async _write(msg: ByteBuffer) {
|
||||||
|
const device = this.getDevice();
|
||||||
|
console.log('Writing', [...msg.buffer]);
|
||||||
|
device.write([...msg.buffer]);
|
||||||
|
// this.closeDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async _read() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const device = this.getDevice();
|
||||||
|
device.read((err, data) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
|
// this.closeDevice();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDevice() {
|
||||||
|
if (this.device) {
|
||||||
|
return this.device;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.device = new HID.HID(this.vendorId, this.productId);
|
||||||
|
return this.device;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Could not open KeepKey HID:', err);
|
||||||
|
throw new Error('Could not open KeepKey wallet, it may be in use by another app');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private closeDevice() {
|
||||||
|
if (this.device) {
|
||||||
|
this.device.close();
|
||||||
|
this.device = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
import { WalletLib } from 'shared/enclave/types';
|
/* tslint:disable max-classes-per-file */
|
||||||
import { DeviceClientManager } from '@keepkey/device-client/dist/device-client-manager';
|
import { DeviceClientManager } from '@keepkey/device-client/dist/device-client-manager';
|
||||||
import { NodeVector } from '@keepkey/device-client/dist/node-vector';
|
import { NodeVector } from '@keepkey/device-client/dist/node-vector';
|
||||||
|
import { WalletLib } from 'shared/enclave/types';
|
||||||
|
import NodeHidHelper from './NodeHidHelper';
|
||||||
|
|
||||||
const dcm = new DeviceClientManager();
|
const dcm = new DeviceClientManager();
|
||||||
|
dcm.hidHelper = new NodeHidHelper();
|
||||||
|
|
||||||
const KeepKey: WalletLib = {
|
const KeepKey: WalletLib = {
|
||||||
async getChainCode() {
|
async getChainCode() {
|
Loading…
Reference in New Issue