Add comments

This commit is contained in:
HenryNguyen5 2018-04-23 21:00:16 -04:00
parent 570b3c42b9
commit e9f04369e3
3 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,13 @@ import {
import { createClientRpcHandler } from './client-utils';
import EventEmitter from 'events';
/**
* This is what the web facing side would use as a package to interact with the enclave
* It contains logic to differentiate between electron and browser / node enviroments
* And then its functions communicate with the "server" to perform RPC calls
* This file is the equivalent to a Provider for shepherd / INode implementation
*/
const eventEmitter = new EventEmitter();
function isElectronEnv() {
return process.env.BUILD_ELECTRON;

View File

@ -2,6 +2,13 @@ import { ipcRenderer } from 'electron';
import { EnclaveEvents, SignRawTransactionParams, SignRawTransaction } from './types';
import { createClientRpcHandler } from './client-utils';
/**
* Contains scripts to inject handlers into the web at runtime via preload
* which "client" then can use to communicate with ipcMain process
* to call methods on the enclave.
* This package would be in the preload section of electron
*/
const createElectronRpcHandler = <T = any, R = any>(channel: EnclaveEvents) =>
createClientRpcHandler<T, R>(ipcRenderer, channel, ipcRenderer.send, ipcRenderer.once);

View File

@ -10,6 +10,12 @@ import {
import { ipcMain } from 'electron';
import { createServerRpcHandler } from './server-utils';
/**
* Contains the "server" implementation, currently only for electron
* this should be run in ipcMain process to have access to node-hid
* to perform signing actions for hardware wallets
*/
// mock
// this hard codes electron specific sending atm (ev.sender.send)
export const signRawTransactionRequest: RpcEventHandler<