From a7dd95eee0f9152a2716ea51f4751df82b999ca2 Mon Sep 17 00:00:00 2001 From: highlander Date: Thu, 9 Jul 2026 14:11:50 -0300 Subject: [PATCH] fix(swap): default token output to native gas asset; collapse EVM summary; kill search autocorrect - Token input now defaults the output to its chain's native gas asset (USDT mainnet -> ETH) instead of a blank output. Only fills an empty output, never overrides a user pick; covers both the token-page fast path and the CAIP-match path. - EVM summary is now a collapsed-by-default
accordion (matches the other payload sections); 'payload ready' status stays in the header. - Asset search input: autoComplete/autoCorrect/autoCapitalize=off + spellCheck=false so 'USDT' isn't re-corrected into a scam-token match. --- .../mainview/components/AssetPickerDialog.tsx | 1 + .../src/mainview/components/SwapDialog.tsx | 45 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/projects/keepkey-vault/src/mainview/components/AssetPickerDialog.tsx b/projects/keepkey-vault/src/mainview/components/AssetPickerDialog.tsx index db545e37..2daf8d99 100644 --- a/projects/keepkey-vault/src/mainview/components/AssetPickerDialog.tsx +++ b/projects/keepkey-vault/src/mainview/components/AssetPickerDialog.tsx @@ -152,6 +152,7 @@ function SearchBar({ value, onChange, placeholder, autoFocus }: { placeholder={placeholder} bg="transparent" border="none" color="kk.textPrimary" px="0" fontSize="12px" _focus={{ outline: "none", boxShadow: "none" }} + autoComplete="off" autoCorrect="off" autoCapitalize="off" spellCheck={false} autoFocus={autoFocus} /> {value && ( onChange("")} diff --git a/projects/keepkey-vault/src/mainview/components/SwapDialog.tsx b/projects/keepkey-vault/src/mainview/components/SwapDialog.tsx index ff436500..9e765aaf 100644 --- a/projects/keepkey-vault/src/mainview/components/SwapDialog.tsx +++ b/projects/keepkey-vault/src/mainview/components/SwapDialog.tsx @@ -1262,6 +1262,18 @@ export function SwapDialog({ open, onClose, chain, balance, address, resumeSwap, } }, [assets, chain, initialFromCaip, initialFromAsset]) + // Default the output to the input chain's native gas asset for a TOKEN input + // (e.g. USDT mainnet → ETH) when no output is chosen yet. Opening swap from a + // token page shouldn't land on a blank output; native inputs keep their own + // DEFAULT_OUTPUT above. Runs once assets are loaded (the initialFromAsset fast + // path sets fromAsset before assets arrive, so we can't do it inline there). + useEffect(() => { + if (!fromAsset || toAsset || assets.length === 0) return + if (!fromAsset.contractAddress) return // native input handled by DEFAULT_OUTPUT + const nativeOut = assets.find(a => a.chainId === fromAsset.chainId && !a.contractAddress) + if (nativeOut) setToAsset(nativeOut) + }, [fromAsset, toAsset, assets]) + // ── Resume from swap history ────────────────────────────────────── const hasResumedRef = useRef(null) // Clear resume guard when dialog closes so re-clicking same swap works @@ -3677,21 +3689,29 @@ export function SwapDialog({ open, onClose, chain, balance, address, resumeSwap, {fromAsset.chainFamily === 'evm' && ( - - + + {t("evmSummary", "EVM summary")} - - {previewLoading - ? t("payloadBuilding", "building payload") - : previewError - ? t("payloadFailed", "payload failed") - : auditPayloadReady - ? t("payloadReady", "payload ready") - : t("payloadRequiredShort", "payload required")} - - + + + {previewLoading + ? t("payloadBuilding", "building payload") + : previewError + ? t("payloadFailed", "payload failed") + : auditPayloadReady + ? t("payloadReady", "payload ready") + : t("payloadRequiredShort", "payload required")} + + + + + + + {previewLoading && ( {t("buildingPayloadDetail", "Building the exact transaction payload for review...")} @@ -3717,6 +3737,7 @@ export function SwapDialog({ open, onClose, chain, balance, address, resumeSwap, /> )} + )}