Skip to content

Commit

Permalink
Feat: new connect button + deprecate mobile pairing (#2544)
Browse files Browse the repository at this point in the history
* Feat: new connect button + deprecate mobile pairing

* 15 November

* Text edits
  • Loading branch information
katspaugh authored Sep 26, 2023
1 parent 019ecae commit 508efd3
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 198 deletions.
26 changes: 26 additions & 0 deletions src/components/common/ConnectWallet/ConnectWalletButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Button } from '@mui/material'
import useConnectWallet from '@/components/common/ConnectWallet/useConnectWallet'

const ConnectWalletButton = ({ onConnect }: { onConnect?: () => void }): React.ReactElement => {
const connectWallet = useConnectWallet()

const handleConnect = () => {
onConnect?.()
connectWallet()
}

return (
<Button
onClick={handleConnect}
variant="contained"
size="small"
disableElevation
fullWidth
sx={{ fontSize: ['12px', '13px'] }}
>
Connect
</Button>
)
}

export default ConnectWalletButton
78 changes: 0 additions & 78 deletions src/components/common/ConnectWallet/ConnectionCenter.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions src/components/common/ConnectWallet/WalletDetails.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/common/ConnectWallet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { ReactElement } from 'react'
import useWallet from '@/hooks/wallets/useWallet'
import AccountCenter from '@/components/common/ConnectWallet/AccountCenter'
import ConnectionCenter from '@/components/common/ConnectWallet/ConnectionCenter'
import ConnectWalletButton from './ConnectWalletButton'

const ConnectWallet = (): ReactElement => {
const wallet = useWallet()

return wallet ? <AccountCenter wallet={wallet} /> : <ConnectionCenter />
return wallet ? <AccountCenter wallet={wallet} /> : <ConnectWalletButton />
}

export default ConnectWallet
23 changes: 0 additions & 23 deletions src/components/common/ConnectWallet/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.connectedContainer {
display: flex;
align-items: center;
}

.buttonContainer {
display: flex;
align-items: center;
Expand Down Expand Up @@ -46,21 +41,3 @@
.row:last-of-type {
border-bottom: 1px solid var(--color-border-light);
}

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

@media (max-width: 599.95px) {
.buttonContainer {
transform: scale(0.8);
}

.notConnected,
.pairingDetails {
display: none;
}
}
12 changes: 12 additions & 0 deletions src/components/common/PairingDetails/PairingDeprecationWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Alert } from '@mui/material'

const PairingDeprecationWarning = (): React.ReactElement => {
return (
<Alert severity="warning" sx={{ mb: 4 }}>
The {'Safe{Wallet}'} web-mobile pairing feature will be discontinued from 15th November 2023. Please migrate to a
different signer wallet before this date.
</Alert>
)
}

export default PairingDeprecationWarning
35 changes: 0 additions & 35 deletions src/components/common/PairingDetails/index.tsx

This file was deleted.

39 changes: 7 additions & 32 deletions src/components/new-safe/create/steps/ConnectWalletStep/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { useEffect, useState } from 'react'
import { Box, Button, Grid, Typography } from '@mui/material'
import { Box, Button } from '@mui/material'
import useWallet from '@/hooks/wallets/useWallet'
import { useCurrentChain } from '@/hooks/useChains'
import { isPairingSupported } from '@/services/pairing/utils'

import type { NewSafeFormData } from '@/components/new-safe/create'
import type { StepRenderProps } from '@/components/new-safe/CardStepper/useCardStepper'
import useSyncSafeCreationStep from '@/components/new-safe/create/useSyncSafeCreationStep'
import layoutCss from '@/components/new-safe/create/styles.module.css'
import useConnectWallet from '@/components/common/ConnectWallet/useConnectWallet'
import KeyholeIcon from '@/components/common/icons/KeyholeIcon'
import PairingDescription from '@/components/common/PairingDetails/PairingDescription'
import PairingQRCode from '@/components/common/PairingDetails/PairingQRCode'
import { usePendingSafe } from '../StatusStep/usePendingSafe'

const ConnectWalletStep = ({ onSubmit, setStep }: StepRenderProps<NewSafeFormData>) => {
const [pendingSafe] = usePendingSafe()
const wallet = useWallet()
const chain = useCurrentChain()
const isSupported = isPairingSupported(chain?.disabledWallets)
const handleConnect = useConnectWallet()
const [, setSubmitted] = useState(false)
useSyncSafeCreationStep(setStep)
Expand All @@ -34,31 +28,12 @@ const ConnectWalletStep = ({ onSubmit, setStep }: StepRenderProps<NewSafeFormDat
}, [onSubmit, wallet, pendingSafe])

return (
<>
<Box className={layoutCss.row}>
<Grid container spacing={3}>
<Grid item xs={12} md={6} display="flex" flexDirection="column" alignItems="center" gap={2}>
<Box width={100} height={100} display="flex" alignItems="center" justifyContent="center">
<KeyholeIcon />
</Box>

<Button onClick={handleConnect} variant="contained" size="stretched" disableElevation>
Connect
</Button>
</Grid>

{isSupported && (
<Grid item xs={12} md={6} display="flex" flexDirection="column" alignItems="center" gap={2}>
<PairingQRCode />
<Typography variant="h6" fontWeight="700">
Connect to {'Safe{Wallet}'} mobile
</Typography>
<PairingDescription />
</Grid>
)}
</Grid>
</Box>
</>
<Box className={layoutCss.row} display="flex" alignItems="center" gap={3}>
<KeyholeIcon />
<Button onClick={handleConnect} variant="contained" size="stretched" disableElevation>
Connect wallet
</Button>
</Box>
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/services/pairing/QRModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { StoreHydrator } from '@/store'
import { AppProviders } from '@/pages/_app'
import { PAIRING_MODULE_LABEL } from '@/services/pairing/module'
import css from './styles.module.css'
import PairingDeprecationWarning from '@/components/common/PairingDetails/PairingDeprecationWarning'

const WRAPPER_ID = 'safe-mobile-qr-modal'
const QR_CODE_SIZE = 200
Expand Down Expand Up @@ -75,6 +76,7 @@ const Modal = ({ uri, cb }: { uri: string; cb: () => void }) => {
</IconButton>
</DialogTitle>
<DialogContent sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 1 }}>
<PairingDeprecationWarning />
<PairingQRCode size={QR_CODE_SIZE} />
<br />
<PairingDescription />
Expand Down

0 comments on commit 508efd3

Please sign in to comment.