fix(wallet): improve imtoken mobile login fallback

This commit is contained in:
TerryM
2026-06-02 23:32:39 +08:00
parent a8863c5478
commit cd85a4bcfa
2 changed files with 74 additions and 5 deletions

View File

@@ -175,6 +175,28 @@ 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);
if (!ethereum) {
console.warn("[wallet-login] no injected provider found");
throw new Error("No injected wallet found");
}
console.info("[wallet-login] requesting BNB wallet account…");
const address = await requestInjectedAddress(ethereum);
console.info("[wallet-login] injected account", address);
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;