Skip to content

Commit 9735a51

Browse files
committed
wallet integrated ui
1 parent 48c5a4c commit 9735a51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1708
-96
lines changed

packages/react-connect/src/hooks/useWaasFeeOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type UseWaasFeeOptionsReturn = [
4949
*/
5050
export interface WaasFeeOptionsConfig {
5151
/** Whether to skip checking token balances (default: false) */
52-
skipFeeBalanceCheck?: boolean;
52+
skipFeeBalanceCheck?: boolean
5353
}
5454

5555
/**
@@ -73,7 +73,7 @@ export interface WaasFeeOptionsConfig {
7373
* ] = useWaasFeeOptions();
7474
*
7575
* // Or skip balance checking if needed
76-
* // const [pendingFeeOptionConfirmation, confirmPendingFeeOption, rejectPendingFeeOption] =
76+
* // const [pendingFeeOptionConfirmation, confirmPendingFeeOption, rejectPendingFeeOption] =
7777
* // useWaasFeeOptions({ skipFeeBalanceCheck: true });
7878
*
7979
* const [selectedFeeOptionTokenName, setSelectedFeeOptionTokenName] = useState<string>();

packages/react-connect/src/hooks/useWallets.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client'
22

33
import { SequenceAPIClient, GetLinkedWalletsArgs, LinkedWallet } from '@0xsequence/api'
4+
import { IconProps } from '@0xsequence/design-system'
45
import { useCallback, useEffect, useRef, useState } from 'react'
56
import { Connector, type UseConnectionsReturnType, useAccount, useConnect, useConnections, useDisconnect } from 'wagmi'
67

@@ -131,6 +132,9 @@ export interface ConnectedWallet {
131132
address: string
132133
isActive: boolean
133134
isEmbedded: boolean
135+
signInMethod: string
136+
logoDark: React.ComponentType<IconProps>
137+
logoLight: React.ComponentType<IconProps>
134138
}
135139

136140
export const useWallets = () => {
@@ -172,7 +176,10 @@ export const useWallets = () => {
172176
name: getConnectorName(connection.connector),
173177
address: connection.accounts[0],
174178
isActive: connection.accounts[0] === address,
175-
isEmbedded: connection.connector.id.includes('waas')
179+
isEmbedded: connection.connector.id.includes('waas'),
180+
signInMethod: (connection.connector._wallet as any)?.id,
181+
logoDark: (connection.connector._wallet as any)?.logoDark,
182+
logoLight: (connection.connector._wallet as any)?.logoLight
176183
}))
177184

178185
const setActiveWallet = async (walletAddress: string) => {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { GradientAvatar } from '@0xsequence/design-system'
2+
3+
export const GradientAvatarList = ({ accountAddressList, size = 'xs' }: { accountAddressList: string[]; size?: 'xs' | 'md' }) => {
4+
const firstThreeAddresses = accountAddressList.slice(0, 3)
5+
const width = size === 'xs' ? firstThreeAddresses.length * 6 + 6 : firstThreeAddresses.length * 12 + 20
6+
7+
return (
8+
<div className="flex flex-row relative" style={{ position: 'relative', width: `${width}px` }}>
9+
{firstThreeAddresses.map((accountAddress, index) => (
10+
<div
11+
key={accountAddress}
12+
style={{
13+
position: 'absolute',
14+
top: '50%',
15+
left: `${index * (size === 'xs' ? 6 : 12)}px`,
16+
transform: 'translateY(-50%)'
17+
}}
18+
>
19+
<GradientAvatar size={size} address={accountAddress || ''} />
20+
</div>
21+
))}
22+
</div>
23+
)
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { cn, cardVariants } from '@0xsequence/design-system'
2+
3+
import { SelectedIndicator } from './SelectedIndicator'
4+
5+
export const SelectRow = ({
6+
isSelected,
7+
children,
8+
onClick
9+
}: {
10+
isSelected: boolean
11+
children: React.ReactNode
12+
onClick: () => void
13+
}) => {
14+
return (
15+
<div
16+
className={cn(cardVariants({ clickable: true }), 'flex flex-row justify-between items-center')}
17+
style={{ height: '60px' }}
18+
onClick={onClick}
19+
>
20+
<div className="flex flex-row items-center gap-2">{children}</div>
21+
<SelectedIndicator selected={isSelected} />
22+
</div>
23+
)
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { CheckmarkIcon } from '@0xsequence/design-system'
2+
import { motion } from 'motion/react'
3+
4+
interface SelectedIndicatorProps {
5+
selected: boolean
6+
className?: string
7+
}
8+
9+
export const SelectedIndicator = (props: SelectedIndicatorProps) => {
10+
const { selected, className } = props
11+
return (
12+
<div className={`${className} border-2 border-border-normal bg-background-muted rounded-full ml-4 relative shrink-0 w-8 h-8`}>
13+
<motion.div
14+
className="flex bg-background-inverse absolute items-center justify-center rounded-full text-inverse w-8 h-8"
15+
initial={{ opacity: selected ? 1 : 0, scale: selected ? 1 : 0.5 }}
16+
animate={{ opacity: selected ? 1 : 0, scale: selected ? 1 : 0.5 }}
17+
transition={{ ease: 'backOut' }}
18+
style={{
19+
top: '-2px',
20+
left: '-2px'
21+
}}
22+
>
23+
<CheckmarkIcon />
24+
</motion.div>
25+
</div>
26+
)
27+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { ChevronRightIcon, Text } from '@0xsequence/design-system'
2+
import { cardVariants } from '@0xsequence/design-system'
3+
import { cn } from '@0xsequence/design-system'
4+
import { formatAddress, ConnectedWallet } from '@0xsequence/react-connect'
5+
6+
import { WalletAccountGradient } from './WalletAccountGradient'
7+
8+
export const SelectWalletRow = ({
9+
wallet,
10+
setActiveWallet,
11+
onClose
12+
}: {
13+
wallet: ConnectedWallet
14+
setActiveWallet: (address: string) => void
15+
onClose: () => void
16+
}) => {
17+
const onSelectWallet = () => {
18+
setActiveWallet(wallet.address)
19+
onClose()
20+
}
21+
22+
return (
23+
<div
24+
key={wallet.address}
25+
className={cn(
26+
cardVariants({ clickable: true }),
27+
'flex flex-row justify-between items-center p-3',
28+
wallet.isActive ? 'bg-background-secondary' : 'bg-background-muted'
29+
)}
30+
onClick={onSelectWallet}
31+
>
32+
<div className="flex flex-row gap-2 items-center">
33+
<WalletAccountGradient accountAddress={wallet.address} loginIcon={wallet.logoDark} size={'small'} />
34+
<div className="flex flex-col">
35+
<Text color="primary" fontWeight="medium" variant="normal">
36+
{formatAddress(wallet.address)}
37+
</Text>
38+
<Text color="primary" fontWeight="medium" variant="small">
39+
{wallet.id}
40+
</Text>
41+
</div>
42+
</div>
43+
<ChevronRightIcon color="white" />
44+
</div>
45+
)
46+
}

packages/react-wallet/src/components/SequenceWalletProvider/SequenceWalletProvider.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { History, Navigation, NavigationContextProvider, WalletModalContextProvi
1111

1212
import { getHeader, getContent } from './utils'
1313

14+
export const WALLET_WIDTH = 400
15+
1416
export type SequenceWalletProviderProps = {
1517
children: React.ReactNode
1618
}
@@ -55,7 +57,13 @@ export const WalletContent = ({ children }: SequenceWalletProviderProps) => {
5557
navigation.location === 'history' ||
5658
navigation.location === 'search' ||
5759
navigation.location === 'search-view-all' ||
58-
navigation.location === 'settings-currency'
60+
navigation.location === 'settings' ||
61+
navigation.location === 'settings-wallets' ||
62+
navigation.location === 'settings-profiles' ||
63+
navigation.location === 'settings-apps' ||
64+
navigation.location === 'legacy-settings-currency' ||
65+
navigation.location === 'search-tokens' ||
66+
navigation.location === 'search-collectibles'
5967

6068
return (
6169
<WalletModalContextProvider value={{ setOpenWalletModal, openWalletModalState: openWalletModal }}>
@@ -66,7 +74,7 @@ export const WalletContent = ({ children }: SequenceWalletProviderProps) => {
6674
<Modal
6775
contentProps={{
6876
style: {
69-
maxWidth: '400px',
77+
maxWidth: WALLET_WIDTH,
7078
height: 'fit-content',
7179
...getModalPositionCss(position),
7280
scrollbarColor: 'gray black',

packages/react-wallet/src/components/SequenceWalletProvider/utils/index.tsx

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react'
2-
31
import { Navigation } from '../../../contexts'
42
import {
53
CoinDetails,
@@ -12,21 +10,29 @@ import {
1210
History,
1311
SearchWallet,
1412
SearchWalletViewAll,
15-
SettingsMenu,
16-
SettingsCurrency,
17-
SettingsNetwork,
18-
SettingsGeneral,
13+
LegacySettingsMenu,
14+
LegacySettingsCurrency,
15+
LegacySettingsNetwork,
16+
LegacySettingsGeneral,
1917
TransactionDetails,
2018
SwapCoin,
21-
SwapList
19+
SwapList,
20+
SearchTokens,
21+
SearchCollectibles
2222
} from '../../../views'
23+
import { SettingsWallets } from '../../../views/Settings'
24+
import { SettingsApps } from '../../../views/Settings/Apps'
25+
import { SettingsMenu } from '../../../views/Settings/Menu'
26+
import { SettingsProfiles } from '../../../views/Settings/Profiles'
2327
import { NavigationHeader } from '../../NavigationHeader'
2428
import { WalletHeader } from '../../WalletHeader'
2529

2630
export const getContent = (navigation: Navigation) => {
2731
const { location } = navigation
2832

2933
switch (location) {
34+
case 'send':
35+
return <History />
3036
case 'send-coin':
3137
return <SendCoin chainId={navigation.params.chainId} contractAddress={navigation.params.contractAddress} />
3238
case 'send-collectible':
@@ -37,22 +43,38 @@ export const getContent = (navigation: Navigation) => {
3743
tokenId={navigation.params.tokenId}
3844
/>
3945
)
46+
case 'swap':
47+
return <History />
4048
case 'receive':
4149
return <Receive />
50+
case 'buy':
51+
return <History />
4252
case 'history':
4353
return <History />
4454
case 'search':
4555
return <SearchWallet />
4656
case 'search-view-all':
4757
return <SearchWalletViewAll defaultTab={navigation.params.defaultTab} />
58+
case 'search-tokens':
59+
return <SearchTokens />
60+
case 'search-collectibles':
61+
return <SearchCollectibles />
4862
case 'settings':
4963
return <SettingsMenu />
50-
case 'settings-general':
51-
return <SettingsGeneral />
52-
case 'settings-currency':
53-
return <SettingsCurrency />
54-
case 'settings-networks':
55-
return <SettingsNetwork />
64+
case 'settings-wallets':
65+
return <SettingsWallets />
66+
case 'settings-profiles':
67+
return <SettingsProfiles />
68+
case 'settings-apps':
69+
return <SettingsApps />
70+
case 'legacy-settings':
71+
return <LegacySettingsMenu />
72+
case 'legacy-settings-general':
73+
return <LegacySettingsGeneral />
74+
case 'legacy-settings-currency':
75+
return <LegacySettingsCurrency />
76+
case 'legacy-settings-networks':
77+
return <LegacySettingsNetwork />
5678
case 'coin-details':
5779
return <CoinDetails contractAddress={navigation.params.contractAddress} chainId={navigation.params.chainId} />
5880
case 'collectible-details':
@@ -77,6 +99,7 @@ export const getContent = (navigation: Navigation) => {
7799
amount={navigation.params.amount}
78100
/>
79101
)
102+
case 'home':
80103
default:
81104
return <Home />
82105
}
@@ -89,16 +112,18 @@ export const getHeader = (navigation: Navigation) => {
89112
return <NavigationHeader primaryText="Search wallet" />
90113
case 'search-view-all':
91114
return <NavigationHeader secondaryText="Search wallet / " primaryText="View all" />
92-
case 'settings':
115+
case 'search-tokens':
116+
return <NavigationHeader primaryText="Search tokens" />
117+
case 'search-collectibles':
118+
return <NavigationHeader primaryText="Search collectibles" />
119+
case 'legacy-settings':
93120
return <NavigationHeader secondaryText="Wallet / " primaryText="Settings" />
94-
case 'settings-general':
121+
case 'legacy-settings-general':
95122
return <NavigationHeader secondaryText="Wallet / Settings / " primaryText="General" />
96-
case 'settings-currency':
123+
case 'legacy-settings-currency':
97124
return <NavigationHeader secondaryText="Wallet / Settings / " primaryText="Currency" />
98-
case 'settings-networks':
125+
case 'legacy-settings-networks':
99126
return <NavigationHeader secondaryText="Wallet / Settings / " primaryText="Networks" />
100-
case 'receive':
101-
return <NavigationHeader secondaryText="Wallet / " primaryText="Receive" />
102127
case 'history':
103128
return <NavigationHeader secondaryText="Wallet / " primaryText="History" />
104129
case 'coin-details':
@@ -107,12 +132,22 @@ export const getHeader = (navigation: Navigation) => {
107132
return <WalletHeader />
108133
case 'transaction-details':
109134
return <NavigationHeader secondaryText="" primaryText="" />
110-
case 'send-collectible':
111-
case 'send-coin':
135+
case 'send':
112136
return <NavigationHeader secondaryText="Wallet / " primaryText="Send" />
137+
case 'send-coin':
138+
return <NavigationHeader secondaryText="Wallet / " primaryText="Send Coin" />
139+
case 'send-collectible':
140+
return <NavigationHeader secondaryText="Wallet / " primaryText="Send Collectible" />
141+
case 'swap':
142+
return <NavigationHeader secondaryText="Wallet / " primaryText="Swap" />
113143
case 'swap-coin':
114144
case 'swap-coin-list':
115145
return <NavigationHeader secondaryText="Wallet / " primaryText="Buy" />
146+
case 'receive':
147+
return <NavigationHeader secondaryText="Wallet / " primaryText="Receive" />
148+
case 'buy':
149+
return <NavigationHeader secondaryText="Wallet / " primaryText="Add Funds" />
150+
case 'home':
116151
default:
117152
return <WalletHeader />
118153
}

0 commit comments

Comments
 (0)