π Description
SettlementForm (src/components/SettlementForm.tsx) initializes const [asset, setAsset] = useState("USDC"); and its reset() function does setAsset("USDC"); β both hardcode the literal string "USDC" as the asset field's default value. The component already receives an availableLiquidity?: Record<string, number> prop (populated by SettlementsPanel from the real pool list via fetchPools) specifically enumerating the assets this deployment actually supports, but the hardcoded default never consults it. On a deployment whose pools don't include a USDC pool at all, the form's default (and every reset) presents a value that isn't actually one of the supported assets, and submitting without changing it would immediately fail the availableLiquidity liquidity check that validate() already performs for asset codes present in the record.
π§© Requirements and context
- The asset field's initial value and
reset() default should prefer an asset that's actually known to be available (e.g. the first key of availableLiquidity when it's populated), falling back to the current "USDC" literal only when availableLiquidity is absent/empty (e.g. before pools have loaded).
- No change to the field's free-text nature β the user must still be able to type any asset code regardless of the default.
- The existing validation behavior (required field, liquidity check) must be unchanged.
π οΈ Suggested execution
- In
src/components/SettlementForm.tsx, derive a defaultAsset (e.g. Object.keys(availableLiquidity ?? {})[0] ?? "USDC") and use it both for the initial useState value and inside reset(), recomputing it if availableLiquidity changes after mount (e.g. via a useEffect that only updates the field when it still holds the previous default, so it doesn't clobber a user's in-progress edit).
- Extend
src/components/SettlementForm.test.tsx with a test supplying an availableLiquidity whose keys don't include "USDC" and asserting the field's initial/reset value is one of the actually-available assets instead.
β
Acceptance criteria
π Security notes
No new attack surface; a client-side default-value correctness fix using data already fetched and displayed elsewhere on the page.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
SettlementForm(src/components/SettlementForm.tsx) initializesconst [asset, setAsset] = useState("USDC");and itsreset()function doessetAsset("USDC");β both hardcode the literal string"USDC"as the asset field's default value. The component already receives anavailableLiquidity?: Record<string, number>prop (populated bySettlementsPanelfrom the real pool list viafetchPools) specifically enumerating the assets this deployment actually supports, but the hardcoded default never consults it. On a deployment whose pools don't include aUSDCpool at all, the form's default (and every reset) presents a value that isn't actually one of the supported assets, and submitting without changing it would immediately fail theavailableLiquidityliquidity check thatvalidate()already performs for asset codes present in the record.π§© Requirements and context
reset()default should prefer an asset that's actually known to be available (e.g. the first key ofavailableLiquiditywhen it's populated), falling back to the current"USDC"literal only whenavailableLiquidityis absent/empty (e.g. before pools have loaded).π οΈ Suggested execution
src/components/SettlementForm.tsx, derive adefaultAsset(e.g.Object.keys(availableLiquidity ?? {})[0] ?? "USDC") and use it both for the initialuseStatevalue and insidereset(), recomputing it ifavailableLiquiditychanges after mount (e.g. via auseEffectthat only updates the field when it still holds the previous default, so it doesn't clobber a user's in-progress edit).src/components/SettlementForm.test.tsxwith a test supplying anavailableLiquiditywhose keys don't include"USDC"and asserting the field's initial/reset value is one of the actually-available assets instead.β Acceptance criteria
availableLiquidityis populated."USDC"whenavailableLiquidityis absent or empty, matching current behavior.π Security notes
No new attack surface; a client-side default-value correctness fix using data already fetched and displayed elsewhere on the page.
π Guidelines