Skip to content

Commit

Permalink
use enum for bypasstype
Browse files Browse the repository at this point in the history
  • Loading branch information
mindofmar committed May 3, 2024
1 parent 2cdbeb6 commit b1f43c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/content-scripts/bypassCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Browser from 'webextension-polyfill';
import {
BypassType,
PersonalSignArgs,
SignatureHashSignArgs,
SignatureRequestArgs,
Expand All @@ -13,7 +14,7 @@ import { PortMessage, PortIdentifiers } from '../lib/helpers/chrome/messageHandl
import { convertObjectValuesToString, shouldSwapPersonalSignArgs } from '../injected/injectWalletGuard';

const bypassed = true;
const bypassType = 'postMessage';
const bypassType = BypassType.PostMessage;

const sendMessageToPort = (stream: Browser.Runtime.Port, data: TransactionArgs): void => {
const message: PortMessage = {
Expand Down
4 changes: 2 additions & 2 deletions src/content-scripts/contentScripts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import logger from '../lib/logger';
import { dispatchResponse, listenToRequest, Response } from '../lib/simulation/requests';
import type { StoredSimulation } from '../lib/simulation/storage';
import { removeSimulation, StoredSimulationState } from '../lib/simulation/storage';
import { TransactionArgs } from '../models/simulation/Transaction';
import { BypassType, TransactionArgs } from '../models/simulation/Transaction';
import { ExtensionSettings, SimulationSettings } from '../lib/settings';
import { KNOWN_MARKETPLACES, shouldSkipBasedOnDomain } from '../lib/simulation/skip';
import { getDomainNameFromURL } from '../lib/helpers/phishing/parseDomainHelper';
Expand Down Expand Up @@ -65,7 +65,7 @@ listenToRequest(async (request: TransactionArgs) => {
}

// Set the bypassType, but do not set bypassed = true because otherwise the simulation buttons will be incorrect
request.bypassType = 'chainId';
request.bypassType = BypassType.ChainId
}

let currentTab = window.location.href;
Expand Down
7 changes: 6 additions & 1 deletion src/models/simulation/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ interface RequestArgs {
// Whether this request is a bypassed request.
bypassed?: boolean;
// The type of the attempted bypass
bypassType?: 'postMessage' | 'chainId';
bypassType?: BypassType;
}

export enum BypassType {
PostMessage = 'postMessage',
ChainId = 'chainId',
}

export type SimulationResponse =
Expand Down

0 comments on commit b1f43c6

Please sign in to comment.