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

3rd web #373

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { useFaucetAPI } from '@/hooks/useFaucetAPI'
import { timeDifferenceInHoursAndMinutes, timeDifferenceInHoursMinutesAndSeconds } from '@/utils/timeFormat'
import { useNavigate } from 'react-router-dom'
import { createThirdwebClient } from 'thirdweb'
import { useConnectModal } from 'thirdweb/react'
import { ConnectButton, darkTheme } from 'thirdweb/react'
import { createWallet } from 'thirdweb/wallets'

interface FaucetViewProps { }
const FaucetView: React.FC<FaucetViewProps> = ({ }) => {
Expand All @@ -34,13 +35,16 @@ const FaucetView: React.FC<FaucetViewProps> = ({ }) => {

const values: AccountType[] = [`External Address`, `Connected Account`]
const networks = getNetworks(selectedNetworkType)
const {connect} = useConnectModal()

if (selectedNetworkType === 'Mainnet') {
navigate('/bridge')
}


const client = createThirdwebClient({
clientId: '6410e98bc50f9521823ca83e255e279d'
})

useEffect(() => {
const targetNetwork = networks?.find((n) => n.chainId === faucetTargetChainId)
if (targetNetwork) {
Expand All @@ -67,17 +71,31 @@ const FaucetView: React.FC<FaucetViewProps> = ({ }) => {
if (!connectedAccount) setSelectedAccountType('External Address')
}, [connectedAccount])

const handleConnect = async () => {
if (!connectedAccount) {
// instantiate wallet
const client = createThirdwebClient({
clientId: '6410e98bc50f9521823ca83e255e279d'
})
const wallet = await connect({ client })
setConnectedAccount(wallet.getAccount()?.address ?? ''); setWallet(wallet)
return
}
}
const wallets = [
createWallet("io.metamask"),
createWallet("com.coinbase.wallet"),
createWallet("me.rainbow"),
createWallet("io.rabby"),
createWallet("io.zerion.wallet"),
createWallet("com.trustwallet.app"),
createWallet("com.bitget.web3"),
createWallet("org.uniswap"),
createWallet("com.okex.wallet"),
createWallet("com.binance"),
createWallet("global.safe"),
]

// const handleConnect = async () => {
// if (!connectedAccount) {
// // instantiate wallet
// const client = createThirdwebClient({
// clientId: '6410e98bc50f9521823ca83e255e279d'
// })
// const wallet = await connect({ client })
// setConnectedAccount(wallet.getAccount()?.address ?? ''); setWallet(wallet)
// return
// }
// }

const handleSelectAccountType = (selectedAccountType: AccountType) => {
if (selectedAccountType === 'External Address') setAddress('')
Expand Down Expand Up @@ -279,14 +297,28 @@ const FaucetView: React.FC<FaucetViewProps> = ({ }) => {
'Or'
)}
</div>
<div
className={styles.connectWalletButton}
onClick={() => {
handleConnect()
<ConnectButton
client={client}
wallets={wallets}
theme={darkTheme({
colors: {
danger: "hsl(358, 76%, 47%)",
success: "hsl(151, 55%, 42%)",
tooltipBg: "hsl(240, 6%, 94%)",
modalBg: "hsl(228, 12%, 8%)",
separatorLine: "hsl(228, 12%, 17%)",
borderColor: "hsl(228, 12%, 17%)",
primaryButtonBg: "hsl(4, 96%, 80%)",
primaryButtonText: "hsl(4, 72%, 33%)",
},
})}
connectButton={{ label: "Connect Wallet", style: { height: '36px' } }}
onConnect={(wallet) => { setConnectedAccount(wallet.getAccount()?.address ?? ''); setWallet(wallet) }}
connectModal={{
size: "compact",
showThirdwebBranding: false,
}}
>
<div className={styles.connectWalletText}>Connect Wallet</div>
</div>
/>
</>
) : (
<div className={styles.selectorContainer}>
Expand Down