Difficulty: Intermediate
Type: performance, UI/UX
Background
In the Swap modal, users can paste custom token contract addresses to import unverified assets. The app validates these addresses against an RPC provider.
Problem
The input field triggers an RPC verification call on every single keystroke. When a user pastes or types quickly, this spams the RPC node, causing UI lag and potential rate limits.
Expected outcome
The input validation and subsequent RPC network request are wrapped in a 300ms debounce, ensuring only the final intended string is processed.
Suggested implementation
- Use a custom hook like
useDebounce(value, delay) or a library like lodash.debounce.
- Delay the state update that triggers the
useEffect checking the token validity.
- Display a subtle loading spinner inside the input field while the debounced validation is pending.
Acceptance criteria
Likely affected files/directories
src/components/Swap/TokenSearchModal.tsx
Requirements
- Do not break standard ERC20 symbol searches (which search the localized cache instead of hitting RPC).
Difficulty: Intermediate
Type: performance, UI/UX
Background
In the Swap modal, users can paste custom token contract addresses to import unverified assets. The app validates these addresses against an RPC provider.
Problem
The input field triggers an RPC verification call on every single keystroke. When a user pastes or types quickly, this spams the RPC node, causing UI lag and potential rate limits.
Expected outcome
The input validation and subsequent RPC network request are wrapped in a 300ms debounce, ensuring only the final intended string is processed.
Suggested implementation
useDebounce(value, delay)or a library likelodash.debounce.useEffectchecking the token validity.Acceptance criteria
Likely affected files/directories
src/components/Swap/TokenSearchModal.tsxRequirements