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

Update staging env #783

Merged
merged 28 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3a55d5a
refactor wallet connect
p6te Nov 8, 2024
edaf2f7
autoconnect fix
matepal00 Nov 9, 2024
f483bbd
simplify wallet adapter interface
matepal00 Nov 9, 2024
306bff8
fix nightly autoconnect
p6te Nov 12, 2024
4aa348b
fix change wallet
p6te Nov 12, 2024
0ffa195
reconnect static wallets
p6te Nov 12, 2024
53836dd
refactor other connect wallet buttons
p6te Nov 12, 2024
c3aad26
fix partial sign
p6te Nov 12, 2024
fae0c8a
Merge branch 'dev' into refactor-wallet-selector
p6te Nov 12, 2024
3787938
trunk format
p6te Nov 12, 2024
00eb2ce
fix build
p6te Nov 12, 2024
2ef010e
add wallet icons and enhance SelectWalletModal styles
kuba80-02 Nov 18, 2024
633cdbd
Merge branch 'dev' of https://github.com/invariant-labs/webapp into r…
kuba80-02 Nov 18, 2024
8c08252
update SelectWalletModal styles to set fixed height of 590px
kuba80-02 Nov 18, 2024
4aca581
update SelectWalletModal styles to reduce marginTop from 24px to 10px
kuba80-02 Nov 18, 2024
3a406dc
refactor SelectWalletModal styles and update SVG colors for improved UI
kuba80-02 Nov 18, 2024
6ad8dcc
remove unused import of Link component in SelectWalletModal
kuba80-02 Nov 18, 2024
b6e255b
update SelectWalletModal text for clarity and adjust styles for impro…
kuba80-02 Nov 18, 2024
152a6bc
update wallet name for NIGHTLY to 'Wallet Selector' for clarity
kuba80-02 Nov 18, 2024
2a2c0d5
update not found search on stats
p6te Nov 19, 2024
f6ff75a
fix fetch global price on new position
p6te Nov 19, 2024
44bf558
update SelectWalletModal text for clarity and adjust button label for…
kuba80-02 Nov 19, 2024
6bf4bdf
add rel='preload' attribute to wallet icons in SelectWalletModal for …
kuba80-02 Nov 19, 2024
08318f2
reduce height of SelectWalletModal component for improved layout
kuba80-02 Nov 19, 2024
4cbc8ba
reduce height of SelectWalletModal component for improved layout
kuba80-02 Nov 19, 2024
ef1aa5e
Merge pull request #765 from invariant-labs/refactor-wallet-selector
wojciech-cichocki Nov 19, 2024
7fea87a
Merge pull request #781 from invariant-labs/update-no-results-on-stats
wojciech-cichocki Nov 19, 2024
7503538
Merge pull request #782 from invariant-labs/fix-global-price
wojciech-cichocki Nov 19, 2024
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
1 change: 0 additions & 1 deletion src/components/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const Primary: Story = {
walletConnected: true,
onFaucet: fn(),
onCopyAddress: fn(),
onChangeWallet: fn(),
activeChain: {
name: Chain.Eclipse,
address: 'https://exlipse.invariant.app'
Expand Down
3 changes: 0 additions & 3 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface IHeader {
onDisconnectWallet: () => void
defaultTestnetRPC: string
onCopyAddress: () => void
onChangeWallet: () => void
activeChain: ISelectChain
onChainSelect: (chain: ISelectChain) => void
network: NetworkType
Expand All @@ -59,7 +58,6 @@ export const Header: React.FC<IHeader> = ({
onDisconnectWallet,
defaultDevnetRPC,
onCopyAddress,
onChangeWallet,
activeChain,
onChainSelect,
network,
Expand Down Expand Up @@ -277,7 +275,6 @@ export const Header: React.FC<IHeader> = ({
walletConnected ? <DotIcon className={classes.connectedWalletIcon} /> : undefined
}
onCopyAddress={onCopyAddress}
onChangeWallet={onChangeWallet}
/>
</Grid>

Expand Down
58 changes: 47 additions & 11 deletions src/components/Header/HeaderButton/ChangeWalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button, Typography } from '@mui/material'
import { blurContent, unblurContent } from '@utils/uiUtils'
import ConnectWallet from '@components/Modals/ConnectWallet/ConnectWallet'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import SelectWalletModal from '@components/Modals/SelectWalletModal/SelectWalletModal'

export interface IProps {
name: string
Expand All @@ -15,7 +16,7 @@ export interface IProps {
hideArrow?: boolean
className?: string
onCopyAddress?: () => void
onChangeWallet?: () => void
textClassName?: string
}
export const ChangeWalletButton: React.FC<IProps> = ({
name,
Expand All @@ -26,20 +27,32 @@ export const ChangeWalletButton: React.FC<IProps> = ({
onDisconnect,
className,
onCopyAddress = () => {},
onChangeWallet = () => {}
textClassName
}) => {
const { classes } = useStyles()
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null)
const [open, setOpen] = React.useState<boolean>(false)
const [isOpenSelectWallet, setIsOpenSelectWallet] = React.useState<boolean>(false)
const [isChangeWallet, setIsChangeWallet] = React.useState<boolean>(false)

const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
console.log('connected', connected)
if (!connected) {
onConnect()
return
setIsOpenSelectWallet(true)
setAnchorEl(event.currentTarget)
blurContent()
} else {
setAnchorEl(event.currentTarget)
blurContent()
setOpen(true)
}
}

setAnchorEl(event.currentTarget)
blurContent()
setOpen(true)
const handleConnect = async () => {
onConnect()
setIsOpenSelectWallet(false)
unblurContent()
setIsChangeWallet(false)
}

const handleClose = () => {
Expand All @@ -51,12 +64,17 @@ export const ChangeWalletButton: React.FC<IProps> = ({
onDisconnect()
unblurContent()
setOpen(false)
localStorage.setItem('WALLET_TYPE', '')
}

const handleChangeWallet = () => {
onChangeWallet()
setIsChangeWallet(true)
unblurContent()
setOpen(false)
setIsOpenSelectWallet(true)
blurContent()

localStorage.setItem('WALLET_TYPE', '')
}

const handleCopyAddress = () => {
Expand All @@ -70,8 +88,8 @@ export const ChangeWalletButton: React.FC<IProps> = ({
<Button
id='connect-wallet-button'
className={classNames(
className,
connected ? classes.headerButtonConnected : classes.headerButtonConnect
connected ? classes.headerButtonConnected : classes.headerButtonConnect,
className
)}
variant='contained'
classes={{
Expand All @@ -85,15 +103,33 @@ export const ChangeWalletButton: React.FC<IProps> = ({
endIcon={
connected && !hideArrow ? <ExpandMoreIcon className={classes.endIcon} /> : undefined
}>
<Typography className={classes.headerButtonTextEllipsis}>{name}</Typography>
<Typography className={classNames(classes.headerButtonTextEllipsis, textClassName)}>
{name}
</Typography>
</Button>
<SelectWalletModal
anchorEl={anchorEl}
handleClose={() => {
setIsOpenSelectWallet(false)
unblurContent()
}}
setIsOpenSelectWallet={() => {
setIsOpenSelectWallet(false)
unblurContent()
}}
handleConnect={handleConnect}
open={isOpenSelectWallet}
isChangeWallet={isChangeWallet}
onDisconnect={handleDisconnect}
/>
<ConnectWallet
open={open}
anchorEl={anchorEl}
handleClose={handleClose}
callDisconect={handleDisconnect}
callCopyAddress={handleCopyAddress}
callChangeWallet={handleChangeWallet}
isChangeWallet={isChangeWallet}
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@ export default meta
type Story = StoryObj<typeof meta>

export const Primary: Story = {
args: { open: true, anchorEl: null, handleClose: fn(), callDisconect: fn() }
args: {
open: true,
anchorEl: null,
handleClose: fn(),
callDisconect: fn(),
isChangeWallet: false
}
}
1 change: 1 addition & 0 deletions src/components/Modals/ConnectWallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IConnectWalletModal {
callDisconect: () => void
callCopyAddress?: () => void
callChangeWallet?: () => void
isChangeWallet: boolean
}
export const ConnectWallet: React.FC<IConnectWalletModal> = ({
open,
Expand Down
162 changes: 162 additions & 0 deletions src/components/Modals/SelectWalletModal/SelectWalletModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import React from 'react'
import { Button, Grid, Popover, Typography, Divider, Box } from '@mui/material'
import useStyles from './styles'
import { walletNames } from '@store/consts/static'
import { WalletType } from '@store/consts/types'
import { openWalletSelectorModal } from '@utils/web3/selector'
import { changeToNightlyAdapter, connectStaticWallet } from '@utils/web3/wallet'
import icons from '@static/icons'
export interface ISelectWalletModal {
open: boolean
anchorEl: HTMLButtonElement | null
handleConnect: () => void
handleClose: () => void
isChangeWallet: boolean
onDisconnect: () => void
setIsOpenSelectWallet: (isOpen: boolean) => void
}

export const SelectWalletModal: React.FC<ISelectWalletModal> = ({
open,
handleConnect,
handleClose,
isChangeWallet,
setIsOpenSelectWallet,
onDisconnect
}) => {
const { classes } = useStyles()

const setWallet = (wallet: WalletType) => {
localStorage.setItem('WALLET_TYPE', wallet.toString())
}

const handleConnectStaticWallet = async (wallet: WalletType) => {
setIsOpenSelectWallet(false)
setTimeout(async () => {
if (isChangeWallet) {
await (async () => onDisconnect())()
await new Promise(resolve => setTimeout(resolve, 100))
}

await connectStaticWallet(wallet)
handleConnect()
setWallet(wallet)
}, 300)
}

return (
<div className={classes.modalContainer}>
<Popover
open={open}
anchorReference='none'
classes={{
root: classes.popoverRoot,
paper: classes.paper
}}
onClose={handleClose}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}>
<Box className={classes.root}>
<Grid
className={classes.topCloseButton}
onClick={() => {
setIsOpenSelectWallet(false)
}}>
<img width={16} src={icons.closeIcon} alt='Close'></img>
</Grid>
<Typography className={classes.title}>Connect your wallet</Typography>

<Grid className={classes.buttonWrapper}>
<Typography className={classes.subTitle}>Connect with popular wallets </Typography>
<Grid className={classes.buttonList}>
<Grid
item
className={classes.button}
onClick={() => {
handleConnectStaticWallet(WalletType.PHANTOM)
}}>
<Typography className={classes.buttonName}>
{' '}
<img width={45} rel='preload' src={icons.PhantomWallet} alt='Close'></img>
{walletNames[WalletType.PHANTOM]}
</Typography>
</Grid>
<Grid
item
className={classes.button}
onClick={async () => {
handleConnectStaticWallet(WalletType.BACKPACK)
}}>
<Typography className={classes.buttonName}>
<img width={40} rel='preload' src={icons.BackpackWallet} alt='Close'></img>

{walletNames[WalletType.BACKPACK]}
</Typography>
</Grid>
<Grid
item
className={classes.button}
onClick={async () => {
handleConnectStaticWallet(WalletType.SOLFLARE)
}}>
<Typography className={classes.buttonName}>
<img width={45} rel='preload' src={icons.SolflareWallet} alt='Close'></img>

{walletNames[WalletType.SOLFLARE]}
</Typography>
</Grid>
</Grid>
</Grid>

<Divider className={classes.divider} />

<Grid className={classes.buttonWrapper}>
<Typography className={classes.subTitle}>
Or connect using Nightly's auto-detection
</Typography>
<Grid className={classes.buttonList}>
<Grid
item
className={classes.button}
onClick={() => {
setIsOpenSelectWallet(false)
setTimeout(async () => {
if (isChangeWallet) {
await (async () => onDisconnect())()
await new Promise(resolve => setTimeout(resolve, 100))
}
changeToNightlyAdapter()
await openWalletSelectorModal()
handleConnect()
setWallet(WalletType.NIGHTLY)
}, 300)
}}>
<Typography className={classes.buttonName}>
{' '}
<img width={35} rel='preload' src={icons.NightlyConnect} alt='Close'></img>
{walletNames[WalletType.NIGHTLY]}
</Typography>
</Grid>
</Grid>
</Grid>

<Divider className={classes.divider} />

<Grid className={classes.modalFooter}>
<Typography className={classes.footerTitle}>Don't have a wallet?</Typography>
<a href={' https://nightly.app/'} target='_blank'>
<Button className={classes.buttonPrimary} variant='contained'>
Download one!
</Button>
</a>
</Grid>
</Box>
</Popover>
</div>
)
}

export default SelectWalletModal
Loading