Skip to content

Commit

Permalink
email prompt for dapp mode
Browse files Browse the repository at this point in the history
  • Loading branch information
SamueleA committed Aug 3, 2023
1 parent e61369c commit 2a2fa5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import * as styles from '../../styles.css'

interface ExtendedWalletListProps {
theme: Theme
onConnect: (connector: ExtendedConnector) => void
}

export const ExtendedWalletList = ({
theme
theme,
onConnect,
}: ExtendedWalletListProps) => {
const { connectors: baseConnectors, connect, isLoading } = useConnect()
const connectors = baseConnectors as ExtendedConnector[]
Expand Down Expand Up @@ -45,7 +47,7 @@ export const ExtendedWalletList = ({
height: '60px',
}}
className={styles.networkButton}
onClick={() => connect({ connector })}
onClick={() => onConnect(connector)}
>
<Text variant="medium">
{walletName}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react'

import { EMAIL_CONNECTOR_LOCAL_STORAGE_KEY } from '@0xsequence/kit-connectors'
import { Box, Image, Text, vars, ChevronLeftIcon, ChevronRightIcon } from '@0xsequence/design-system'
import { useConnect } from 'wagmi'

Expand All @@ -24,6 +25,14 @@ export const WalletList = ({
const connectors = baseConnectors as ExtendedConnector[]
const displayExtendedListButton = connectors.length > 6

const onConnect = (connector: ExtendedConnector) => {
if (connector._wallet.id === 'email') {
const email = prompt('Auto-email login, please specify the email address:')
localStorage.setItem(EMAIL_CONNECTOR_LOCAL_STORAGE_KEY, email || '')
}
connect({ connector })
}

if (showExtendedList) {
return (
<>
Expand All @@ -36,7 +45,7 @@ export const WalletList = ({
>
<ChevronLeftIcon />
</Box>
<ExtendedWalletList theme={theme} />
<ExtendedWalletList onConnect={onConnect} theme={theme} />
</>
)
}
Expand Down Expand Up @@ -82,7 +91,7 @@ export const WalletList = ({
width: `calc(50% - ${vars.space[2]})`
}}
className={styles.networkButton}
onClick={() => connect({ connector })}
onClick={() => onConnect(connector)}
>
<Box
marginTop="3"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a2fa5e

Please sign in to comment.