-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
On the Create Campaign page, every user interaction (clicks, focus changes, keystrokes) triggers unnecessary calls to the free NEAR RPC
endpoint, causing excessive network traffic and potential rate limiting.
Cause
The Zod validation schema for the campaign form validates the recipient field using isNearAccountValid, which makes a direct nearRpc.query()
call (no SWR, no caching, no deduplication) to check if a NEAR account exists. The form uses mode: "all", which re-runs the entire schema
validation on every keystroke in any field — so typing in the campaign name, description, or amount all trigger an RPC call to validate the
recipient.
Additionally, useIsHuman had no SWR caching config, causing it to refetch on every window focus event.
Fix
- Added debouncing (300ms) and an in-memory cache to isNearAccountValid so it only fires one RPC call after the user stops typing, and never
re-validates the same account ID twice. - Added revalidateOnFocus: false to useIsHuman SWR config.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working