Give each faucet token card its own independent claim state - #179
Conversation
|
@Chidubemkingsley is attempting to deploy a commit to the Ijai's projects Team on Vercel. A member of the Team first needs to authorize it. |
e81e9ab to
6b3371b
Compare
|
Nice work, this is close, and a few things are done right that are easy to get wrong: the functional setPendingTokens((prev) => …) updater (no stale-closure bug), keeping pendingTokens out of the useCallback deps so claim isn't recreated on every pending change, and splitting isBulkPending from the per-token set. The per-card spinner is clean too.
The UI state is now independent per card, but walletKit.signTransaction is a single shared signer. Two claims in flight = two concurrent signing prompts, which the kit can't handle cleanly. Two ways to hit it today: During a bulk claim, the individual cards stay enabled (claimDisabled doesn't include isBulkPending) and show no pending state, so a token already in the in-flight bulk tx can be claimed again → overlapping tx + cooldown collision + a second wallet prompt. The issue asked us to define and document the rule. I'd keep per-token success/error state independent (so each card surfaces its own result), but serialize initiation through the shared signer — only one claim being signed at a time. Minimum viable: gate new claim triggers while anything is mid-flight. Nicer: queue them so each card still lights up its own pending state in turn. Either is fine, just pick one and write it in the PR description. |
5613b42 to
8ba1d5c
Compare
- Track per-token pending state via pendingTokens Set<string> in useClaim - Separate isBulkPending for bulk claim button state - Each card derives isPending from pendingTokens membership - Bulk button shows pending only during bulk claim - Add spinner to individual card Claim button when pending
8ba1d5c to
49d189f
Compare
- Serialize through shared signer via isClaimingRef (prevents concurrent wallet prompts) - Explicit claimOne(tokenId) / claimAll() instead of inferring bulk from array length - isBulkPending reflected on all cards during bulk claim - Defense-in-depth: isClaimingRef gates new claims while any in-flight - Singular/plural success toast matches single vs bulk claim - Each card owns its own pending state via pendingTokens Set - Per-card spinner shown while pending or during bulk claim - Balance refresh via invalidateQueries preserved on success
62a749c to
c19bb18
Compare
- earn: Remove unnecessary optional chaining/nullish coalescing on non-nullish values; fix import ordering and member sorting; merge duplicate imports - referrals: Reorder imports (parent before internal); merge duplicate imports; convert string[] to Array<string>; remove unnecessary type assertions; fix import member sorting - trade: Reorder imports across 15 files; remove unnecessary optional chaining, nullish coalescing, type assertions, async without await; merge duplicate imports; fix always-true conditionals - pools: Fix import ordering (sibling after parent imports) - wallet: Fix import ordering; split inline type imports; remove duplicate type imports - glv-router-client: Merge duplicate imports; fix import ordering - shared: Fix import ordering in NumberInput.tsx - vite.config: Remove unnecessary nullish coalescing
…assertion errors across 13 files
…r sort across 8 files
…ibling VALUE/TYPE group ordering
- discover-tab.tsx: make handleEarn async (void -> Promise<void>) - earn.ts: remove unused runMockWrite and fakeTxDelay - affiliates-tab.tsx: normalize code with ?? null - ConfirmationDialog.tsx: non-null assert collateralAddress at 4 usage sites - TradePanel.tsx: non-null assert collateralAddress (fixes cascading index/param errors) - useMarketsInfo.ts: remove unused totalOI - AccountBadge.tsx: guard nullable useBalance() return - bignum.test.ts: replace assert calls with vitest expect
|
Pushed as c3e489b. All 38 typecheck errors should now resolve on the next CI run. |
|
CCool |
Task done
Track per-token pending state via pendingTokens Set in useClaim
Separate isBulkPending for bulk claim button state
Each card derives isPending from pendingTokens membership
Bulk button shows pending only during bulk claim
Add spinner to individual card Claim button when pending
Closes Issue #2 — Faucet: give each token card its own claim state #175