Skip to content

Commit

Permalink
[DDW-596] Applied prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mchappell committed Jan 31, 2022
1 parent 2d949a0 commit 2df8fc7
Show file tree
Hide file tree
Showing 131 changed files with 682 additions and 1,126 deletions.
27 changes: 18 additions & 9 deletions source/common/ipc/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ export type ExportWalletsMainResponse = {
*/
export const GENERATE_WALLET_MIGRATION_REPORT_CHANNEL =
'GENERATE_WALLET_MIGRATION_REPORT_CHANNEL';
export type GenerateWalletMigrationReportRendererRequest = WalletMigrationReportData;
export type GenerateWalletMigrationReportRendererRequest =
WalletMigrationReportData;
export type GenerateWalletMigrationReportMainResponse = void;

/**
Expand Down Expand Up @@ -365,7 +366,8 @@ export type ResumeDownloadMainResponse = ResumeDownloadResponse | void;
*/
export const DELETE_DOWNLOADED_FILE = 'DELETE_DOWNLOADED_FILE';
export type DeleteDownloadedFileRendererRequest = DeleteDownloadedFileRequest;
export type DeleteDownloadedFileMainResponse = DeleteDownloadedFileResponse | void;
export type DeleteDownloadedFileMainResponse =
DeleteDownloadedFileResponse | void;

/**
* Channel for initiating the download manager
Expand All @@ -378,14 +380,16 @@ export type DownloadLocalDataMainResponse = DownloadLocalDataResponse;
* Channel for initiating the download manager
*/
export const GET_DOWNLOADS_LOCAL_DATA = 'GET_DOWNLOADS_LOCAL_DATA';
export type DownloadsLocalDataRendererRequest = DownloadsLocalDataRequest | void;
export type DownloadsLocalDataRendererRequest =
DownloadsLocalDataRequest | void;
export type DownloadsLocalDataMainResponse = DownloadsLocalDataResponse | void;

/**
* Channel for initiating the download manager
*/
export const CLEAR_DOWNLOAD_LOCAL_DATA = 'CLEAR_DOWNLOAD_LOCAL_DATA';
export type ClearDownloadLocalDataRendererRequest = ClearDownloadLocalDataRequest;
export type ClearDownloadLocalDataRendererRequest =
ClearDownloadLocalDataRequest;
export type ClearDownloadLocalDataMainResponse = ClearDownloadLocalDataResponse;

/**
Expand Down Expand Up @@ -461,20 +465,25 @@ export type GetBlockReplayProgressMainResponse = number;
*/
export const GET_HARDWARE_WALLET_TRANSPORT_CHANNEL =
'GET_HARDWARE_WALLET_TRANSPORT_CHANNEL';
export type getHardwareWalletTransportRendererRequest = HardwareWalletTransportDeviceRequest;
export type getHardwareWalletTransportMainResponse = HardwareWalletTransportDeviceResponse;
export type getHardwareWalletTransportRendererRequest =
HardwareWalletTransportDeviceRequest;
export type getHardwareWalletTransportMainResponse =
HardwareWalletTransportDeviceResponse;
export const GET_EXTENDED_PUBLIC_KEY_CHANNEL =
'GET_EXTENDED_PUBLIC_KEY_CHANNEL';
export type getExtendedPublicKeyRendererRequest = HardwareWalletExtendedPublicKeyRequest;
export type getExtendedPublicKeyMainResponse = HardwareWalletExtendedPublicKeyResponse;
export type getExtendedPublicKeyRendererRequest =
HardwareWalletExtendedPublicKeyRequest;
export type getExtendedPublicKeyMainResponse =
HardwareWalletExtendedPublicKeyResponse;
export const GET_CARDANO_ADA_APP_CHANNEL = 'GET_CARDANO_ADA_APP_CHANNEL';
export type getCardanoAdaAppRendererRequest = {
path: string | null | undefined;
};
export type getCardanoAdaAppMainResponse = HardwareWalletCardanoAdaAppResponse;
export const GET_HARDWARE_WALLET_CONNECTION_CHANNEL =
'GET_HARDWARE_WALLET_CONNECTION_CHANNEL';
export type getHardwareWalletConnectiontMainRequest = HardwareWalletConnectionRequest;
export type getHardwareWalletConnectiontMainRequest =
HardwareWalletConnectionRequest;
export type getHardwareWalletConnectiontRendererResponse = Record<string, any>;
export const SIGN_TRANSACTION_LEDGER_CHANNEL =
'SIGN_TRANSACTION_LEDGER_CHANNEL';
Expand Down
10 changes: 4 additions & 6 deletions source/common/types/hardware-wallets.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ export type StakingBlockchainPointer = {
txIndex: number;
certificateIndex: number;
};
export type LedgerSignTransactionInputsType = Array<
LedgerSignTransactionInputType
>;
export type LedgerSignTransactionInputsType =
Array<LedgerSignTransactionInputType>;
export type LedgerSignTransactionOutputsType =
| []
| Array<LedgerOutputTypeAddress | LedgerOutputTypeChange>;
Expand Down Expand Up @@ -189,9 +188,8 @@ export type TrezorOutputTypeChange = {
stakingPath: string;
};
};
export type TrezorSignTransactionInputsType = Array<
TrezorSignTransactionInputType
>;
export type TrezorSignTransactionInputsType =
Array<TrezorSignTransactionInputType>;
export type TrezorSignTransactionOutputsType = Array<
TrezorOutputTypeAddress | TrezorOutputTypeChange
>;
Expand Down
16 changes: 8 additions & 8 deletions source/common/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export const generateFileNameWithTimestamp = (props: Props = {}) => {
if (sanitize) fileName = sanitizeFilename(fileName);
return fileName;
};
export const isFileNameWithTimestamp = (prefix = 'logs', extension = 'zip') => (
fileName: string
) =>
fileName.match(
RegExp(
`(${prefix}-)([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}.0[0-9]{3}Z)(.${extension})`
)
);
export const isFileNameWithTimestamp =
(prefix = 'logs', extension = 'zip') =>
(fileName: string) =>
fileName.match(
RegExp(
`(${prefix}-)([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}.0[0-9]{3}Z)(.${extension})`
)
);
export const getPathSlash = (path: string) =>
path.indexOf('/') > -1 ? '/' : '\\';
export const extractFileNameFromPath = (path: string) =>
Expand Down
8 changes: 2 additions & 6 deletions source/main/cardano/CardanoSelfnodeLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ export async function CardanoSelfnodeLauncher(
replyPort: number;
}> {
return new Promise(async (resolve, reject) => {
const {
selfnodeBin,
mockTokenMetadataServerBin,
processName,
onStop,
} = selfnodeOptions;
const { selfnodeBin, mockTokenMetadataServerBin, processName, onStop } =
selfnodeOptions;
setupMockTokenMetadataServer(mockTokenMetadataServerBin);
// @ts-ignore ts-migrate(2322) FIXME: Type '{ pid: number; ppid?: number; uid?: number; ... Remove this comment to see the full error message
const processList: Array<Process> = await find('port', CARDANO_WALLET_PORT);
Expand Down
9 changes: 2 additions & 7 deletions source/main/cardano/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,8 @@ export const exportWallets = async (
mainWindow: BrowserWindow,
locale: string
): Promise<ExportWalletsMainResponse> => {
const {
legacySecretKey,
legacyWalletDB,
stateDir,
cluster,
isFlight,
} = launcherConfig;
const { legacySecretKey, legacyWalletDB, stateDir, cluster, isFlight } =
launcherConfig;
logger.info('ipcMain: Starting wallets export...', {
exportSourcePath,
legacySecretKey,
Expand Down
5 changes: 2 additions & 3 deletions source/main/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ export const windowOptions: WindowOptionsType = {
},
useContentSize: true,
};
export const launcherConfig: LauncherConfig = readLauncherConfig(
LAUNCHER_CONFIG
);
export const launcherConfig: LauncherConfig =
readLauncherConfig(LAUNCHER_CONFIG);
export const {
cluster,
nodeImplementation,
Expand Down
30 changes: 9 additions & 21 deletions source/main/ipc/downloadManagerChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ const requestResumeDownload = async (

const deleteDownloadedFile = async ({
id,
}: DeleteDownloadedFileRendererRequest): Promise<
DeleteDownloadedFileMainResponse
> => {
}: DeleteDownloadedFileRendererRequest): Promise<DeleteDownloadedFileMainResponse> => {
const downloadLocalData = await getDownloadLocalData({
id,
});
Expand All @@ -201,9 +199,7 @@ const deleteDownloadedFile = async ({
const getDownloadLocalData = async ({
fileName,
id = fileName,
}: DownloadLocalDataRendererRequest): Promise<
DownloadLocalDataMainResponse
> => {
}: DownloadLocalDataRendererRequest): Promise<DownloadLocalDataMainResponse> => {
if (!id) throw new Error('Requires `id` or `fileName`');
const downloadId: string = getIdFromFileName(String(id));
return localStorage.get(downloadId);
Expand All @@ -216,9 +212,7 @@ const getDownloadsLocalData =
const clearDownloadLocalData = async ({
fileName,
id = fileName,
}: ClearDownloadLocalDataRendererRequest): Promise<
ClearDownloadLocalDataMainResponse
> => {
}: ClearDownloadLocalDataRendererRequest): Promise<ClearDownloadLocalDataMainResponse> => {
if (!id) throw new Error('Requires `id` or `fileName`');
const downloadId: string = getIdFromFileName(String(id));
return localStorage.unset(downloadId);
Expand All @@ -241,15 +235,11 @@ const checkFileExists = async ({
};

const requestDownloadChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
DownloadRendererRequest,
DownloadMainResponse
> = new MainIpcChannel(REQUEST_DOWNLOAD);
MainIpcChannel<DownloadRendererRequest, DownloadMainResponse> =
new MainIpcChannel(REQUEST_DOWNLOAD);
const requestResumeDownloadChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
ResumeDownloadRendererRequest,
ResumeDownloadMainResponse
> = new MainIpcChannel(RESUME_DOWNLOAD);
MainIpcChannel<ResumeDownloadRendererRequest, ResumeDownloadMainResponse> =
new MainIpcChannel(RESUME_DOWNLOAD);
const deleteDownloadedFileChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
DeleteDownloadedFileRendererRequest,
Expand All @@ -271,10 +261,8 @@ MainIpcChannel<
ClearDownloadLocalDataMainResponse
> = new MainIpcChannel(CLEAR_DOWNLOAD_LOCAL_DATA);
const checkFileExistsChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
CheckFileExistsRendererRequest,
CheckFileExistsMainResponse
> = new MainIpcChannel(CHECK_FILE_EXISTS);
MainIpcChannel<CheckFileExistsRendererRequest, CheckFileExistsMainResponse> =
new MainIpcChannel(CHECK_FILE_EXISTS);
export const downloadManagerChannel = (window: BrowserWindow) => {
requestDownloadChannel.onRequest(
(downloadRequestPayload: DownloadRendererRequest) =>
Expand Down
6 changes: 2 additions & 4 deletions source/main/ipc/generateCsvChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import type {
} from '../../common/ipc/api';

export const generateCsvChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
GenerateCsvRendererRequest,
GenerateCsvMainResponse
> = new MainIpcChannel(GENERATE_CSV_CHANNEL);
MainIpcChannel<GenerateCsvRendererRequest, GenerateCsvMainResponse> =
new MainIpcChannel(GENERATE_CSV_CHANNEL);
export const handleRewardsCsvRequests = () => {
generateCsvChannel.onReceive(
(request: GenerateCsvRendererRequest) =>
Expand Down
6 changes: 2 additions & 4 deletions source/main/ipc/generateFileMetaChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import type {
} from '../../common/ipc/api';

export const generateFileMetaChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
GenerateFileMetaRendererRequest,
GenerateFileMetaMainResponse
> = new MainIpcChannel(GENERATE_FILE_META_CHANNEL);
MainIpcChannel<GenerateFileMetaRendererRequest, GenerateFileMetaMainResponse> =
new MainIpcChannel(GENERATE_FILE_META_CHANNEL);
export const handleFileMetaRequests = () => {
generateFileMetaChannel.onReceive(
(request: GenerateFileMetaRendererRequest) =>
Expand Down
7 changes: 3 additions & 4 deletions source/main/ipc/getHardwareWalletChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,11 @@ export const handleHardwareWalletRequests = async (
});

if (deviceFeatures.success) {
const extendedPublicKeyResponse = await TrezorConnect.cardanoGetPublicKey(
{
const extendedPublicKeyResponse =
await TrezorConnect.cardanoGetPublicKey({
path: `m/${path}`,
showOnTrezor: true,
}
);
});

if (!extendedPublicKeyResponse.success) {
throw extendedPublicKeyResponse.payload;
Expand Down
6 changes: 2 additions & 4 deletions source/main/ipc/manageAppUpdateChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import { safeExitWithCode } from '../utils/safeExitWithCode';
import { logger } from '../utils/logging';
import { launcherConfig } from '../config';
// IpcChannel<Incoming, Outgoing>
const manageAppUpdateChannel: MainIpcChannel<
Request,
Response
> = new MainIpcChannel(MANAGE_APP_UPDATE);
const manageAppUpdateChannel: MainIpcChannel<Request, Response> =
new MainIpcChannel(MANAGE_APP_UPDATE);
const logPrefix = 'appUpdateInstall';

const getMessage = (functionPrefix: string, message?: string): string => {
Expand Down
6 changes: 2 additions & 4 deletions source/main/ipc/rebuild-application-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ import type {
} from '../../common/ipc/api';

export const rebuildApplicationMenu: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
RebuildAppMenuRendererRequest,
RebuildAppMenuMainResponse
> = new MainIpcChannel(REBUILD_APP_MENU_CHANNEL);
MainIpcChannel<RebuildAppMenuRendererRequest, RebuildAppMenuMainResponse> =
new MainIpcChannel(REBUILD_APP_MENU_CHANNEL);
6 changes: 2 additions & 4 deletions source/main/ipc/saveQRCodeImageChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import type {
} from '../../common/ipc/api';

export const saveQRCodeImageChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
GenerateQRCodeRendererRequest,
GenerateQRCodeMainResponse
> = new MainIpcChannel(GENERATE_QRCODE_CHANNEL);
MainIpcChannel<GenerateQRCodeRendererRequest, GenerateQRCodeMainResponse> =
new MainIpcChannel(GENERATE_QRCODE_CHANNEL);
export const saveQRCodeImageRequests = () => {
saveQRCodeImageChannel.onReceive(
(request: GenerateQRCodeRendererRequest) =>
Expand Down
12 changes: 4 additions & 8 deletions source/main/ipc/show-file-dialog-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ import type {
} from '../../common/ipc/api';

export const showOpenDialogChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
ShowOpenDialogRendererRequest,
ShowOpenDialogMainResponse
> = new MainIpcChannel(SHOW_OPEN_DIALOG_CHANNEL);
MainIpcChannel<ShowOpenDialogRendererRequest, ShowOpenDialogMainResponse> =
new MainIpcChannel(SHOW_OPEN_DIALOG_CHANNEL);
export const showSaveDialogChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
ShowSaveDialogRendererRequest,
ShowSaveDialogMainResponse
> = new MainIpcChannel(SHOW_SAVE_DIALOG_CHANNEL);
MainIpcChannel<ShowSaveDialogRendererRequest, ShowSaveDialogMainResponse> =
new MainIpcChannel(SHOW_SAVE_DIALOG_CHANNEL);
export const handleFileDialogRequests = (window: BrowserWindow) => {
showOpenDialogChannel.onReceive((request: ShowOpenDialogRendererRequest) =>
// @ts-ignore ts-migrate(2345) FIXME: Argument of type 'FileDialogRequestParams' is not ... Remove this comment to see the full error message
Expand Down
6 changes: 2 additions & 4 deletions source/main/utils/getContentMinimumSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ export const getContentMinimumSize = (
): getContentMinimumSizeResponse => {
const { isWindows } = environment;
const { width: frameWidth, height: frameHeight } = window.getBounds();
const {
width: contentWidth,
height: contentHeight,
} = window.getContentBounds();
const { width: contentWidth, height: contentHeight } =
window.getContentBounds();
const paddingWidth = frameWidth - contentWidth || 0;
let paddingHeight = frameHeight - contentHeight || 0;

Expand Down
17 changes: 8 additions & 9 deletions source/main/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ const environmentData = {
version,
};

const logToLevel = (level: string) => (
message: string,
data: Record<string, any> | null | undefined
) =>
log[level](formatContext({ ...messageContext, level }), {
message,
data: toJS(data),
environmentData,
});
const logToLevel =
(level: string) =>
(message: string, data: Record<string, any> | null | undefined) =>
log[level](formatContext({ ...messageContext, level }), {
message,
data: toJS(data),
environmentData,
});

export const logger: Logger = {
debug: logToLevel('debug'),
Expand Down
9 changes: 2 additions & 7 deletions source/main/utils/setupLogging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,8 @@ export const logStateSnapshot = (
): MessageBody => {
const { ...data } = props;
const { currentTime: at, systemInfo, coreInfo } = data;
const {
platform,
platformVersion,
cpu,
ram,
availableDiskSpace,
} = systemInfo;
const { platform, platformVersion, cpu, ram, availableDiskSpace } =
systemInfo;
const {
daedalusVersion,
daedalusProcessID,
Expand Down
Loading

0 comments on commit 2df8fc7

Please sign in to comment.