From b1f43c6b6a2ac6e5b675ea900d7d459a6501eb6a Mon Sep 17 00:00:00 2001 From: mindofmar Date: Thu, 2 May 2024 23:12:45 -0500 Subject: [PATCH] use enum for bypasstype --- src/content-scripts/bypassCheck.tsx | 3 ++- src/content-scripts/contentScripts.tsx | 4 ++-- src/models/simulation/Transaction.ts | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/content-scripts/bypassCheck.tsx b/src/content-scripts/bypassCheck.tsx index 9c19fa0..89ba726 100644 --- a/src/content-scripts/bypassCheck.tsx +++ b/src/content-scripts/bypassCheck.tsx @@ -1,5 +1,6 @@ import Browser from 'webextension-polyfill'; import { + BypassType, PersonalSignArgs, SignatureHashSignArgs, SignatureRequestArgs, @@ -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 = { diff --git a/src/content-scripts/contentScripts.tsx b/src/content-scripts/contentScripts.tsx index f33c294..4a9699d 100644 --- a/src/content-scripts/contentScripts.tsx +++ b/src/content-scripts/contentScripts.tsx @@ -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'; @@ -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; diff --git a/src/models/simulation/Transaction.ts b/src/models/simulation/Transaction.ts index 6b002d4..5e8f5f8 100644 --- a/src/models/simulation/Transaction.ts +++ b/src/models/simulation/Transaction.ts @@ -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 =