From 2d11f8aeea33ccbc9182f6b30e6451506dfedf1e Mon Sep 17 00:00:00 2001 From: alex luu Date: Thu, 19 Mar 2026 17:04:49 -0400 Subject: [PATCH 1/3] fix: update colors --- src/components/trade/tradebox/trade-panel.tsx | 3 +-- src/components/ui/button.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/trade/tradebox/trade-panel.tsx b/src/components/trade/tradebox/trade-panel.tsx index 5e6175a4..6092ca27 100644 --- a/src/components/trade/tradebox/trade-panel.tsx +++ b/src/components/trade/tradebox/trade-panel.tsx @@ -13,7 +13,6 @@ import { buildOrderPlan } from "@/domain/trade/order-intent"; import { formatPriceForOrder, formatSizeForOrder, throwIfResponseError } from "@/domain/trade/orders"; import { useFeeRates } from "@/hooks/trade/use-fee-rates"; import { useOrderEntryData } from "@/hooks/trade/use-order-entry-data"; -import { cn } from "@/lib/cn"; import { useAgentRegistration, useAgentStatus, useSelectedMarketInfo, useUserPositions } from "@/lib/hyperliquid"; import { useExchangeOrder } from "@/lib/hyperliquid/hooks/exchange/useExchangeOrder"; import { useExchangeTwapOrder } from "@/lib/hyperliquid/hooks/exchange/useExchangeTwapOrder"; @@ -501,7 +500,7 @@ export function TradePanel() { size="lg" onClick={buttonContent.action} disabled={buttonContent.disabled} - className={cn("w-full", !isConnected && "text-primary-text")} + className="w-full" aria-label={buttonContent.text} > {(isSubmitting || isRegistering) && } diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 5dabb642..55cd1ef3 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -35,7 +35,7 @@ const buttonVariants = cva( { variant: "contained", tone: "accent", - class: "bg-primary-default text-white hover:bg-primary-hover active:bg-primary-active", + class: "bg-primary-default text-primary-text hover:bg-primary-hover active:bg-primary-active", }, { variant: "outlined", From 079fec901d49d89c4a7353205cc7ceacc107e78b Mon Sep 17 00:00:00 2001 From: alex luu Date: Fri, 20 Mar 2026 18:14:44 -0400 Subject: [PATCH 2/3] feat: support wallets --- src/components/trade/header/top-nav.tsx | 26 ------------ .../trade/mobile/mobile-trade-view.tsx | 23 ++--------- src/components/trade/tradebox/trade-panel.tsx | 15 +++---- src/config/privy.ts | 4 +- src/config/wagmi.ts | 5 ++- src/hooks/use-privy-wagmi-sync.ts | 17 ++++++-- src/lib/hyperliquid/hooks/useClients.ts | 40 ++++++++++++++----- src/locales/ar/messages.po | 21 +++++----- src/locales/en/messages.po | 21 +++++----- src/locales/es/messages.po | 21 +++++----- src/locales/fr/messages.po | 21 +++++----- src/locales/hi/messages.po | 21 +++++----- src/locales/zh/messages.po | 21 +++++----- 13 files changed, 118 insertions(+), 138 deletions(-) diff --git a/src/components/trade/header/top-nav.tsx b/src/components/trade/header/top-nav.tsx index 20567067..0543b586 100644 --- a/src/components/trade/header/top-nav.tsx +++ b/src/components/trade/header/top-nav.tsx @@ -13,20 +13,6 @@ import { UserMenu } from "./user-menu"; const SCOPE_NAV_ITEMS = [ { scope: "all" as const, label: All, to: "/", activeClass: "text-text-950 font-medium" }, { scope: "perp" as const, label: Perp, to: "/perp", activeClass: "text-scope-perp font-medium" }, - { scope: "spot" as const, label: Spot, to: "/spot", activeClass: "text-scope-spot font-medium" }, - { - scope: "builders-perp" as const, - label: Builders, - to: "/builders-perp", - activeClass: "text-scope-builders font-medium", - }, -] as const; - -const STATIC_NAV_ITEMS = [ - { key: "vaults", label: Vaults }, - { key: "portfolio", label: Portfolio }, - { key: "staking", label: Staking }, - { key: "leaderboard", label: Leaderboard }, ] as const; function getScopeAccentClass(scope: string): string { @@ -81,18 +67,6 @@ export function TopNav() { {item.label} ))} -
- {STATIC_NAV_ITEMS.map((item) => ( - - ))}
diff --git a/src/components/trade/mobile/mobile-trade-view.tsx b/src/components/trade/mobile/mobile-trade-view.tsx index c2cead5e..d7a78140 100644 --- a/src/components/trade/mobile/mobile-trade-view.tsx +++ b/src/components/trade/mobile/mobile-trade-view.tsx @@ -1,13 +1,12 @@ import { CaretDownIcon, SpinnerGapIcon, TrendDownIcon, TrendUpIcon } from "@phosphor-icons/react"; import { useLogin } from "@privy-io/react-auth"; import { useEffect, useMemo, useState } from "react"; -import { useConnection, useSwitchChain, useWalletClient } from "wagmi"; +import { useConnection } from "wagmi"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Slider, type SliderMark } from "@/components/ui/slider"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { FALLBACK_VALUE_PLACEHOLDER, ORDER_MIN_NOTIONAL_USD, UI_TEXT } from "@/config/constants"; -import { ARBITRUM_CHAIN_ID } from "@/config/contracts"; import { getBaseQuoteFromPairName } from "@/domain/market"; import { formatPriceForOrder, formatSizeForOrder, throwIfResponseError } from "@/domain/trade/orders"; import { useAccountBalances } from "@/hooks/trade/use-account-balances"; @@ -46,12 +45,8 @@ interface MobileTradeViewProps { export function MobileTradeView({ className }: MobileTradeViewProps) { const { address, isConnected } = useConnection(); - const { data: walletClient, isLoading: isWalletLoading, error: walletClientError } = useWalletClient(); - const { switchChain, isPending: isSwitchingChain } = useSwitchChain(); const { login } = useLogin(); - const needsChainSwitch = !!walletClientError && walletClientError.message.includes("does not match"); - const { data: market } = useSelectedMarketInfo(); const { scope } = useExchangeScope(); const { setSelectedMarket } = useMarketActions(); @@ -68,7 +63,7 @@ export function MobileTradeView({ className }: MobileTradeViewProps) { const { isReady: isAgentApproved } = useAgentStatus(); const { register: registerAgent, status: registerStatus } = useAgentRegistration(); - const canApprove = !!walletClient && !!address; + const canApprove = !!address; const isRegistering = registerStatus === "switching_account_mode" || registerStatus === "approving_fee" || @@ -149,14 +144,12 @@ export function MobileTradeView({ className }: MobileTradeViewProps) { return side === "buy" ? price - buffer : price + buffer; })(); - const canSign = isAgentApproved || !!walletClient; + const canSign = isAgentApproved || !!address; const validation = useMemo(() => { const errors: string[] = []; if (!isConnected) return { valid: false, errors: [ORDER_TEXT.ERROR_NOT_CONNECTED], canSubmit: false, needsApproval: false }; - if (isWalletLoading) - return { valid: false, errors: [ORDER_TEXT.ERROR_LOADING_WALLET], canSubmit: false, needsApproval: false }; if (availableBalance <= 0) return { valid: false, errors: [ORDER_TEXT.ERROR_NO_BALANCE], canSubmit: false, needsApproval: false }; if (!market) return { valid: false, errors: [ORDER_TEXT.ERROR_NO_MARKET], canSubmit: false, needsApproval: false }; @@ -174,7 +167,6 @@ export function MobileTradeView({ className }: MobileTradeViewProps) { return { valid: errors.length === 0, errors, canSubmit: errors.length === 0, needsApproval: false }; }, [ isConnected, - isWalletLoading, availableBalance, market, isMarketExecution, @@ -218,8 +210,6 @@ export function MobileTradeView({ className }: MobileTradeViewProps) { if (markPx > 0) setLimitPriceInput(markPx.toFixed(szDecimalsToPriceDecimals(market?.szDecimals ?? 4))); }; - const handleSwitchChain = () => switchChain({ chainId: ARBITRUM_CHAIN_ID }); - const handleApprove = async () => { if (isRegistering) return; setApprovalError(null); @@ -290,13 +280,6 @@ export function MobileTradeView({ className }: MobileTradeViewProps) { disabled: false, variant: "cyan" as const, }; - if (needsChainSwitch) - return { - text: isSwitchingChain ? ORDER_TEXT.BUTTON_SWITCHING : ORDER_TEXT.BUTTON_SWITCH_CHAIN, - action: handleSwitchChain, - disabled: isSwitchingChain, - variant: "cyan" as const, - }; if (availableBalance <= 0) return { text: ORDER_TEXT.BUTTON_DEPOSIT, diff --git a/src/components/trade/tradebox/trade-panel.tsx b/src/components/trade/tradebox/trade-panel.tsx index 6092ca27..db6bf171 100644 --- a/src/components/trade/tradebox/trade-panel.tsx +++ b/src/components/trade/tradebox/trade-panel.tsx @@ -2,7 +2,7 @@ import { t } from "@lingui/core/macro"; import { SpinnerGapIcon } from "@phosphor-icons/react"; import { useLogin } from "@privy-io/react-auth"; import { useCallback, useEffect, useId, useMemo, useState } from "react"; -import { useConnection, useSwitchChain, useWalletClient } from "wagmi"; +import { useConnection } from "wagmi"; import { Button } from "@/components/ui/button"; import { DEFAULT_QUOTE_TOKEN, isUsdStablecoin, TWAP_MINUTES_MAX, TWAP_MINUTES_MIN } from "@/config/constants"; import { APPROVAL_ERROR_DISMISS_MS } from "@/config/time"; @@ -66,10 +66,7 @@ export function TradePanel() { const tpSlId = useId(); const { address, isConnected } = useConnection(); - const { data: walletClient, isLoading: isWalletLoading, error: walletClientError } = useWalletClient(); - const switchChain = useSwitchChain(); const { login } = useLogin(); - const needsChainSwitch = !!walletClientError && walletClientError.message.includes("does not match"); const { data: market } = useSelectedMarketInfo(); @@ -200,11 +197,11 @@ export function TradePanel() { const needsAgentApproval = !isAgentReady; const isReadyToTrade = isAgentReady; - const canApprove = !!walletClient && !!address; + const canApprove = !!address; const baseInput = { isConnected, - isWalletLoading, + isWalletLoading: false, availableBalance, hasMarket: !!market, hasAssetIndex: typeof market?.assetId === "number", @@ -420,9 +417,9 @@ export function TradePanel() { const buttonContent = useButtonContent({ isConnected, - needsChainSwitch, - isSwitchingChain: switchChain.isPending, - switchChain: (chainId) => switchChain.mutate({ chainId }), + needsChainSwitch: false, + isSwitchingChain: false, + switchChain: () => {}, availableBalance, validation, isAgentLoading, diff --git a/src/config/privy.ts b/src/config/privy.ts index eee0851c..e37cd90c 100644 --- a/src/config/privy.ts +++ b/src/config/privy.ts @@ -1,5 +1,5 @@ import type { PrivyClientConfig } from "@privy-io/react-auth"; -import { arbitrum } from "wagmi/chains"; +import { arbitrum, arbitrumSepolia } from "wagmi/chains"; export const privyConfig: PrivyClientConfig = { loginMethods: ["email", "google", "wallet"], @@ -11,5 +11,5 @@ export const privyConfig: PrivyClientConfig = { appearance: { showWalletLoginFirst: false, }, - supportedChains: [arbitrum], + supportedChains: [arbitrum, arbitrumSepolia], }; diff --git a/src/config/wagmi.ts b/src/config/wagmi.ts index e9859f54..40ec3297 100644 --- a/src/config/wagmi.ts +++ b/src/config/wagmi.ts @@ -1,10 +1,11 @@ import { createConfig } from "@privy-io/wagmi"; import { http } from "wagmi"; -import { arbitrum } from "wagmi/chains"; +import { arbitrum, arbitrumSepolia } from "wagmi/chains"; export const config = createConfig({ - chains: [arbitrum], + chains: [arbitrum, arbitrumSepolia], transports: { [arbitrum.id]: http(), + [arbitrumSepolia.id]: http(), }, }); diff --git a/src/hooks/use-privy-wagmi-sync.ts b/src/hooks/use-privy-wagmi-sync.ts index 6051affa..4ca74972 100644 --- a/src/hooks/use-privy-wagmi-sync.ts +++ b/src/hooks/use-privy-wagmi-sync.ts @@ -1,5 +1,5 @@ import { usePrivy } from "@privy-io/react-auth"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useConnection, useDisconnect } from "wagmi"; /** @@ -11,16 +11,25 @@ import { useConnection, useDisconnect } from "wagmi"; * * This hook detects that mismatch once Privy is ready and force-disconnects * wagmi so both layers agree on the unauthenticated state. + * + * The check runs only when Privy becomes ready (once on init), not reactively + * on auth/connection changes — otherwise it would disconnect wagmi mid-login + * before Privy finishes the wallet authentication handshake. */ export function usePrivyWagmiSync() { const { ready, authenticated } = usePrivy(); const { isConnected } = useConnection(); - const { disconnect } = useDisconnect(); + const { mutate: disconnect } = useDisconnect(); + + const authenticatedRef = useRef(authenticated); + const isConnectedRef = useRef(isConnected); + authenticatedRef.current = authenticated; + isConnectedRef.current = isConnected; useEffect(() => { if (!ready) return; - if (!authenticated && isConnected) { + if (!authenticatedRef.current && isConnectedRef.current) { disconnect(); } - }, [ready, authenticated, isConnected, disconnect]); + }, [ready, disconnect]); } diff --git a/src/lib/hyperliquid/hooks/useClients.ts b/src/lib/hyperliquid/hooks/useClients.ts index 9fa17ab9..73da46c2 100644 --- a/src/lib/hyperliquid/hooks/useClients.ts +++ b/src/lib/hyperliquid/hooks/useClients.ts @@ -1,10 +1,11 @@ import type { ExchangeClient, InfoClient, SubscriptionClient } from "@nktkas/hyperliquid"; +import { useWallets } from "@privy-io/react-auth"; import { useMemo } from "react"; -import { useConnection, useWalletClient } from "wagmi"; +import { useConnection } from "wagmi"; +import { arbitrum, arbitrumSepolia } from "wagmi/chains"; import { createExchangeClient } from "@/lib/hyperliquid/clients"; import { useHyperliquid } from "@/lib/hyperliquid/provider"; import { useAgentWallet } from "@/lib/hyperliquid/signing/use-agent-wallet"; -import { toHyperliquidWallet } from "@/lib/hyperliquid/wallet"; export interface HyperliquidClients { info: InfoClient; @@ -16,10 +17,10 @@ export interface HyperliquidClients { } export function useHyperliquidClients(): HyperliquidClients { - const { info, subscription } = useHyperliquid(); + const { info, subscription, env } = useHyperliquid(); const { signer, isReady: agentReady } = useAgentWallet(); const { address } = useConnection(); - const { data: walletClient } = useWalletClient(); + const { wallets } = useWallets(); const trading = useMemo(() => { if (!signer || !agentReady) return null; @@ -27,11 +28,32 @@ export function useHyperliquidClients(): HyperliquidClients { }, [signer, agentReady]); const user = useMemo(() => { - if (!walletClient || !address) return null; - const wallet = toHyperliquidWallet(walletClient, address); - if (!wallet) return null; - return createExchangeClient(wallet); - }, [walletClient, address]); + if (!address) return null; + const privyWallet = wallets.find((w) => w.address.toLowerCase() === address.toLowerCase()); + if (!privyWallet) return null; + const chain = env === "Testnet" ? arbitrumSepolia : arbitrum; + return createExchangeClient({ + address, + // Required for SDK to detect this as AbstractViemJsonRpcAccount and call getChainId() + // for signatureChainId. Without these, SDK falls back to chainId 1 (mainnet), which + // causes switchChain(1) and Hyperliquid signature validation to fail. + getAddresses: async () => [address], + getChainId: async () => chain.id, + signTypedData: async (params) => { + const provider = await privyWallet.getEthereumProvider(); + // Switch chain only if needed — avoids redundant popups on subsequent signing steps + // MetaMask v11+ rejects eth_signTypedData_v4 if domain chainId ≠ active chain + const currentChainId = parseInt((await provider.request({ method: "eth_chainId" })) as string, 16); + if (currentChainId !== chain.id) { + await privyWallet.switchChain(chain.id); + } + return provider.request({ + method: "eth_signTypedData_v4", + params: [address, JSON.stringify(params)], + }) as Promise<`0x${string}`>; + }, + }); + }, [address, wallets, env]); return { info, diff --git a/src/locales/ar/messages.po b/src/locales/ar/messages.po index 5aaf4710..894c93d9 100644 --- a/src/locales/ar/messages.po +++ b/src/locales/ar/messages.po @@ -205,8 +205,8 @@ msgstr "" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Builders" -msgstr "" +#~ msgid "Builders" +#~ msgstr "" #: src/components/trade/positions/twap-tab.tsx msgid "buy" @@ -793,8 +793,8 @@ msgstr "معزول" #~ msgstr "التأخير:" #: src/components/trade/header/top-nav.tsx -msgid "Leaderboard" -msgstr "لوحة المتصدرين" +#~ msgid "Leaderboard" +#~ msgstr "لوحة المتصدرين" #: src/components/trade/components/wallet-dialog.tsx #~ msgid "Learn more" @@ -1298,8 +1298,8 @@ msgstr "الربح والخسارة" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Portfolio" -msgstr "المحفظة" +#~ msgid "Portfolio" +#~ msgstr "المحفظة" #: src/components/trade/positions/funding-tab.tsx #: src/components/trade/tradebox/trade-form-fields.tsx @@ -1680,7 +1680,6 @@ msgstr "مرتب حسب {0}" #~ msgid "spot" #~ msgstr "فوري" -#: src/components/trade/header/top-nav.tsx #: src/components/trade/positions/balances-tab.tsx #: src/components/trade/positions/transfer-dialog.tsx #: src/components/trade/positions/transfer-dialog.tsx @@ -1701,8 +1700,8 @@ msgid "Spread" msgstr "الفارق" #: src/components/trade/header/top-nav.tsx -msgid "Staking" -msgstr "التخزين" +#~ msgid "Staking" +#~ msgstr "التخزين" #: src/lib/errors/definitions/scale.ts msgid "Start and end must differ" @@ -2059,8 +2058,8 @@ msgstr "القيمة بالدولار" #~ msgstr "القيمة" #: src/components/trade/header/top-nav.tsx -msgid "Vaults" -msgstr "الخزائن" +#~ msgid "Vaults" +#~ msgstr "الخزائن" #: src/lib/trade/use-button-content.ts msgid "Verifying..." diff --git a/src/locales/en/messages.po b/src/locales/en/messages.po index b36b8b43..3a41fdf8 100644 --- a/src/locales/en/messages.po +++ b/src/locales/en/messages.po @@ -205,8 +205,8 @@ msgstr "Builder Fee" #~ msgstr "Builder must have at least 100 USDC in perps account value" #: src/components/trade/header/top-nav.tsx -msgid "Builders" -msgstr "Builders" +#~ msgid "Builders" +#~ msgstr "Builders" #: src/components/trade/positions/twap-tab.tsx msgid "buy" @@ -797,8 +797,8 @@ msgstr "Isolated" #~ msgstr "Latency:" #: src/components/trade/header/top-nav.tsx -msgid "Leaderboard" -msgstr "Leaderboard" +#~ msgid "Leaderboard" +#~ msgstr "Leaderboard" #: src/components/trade/components/wallet-dialog.tsx #~ msgid "Learn more" @@ -1302,8 +1302,8 @@ msgstr "PNL" #~ msgstr "Popular" #: src/components/trade/header/top-nav.tsx -msgid "Portfolio" -msgstr "Portfolio" +#~ msgid "Portfolio" +#~ msgstr "Portfolio" #: src/components/trade/positions/funding-tab.tsx #: src/components/trade/tradebox/trade-form-fields.tsx @@ -1684,7 +1684,6 @@ msgstr "Sorted by {0}" #~ msgid "spot" #~ msgstr "spot" -#: src/components/trade/header/top-nav.tsx #: src/components/trade/positions/balances-tab.tsx #: src/components/trade/positions/transfer-dialog.tsx #: src/components/trade/positions/transfer-dialog.tsx @@ -1705,8 +1704,8 @@ msgid "Spread" msgstr "Spread" #: src/components/trade/header/top-nav.tsx -msgid "Staking" -msgstr "Staking" +#~ msgid "Staking" +#~ msgstr "Staking" #: src/lib/errors/definitions/scale.ts msgid "Start and end must differ" @@ -2067,8 +2066,8 @@ msgstr "USD Value" #~ msgstr "Value" #: src/components/trade/header/top-nav.tsx -msgid "Vaults" -msgstr "Vaults" +#~ msgid "Vaults" +#~ msgstr "Vaults" #: src/lib/trade/use-button-content.ts msgid "Verifying..." diff --git a/src/locales/es/messages.po b/src/locales/es/messages.po index 6135324d..a279ca24 100644 --- a/src/locales/es/messages.po +++ b/src/locales/es/messages.po @@ -205,8 +205,8 @@ msgstr "" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Builders" -msgstr "" +#~ msgid "Builders" +#~ msgstr "" #: src/components/trade/positions/twap-tab.tsx msgid "buy" @@ -793,8 +793,8 @@ msgstr "Aislado" #~ msgstr "Latencia:" #: src/components/trade/header/top-nav.tsx -msgid "Leaderboard" -msgstr "Clasificación" +#~ msgid "Leaderboard" +#~ msgstr "Clasificación" #: src/components/trade/components/wallet-dialog.tsx #~ msgid "Learn more" @@ -1298,8 +1298,8 @@ msgstr "PNL" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Portfolio" -msgstr "Portafolio" +#~ msgid "Portfolio" +#~ msgstr "Portafolio" #: src/components/trade/positions/funding-tab.tsx #: src/components/trade/tradebox/trade-form-fields.tsx @@ -1680,7 +1680,6 @@ msgstr "Ordenado por {0}" #~ msgid "spot" #~ msgstr "spot" -#: src/components/trade/header/top-nav.tsx #: src/components/trade/positions/balances-tab.tsx #: src/components/trade/positions/transfer-dialog.tsx #: src/components/trade/positions/transfer-dialog.tsx @@ -1701,8 +1700,8 @@ msgid "Spread" msgstr "Diferencial" #: src/components/trade/header/top-nav.tsx -msgid "Staking" -msgstr "Staking" +#~ msgid "Staking" +#~ msgstr "Staking" #: src/lib/errors/definitions/scale.ts msgid "Start and end must differ" @@ -2059,8 +2058,8 @@ msgstr "Valor en USD" #~ msgstr "Valor" #: src/components/trade/header/top-nav.tsx -msgid "Vaults" -msgstr "Bóvedas" +#~ msgid "Vaults" +#~ msgstr "Bóvedas" #: src/lib/trade/use-button-content.ts msgid "Verifying..." diff --git a/src/locales/fr/messages.po b/src/locales/fr/messages.po index b3126b61..f5604fcc 100644 --- a/src/locales/fr/messages.po +++ b/src/locales/fr/messages.po @@ -205,8 +205,8 @@ msgstr "" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Builders" -msgstr "" +#~ msgid "Builders" +#~ msgstr "" #: src/components/trade/positions/twap-tab.tsx msgid "buy" @@ -793,8 +793,8 @@ msgstr "Isolé" #~ msgstr "Latence :" #: src/components/trade/header/top-nav.tsx -msgid "Leaderboard" -msgstr "Classement" +#~ msgid "Leaderboard" +#~ msgstr "Classement" #: src/components/trade/components/wallet-dialog.tsx #~ msgid "Learn more" @@ -1298,8 +1298,8 @@ msgstr "PNL" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Portfolio" -msgstr "Portefeuille" +#~ msgid "Portfolio" +#~ msgstr "Portefeuille" #: src/components/trade/positions/funding-tab.tsx #: src/components/trade/tradebox/trade-form-fields.tsx @@ -1680,7 +1680,6 @@ msgstr "Trié par {0}" #~ msgid "spot" #~ msgstr "spot" -#: src/components/trade/header/top-nav.tsx #: src/components/trade/positions/balances-tab.tsx #: src/components/trade/positions/transfer-dialog.tsx #: src/components/trade/positions/transfer-dialog.tsx @@ -1701,8 +1700,8 @@ msgid "Spread" msgstr "Écart" #: src/components/trade/header/top-nav.tsx -msgid "Staking" -msgstr "Staking" +#~ msgid "Staking" +#~ msgstr "Staking" #: src/lib/errors/definitions/scale.ts msgid "Start and end must differ" @@ -2059,8 +2058,8 @@ msgstr "Valeur en USD" #~ msgstr "Valeur" #: src/components/trade/header/top-nav.tsx -msgid "Vaults" -msgstr "Coffres" +#~ msgid "Vaults" +#~ msgstr "Coffres" #: src/lib/trade/use-button-content.ts msgid "Verifying..." diff --git a/src/locales/hi/messages.po b/src/locales/hi/messages.po index 84464b55..84ca6c6b 100644 --- a/src/locales/hi/messages.po +++ b/src/locales/hi/messages.po @@ -205,8 +205,8 @@ msgstr "" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Builders" -msgstr "" +#~ msgid "Builders" +#~ msgstr "" #: src/components/trade/positions/twap-tab.tsx msgid "buy" @@ -793,8 +793,8 @@ msgstr "आइसोलेटेड" #~ msgstr "लेटेंसी:" #: src/components/trade/header/top-nav.tsx -msgid "Leaderboard" -msgstr "लीडरबोर्ड" +#~ msgid "Leaderboard" +#~ msgstr "लीडरबोर्ड" #: src/components/trade/components/wallet-dialog.tsx #~ msgid "Learn more" @@ -1298,8 +1298,8 @@ msgstr "PNL" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Portfolio" -msgstr "पोर्टफोलियो" +#~ msgid "Portfolio" +#~ msgstr "पोर्टफोलियो" #: src/components/trade/positions/funding-tab.tsx #: src/components/trade/tradebox/trade-form-fields.tsx @@ -1680,7 +1680,6 @@ msgstr "{0} से क्रमबद्ध" #~ msgid "spot" #~ msgstr "स्पॉट" -#: src/components/trade/header/top-nav.tsx #: src/components/trade/positions/balances-tab.tsx #: src/components/trade/positions/transfer-dialog.tsx #: src/components/trade/positions/transfer-dialog.tsx @@ -1701,8 +1700,8 @@ msgid "Spread" msgstr "स्प्रेड" #: src/components/trade/header/top-nav.tsx -msgid "Staking" -msgstr "स्टेकिंग" +#~ msgid "Staking" +#~ msgstr "स्टेकिंग" #: src/lib/errors/definitions/scale.ts msgid "Start and end must differ" @@ -2059,8 +2058,8 @@ msgstr "USD मूल्य" #~ msgstr "वैल्यू" #: src/components/trade/header/top-nav.tsx -msgid "Vaults" -msgstr "वॉल्ट" +#~ msgid "Vaults" +#~ msgstr "वॉल्ट" #: src/lib/trade/use-button-content.ts msgid "Verifying..." diff --git a/src/locales/zh/messages.po b/src/locales/zh/messages.po index 20510c35..c7148c8b 100644 --- a/src/locales/zh/messages.po +++ b/src/locales/zh/messages.po @@ -205,8 +205,8 @@ msgstr "" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Builders" -msgstr "" +#~ msgid "Builders" +#~ msgstr "" #: src/components/trade/positions/twap-tab.tsx msgid "buy" @@ -793,8 +793,8 @@ msgstr "逐仓" #~ msgstr "延迟:" #: src/components/trade/header/top-nav.tsx -msgid "Leaderboard" -msgstr "排行榜" +#~ msgid "Leaderboard" +#~ msgstr "排行榜" #: src/components/trade/components/wallet-dialog.tsx #~ msgid "Learn more" @@ -1298,8 +1298,8 @@ msgstr "盈亏" #~ msgstr "" #: src/components/trade/header/top-nav.tsx -msgid "Portfolio" -msgstr "投资组合" +#~ msgid "Portfolio" +#~ msgstr "投资组合" #: src/components/trade/positions/funding-tab.tsx #: src/components/trade/tradebox/trade-form-fields.tsx @@ -1680,7 +1680,6 @@ msgstr "已按 {0} 排序" #~ msgid "spot" #~ msgstr "现货" -#: src/components/trade/header/top-nav.tsx #: src/components/trade/positions/balances-tab.tsx #: src/components/trade/positions/transfer-dialog.tsx #: src/components/trade/positions/transfer-dialog.tsx @@ -1701,8 +1700,8 @@ msgid "Spread" msgstr "价差" #: src/components/trade/header/top-nav.tsx -msgid "Staking" -msgstr "质押" +#~ msgid "Staking" +#~ msgstr "质押" #: src/lib/errors/definitions/scale.ts msgid "Start and end must differ" @@ -2059,8 +2058,8 @@ msgstr "美元价值" #~ msgstr "价值" #: src/components/trade/header/top-nav.tsx -msgid "Vaults" -msgstr "金库" +#~ msgid "Vaults" +#~ msgstr "金库" #: src/lib/trade/use-button-content.ts msgid "Verifying..." From b4d6d15f6e6bb1ebfd5afd40f66914ad89f83129 Mon Sep 17 00:00:00 2001 From: alex luu Date: Fri, 20 Mar 2026 18:25:36 -0400 Subject: [PATCH 3/3] fix: remove dead code --- src/components/trade/tradebox/trade-panel.tsx | 4 ---- src/lib/errors/stacks/perp-order.ts | 8 +------- src/lib/errors/stacks/spot-order.ts | 8 +------- src/lib/trade/use-button-content.ts | 15 --------------- src/lib/trade/use-order-validation.ts | 1 - src/locales/ar/messages.po | 2 -- src/locales/en/messages.po | 2 -- src/locales/es/messages.po | 2 -- src/locales/fr/messages.po | 2 -- src/locales/hi/messages.po | 2 -- src/locales/zh/messages.po | 2 -- 11 files changed, 2 insertions(+), 46 deletions(-) diff --git a/src/components/trade/tradebox/trade-panel.tsx b/src/components/trade/tradebox/trade-panel.tsx index db6bf171..fb83e9a6 100644 --- a/src/components/trade/tradebox/trade-panel.tsx +++ b/src/components/trade/tradebox/trade-panel.tsx @@ -201,7 +201,6 @@ export function TradePanel() { const baseInput = { isConnected, - isWalletLoading: false, availableBalance, hasMarket: !!market, hasAssetIndex: typeof market?.assetId === "number", @@ -417,9 +416,6 @@ export function TradePanel() { const buttonContent = useButtonContent({ isConnected, - needsChainSwitch: false, - isSwitchingChain: false, - switchChain: () => {}, availableBalance, validation, isAgentLoading, diff --git a/src/lib/errors/stacks/perp-order.ts b/src/lib/errors/stacks/perp-order.ts index 0d435736..a7a93a2e 100644 --- a/src/lib/errors/stacks/perp-order.ts +++ b/src/lib/errors/stacks/perp-order.ts @@ -1,9 +1,5 @@ import { noBalanceValidator } from "../definitions/balance"; -import { - signerNotReadyValidator, - walletLoadingValidator, - walletNotConnectedValidator, -} from "../definitions/connection"; +import { signerNotReadyValidator, walletNotConnectedValidator } from "../definitions/connection"; import { marketNotReadyValidator, noMarketValidator, noMarkPriceValidator } from "../definitions/market"; import { enterLimitPriceValidator, @@ -33,7 +29,6 @@ import { runValidators, type ValidationError, type Validator } from "../types"; export interface PerpOrderContext extends OrderInputContext, TpSlContext, TriggerContext, ScaleContext, TwapContext { isConnected: boolean; - isWalletLoading: boolean; isReadyToTrade: boolean; needsAgentApproval: boolean; availableBalance: number; @@ -51,7 +46,6 @@ export interface PerpOrderValidationResult { const perpOrderValidators: Validator[] = [ walletNotConnectedValidator, - walletLoadingValidator, noBalanceValidator, noMarketValidator, marketNotReadyValidator, diff --git a/src/lib/errors/stacks/spot-order.ts b/src/lib/errors/stacks/spot-order.ts index cd127ce0..8b36bece 100644 --- a/src/lib/errors/stacks/spot-order.ts +++ b/src/lib/errors/stacks/spot-order.ts @@ -1,9 +1,5 @@ import { noBalanceValidator } from "../definitions/balance"; -import { - signerNotReadyValidator, - walletLoadingValidator, - walletNotConnectedValidator, -} from "../definitions/connection"; +import { signerNotReadyValidator, walletNotConnectedValidator } from "../definitions/connection"; import { marketNotReadyValidator, noMarketValidator } from "../definitions/market"; import { insufficientBaseBalanceValidator, @@ -20,7 +16,6 @@ import { runValidators, type ValidationError, type Validator } from "../types"; export interface SpotOrderContext extends SpotInputContext, SpotBalanceContext { isConnected: boolean; - isWalletLoading: boolean; isReadyToTrade: boolean; needsAgentApproval: boolean; availableBalance: number; @@ -37,7 +32,6 @@ export interface SpotOrderValidationResult { const spotOrderValidators: Validator[] = [ walletNotConnectedValidator, - walletLoadingValidator, noBalanceValidator, noMarketValidator, marketNotReadyValidator, diff --git a/src/lib/trade/use-button-content.ts b/src/lib/trade/use-button-content.ts index d5f6146f..6e07c7a7 100644 --- a/src/lib/trade/use-button-content.ts +++ b/src/lib/trade/use-button-content.ts @@ -1,14 +1,10 @@ import { t } from "@lingui/core/macro"; import { useMemo } from "react"; -import { ARBITRUM_CHAIN_ID } from "@/config/contracts"; import type { RegistrationStatus } from "@/lib/hyperliquid/signing/types"; import type { ButtonContent, Side, ValidationResult } from "@/lib/trade/types"; interface ButtonContentInput { isConnected: boolean; - needsChainSwitch: boolean; - isSwitchingChain: boolean; - switchChain: (chainId: number) => void; availableBalance: number; validation: ValidationResult; isAgentLoading: boolean; @@ -52,14 +48,6 @@ export function useButtonContent(input: ButtonContentInput): ButtonContent { variant: "cyan", }; } - if (input.needsChainSwitch) { - return { - text: input.isSwitchingChain ? t`Switching...` : t`Switch to Arbitrum`, - action: () => input.switchChain(ARBITRUM_CHAIN_ID), - disabled: input.isSwitchingChain, - variant: "cyan", - }; - } if (input.validation.needsApproval) { return { text: registerText, @@ -84,9 +72,6 @@ export function useButtonContent(input: ButtonContentInput): ButtonContent { }; }, [ input.isConnected, - input.needsChainSwitch, - input.isSwitchingChain, - input.switchChain, input.availableBalance, input.validation.needsApproval, input.validation.canSubmit, diff --git a/src/lib/trade/use-order-validation.ts b/src/lib/trade/use-order-validation.ts index 918cb7b1..c36d5db9 100644 --- a/src/lib/trade/use-order-validation.ts +++ b/src/lib/trade/use-order-validation.ts @@ -4,7 +4,6 @@ import type { Side, ValidationResult } from "@/lib/trade/types"; export interface BaseOrderInput { isConnected: boolean; - isWalletLoading: boolean; availableBalance: number; hasMarket: boolean; hasAssetIndex: boolean; diff --git a/src/locales/ar/messages.po b/src/locales/ar/messages.po index 894c93d9..32d7f42b 100644 --- a/src/locales/ar/messages.po +++ b/src/locales/ar/messages.po @@ -1791,7 +1791,6 @@ msgid "Switch to {displayName} market" msgstr "" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switch to Arbitrum" msgstr "التبديل إلى Arbitrum" @@ -1808,7 +1807,6 @@ msgid "Switch to light mode" msgstr "التبديل إلى الوضع الفاتح" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switching..." msgstr "جاري التبديل..." diff --git a/src/locales/en/messages.po b/src/locales/en/messages.po index 3a41fdf8..713a453d 100644 --- a/src/locales/en/messages.po +++ b/src/locales/en/messages.po @@ -1795,7 +1795,6 @@ msgid "Switch to {displayName} market" msgstr "Switch to {displayName} market" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switch to Arbitrum" msgstr "Switch to Arbitrum" @@ -1812,7 +1811,6 @@ msgid "Switch to light mode" msgstr "Switch to light mode" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switching..." msgstr "Switching..." diff --git a/src/locales/es/messages.po b/src/locales/es/messages.po index a279ca24..ba93ad43 100644 --- a/src/locales/es/messages.po +++ b/src/locales/es/messages.po @@ -1791,7 +1791,6 @@ msgid "Switch to {displayName} market" msgstr "" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switch to Arbitrum" msgstr "Cambiar a Arbitrum" @@ -1808,7 +1807,6 @@ msgid "Switch to light mode" msgstr "Cambiar a modo claro" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switching..." msgstr "Cambiando..." diff --git a/src/locales/fr/messages.po b/src/locales/fr/messages.po index f5604fcc..33dfa793 100644 --- a/src/locales/fr/messages.po +++ b/src/locales/fr/messages.po @@ -1791,7 +1791,6 @@ msgid "Switch to {displayName} market" msgstr "" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switch to Arbitrum" msgstr "Passer à Arbitrum" @@ -1808,7 +1807,6 @@ msgid "Switch to light mode" msgstr "Passer en mode clair" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switching..." msgstr "Changement..." diff --git a/src/locales/hi/messages.po b/src/locales/hi/messages.po index 84ca6c6b..655a0957 100644 --- a/src/locales/hi/messages.po +++ b/src/locales/hi/messages.po @@ -1791,7 +1791,6 @@ msgid "Switch to {displayName} market" msgstr "" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switch to Arbitrum" msgstr "Arbitrum पर स्विच करें" @@ -1808,7 +1807,6 @@ msgid "Switch to light mode" msgstr "लाइट मोड में बदलें" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switching..." msgstr "स्विच हो रहा है..." diff --git a/src/locales/zh/messages.po b/src/locales/zh/messages.po index c7148c8b..45cf8b1e 100644 --- a/src/locales/zh/messages.po +++ b/src/locales/zh/messages.po @@ -1791,7 +1791,6 @@ msgid "Switch to {displayName} market" msgstr "" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switch to Arbitrum" msgstr "切换到 Arbitrum" @@ -1808,7 +1807,6 @@ msgid "Switch to light mode" msgstr "切换到浅色模式" #: src/components/trade/tradebox/deposit-modal.tsx -#: src/lib/trade/use-button-content.ts msgid "Switching..." msgstr "切换中..."