Skip to content

Commit

Permalink
[DDW-414] Converting to plain JS Objects any argument passed via ipc
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmain committed Jun 8, 2021
1 parent 81c0936 commit 2f2efcb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
11 changes: 10 additions & 1 deletion source/renderer/app/components/widgets/forms/FileUploadWidget.js
Expand Up @@ -15,10 +15,19 @@ type Props = {
acceptedFileTypes: Array<string>,
};

type openDialogChannelFilterType = {
name: string,
extensions: string[],
};
type openDialogChannelType = {
defaultPath: string,
filters: openDialogChannelFilterType[],
};

@observer
export default class FileUploadWidget extends Component<Props> {
onOpen = async () => {
const params = {
const params: openDialogChannelType = {
filters: [
{
name: 'file-upload',
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/containers/wallet/WalletReceivePage.js
Expand Up @@ -95,7 +95,7 @@ export default class WalletReceivePage extends Component<Props, State> {
this.props.actions.walletSettings.toggleShowUsedAddresses.trigger();
};

getAddressAndFilepath = async (fileExtension?: string = 'pdf') => {
getAddressAndFilepath = async (fileExtension: ?string = 'pdf') => {
const { addressToShare } = this.state;
const { activeWallet } = this;
const { intl } = this.context;
Expand Down
Expand Up @@ -10,6 +10,16 @@ import { generateFileNameWithTimestamp } from '../../../../../../common/utils/fi

type Props = InjectedDialogContainerProps;

type pdfType = 'pdf';
type saveDialogChannelFilterType = {
name: string,
extensions: pdfType[],
};
type saveDialogChannelType = {
defaultPath: string,
filters: saveDialogChannelFilterType[],
};

@inject('stores', 'actions')
@observer
export default class InstructionsDialogContainer extends Component<Props> {
Expand Down Expand Up @@ -37,8 +47,8 @@ export default class InstructionsDialogContainer extends Component<Props> {
isUTC: false,
});
const { desktopDirectoryPath } = this.props.stores.profile;
const defaultPath = path.join(desktopDirectoryPath, `${name}.pdf`);
const params = {
const defaultPath: string = path.join(desktopDirectoryPath, `${name}.pdf`);
const params: saveDialogChannelType = {
defaultPath,
filters: [
{
Expand Down
10 changes: 5 additions & 5 deletions source/renderer/app/stores/WalletMigrationStore.js
@@ -1,5 +1,5 @@
// @flow
import { action, computed, observable, runInAction } from 'mobx';
import { action, computed, observable, runInAction, toJS } from 'mobx';
import path from 'path';
import { orderBy } from 'lodash';
import Store from './lib/Store';
Expand Down Expand Up @@ -262,7 +262,7 @@ export default class WalletMigrationStore extends Store {
logger.debug(
`WalletMigrationStore: Exported ${this.exportedWalletsCount} wallets`,
{
exportedWalletsData: this.exportedWalletsData,
exportedWalletsData: toJS(this.exportedWalletsData),
exportErrors: this.exportErrors,
}
);
Expand Down Expand Up @@ -368,7 +368,7 @@ export default class WalletMigrationStore extends Store {
);
try {
await generateWalletMigrationReportChannel.send(
walletMigrationReportData
toJS(walletMigrationReportData)
);
logger.debug('WalletMigrationStore: Generated wallet migration report');
} catch (error) {
Expand Down Expand Up @@ -511,11 +511,11 @@ export default class WalletMigrationStore extends Store {
}

@computed get exportedWalletsData(): Array<ExportedWalletData> {
return this.exportedWallets.map((wallet) => ({
return this.exportedWallets.map((wallet: ExportedWalletData) => ({
id: wallet.id,
name: wallet.name,
hasPassword: !wallet.isEmptyPassphrase,
import: wallet.import,
import: toJS(wallet.import),
}));
}

Expand Down
10 changes: 1 addition & 9 deletions source/renderer/app/utils/logging.js
Expand Up @@ -33,15 +33,7 @@ const logToLevel = (level: LoggingLevel) => (
formatContext({ ...messageContext, level }),
{
message,
// The algorithm used to serialize objects sent over IPC on electron v9+
// does not support sending Functions, Promises, WeakMaps, WeakSets,
// or objects containing any such values.
// https://github.com/electron/electron/blob/main/docs/breaking-changes.md#behavior-changed-values-sent-over-ipc-are-now-serialized-with-structured-clone-algorithm
data: ((dataVal: ?Object) =>
!!dataVal &&
typeof dataVal === 'object' &&
typeof dataVal !== 'function' &&
JSON.parse(JSON.stringify(dataVal)))(data),
data,
environmentData,
},
];
Expand Down

0 comments on commit 2f2efcb

Please sign in to comment.