fix: restore imtoken direct login path

This commit is contained in:
TerryM
2026-06-04 09:39:14 +08:00
parent 93790cb885
commit 53eab4a066
3 changed files with 62 additions and 1 deletions

View File

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