React doctor cleanup - #7
Conversation
Extract source/destination/CTA/engine hooks out of PaySwapIntentWidget (918 -> 220 lines), share latest-ref/token-pick/ActionButton across flows, and remove dead code. react-doctor: 111 -> 10 issues.
Modal now uses <dialog> + showModal() for a real focus trap. Remove the never-imported EVM->Miden bridge path. react-doctor: 10 -> 2.
Move Earn state and SDK wiring into useEarnEngine (1091 -> 245 lines). Network-scoped choices become one self-evicting value, so a network flip invalidates them together instead of a 6-setter reset. Share TokenPickerModal/IntentProgress/GaslessSection across flows. react-doctor: 2 -> 0.
Break WithdrawDetailPanel (452 -> 157) into withdraw/ subcomponents: FromCard, AmountCard, SmartWithdrawToggle, SmartWithdrawDestination. Drop a stale comment and pure-restate comments across the pay/earn files.
Adopt DEPOSIT_EXTRADATA_TYPESTRING / WITHDRAW_EXTRADATA_TYPESTRING (added on smallocator dev) instead of hand-building the fields. Adds the canonical `isAll` and drops the stale `simulate` — no solver reads it.
Extract usePropOverride (network/tab self-eviction) and useEffectiveGasless, shared by both engines. Consolidate the duplicated formatUsd into lib/format-usd. Remove unused SourcePicker.
showModal() puts the modal in the browser top layer, above any menu portalled to document.body — so the Smart Withdraw token/chain dropdowns rendered behind it. Portal dropdown menus into the containing <dialog> instead, and move the blur scrim off the dialog so it doesn't become a containing block that offsets their fixed positioning.
Each view rendered a different modal component (TokenPickerModal vs Modal), so React remounted the <dialog> across the boundary — closing and reopening it, replaying the open animation. Render one Modal whose content/title/chrome change with the view, so it stays mounted. Removes the now-unused TokenPickerModal.
Insufficient-balance now compares the entered amount against the funding source's balance (EVM wallet, Miden wallet, or the position's withdrawable on withdraw) instead of only flagging a zero balance. The CTA disables and reads "Insufficient <token> balance", so the intent can't be submitted.
Add MIDEN_CHAIN + getMidenChainTokens (Miden graph faucets shaped as tokens on the virtual Miden chain) and inject them into the swap source and destination token lists, so Miden and its tokens appear in the pickers alongside the EVM chains — no separate tab. Also folds in the pending miden.ts refactor (SDK-sourced MIDEN_VIRTUAL_CHAIN_ID / EVM_ZERO_ADDRESS, dropped unused EARN_MIDEN_WITHDRAW_EXTRA_FIELDS), which shared the file.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
React Doctor found 1 new issue in 1 file · 1 warning · score 89 / 100 (Great) · 101 fixed · vs 1 warning
Reviewed by React Doctor for commit |
| if (!first) return; | ||
| didAutoPickRef.current = true; | ||
| selectPosition(first); | ||
| setView("withdrawDetail"); |
There was a problem hiding this comment.
React Doctor · react-doctor/no-adjust-state-on-prop-change (warning)
This effect adjusts state after a prop changes, so users briefly see the stale value.
Fix → Remove the adjustment effect by deriving values during render, resetting the component with a key, or updating related state in the event that changes the prop. Avoid tracking the previous prop in more state, which preserves the duplication. See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
No description provided.