diff --git a/common/libs/EthEnclave/client.ts b/common/libs/EthEnclave/client.ts index 26d311c9..2b0e0f03 100644 --- a/common/libs/EthEnclave/client.ts +++ b/common/libs/EthEnclave/client.ts @@ -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; diff --git a/common/libs/EthEnclave/preload.ts b/common/libs/EthEnclave/preload.ts index be436d1e..4b4f5630 100644 --- a/common/libs/EthEnclave/preload.ts +++ b/common/libs/EthEnclave/preload.ts @@ -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 = (channel: EnclaveEvents) => createClientRpcHandler(ipcRenderer, channel, ipcRenderer.send, ipcRenderer.once); diff --git a/common/libs/EthEnclave/server.ts b/common/libs/EthEnclave/server.ts index a027c972..e6ae7dfc 100644 --- a/common/libs/EthEnclave/server.ts +++ b/common/libs/EthEnclave/server.ts @@ -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<