Skip to content

Commit

Permalink
Fix: remove deprecated mobile pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 13, 2023
1 parent d95a943 commit 58e50c6
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 814 deletions.
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.

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
</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
19 changes: 1 addition & 18 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 @@ -43,7 +42,7 @@ export const getConnectedWallet = (wallets: WalletState[]): ConnectedWallet | nu
const primaryWallet = wallets[0]
if (!primaryWallet) return null

const account = primaryWallet.accounts[0]
const account = primaryWallet.accounts[primaryWallet.accounts.length - 1]
if (!account) return null

try {
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

0 comments on commit 58e50c6

Please sign in to comment.