Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove deprecated mobile pairing #2794

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/common/AppStoreButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { MOBILE_APP_EVENTS, trackEvent } from '@/services/analytics'

// App Store campaigns track the user interaction
enum LINKS {
pairing = 'https://apps.apple.com/app/apple-store/id1515759131?pt=119497694&ct=Web%20App%20Connect&mt=8',
footer = 'https://apps.apple.com/app/apple-store/id1515759131?pt=119497694&ct=Web%20App%20Footer&mt=8',
}

Expand Down
7 changes: 0 additions & 7 deletions src/components/common/ConnectWallet/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@
border-bottom: 1px solid var(--color-border-light);
}

.pairingDetails {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--space-2);
}

.loginButton {
min-height: 42px;
}
Expand Down
12 changes: 0 additions & 12 deletions src/components/common/PairingDetails/PairingDeprecationWarning.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/common/PairingDetails/PairingDescription.tsx

This file was deleted.

53 changes: 0 additions & 53 deletions src/components/common/PairingDetails/PairingQRCode.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/common/WalletInfo/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
expect(mockOnboard.disconnectWallet).toHaveBeenCalled()
})

it('should display a Delete Account button on dev for social login', () => {

Check failure on line 92 in src/components/common/WalletInfo/index.test.tsx

View workflow job for this annotation

GitHub Actions / Tests annotations (🧪 jest-coverage-report-action)

WalletInfo > should display a Delete Account button on dev for social login

TestingLibraryElementError: Unable to find an element with the text: Delete Account. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <div class="container MuiBox-root css-0" > <div class="accountContainer MuiBox-root css-0" > <span class="MuiSkeleton-root MuiSkeleton-rectangular MuiSkeleton-pulse css-1jqhpi8-MuiSkeleton-root" style="width: 100%; height: 22px;" /> <div class="addressContainer MuiBox-root css-0" > <a href="/settings/security-login" > <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedWarning MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-disableElevation MuiButton-fullWidth MuiButton-root MuiButton-contained MuiButton-containedWarning MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-disableElevation MuiButton-fullWidth warningButton css-nfsdpt-MuiButtonBase-root-MuiButton-root" tabindex="0" type="button" > <span class="MuiButton-startIcon MuiButton-iconSizeMedium css-gcc2o7-MuiButton-startIcon" > <mock-icon /> </span> Add multifactor authentication <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" /> </button> </a> </div> </div> <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeSmall MuiButton-containedSizeSmall MuiButton-fullWidth MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeSmall MuiButton-containedSizeSmall MuiButton-fullWidth css-193jcx1-MuiButtonBase-root-MuiButton-root" tabindex="0" type="button" > Switch wallet <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" /> </button> <button class="MuiButtonBase-root MuiButton-root MuiButton-danger MuiButton-dangerPrimary MuiButton-sizeSmall MuiButton-dangerSizeSmall MuiButton-disableElevation MuiButton-fullWidth MuiButton-root MuiButton-danger MuiButton-dangerPrimary MuiButton-sizeSmall MuiButton-dangerSizeSmall MuiButton-disableElevation MuiButton-fullWidth css-1gbexdt-MuiButtonBase-root-MuiButton-root" tabindex="0" type="button" > Disconnect <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" /> </button> <button class="MuiButtonBase-root MuiButton-root MuiButton-danger MuiButton-dangerPrimary MuiButton-sizeSmall MuiButton-dangerSizeSmall MuiButton-disableElevation MuiButton-fullWidth MuiButton-root MuiButton-danger MuiButton-dangerPrimary MuiButton-sizeSmall MuiButton-dangerSizeSmall MuiButton-disableElevation MuiButton-fullWidth css-1gbexdt-MuiButtonBase-root-MuiButton-root" tabindex="0" type="button" > Delete account <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" /> </button> </div> </div> </body> at Object.getElementError (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/@testing-library/dom/dist/config.js:37:19) at /home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/@testing-library/dom/dist/query-helpers.js:76:38 at /home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/@testing-library/dom/dist/query-helpers.js:52:17 at /home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/@testing-library/dom/dist/query-helpers.js:95:19 at Object.getByText (/home/runner/work/safe-wallet-web/safe-wallet-web/src/components/common/WalletInfo/index.test.tsx:107:12) at Promise.then.completed (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/utils.js:298:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/utils.js:231:10) at _callCircusTest (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/run.js:316:40) at _runTest (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/run.js:252:3) at _runTestsForDescribeBlock (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/run.js:126:9) at _runTestsForDescribeBlock (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/run.js:121:9) at run (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/run.js:71:3) at runAndTransformResultsToJestFormat (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/safe-wallet-web/safe-wallet-web/node_modules/jest-runner/build/runTest.js:444:34)
jest.spyOn(mpcModule, 'isSocialLoginWallet').mockReturnValue(true)
jest.spyOn(constants, 'IS_PRODUCTION', 'get').mockImplementation(() => false)

Expand Down Expand Up @@ -122,7 +122,7 @@
/>,
)

expect(queryByText('Delete Account')).not.toBeInTheDocument()
expect(queryByText('Delete account')).not.toBeInTheDocument()
})

it('should not display a Delete Account if not social login', () => {
Expand All @@ -140,7 +140,7 @@
/>,
)

expect(queryByText('Delete Account')).not.toBeInTheDocument()
expect(queryByText('Delete account')).not.toBeInTheDocument()
})

it('should display an enable mfa button if mfa is not enabled', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/components/common/WalletInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ export const WalletInfo = ({
const isSocialLogin = isSocialLoginWallet(wallet.label)

return (
<>
<Box className={css.container}>
<Box className={css.accountContainer}>
<ChainIndicator />

<Box className={css.addressContainer}>
{isSocialLogin ? (
<>
Expand Down Expand Up @@ -108,10 +109,10 @@ export const WalletInfo = ({

{!IS_PRODUCTION && isSocialLogin && (
<Button onClick={resetAccount} variant="danger" size="small" fullWidth disableElevation>
Delete Account
Delete account
katspaugh marked this conversation as resolved.
Show resolved Hide resolved
</Button>
)}
</>
</Box>
)
}

Expand Down
7 changes: 7 additions & 0 deletions src/components/common/WalletInfo/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.container {
width: 100%;
display: flex;
flex-direction: column;
gap: var(--space-2);
}

.accountContainer {
width: 100%;
margin-bottom: var(--space-1);
Expand Down
4 changes: 2 additions & 2 deletions src/components/walletconnect/WcSessionList/WcNoSessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const WcSampleDapps = ({ onUnload }: { onUnload: () => void }) => {
return (
<Typography variant="body2" display="flex" justifyContent="space-between" alignItems="center" mt={3}>
{SAMPLE_DAPPS.map((item) => (
<Typography variant="body2" ml={1} key={item.url}>
<Typography variant="body2" key={item.url}>
<ExternalLink href={item.url} noIcon px={1}>
<img src={item.icon} alt={item.name} width={32} height={32} />
<img src={item.icon} alt={item.name} width={32} height={32} style={{ marginRight: '0.5em' }} />
{item.name}
</ExternalLink>
</Typography>
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/wallets/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const enum WALLET_KEYS {
WALLETCONNECT_V2 = 'WALLETCONNECT_V2',
SOCIAL = 'SOCIAL_LOGIN',
COINBASE = 'COINBASE',
PAIRING = 'PAIRING',
LEDGER = 'LEDGER',
TREZOR = 'TREZOR',
KEYSTONE = 'KEYSTONE',
Expand All @@ -14,7 +13,6 @@ export const CGW_NAMES: { [key in WALLET_KEYS]: string | undefined } = {
[WALLET_KEYS.INJECTED]: 'detectedwallet',
[WALLET_KEYS.WALLETCONNECT_V2]: 'walletConnect_v2',
[WALLET_KEYS.COINBASE]: 'coinbase',
[WALLET_KEYS.PAIRING]: 'safeMobile',
[WALLET_KEYS.SOCIAL]: 'socialSigner',
[WALLET_KEYS.LEDGER]: 'ledger',
[WALLET_KEYS.TREZOR]: 'trezor',
Expand Down
17 changes: 0 additions & 17 deletions src/hooks/wallets/useOnboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useChains, { useCurrentChain } from '@/hooks/useChains'
import ExternalStore from '@/services/ExternalStore'
import { logError, Errors } from '@/services/exceptions'
import { trackEvent, WALLET_EVENTS } from '@/services/analytics'
import { useInitPairing } from '@/services/pairing/hooks'
import { useAppSelector } from '@/store'
import { type EnvState, selectRpc } from '@/store/settingsSlice'
import { E2E_WALLET_NAME } from '@/tests/e2e-wallet'
Expand Down Expand Up @@ -93,21 +92,11 @@ const isMobile = () => /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)
// Detect injected wallet
const hasInjectedWallet = () => typeof window !== 'undefined' && !!window?.ethereum

// `connectWallet` is called when connecting/switching wallets and on pairing `connect` event (when prev. session connects)
// This re-entrant lock prevents multiple `connectWallet`/tracking calls that would otherwise occur for pairing module
let isConnecting = false

// Wrapper that tracks/sets the last used wallet
export const connectWallet = async (
onboard: OnboardAPI,
options?: Parameters<OnboardAPI['connectWallet']>[0],
): Promise<WalletState[] | undefined> => {
if (isConnecting) {
return
}

isConnecting = true

// On mobile, automatically choose WalletConnect if there is no injected wallet
if (!options && isMobile() && !hasInjectedWallet()) {
options = {
Expand All @@ -121,13 +110,9 @@ export const connectWallet = async (
wallets = await onboard.connectWallet(options)
} catch (e) {
logError(Errors._302, e)

isConnecting = false
return
}

isConnecting = false

return wallets
}

Expand All @@ -153,8 +138,6 @@ export const useInitOnboard = () => {
const onboard = useStore()
const customRpc = useAppSelector(selectRpc)

useInitPairing()

useEffect(() => {
if (configs.length > 0 && chain) {
void initOnboard(configs, chain, customRpc)
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/wallets/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ledgerModule from '@web3-onboard/ledger/dist/index'
import trezorModule from '@web3-onboard/trezor'
import walletConnect from '@web3-onboard/walletconnect'

import pairingModule from '@/services/pairing/module'
import e2eWalletModule from '@/tests/e2e-wallet'
import { CGW_NAMES, WALLET_KEYS } from './consts'
import MpcModule from '@/services/mpc/SocialLoginModule'
Expand Down Expand Up @@ -42,7 +41,6 @@ const WALLET_MODULES: { [key in WALLET_KEYS]: (chain: ChainInfo) => WalletInit }
[WALLET_KEYS.INJECTED]: () => injectedWalletModule(),
[WALLET_KEYS.WALLETCONNECT_V2]: (chain) => walletConnectV2(chain),
[WALLET_KEYS.COINBASE]: () => coinbaseModule({ darkMode: prefersDarkMode() }),
[WALLET_KEYS.PAIRING]: () => pairingModule(),
[WALLET_KEYS.SOCIAL]: (chain) => MpcModule(chain),
[WALLET_KEYS.LEDGER]: () => ledgerModule(),
[WALLET_KEYS.TREZOR]: () => trezorModule({ appUrl: TREZOR_APP_URL, email: TREZOR_EMAIL }),
Expand Down
3 changes: 0 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { WalletConnectProvider } from '@/services/walletconnect/WalletConnectCon
import useABTesting from '@/services/tracking/useAbTesting'
import { AbTest } from '@/services/tracking/abTesting'
import { useNotificationTracking } from '@/components/settings/PushNotifications/hooks/useNotificationTracking'
import MobilePairingModal from '@/services/pairing/QRModal'

const GATEWAY_URL = IS_PRODUCTION || cgwDebugStorage.get() ? GATEWAY_URL_PRODUCTION : GATEWAY_URL_STAGING

Expand Down Expand Up @@ -126,8 +125,6 @@ const WebCoreApp = ({

<Notifications />

<MobilePairingModal />

<PasswordRecoveryModal />
</AppProviders>
</CacheProvider>
Expand Down
1 change: 0 additions & 1 deletion src/services/exceptions/ErrorCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ enum ErrorCodes {
_106 = '106: Failed to get connected wallet',

_302 = '302: Error connecting to the wallet',
_303 = '303: Error creating pairing session',
_304 = '304: Error enabling MFA',
_305 = '305: Error exporting account key',
_306 = '306: Error logging in',
Expand Down
55 changes: 0 additions & 55 deletions src/services/pairing/QRModal.tsx

This file was deleted.

Loading
Loading