Skip to content

Commit

Permalink
extracting MessageType to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Sep 12, 2024
1 parent b87041b commit 7c828da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app/scripts/streams/phishing-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
PHISHING_SAFELIST,
PHISHING_WARNING_PAGE,
} from '../constants/stream';
import { logStreamDisconnectWarning } from './stream-utils';
import { logStreamDisconnectWarning, MessageType } from './stream-utils';

const phishingPageUrl = new URL(
process.env.PHISHING_WARNING_PAGE_URL as string,
Expand Down Expand Up @@ -139,9 +139,9 @@ const onDisconnectDestroyPhishingStreams = (): void => {
* @param msg - The message object
* @param msg.name - Custom property and name to identify the message received
*/
const onMessageSetUpPhishingStreams = (msg: {
name: string;
}): Promise<string | undefined> | undefined => {
const onMessageSetUpPhishingStreams = (
msg: MessageType,
): Promise<string | undefined> | undefined => {
if (msg.name === EXTENSION_MESSAGES.READY) {
if (!phishingExtStream) {
setupPhishingExtStreams();
Expand Down
12 changes: 1 addition & 11 deletions app/scripts/streams/provider-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@ import {
} from '../constants/stream';
import { EXTENSION_MESSAGES } from '../../../shared/constants/app';
import { checkForLastError } from '../../../shared/modules/browser-runtime.utils';
import { logStreamDisconnectWarning } from './stream-utils';
import { logStreamDisconnectWarning, MessageType } from './stream-utils';
import { connectPhishingChannelToWarningSystem } from './phishing-stream';

type MessageType = {
name: string;
data: {
jsonrpc: string;
method: string;
params?: Record<string, unknown> | null;
id: string;
origin?: string;
};
};
let legacyExtMux: ObjectMultiplex,
legacyExtChannel: Substream,
legacyExtPublicConfigChannel: Substream,
Expand Down
11 changes: 11 additions & 0 deletions app/scripts/streams/stream-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ export function logStreamDisconnectWarning(
error,
);
}

export type MessageType = {
name: string;
data: {
jsonrpc: string;
method: string;
params?: Record<string, unknown>[];
id: string;
origin?: string;
};
};

0 comments on commit 7c828da

Please sign in to comment.