From cd43453649fc84142155fe8d170084f0a8ca7408 Mon Sep 17 00:00:00 2001 From: Khac Kien Date: Fri, 22 May 2026 14:37:36 +0700 Subject: [PATCH 1/2] Revert "fix: safepal wallet connection (#3097)" This reverts commit 97ab1bd8e46686f7ebbebff9c0549732c0cb9756. --- .../web3/WalletModal/useConnections.tsx | 32 +++++++------------ .../src/components/Web3Provider/index.tsx | 5 ++- .../SwapV3/Components/SwapTradeRoute.tsx | 4 +-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx b/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx index f0a8c95f9b..a3cfd8a899 100644 --- a/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx +++ b/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx @@ -5,8 +5,6 @@ import { Connector, useConnectors } from 'wagmi' import { CONNECTION, CONNECTION_ORDER, HardCodedConnectors, getConnectorWithId } from 'components/Web3Provider' import { isInSafeApp } from 'utils' -const normalizeConnectorName = (name: string) => name.trim().toLowerCase() - function getInjectedConnectors(connectors: readonly Connector[]) { let isCoinbaseWalletBrowser = false const injectedConnectors = connectors.filter(c => { @@ -25,6 +23,11 @@ function getInjectedConnectors(connectors: readonly Connector[]) { return false } + // SafePal is registered as an injected connector, but should only be shown when its provider is actually present. + if (c.id === CONNECTION.SAFEPAL && !window.safepalProvider) { + return false + } + return c.type === CONNECTION.INJECTED_CONNECTOR_TYPE && c.id !== CONNECTION.INJECTED_CONNECTOR_ID }) @@ -47,20 +50,6 @@ function getInjectedConnectors(connectors: readonly Connector[]) { return { injectedConnectors, isCoinbaseWalletBrowser } } -function dedupeConnectorsByName(connectors: InjectableConnector[]) { - const seen = new Set() - return connectors.filter(connector => { - const name = normalizeConnectorName(connector.name) - if (seen.has(name)) return false - seen.add(name) - return true - }) -} - -function getConnectorOrderId(connector: Connector) { - return HardCodedConnectors.find(c => c.id === connector.id)?.realId ?? connector.id -} - type InjectableConnector = Connector & { isInjected?: boolean } export function useOrderedConnections(): InjectableConnector[] { const connectors = useConnectors() @@ -118,20 +107,21 @@ export function useOrderedConnections(): InjectableConnector[] { // Other EIP-6963 injected connectors (Rabby, Phantom, Trust, etc.) the user has installed. orderedConnectors.push(...injectedConnectorsWithoutHardcoded) - // Add always-available connectors before applying CONNECTION_ORDER. + // WalletConnect and Coinbase are added last in the list. orderedConnectors.push(walletConnectConnector) orderedConnectors.push(coinbaseSdkConnector) - orderedConnectors.push(...hardcodeInjectedConnectors) // Sort the connectors by the CONNECTION_ORDER, if not found, put at the end orderedConnectors.sort((a, b) => { - const aIndex = CONNECTION_ORDER.indexOf(getConnectorOrderId(a) as any) - const bIndex = CONNECTION_ORDER.indexOf(getConnectorOrderId(b) as any) + const aIndex = CONNECTION_ORDER.indexOf(a.id as any) + const bIndex = CONNECTION_ORDER.indexOf(b.id as any) if (aIndex === -1) return 1 if (bIndex === -1) return -1 return aIndex - bIndex }) - return dedupeConnectorsByName(orderedConnectors) + orderedConnectors.push(...hardcodeInjectedConnectors) + + return orderedConnectors }, [connectors]) } diff --git a/apps/kyberswap-interface/src/components/Web3Provider/index.tsx b/apps/kyberswap-interface/src/components/Web3Provider/index.tsx index 286e651db0..227ba312fd 100644 --- a/apps/kyberswap-interface/src/components/Web3Provider/index.tsx +++ b/apps/kyberswap-interface/src/components/Web3Provider/index.tsx @@ -153,8 +153,8 @@ export const CONNECTION = { COINBASE_RDNS: 'com.coinbase.wallet', METAMASK_SDK_CONNECTOR_ID: 'metaMaskSDK', METAMASK_RDNS: 'io.metamask', - PHANTOM: 'app.phantom', RABBY: 'io.rabby', + //UNISWAP_EXTENSION_RDNS: 'org.uniswap.app', SAFE_CONNECTOR_ID: 'safe', PORTO: 'xyz.ithaca.porto', BINANCE: 'com.binance.wallet', @@ -165,8 +165,6 @@ export const CONNECTION = { export const CONNECTION_ORDER = [ CONNECTION.METAMASK_SDK_CONNECTOR_ID, CONNECTION.METAMASK_RDNS, - CONNECTION.WALLET_CONNECT_CONNECTOR_ID, - CONNECTION.PHANTOM, CONNECTION.RABBY, CONNECTION.COINBASE_SDK_CONNECTOR_ID, CONNECTION.COINBASE_RDNS, @@ -174,6 +172,7 @@ export const CONNECTION_ORDER = [ CONNECTION.BITGET, CONNECTION.SAFEPAL, CONNECTION.PORTO, + CONNECTION.WALLET_CONNECT_CONNECTOR_ID, ] export const CONNECTOR_ICON_OVERRIDE_MAP: { [id in string]?: string } = { diff --git a/apps/kyberswap-interface/src/pages/SwapV3/Components/SwapTradeRoute.tsx b/apps/kyberswap-interface/src/pages/SwapV3/Components/SwapTradeRoute.tsx index 2d03260459..d7245f93bb 100644 --- a/apps/kyberswap-interface/src/pages/SwapV3/Components/SwapTradeRoute.tsx +++ b/apps/kyberswap-interface/src/pages/SwapV3/Components/SwapTradeRoute.tsx @@ -171,8 +171,8 @@ const SwapTradeRoute = ({ const titleData = useMemo( () => ({ - amountIn: inputAmount?.toSignificant(8), - amountOut: outputAmount?.toSignificant(8), + amountIn: inputAmount?.toSignificant(4), + amountOut: outputAmount?.toSignificant(4), inputSymbol: currencyIn?.symbol, outputSymbol: currencyOut?.symbol, }), From caff3c5a84ff2dec4e567af598a10f2bf5547af9 Mon Sep 17 00:00:00 2001 From: Khac Kien Date: Fri, 22 May 2026 14:38:23 +0700 Subject: [PATCH 2/2] Revert "hotfix: check safepal connection without provider (#3076)" This reverts commit babefc7524fbc7c062baf1f48aa5793a5bb48682. --- .../Header/web3/WalletModal/useConnections.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx b/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx index a3cfd8a899..d23089e79e 100644 --- a/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx +++ b/apps/kyberswap-interface/src/components/Header/web3/WalletModal/useConnections.tsx @@ -23,11 +23,6 @@ function getInjectedConnectors(connectors: readonly Connector[]) { return false } - // SafePal is registered as an injected connector, but should only be shown when its provider is actually present. - if (c.id === CONNECTION.SAFEPAL && !window.safepalProvider) { - return false - } - return c.type === CONNECTION.INJECTED_CONNECTOR_TYPE && c.id !== CONNECTION.INJECTED_CONNECTOR_ID }) @@ -68,7 +63,7 @@ export function useOrderedConnections(): InjectableConnector[] { let hardcodeInjectedConnectors = connectors.filter(c => hardcodedInjectedIds.includes(c.id)) - let injectedConnectorsWithoutHardcoded = injectedConnectors.filter(c => { + const injectedConnectorsWithoutHardcoded = injectedConnectors.filter(c => { return !hardcodedInjectedIds.includes(c.id) }) @@ -90,7 +85,7 @@ export function useOrderedConnections(): InjectableConnector[] { injectedConnectorsWithoutHardcoded.length === 2 && injectedConnectorsWithoutHardcoded.some(c => c.id === CONNECTION.PORTO) ) { - injectedConnectorsWithoutHardcoded = injectedConnectorsWithoutHardcoded.filter(c => c.id !== CONNECTION.PORTO) + return injectedConnectorsWithoutHardcoded.filter(c => c.id !== CONNECTION.PORTO) } // Special-case: Only display the Coinbase connector in the Coinbase Wallet.