Skip to content

Commit

Permalink
fix: reset logs on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
a0ngo committed Nov 7, 2023
1 parent c63723f commit 1b3373b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
RelayCreateTxRequestParams,
RelaySignTxResponseParams,
getLogger,
sanatize,
} from '@fireblocks/recovery-shared';
import { AssetConfig } from '@fireblocks/asset-config';
import { useWorkspace } from '../../../context/Workspace';
Expand Down Expand Up @@ -181,7 +182,7 @@ export const CreateTransaction = ({ asset, inboundRelayParams, setSignTxResponse
accountId,
values,
asset,
derivation,
derivation: sanatize(derivation),
prepare: prepareQuery.data,
});

Expand Down
1 change: 1 addition & 0 deletions apps/recovery-utility/main/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let protocol = deployment.exp
: DEFAULT_PROTOCOL;
const relay = app.commandLine.hasSwitch('relay');
const util = app.commandLine.hasSwitch('util');
resetLogs();
console.log(`Command line specified: relay: ${relay}, util: ${util}.`);
if (relay && util) {
console.error('Both relay and util flags were used, ignoring.');
Expand Down
2 changes: 2 additions & 0 deletions apps/recovery-utility/main/ipc/getLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ ipcMain.handle('logs/get', async () =>
),
);

ipcMain.handle('logs/reset', async () => resetLogs());

export const resetLogs = () => {
const logFiles = [
getLogPath('utility'),
Expand Down
2 changes: 2 additions & 0 deletions apps/recovery-utility/renderer/lib/ipc/getLogs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ipcRenderer } from 'electron';

export const getLogs = () => ipcRenderer.invoke('logs/get') as Promise<Buffer>;

export const resetLogs = () => ipcRenderer.invoke('logs/reset') as Promise<void>;
2 changes: 2 additions & 0 deletions apps/recovery-utility/renderer/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useWorkspace } from '../context/Workspace';
import { getDeployment, useDeployment } from '../lib/ipc';
import { LOGGER_NAME_UTILITY } from '@fireblocks/recovery-shared/constants';
import { resetDeployment } from '../lib/ipc/useDeployment';
import { resetLogs } from '../lib/ipc/getLogs';

const buttonStyles: SxProps = {
padding: '0.2rem',
Expand Down Expand Up @@ -63,6 +64,7 @@ const Index = () => {
const [protocol, setProtocol] = useWrappedState<'UTILITY' | 'RELAY' | null>('util-protocol', null);

const onClickDeployment = async (_protocol: 'UTILITY' | 'RELAY') => {
resetLogs();
logger.debug(`Setting deployment ${_protocol}`);
useDeployment(_protocol);
};
Expand Down

0 comments on commit 1b3373b

Please sign in to comment.