chore: remove wallet code comments

This commit is contained in:
TerryM
2026-06-04 09:55:19 +08:00
parent f8369b6361
commit 355c920c80
7 changed files with 2 additions and 46 deletions

View File

@@ -51,7 +51,6 @@ export default function App() {
<ScrollToTop />
<Routes>
<Route element={<PublicLayout />}>
{/* English (root, no prefix) */}
<Route
path="/"
element={<LocalizedHomePage targetLang="en" />}
@@ -79,7 +78,6 @@ export default function App() {
element={<Favorites />}
/>
{/* Each non-English language gets its own nested tree. */}
{localizedHomeRoutes.map((route) => (
<Route key={route.path} path={route.path}>
<Route

View File

@@ -45,13 +45,6 @@ function waitForInjected(kind: WalletKind): Promise<boolean> {
});
}
/**
* When the page is opened via a `?autoLogin=<wallet>` deeplink (typically from
* inside TokenPocket / imToken in-app browsers), wait for the wallet to inject
* `window.ethereum`, then complete wallet login without WalletConnect. imToken
* may drop the query string while opening its in-app browser, so imToken browser
* detection also starts the same direct-login path.
*/
export function AutoInjectedLogin() {
const { completeLogin, status } = useWallet();
@@ -81,7 +74,6 @@ export function AutoInjectedLogin() {
if (cancelled) return;
completeLogin(res.token, res.wallet);
} catch (err) {
// eslint-disable-next-line no-console
console.warn("[wallet-autologin] failed", err);
}
});

View File

@@ -8,11 +8,6 @@ const brands: Record<WalletKind, Brand> = {
imToken: { bg: "#11C4D1", label: "im" },
};
/**
* Lightweight brand badge for wallet buttons — a rounded square tinted with the
* wallet's brand color and its monogram. Keeps bundle small while making each
* wallet visually distinguishable.
*/
export function WalletBrandIcon({
kind,
size = 28,

View File

@@ -11,7 +11,6 @@ export class WalletStackErrorBoundary extends Component<Props, State> {
}
componentDidCatch(error: unknown): void {
// eslint-disable-next-line no-console
console.error("[wallet-stack] error boundary caught", error);
}

View File

@@ -120,7 +120,6 @@ async function personalSign(params: {
});
} catch (error) {
if (!shouldRetryPersonalSign(error)) throw error;
// Some injected wallets incorrectly expect the legacy param order.
return ethereum
.request<string>({
method: "personal_sign",
@@ -157,16 +156,11 @@ export function getInjectedWallet(kind?: WalletKind): EthereumProvider | null {
});
if (match) return match;
// Some imToken mobile versions inject a usable EIP-1193 provider without
// setting `isImToken`. Inside the imToken in-app browser, prefer the injected
// provider instead of falling back to WalletConnect, which can leave the UI at
// connected:no on China networks.
if (kind === "imToken" && isImTokenBrowser()) return providers[0] ?? ethereum;
return null;
}
/** Diagnostic: log what injected providers the browser exposes. */
export function logWalletProviders(): void {
const ethereum = getInjectedEthereum();
const list = (
@@ -180,7 +174,6 @@ export function logWalletProviders(): void {
isTokenPocket: Boolean(p.isTokenPocket),
isImToken: Boolean(p.isImToken),
}));
// eslint-disable-next-line no-console
console.info("[wallet-login] providers", {
hasEthereum: Boolean(ethereum),
count: list.length,
@@ -191,7 +184,6 @@ export function logWalletProviders(): void {
export async function connectInjectedWallet(
kind?: WalletKind,
): Promise<string> {
/* eslint-disable no-console */
console.info("[wallet-login] start injected connect", { kind });
logWalletProviders();
const ethereum = getInjectedWallet(kind);
@@ -207,14 +199,12 @@ export async function connectInjectedWallet(
console.info("[wallet-login] ensuring BNB Chain (0x38)…");
await ensureBnbChain(ethereum);
return address;
/* eslint-enable no-console */
}
export async function signInWithInjectedWallet(kind?: WalletKind): Promise<{
token: string;
wallet: string;
}> {
/* eslint-disable no-console */
console.info("[wallet-login] start injected", { kind });
logWalletProviders();
const ethereum = getInjectedWallet(kind);
@@ -223,8 +213,6 @@ export async function signInWithInjectedWallet(kind?: WalletKind): Promise<{
throw new Error("No injected wallet found");
}
// BNB Smart Chain is EVM-compatible, so browser wallets still expose the
// standard EIP-1193 method names (`eth_*`) while operating on BNB chain 56.
console.info("[wallet-login] requesting BNB wallet account…");
const address = await requestInjectedAddress(ethereum);
console.info("[wallet-login] account", address);
@@ -248,5 +236,4 @@ export async function signInWithInjectedWallet(kind?: WalletKind): Promise<{
});
console.info("[wallet-login] verified, wallet =", result.wallet);
return result;
/* eslint-enable no-console */
}

View File

@@ -14,7 +14,7 @@ export function writeWalletToken(token: string): void {
try {
window.localStorage.setItem(walletTokenKey, token);
} catch {
// Ignore storage failures; session will only live in memory.
return;
}
}
@@ -23,6 +23,6 @@ export function clearWalletToken(): void {
try {
window.localStorage.removeItem(walletTokenKey);
} catch {
// Ignore storage failures.
return;
}
}

View File

@@ -95,17 +95,6 @@ function connectorMatchesWallet(
return false;
}
/**
* MetaMask / imToken QR fallback via RainbowKit + WalletConnect.
*
* Flow: connect through RainbowKit/Wagmi on BNB Chain -> once an account is
* connected, complete a local frontend wallet session. WalletConnect fallback
* does not require message signature, backend nonce, or verify call.
*
* Entirely gated behind a real `VITE_WALLETCONNECT_PROJECT_ID`: when it is
* missing `available` is false and `start` is a no-op, so callers can hide or
* disable the entry instead of triggering a connect with a fake project id.
*/
export function useWalletConnectLogin() {
const available = hasWalletConnectProjectId();
const { address: localAddress, completeLogin } = useWallet();
@@ -215,10 +204,6 @@ export function useWalletConnectLogin() {
}
}
// QR mode must always use a WalletConnect-compatible connector so the
// desktop page can render a scannable `wc:` URI instead of opening a
// local browser extension. Deeplink mode can prefer wallet-specific
// connectors (notably MetaMask SDK on mobile).
const walletConnectConnector =
connectors.find((item) => item.type === "walletConnect") ??
connectors.find((item) => item.id === "walletConnect");