diff --git a/src/components/BitgoOrchestrator.tsx b/src/components/BitgoOrchestrator.tsx index f589d4cf..bd1282f1 100644 --- a/src/components/BitgoOrchestrator.tsx +++ b/src/components/BitgoOrchestrator.tsx @@ -6,10 +6,10 @@ import log from 'electron-log'; import { dispatch } from 'store/rematch'; import { selectAccountAddress } from 'store/selectors'; -import { BitgoAction, sendToBitgo } from 'util/bitgoHelper'; +import { BitgoAction, checkData, sendToBitgo } from 'util/bitgoHelper'; import { parseUnspent } from 'util/transactions'; import { spendSuccess } from 'util/transactionsHelper'; -import { BITGO_IPC_ID, ErrorMessages } from 'vars/defines'; +import { BITGO_IPC_ID, ErrorMessages, IS_DEV } from 'vars/defines'; const BAD_WALLET_ERRORS = ['Error: RangeError: value out of range']; export const BROKEN_WALLET_MSG = @@ -32,7 +32,11 @@ const BitgoOrchestrator = () => { useEffect(() => { ipcRenderer.on(BITGO_IPC_ID, (_, payload) => { console.group('BITGO (ORCHESTRATOR)'); - console.log(payload); + if (IS_DEV) { + console.group('BITGO (WORKER -> [MAIN] -> RENDERER)'); + console.log(checkData(payload)); + console.groupEnd(); + } console.groupEnd(); if (payload.type === BitgoAction.SET_NETWORK) { dispatch.environment.SET_SHOW_NETWORK_PREFS(false); diff --git a/src/electron/main.ts b/src/electron/main.ts index 31f89519..11e4ed4c 100644 --- a/src/electron/main.ts +++ b/src/electron/main.ts @@ -22,7 +22,7 @@ import installExtension, { import log from 'electron-log'; import { autoUpdater } from 'electron-updater'; -import { BitgoAction } from '../util/bitgoHelper'; +import { BitgoAction, checkData } from '../util/bitgoHelper'; import { BITGO_IPC_ID, IPFS_IPC_ID, WindowControl } from '../vars/defines'; import MenuBuilder from './menu'; @@ -64,9 +64,11 @@ const installExtensions = async () => { // bitgo events from renderer ipcMain.on(BITGO_IPC_ID, (_, msg) => { - console.group('BITGO (RENDERER -> [MAIN] -> WORKER)'); - console.log(msg); - console.groupEnd(); + if (isDev) { + console.group('BITGO (RENDERER -> [MAIN] -> WORKER)'); + console.log(checkData(msg)); + console.groupEnd(); + } bitgoWorker.postMessage(msg); }); @@ -147,9 +149,11 @@ const createWindow = async () => { // pass messages to renderer from bitgo worker bitgoWorker.on('message', msg => { - console.group('BITGO (WORKER -> [MAIN] -> RENDERER)'); - console.log(msg); - console.groupEnd(); + if (isDev) { + console.group('BITGO (WORKER -> [MAIN] -> RENDERER)'); + console.log(checkData(msg)); + console.groupEnd(); + } mainWindow.webContents.send(BITGO_IPC_ID, msg); }); diff --git a/src/electron/package.json b/src/electron/package.json index c99ab447..de0e25ce 100644 --- a/src/electron/package.json +++ b/src/electron/package.json @@ -1,7 +1,7 @@ { "name": "tokel_app", "productName": "tokelPlatform", - "version": "1.1.1", + "version": "1.1.2", "description": "Komodo ecosystem’s Token Platform", "main": "./main.js", "author": { diff --git a/src/electron/worker.js b/src/electron/worker.js index dd8cbf92..4ddb3bff 100644 --- a/src/electron/worker.js +++ b/src/electron/worker.js @@ -26,7 +26,7 @@ const BitgoAction = { }; const SATOSHIS = 100000000; - +const isDev = process.env.NODE_ENV === 'development'; class BitgoSingleton { constructor(network) { this.network = network; @@ -272,13 +272,24 @@ class BitgoSingleton { } } -let network = networks.tokel; +let network = isDev ? networks.tkltest : networks.tokel; let bitgo = new BitgoSingleton(network); +const checkData = msg => { + if (msg.type === BitgoAction.LOGIN) { + return { + type: msg.type, + }; + } + return msg; +}; + parentPort.on('message', msg => { - console.group('BITGO (WORKER)'); - console.log(msg); - console.groupEnd(); + if (isDev) { + console.group('BITGO (WORKER)'); + console.log(checkData(msg)); + console.groupEnd(); + } if (msg.type === BitgoAction.SET_NETWORK) { bitgo.cleanup(); diff --git a/src/util/bitgoHelper.ts b/src/util/bitgoHelper.ts index 3fe91dcd..d27db3ac 100644 --- a/src/util/bitgoHelper.ts +++ b/src/util/bitgoHelper.ts @@ -44,3 +44,17 @@ export function sendToBitgo( ): void { ipcRenderer.send(BITGO_IPC_ID, { type, payload: options[0] }); } + +type BitgoMsg = { + type: BitgoAction; + payload: any; +}; + +export const checkData = (msg: BitgoMsg) => { + if (msg.type === BitgoAction.LOGIN) { + return { + type: msg.type, + }; + } + return msg; +};