-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2059709
commit 3d920ab
Showing
13 changed files
with
360 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ const nextConfig = { | |
}, | ||
], | ||
}, | ||
output: 'standalone', | ||
}; | ||
|
||
module.exports = nextConfig; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { useAppDispatch, useAppSelector } from '@/custom-hooks/StateHooks'; | ||
import { | ||
establishWalletConnection, | ||
setConnectWalletOpen, | ||
} from '@/store/features/wallet/walletSlice'; | ||
import { networks } from '@/utils/chainsInfo'; | ||
import { SUPPORTED_WALLETS } from '@/utils/constants'; | ||
import { getLocalNetworks } from '@/utils/localStorage'; | ||
import { | ||
connectSnap, | ||
experimentalSuggestChain, | ||
getSnap, | ||
} from '@leapwallet/cosmos-snap-provider'; | ||
import { Dialog, DialogContent, Slide, SlideProps } from '@mui/material'; | ||
import Image from 'next/image'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const Transition = forwardRef(function Transition( | ||
props: SlideProps & { children: React.ReactElement<any, any> }, | ||
ref: React.Ref<any> | ||
) { | ||
return <Slide direction="down" ref={ref} {...props} timeout={500} />; | ||
}); | ||
|
||
const ConnectWallet = () => { | ||
const dispatch = useAppDispatch(); | ||
const open = useAppSelector((state) => state.wallet.connectWalletOpen); | ||
const connectWalletClose = () => { | ||
dispatch(setConnectWalletOpen(false)); | ||
}; | ||
|
||
const selectWallet = (walletName: string) => { | ||
tryConnectWallet(walletName.toLowerCase()); | ||
connectWalletClose(); | ||
}; | ||
|
||
const tryConnectWallet = async (walletName: string) => { | ||
if (walletName === 'metamask') { | ||
try { | ||
for (let i = 0; i < networks.length; i++) { | ||
const chainId: string = networks[i].config.chainId; | ||
const snapInstalled = await getSnap(); | ||
if (!snapInstalled) { | ||
await connectSnap(); // Initiates installation if not already present | ||
} | ||
|
||
try { | ||
await experimentalSuggestChain(networks[i].config, { | ||
force: false, | ||
}); | ||
} catch (error) { | ||
console.log('Error while connecting ', chainId); | ||
} | ||
} | ||
} catch (error) { | ||
console.log('trying to connect wallet ', error); | ||
} | ||
} | ||
|
||
dispatch( | ||
establishWalletConnection({ | ||
walletName, | ||
networks: [...networks, ...getLocalNetworks()], | ||
}) | ||
); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
maxWidth="lg" | ||
TransitionComponent={Transition} | ||
sx={{ | ||
'& .MuiDialog-paper': { | ||
color: 'white', | ||
}, | ||
}} | ||
PaperProps={{ | ||
sx: { | ||
borderRadius: '16px', | ||
background: '#1c1c1d', | ||
}, | ||
}} | ||
onClose={connectWalletClose} | ||
> | ||
<DialogContent sx={{ padding: 0 }}> | ||
<div className="connect-wallet-popup"> | ||
<div className="flex justify-end p-6"> | ||
<button onClick={connectWalletClose} className="secondary-btn"> | ||
Close | ||
</button> | ||
</div> | ||
<div className="text-center"> | ||
<div className="font-bold text-[28px] leading-normal"> | ||
Connect Wallet | ||
</div> | ||
<div className="secondary-text"> | ||
Connect your wallet now to access all the modules on Resolute | ||
</div> | ||
</div> | ||
<div className="grid grid-cols-4 gap-10 px-10"> | ||
{SUPPORTED_WALLETS.map((wallet, index) => ( | ||
<div | ||
className="w-[200px] border-[0.25px] border-[#ffffff2f] py-6 flex flex-col gap-4 items-center justify-center rounded-2xl cursor-pointer hover:scale-[1.1] transition-all delay-75" | ||
onClick={() => { | ||
selectWallet(wallet.name); | ||
}} | ||
key={index} | ||
> | ||
<Image | ||
src={wallet.logo} | ||
width={100} | ||
height={100} | ||
alt={wallet.name} | ||
/> | ||
<p className="text-[14px] leading-[24px]">{wallet.name}</p> | ||
</div> | ||
))} | ||
<div className="p-6 h-[18px]"></div> | ||
</div> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default ConnectWallet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useAppSelector } from '@/custom-hooks/StateHooks'; | ||
import { getConnectWalletLogo } from '@/utils/util'; | ||
import { Dialog, DialogContent, Slide, SlideProps } from '@mui/material'; | ||
import Image from 'next/image'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const Transition = forwardRef(function Transition( | ||
props: SlideProps & { children: React.ReactElement<any, any> }, | ||
ref: React.Ref<any> | ||
) { | ||
return <Slide direction="left" ref={ref} {...props} timeout={500} />; | ||
}); | ||
|
||
const ProfileDialog = ({ | ||
onClose, | ||
open, | ||
}: { | ||
open: boolean; | ||
onClose: () => void; | ||
}) => { | ||
const connnectedWalletLogo = getConnectWalletLogo(); | ||
const walletUserName = useAppSelector((state) => state.wallet.name); | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
maxWidth="lg" | ||
TransitionComponent={Transition} | ||
sx={{ | ||
'& .MuiDialog-paper': { | ||
position: 'absolute', | ||
right: '30px', | ||
left: 'auto', | ||
height: 'calc(100% - 60px)', | ||
margin: 0, | ||
color: 'white', | ||
}, | ||
}} | ||
PaperProps={{ | ||
sx: { | ||
borderRadius: '16px', | ||
background: '#1c1c1d', | ||
}, | ||
}} | ||
onClose={onClose} | ||
> | ||
<DialogContent sx={{ padding: 0 }}> | ||
<div className="profile-section"> | ||
<div className="space-y-6"> | ||
<div className="space-y-2"> | ||
<div className="text-[20px] font-bold leading-[27px]"> | ||
Profile | ||
</div> | ||
<div className="secondary-text"> | ||
Connect your wallet now to access all the modules on resolute | ||
</div> | ||
<div className="divider-line"></div> | ||
</div> | ||
<div className="flex flex-col items-center gap-2 px-6 py-[10px]"> | ||
<Image src={connnectedWalletLogo} height={40} width={40} alt="" /> | ||
<div className="font-medium">{walletUserName}</div> | ||
</div> | ||
<div> | ||
<button className="primary-btn w-full">Logout</button> | ||
</div> | ||
<button onClick={onClose} className="secondary-btn w-full"> | ||
Close Tab | ||
</button> | ||
</div> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default ProfileDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.