Skip to content

Commit 0c29832

Browse files
committed
added send, swap foundation
1 parent 8789e96 commit 0c29832

File tree

29 files changed

+342
-192
lines changed

29 files changed

+342
-192
lines changed

packages/wallet-widget/src/components/IconWrappers/StackedIconTag.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const StackedIconTag = ({
2020
style={{ height: '28px', gap: '3px' }}
2121
onClick={onClick}
2222
>
23-
<MediaIconWrapper iconList={iconList} isAccount={isAccount} shape={shape} size="4xs" />
23+
{iconList.length > 0 && <MediaIconWrapper iconList={iconList} isAccount={isAccount} shape={shape} size="4xs" />}
2424
{label}
2525
</div>
2626
)

packages/wallet-widget/src/components/ListCard/ListCardNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ListCardNav = ({
2626

2727
<div className="flex flex-row gap-1 items-center">
2828
{rightChildren}
29-
<ChevronRightIcon color="white" size="lg" />
29+
<ChevronRightIcon color="white" />
3030
</div>
3131
</div>
3232
)

packages/wallet-widget/src/components/ListCard/ListCardSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const ListCardSelect = ({
1717
shape?: 'rounded' | 'square'
1818
style?: React.CSSProperties
1919
type?: 'radio' | 'custom'
20-
isSelected: boolean
20+
isSelected?: boolean
2121
disabled?: boolean
2222
onClick?: () => void
2323
}) => {

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Modal, Scroll } from '@0xsequence/design-system'
66
import { AnimatePresence } from 'motion/react'
77
import React, { useState } from 'react'
88

9-
import { HEADER_HEIGHT } from '../../constants'
9+
import { HEADER_HEIGHT, HEADER_HEIGHT_WITH_LABEL } from '../../constants'
1010
import { History, Navigation, NavigationContextProvider, WalletModalContextProvider, WalletOptions } from '../../contexts'
1111

1212
import { getHeader, getContent } from './utils'
@@ -50,6 +50,8 @@ export const WalletContent = ({ children }: SequenceWalletProviderProps) => {
5050

5151
const displayScrollbar =
5252
navigation.location === 'home' ||
53+
navigation.location === 'send-general' ||
54+
navigation.location === 'swap' ||
5355
navigation.location === 'collection-details' ||
5456
navigation.location === 'collectible-details' ||
5557
navigation.location === 'coin-details' ||
@@ -61,11 +63,27 @@ export const WalletContent = ({ children }: SequenceWalletProviderProps) => {
6163
navigation.location === 'settings-networks' ||
6264
navigation.location === 'settings-currency' ||
6365
navigation.location === 'settings-profiles' ||
66+
navigation.location === 'settings-preferences' ||
6467
navigation.location === 'settings-apps' ||
6568
navigation.location === 'legacy-settings-currency' ||
6669
navigation.location === 'search-tokens' ||
6770
navigation.location === 'search-collectibles'
6871

72+
let paddingTop = 0
73+
switch (navigation.location) {
74+
case 'home':
75+
paddingTop = 0
76+
break
77+
case 'send-general':
78+
paddingTop = HEADER_HEIGHT_WITH_LABEL
79+
break
80+
case 'swap':
81+
paddingTop = HEADER_HEIGHT_WITH_LABEL
82+
break
83+
default:
84+
paddingTop = HEADER_HEIGHT
85+
}
86+
6987
return (
7088
<WalletModalContextProvider value={{ setOpenWalletModal, openWalletModalState: openWalletModal }}>
7189
<NavigationContextProvider value={{ setHistory, history, isBackButtonEnabled, setIsBackButtonEnabled }}>
@@ -89,11 +107,7 @@ export const WalletContent = ({ children }: SequenceWalletProviderProps) => {
89107
{getHeader(navigation)}
90108

91109
{displayScrollbar ? (
92-
<Scroll
93-
style={{ paddingTop: navigation.location === 'home' ? '' : HEADER_HEIGHT, height: 'min(800px, 90vh)' }}
94-
>
95-
{getContent(navigation)}
96-
</Scroll>
110+
<Scroll style={{ paddingTop: paddingTop, height: 'min(800px, 90vh)' }}>{getContent(navigation)}</Scroll>
97111
) : (
98112
getContent(navigation)
99113
)}

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@ import {
2020
SearchTokens,
2121
SearchCollectibles
2222
} from '../../../views'
23+
import { SendGeneral } from '../../../views/SendGeneral'
2324
import { SettingsWallets } from '../../../views/Settings'
2425
import { SettingsApps } from '../../../views/Settings/Apps'
2526
import { SettingsCurrency } from '../../../views/Settings/Currency'
2627
import { SettingsMenu } from '../../../views/Settings/Menu'
2728
import { SettingsNetworks } from '../../../views/Settings/Networks'
29+
import { SettingsPreferences } from '../../../views/Settings/Preferences'
2830
import { SettingsProfiles } from '../../../views/Settings/Profiles'
2931
import { QrScan } from '../../../views/Settings/QrScan'
32+
import { Swap } from '../../../views/Swap'
3033
import { NavigationHeader } from '../../NavigationHeader'
3134
import { WalletHeader } from '../../WalletHeader'
3235

3336
export const getContent = (navigation: Navigation) => {
3437
const { location } = navigation
3538

3639
switch (location) {
37-
case 'send':
38-
return <History />
40+
case 'send-general':
41+
return <SendGeneral />
3942
case 'send-coin':
4043
return <SendCoin chainId={navigation.params.chainId} contractAddress={navigation.params.contractAddress} />
4144
case 'send-collectible':
@@ -47,7 +50,7 @@ export const getContent = (navigation: Navigation) => {
4750
/>
4851
)
4952
case 'swap':
50-
return <History />
53+
return <Swap />
5154
case 'receive':
5255
return <Receive />
5356
case 'history':
@@ -70,6 +73,8 @@ export const getContent = (navigation: Navigation) => {
7073
return <SettingsCurrency />
7174
case 'settings-profiles':
7275
return <SettingsProfiles />
76+
case 'settings-preferences':
77+
return <SettingsPreferences />
7378
case 'settings-apps':
7479
return <SettingsApps />
7580
case 'connect-dapp':
@@ -83,13 +88,21 @@ export const getContent = (navigation: Navigation) => {
8388
case 'legacy-settings-networks':
8489
return <LegacySettingsNetwork />
8590
case 'coin-details':
86-
return <CoinDetails contractAddress={navigation.params.contractAddress} chainId={navigation.params.chainId} />
91+
return (
92+
<CoinDetails
93+
contractAddress={navigation.params.contractAddress}
94+
chainId={navigation.params.chainId}
95+
accountAddress={navigation.params.accountAddress}
96+
/>
97+
)
98+
8799
case 'collectible-details':
88100
return (
89101
<CollectibleDetails
90102
contractAddress={navigation.params.contractAddress}
91103
chainId={navigation.params.chainId}
92104
tokenId={navigation.params.tokenId}
105+
accountAddress={navigation.params.accountAddress}
93106
/>
94107
)
95108
case 'collection-details':
@@ -141,6 +154,8 @@ export const getHeader = (navigation: Navigation) => {
141154
return <NavigationHeader primaryText="Currency" />
142155
case 'settings-profiles':
143156
return <NavigationHeader primaryText="Profiles" />
157+
case 'settings-preferences':
158+
return <NavigationHeader primaryText="Preferences" />
144159
case 'settings-apps':
145160
return <NavigationHeader primaryText="Apps" />
146161
case 'connect-dapp':
@@ -153,7 +168,7 @@ export const getHeader = (navigation: Navigation) => {
153168
return <WalletHeader />
154169
case 'transaction-details':
155170
return <NavigationHeader secondaryText="" primaryText="" />
156-
case 'send':
171+
case 'send-general':
157172
return <WalletHeader label="Send" />
158173
case 'send-coin':
159174
return <NavigationHeader secondaryText="Wallet / " primaryText="Send Coin" />
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { formatAddress } from '@0xsequence/connect'
2-
import { Text, GradientAvatar, ChevronDownIcon } from '@0xsequence/design-system'
2+
import { Text, GradientAvatar, ChevronDownIcon, Card } from '@0xsequence/design-system'
33
import React, { forwardRef } from 'react'
44
import { useAccount } from 'wagmi'
55

@@ -11,21 +11,18 @@ export const AccountInformation = forwardRef(({ onClickAccount }: AccountInforma
1111
const { address } = useAccount()
1212

1313
return (
14-
<div className="flex gap-2 items-center">
15-
<div className="flex w-full flex-col items-center justify-center">
16-
<div
17-
className="flex gap-2 items-center justify-center relative select-none cursor-pointer"
18-
onClick={onClickAccount}
19-
// @ts-ignore-next-line
20-
ref={ref}
21-
>
22-
<GradientAvatar size="sm" address={address || ''} />
23-
<Text color="primary" fontWeight="medium" variant="normal">
24-
{formatAddress(address || '')}
25-
</Text>
26-
<ChevronDownIcon className="text-primary" />
27-
</div>
28-
</div>
29-
</div>
14+
<Card
15+
className="flex gap-1 items-center justify-center select-none cursor-pointer rounded-full py-1 px-3"
16+
style={{ width: 'fit-content' }}
17+
onClick={onClickAccount}
18+
// @ts-ignore-next-line
19+
ref={ref}
20+
>
21+
<GradientAvatar size="sm" address={address || ''} />
22+
<Text color="primary" fontWeight="medium" variant="normal">
23+
{formatAddress(address || '')}
24+
</Text>
25+
<ChevronDownIcon className="text-primary" />
26+
</Card>
3027
)
3128
})

packages/wallet-widget/src/components/WalletHeader/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ChevronLeftIcon, IconButton, Text } from '@0xsequence/design-system'
33
import { AnimatePresence } from 'motion/react'
44
import { useState } from 'react'
55

6-
import { HEADER_HEIGHT } from '../../constants'
6+
import { HEADER_HEIGHT, HEADER_HEIGHT_WITH_LABEL } from '../../constants'
77
import { useNavigation } from '../../hooks'
88
import { SelectWalletRow } from '../SelectWalletRow'
99
import { SlideupDrawer } from '../SlideupDrawer'
@@ -32,9 +32,9 @@ export const WalletHeader = ({ label }: { label?: string }) => {
3232

3333
return (
3434
<div
35-
className="flex justify-between items-center fixed bg-background-primary w-full px-4 z-20 "
35+
className="flex flex-col justify-between items-center fixed bg-background-primary w-full p-4 z-20 "
3636
style={{
37-
height: HEADER_HEIGHT
37+
height: label ? HEADER_HEIGHT_WITH_LABEL : HEADER_HEIGHT
3838
}}
3939
>
4040
<div className="flex flex-row justify-between items-center w-full">
@@ -43,7 +43,7 @@ export const WalletHeader = ({ label }: { label?: string }) => {
4343
<div style={{ width: '28px' }} />
4444
</div>
4545
{label && (
46-
<Text variant="normal" color="primary" fontWeight="medium">
46+
<Text variant="normal" color="primary" fontWeight="bold">
4747
{label}
4848
</Text>
4949
)}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export const HEADER_HEIGHT = '60px'
1+
export const HEADER_HEIGHT = 60
2+
export const HEADER_HEIGHT_WITH_LABEL = 100

packages/wallet-widget/src/contexts/Navigation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createGenericContext } from './genericContext'
77
export interface CollectionDetailsParams {
88
contractAddress: string
99
chainId: number
10+
accountAddress: string
1011
}
1112

1213
export interface CollectionDetailsNavigation {
@@ -17,6 +18,7 @@ export interface CollectionDetailsNavigation {
1718
export interface CoinDetailsParams {
1819
contractAddress: string
1920
chainId: number
21+
accountAddress: string
2022
}
2123

2224
export interface CoinDetailsNavigation {
@@ -28,6 +30,7 @@ export interface CollectibleDetailsParams {
2830
contractAddress: string
2931
chainId: number
3032
tokenId: string
33+
accountAddress: string
3134
}
3235

3336
export interface CollectibleDetailsNavigation {
@@ -98,10 +101,9 @@ export interface SendCollectibleNavigation {
98101
export interface BasicNavigation {
99102
location:
100103
| 'home'
101-
| 'send'
104+
| 'send-general'
102105
| 'swap'
103106
| 'receive'
104-
| 'receive'
105107
| 'history'
106108
| 'legacy-settings'
107109
| 'legacy-settings-general'
@@ -113,6 +115,7 @@ export interface BasicNavigation {
113115
| 'settings-currency'
114116
| 'settings-profiles'
115117
| 'settings-apps'
118+
| 'settings-preferences'
116119
| 'connect-dapp'
117120
| 'search'
118121
| 'search-tokens'

packages/wallet-widget/src/views/CoinDetails/index.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { compareAddress, formatDisplay, getNativeTokenInfoByChainId, ContractVerificationStatus } from '@0xsequence/connect'
1+
import {
2+
compareAddress,
3+
formatDisplay,
4+
getNativeTokenInfoByChainId,
5+
ContractVerificationStatus,
6+
useWallets
7+
} from '@0xsequence/connect'
28
import { Button, SendIcon, SwapIcon, Text, TokenImage } from '@0xsequence/design-system'
39
import { useGetTokenBalancesSummary, useGetCoinPrices, useGetExchangeRate, useGetTransactionHistory } from '@0xsequence/hooks'
10+
import { useEffect } from 'react'
411
import { formatUnits, zeroAddress } from 'viem'
5-
import { useAccount, useConfig } from 'wagmi'
12+
import { useConfig } from 'wagmi'
613

714
import { InfiniteScroll } from '../../components/InfiniteScroll'
815
import { NetworkBadge } from '../../components/NetworkBadge'
@@ -16,13 +23,18 @@ import { CoinDetailsSkeleton } from './Skeleton'
1623
export interface CoinDetailsProps {
1724
contractAddress: string
1825
chainId: number
26+
accountAddress: string
1927
}
2028

21-
export const CoinDetails = ({ contractAddress, chainId }: CoinDetailsProps) => {
29+
export const CoinDetails = ({ contractAddress, chainId, accountAddress }: CoinDetailsProps) => {
2230
const { chains } = useConfig()
2331
const { setNavigation } = useNavigation()
32+
const { setActiveWallet } = useWallets()
2433
const { fiatCurrency, hideUnlistedTokens } = useSettings()
25-
const { address: accountAddress } = useAccount()
34+
35+
useEffect(() => {
36+
setActiveWallet(accountAddress || '')
37+
}, [accountAddress])
2638

2739
const isReadOnly = !chains.map(chain => chain.id).includes(chainId)
2840

@@ -118,6 +130,9 @@ export const CoinDetails = ({ contractAddress, chainId }: CoinDetailsProps) => {
118130
</Text>
119131
<NetworkBadge chainId={chainId} />
120132
</div>
133+
<Text variant="normal" fontWeight="medium" color="muted">
134+
{accountAddress}
135+
</Text>
121136
<div>
122137
<Text variant="normal" fontWeight="medium" color="muted">
123138
Balance

0 commit comments

Comments
 (0)