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

Feat: new connect button + deprecate mobile pairing #2544

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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