diff --git a/src/components/simulation/SimulationButton.tsx b/src/components/simulation/SimulationButton.tsx index d1c7f70..224505a 100644 --- a/src/components/simulation/SimulationButton.tsx +++ b/src/components/simulation/SimulationButton.tsx @@ -6,7 +6,7 @@ import { StoredSimulationState, updateSimulationAction, } from '../../lib/simulation/storage'; -import { RecommendedActionType } from '../../models/simulation/Transaction'; +import { BypassType, RecommendedActionType } from '../../models/simulation/Transaction'; import styles from '../../styles/simulation/SimulationButton.module.css'; import localStorageHelpers from '../../lib/helpers/chrome/localStorage'; import { WgKeys } from '../../lib/helpers/chrome/localStorageKeys'; @@ -54,6 +54,10 @@ export const ConfirmSimulationButton: React.FC = ( setNeedsConfirm(false); } + function joinDiscord() { + chrome.tabs.create({ url: 'https://discord.gg/mvbtaJzXDP' }); + } + function handlePosthogIds() { localStorageHelpers.get(WgKeys.AddressList).then((res) => { const addresses = res || []; @@ -76,78 +80,92 @@ export const ConfirmSimulationButton: React.FC = ( return (
-
-
- { - posthog.capture('simulation rejected', { - storedSimulation: storedSimulation, - }); - updateSimulationAction(id, StoredSimulationState.Rejected); - }} - /> -
-
- {!storedSimulation || storedSimulation.state === StoredSimulationState.Simulating ? ( - { - posthog.capture('simulation skipped', { - storedSimulation: storedSimulation, - }); - updateSimulationAction(id, StoredSimulationState.Confirmed); - }} - /> - ) : !storedSimulation.simulation.error && - storedSimulation.simulation.recommendedAction === RecommendedActionType.Block && - needsConfirm ? ( +
+ {storedSimulation.args.bypassType === BypassType.ChainId && ( + <> +

Caution: Your wallet may be incompatible with Wallet Guard

+ + Open Support Ticket + + + )} + +
+
{ - posthog.capture('simulation proceed anyway', { + posthog.capture('simulation rejected', { storedSimulation: storedSimulation, }); - handleProceedAnyway(); + updateSimulationAction(id, StoredSimulationState.Rejected); }} /> - ) : storedSimulation.lockedAssetsState?.shouldBlockTx ? - ( +
+
+ {!storedSimulation || storedSimulation.state === StoredSimulationState.Simulating ? ( { - posthog.capture('simulation rejected', { + posthog.capture('simulation skipped', { storedSimulation: storedSimulation, - isSoftLockedTx: true }); - openDashboard('lockedAsset'); - updateSimulationAction(id, StoredSimulationState.Rejected); + updateSimulationAction(id, StoredSimulationState.Confirmed); }} - />) : - ( + /> + ) : !storedSimulation.simulation.error && + storedSimulation.simulation.recommendedAction === RecommendedActionType.Block && + needsConfirm ? ( { - posthog.capture('simulation confirmed', { + posthog.capture('simulation proceed anyway', { storedSimulation: storedSimulation, }); - updateSimulationAction(id, StoredSimulationState.Confirmed); + handleProceedAnyway(); }} /> - )} + ) : storedSimulation.lockedAssetsState?.shouldBlockTx ? + ( + { + posthog.capture('simulation rejected', { + storedSimulation: storedSimulation, + isSoftLockedTx: true + }); + openDashboard('lockedAsset'); + updateSimulationAction(id, StoredSimulationState.Rejected); + }} + />) : + ( + { + posthog.capture('simulation confirmed', { + storedSimulation: storedSimulation, + }); + updateSimulationAction(id, StoredSimulationState.Confirmed); + }} + /> + )} +
diff --git a/src/content-scripts/contentScripts.tsx b/src/content-scripts/contentScripts.tsx index 4a9699d..aaba087 100644 --- a/src/content-scripts/contentScripts.tsx +++ b/src/content-scripts/contentScripts.tsx @@ -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 = BypassType.ChainId + request.bypassType = BypassType.ChainId; } let currentTab = window.location.href; diff --git a/src/injected/injectWalletGuard.tsx b/src/injected/injectWalletGuard.tsx index 890ce93..6bb2b68 100644 --- a/src/injected/injectWalletGuard.tsx +++ b/src/injected/injectWalletGuard.tsx @@ -1,6 +1,7 @@ import { EthereumProviderError, ethErrors } from 'eth-rpc-errors'; import logger from '../lib/logger'; import { RequestManager, Response } from '../lib/simulation/requests'; +import posthog from 'posthog-js'; declare global { interface Window { @@ -41,6 +42,14 @@ export function convertObjectValuesToString(inputObj: any): any { return output; } +posthog.init('phc_rb7Dd9nqkBMJYCCh7MQWpXtkNqIGUFdCZbUThgipNQD', { + api_host: 'https://app.posthog.com', + persistence: 'localStorage', + autocapture: false, + capture_pageleave: false, + disable_session_recording: true, +}); + const log = logger.child({ component: 'Injected' }); // Handling all the request communication. @@ -117,6 +126,13 @@ const addWalletGuardProxy = (provider: any) => { // Override the result if it cannot be trusted if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -160,6 +176,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -190,6 +213,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -221,6 +251,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -259,6 +296,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -317,6 +361,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -373,6 +424,13 @@ const addWalletGuardProxy = (provider: any) => { // Override the result if it cannot be trusted if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -410,6 +468,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -451,6 +516,13 @@ const addWalletGuardProxy = (provider: any) => { const requestAsString = provider?.request?.toString(); if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; } @@ -495,9 +567,16 @@ const addWalletGuardProxy = (provider: any) => { } let chainId = await provider.request({ method: 'eth_chainId' }); - const requestAsString = provider?.request?.toString(); + const requestAsString = provider?.request?.toString() if (requestAsString !== 'function () { [native code] }') { + posthog.capture('window.ethereum.request override', { + requestAsString: requestAsString, + isMetaMask: window.ethereum.isMetaMask, + isPhantom: window?.phantom?.ethereum?.isPhantom, + isCoinbaseWallet: window?.ethereum?.isCoinbaseWallet, + isRabby: window.ethereum?.isRabby, + }); chainId = ''; }