Skip to content

Commit

Permalink
Merge pull request #177 from TokelPlatform/development
Browse files Browse the repository at this point in the history
Follow up to Alpha 1.1.1 Release - Tokel Token Wallet Updates: 2
  • Loading branch information
piggydoughnut authored Nov 8, 2021
2 parents 52ae764 + 2788d65 commit ae600c7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
10 changes: 7 additions & 3 deletions src/components/BitgoOrchestrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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);
Expand Down
18 changes: 11 additions & 7 deletions src/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
2 changes: 1 addition & 1 deletion src/electron/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
21 changes: 16 additions & 5 deletions src/electron/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const BitgoAction = {
};

const SATOSHIS = 100000000;

const isDev = process.env.NODE_ENV === 'development';
class BitgoSingleton {
constructor(network) {
this.network = network;
Expand Down Expand Up @@ -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();
Expand Down
14 changes: 14 additions & 0 deletions src/util/bitgoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ export function sendToBitgo<T extends MsgValue>(
): 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;
};

0 comments on commit ae600c7

Please sign in to comment.