terry-staging #16

Merged
terry merged 96 commits from terry-staging into main 2026-06-05 16:33:12 +00:00
3 changed files with 62 additions and 1 deletions
Showing only changes of commit 53eab4a066 - Show all commits

View File

@@ -0,0 +1,38 @@
---
title: "Restore imToken direct injected login path — Quick Fix"
type: quick-fix
date: 2026-06-04
---
# Restore imToken direct injected login path — Quick Fix
## Bug
imToken could log in on the 2026-06-03 22:00 Malaysia-time-era build, but the current build can no longer log in after opening imToken's in-app browser.
## Root Cause
The working 2026-06-03 evening flow used `connectInjectedWallet()` and completed a local frontend session for TokenPocket/imToken direct in-app-browser login. Later changes switched injected direct login to `signInWithInjectedWallet()`, which requires backend nonce + `personal_sign` verification. imToken mobile appears incompatible or unstable with that newer signature-verification path in this flow.
## Fix
Restored the old local-session direct injected path for imToken only:
- imToken `?autoLogin=` in-app-browser flow now uses `connectInjectedWallet()` and `localWalletToken(address)`.
- imToken direct injected login from the wallet modal uses the same local-session path.
- TokenPocket still uses the newer backend signature verification path.
### Files Modified
- `src/wallet/AutoInjectedLogin.tsx` — restores imToken auto-login to the 2026-06-03 direct injected local-session behavior.
- `src/wallet/useWalletConnectLogin.ts` — restores imToken injected deeplink login to the local-session behavior.
## Verification
- `npx tsc --noEmit`
- `npm run format:check`
- `npm test`
## Notes
This is intentionally scoped to imToken to match the known-working Malaysia 10pm behavior without undoing the TokenPocket signature-verification work.

View File

@@ -1,10 +1,11 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { import {
connectInjectedWallet,
getInjectedWallet, getInjectedWallet,
signInWithInjectedWallet, signInWithInjectedWallet,
type WalletKind, type WalletKind,
} from "./injected"; } from "./injected";
import { useWallet } from "./WalletProvider"; import { localWalletToken, useWallet } from "./WalletProvider";
const AUTO_LOGIN_PARAM = "autoLogin"; const AUTO_LOGIN_PARAM = "autoLogin";
const ETHEREUM_WAIT_MS = 8000; const ETHEREUM_WAIT_MS = 8000;
@@ -67,6 +68,13 @@ export function AutoInjectedLogin() {
void waitForInjected(kind).then(async (ready) => { void waitForInjected(kind).then(async (ready) => {
if (cancelled || !ready) return; if (cancelled || !ready) return;
try { try {
if (kind === "imToken") {
const address = await connectInjectedWallet(kind);
if (cancelled) return;
completeLogin(localWalletToken(address), address);
return;
}
const res = await signInWithInjectedWallet(kind); const res = await signInWithInjectedWallet(kind);
if (cancelled) return; if (cancelled) return;
completeLogin(res.token, res.wallet); completeLogin(res.token, res.wallet);

View File

@@ -3,6 +3,7 @@ import { useAccount, useConnect, useDisconnect } from "wagmi";
import { bsc } from "wagmi/chains"; import { bsc } from "wagmi/chains";
import { hasWalletConnectProjectId } from "./RainbowWalletProvider"; import { hasWalletConnectProjectId } from "./RainbowWalletProvider";
import { import {
connectInjectedWallet,
getInjectedWallet, getInjectedWallet,
signInWithInjectedWallet, signInWithInjectedWallet,
type WalletKind, type WalletKind,
@@ -177,6 +178,20 @@ export function useWalletConnectLogin() {
getInjectedWallet(preferredWallet) getInjectedWallet(preferredWallet)
) { ) {
try { try {
if (preferredWallet === "imToken") {
const injectedAddress =
await connectInjectedWallet(preferredWallet);
console.info("[wallet-login] injected connected", {
preferredWallet,
address: injectedAddress,
chain: "BNB Chain",
chainId: bsc.id,
});
completeLogin(localWalletToken(injectedAddress), injectedAddress);
setState("idle");
return;
}
setState("signing"); setState("signing");
const result = await signInWithInjectedWallet(preferredWallet); const result = await signInWithInjectedWallet(preferredWallet);
console.info("[wallet-login] injected verified", { console.info("[wallet-login] injected verified", {