Skip to content

Commit 3c19ebb

Browse files
committed
clean up demo page
1 parent 69c5616 commit 3c19ebb

File tree

1 file changed

+13
-134
lines changed

1 file changed

+13
-134
lines changed

demo/pages/ui/token/[[...params]].tsx

Lines changed: 13 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@ import {
1212
useUserWallets,
1313
type Wallet
1414
} from '@dynamic-labs/sdk-react-core'
15-
import {
16-
useCallback,
17-
useEffect,
18-
useMemo,
19-
useRef,
20-
useState,
21-
type FormEvent
22-
} from 'react'
15+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
2316
import { isEthereumWallet } from '@dynamic-labs/ethereum'
2417
import { isSolanaWallet } from '@dynamic-labs/solana'
2518
import { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'
@@ -91,9 +84,6 @@ const TokenWidgetPage: NextPage = () => {
9184
const [urlTokenAddress, setUrlTokenAddress] = useState<string | undefined>()
9285
const [urlTokenChainId, setUrlTokenChainId] = useState<number | undefined>()
9386

94-
const [addressInput, setAddressInput] = useState('')
95-
const [chainInput, setChainInput] = useState('')
96-
const [inputError, setInputError] = useState<string | null>(null)
9787
const [tokenNotFound, setTokenNotFound] = useState(false)
9888
const [activeTab, setActiveTab] = useState<'buy' | 'sell'>('buy')
9989

@@ -205,8 +195,6 @@ const TokenWidgetPage: NextPage = () => {
205195
if (!addressParam || !chainParam) {
206196
setUrlTokenAddress(undefined)
207197
setUrlTokenChainId(undefined)
208-
setAddressInput('')
209-
setChainInput('')
210198
return
211199
}
212200

@@ -221,8 +209,6 @@ const TokenWidgetPage: NextPage = () => {
221209
if (!Number.isNaN(chainId)) {
222210
setUrlTokenAddress(decodedAddress)
223211
setUrlTokenChainId(chainId)
224-
setAddressInput(decodedAddress)
225-
setChainInput(chainId.toString())
226212
setTokenNotFound(false)
227213
}
228214
}, [router.isReady, router.query.params])
@@ -253,36 +239,6 @@ const TokenWidgetPage: NextPage = () => {
253239
console.log('Analytic Event', eventName, data)
254240
}, [])
255241

256-
const handleApplyCustomToken = useCallback(
257-
(event?: FormEvent<HTMLFormElement>) => {
258-
event?.preventDefault()
259-
setInputError(null)
260-
261-
const normalizedAddress = addressInput.trim()
262-
const normalizedChain = chainInput.trim()
263-
264-
if (!normalizedAddress) {
265-
setInputError('Enter a token address (or symbol) to load.')
266-
return
267-
}
268-
269-
const parsedChainId = Number(normalizedChain)
270-
if (Number.isNaN(parsedChainId)) {
271-
setInputError('Enter a valid chain id.')
272-
return
273-
}
274-
275-
setFromToken(undefined)
276-
setToToken(undefined)
277-
setTokenNotFound(false)
278-
279-
setUrlTokenAddress(normalizedAddress)
280-
setUrlTokenChainId(parsedChainId)
281-
updateDemoUrlWithRawParams(normalizedAddress, parsedChainId)
282-
},
283-
[addressInput, chainInput, updateDemoUrlWithRawParams]
284-
)
285-
286242
useEffect(() => {
287243
switchWallet.current = _switchWallet
288244
}, [_switchWallet])
@@ -298,8 +254,6 @@ const TokenWidgetPage: NextPage = () => {
298254

299255
setUrlTokenAddress(targetAddress)
300256
setUrlTokenChainId(targetChainId)
301-
setAddressInput(targetAddress)
302-
setChainInput(targetChainId.toString())
303257
updateDemoUrlWithRawParams(targetAddress, targetChainId)
304258
}
305259

@@ -489,18 +443,6 @@ const TokenWidgetPage: NextPage = () => {
489443
>
490444
Open Sell Tab
491445
</button>
492-
<div
493-
style={{
494-
display: 'flex',
495-
alignItems: 'center',
496-
padding: '0 12px',
497-
color: theme === 'light' ? '#475569' : '#94a3b8',
498-
fontSize: 14,
499-
fontWeight: 500
500-
}}
501-
>
502-
Current: {activeTab === 'buy' ? 'Buy' : 'Sell'}
503-
</div>
504446
</div>
505447
<TokenWidget
506448
key={`swap-widget-${singleChainMode ? 'single' : 'multi'}-chain`}
@@ -616,79 +558,16 @@ const TokenWidgetPage: NextPage = () => {
616558
// setSlippageToleranceConfigOpen(true)
617559
}}
618560
/>
619-
<div
620-
style={{
621-
display: 'flex',
622-
flexDirection: 'column',
623-
gap: 8,
624-
width: '100%',
625-
maxWidth: 400
626-
}}
627-
>
628-
<form onSubmit={handleApplyCustomToken} style={{ width: '100%' }}>
629-
<div
630-
style={{
631-
display: 'flex',
632-
gap: 8,
633-
alignItems: 'center'
634-
}}
635-
>
636-
<input
637-
value={addressInput}
638-
onChange={(event) => setAddressInput(event.target.value)}
639-
placeholder="Token address"
640-
style={{
641-
flex: '2',
642-
padding: '10px 12px',
643-
borderRadius: 12,
644-
border: '1px solid rgba(148, 163, 184, 0.4)'
645-
}}
646-
autoComplete="off"
647-
/>
648-
<input
649-
value={chainInput}
650-
onChange={(event) => setChainInput(event.target.value)}
651-
placeholder="Chain ID"
652-
style={{
653-
flex: '1',
654-
minWidth: 100,
655-
padding: '10px 12px',
656-
borderRadius: 12,
657-
border: '1px solid rgba(148, 163, 184, 0.4)'
658-
}}
659-
inputMode="numeric"
660-
autoComplete="off"
661-
/>
662-
<button
663-
type="submit"
664-
style={{
665-
padding: '10px 16px',
666-
borderRadius: 12,
667-
border: 'none',
668-
background: '#4f46e5',
669-
color: 'white',
670-
fontWeight: 600,
671-
cursor: 'pointer',
672-
whiteSpace: 'nowrap'
673-
}}
674-
>
675-
Load token
676-
</button>
677-
</div>
678-
</form>
679-
{inputError ? (
680-
<p
681-
style={{
682-
margin: 0,
683-
color: '#b91c1c',
684-
fontSize: 12,
685-
textAlign: 'center'
686-
}}
687-
>
688-
{inputError}
689-
</p>
690-
) : null}
691-
{tokenNotFound ? (
561+
{tokenNotFound ? (
562+
<div
563+
style={{
564+
display: 'flex',
565+
flexDirection: 'column',
566+
gap: 8,
567+
width: '100%',
568+
maxWidth: 400
569+
}}
570+
>
692571
<p
693572
style={{
694573
margin: 0,
@@ -704,8 +583,8 @@ const TokenWidgetPage: NextPage = () => {
704583
? `Chain ${urlTokenChainId} is not supported by Relay. Please select a token from a supported chain.`
705584
: 'Token from URL was not found on the specified chain. Please select a token manually to continue.'}
706585
</p>
707-
) : null}
708-
</div>
586+
</div>
587+
) : null}
709588
</div>
710589
</div>
711590
</Layout>

0 commit comments

Comments
 (0)