fix: restore imtoken direct login path
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useAccount, useConnect, useDisconnect } from "wagmi";
|
||||
import { bsc } from "wagmi/chains";
|
||||
import { hasWalletConnectProjectId } from "./RainbowWalletProvider";
|
||||
import {
|
||||
connectInjectedWallet,
|
||||
getInjectedWallet,
|
||||
signInWithInjectedWallet,
|
||||
type WalletKind,
|
||||
@@ -177,6 +178,20 @@ export function useWalletConnectLogin() {
|
||||
getInjectedWallet(preferredWallet)
|
||||
) {
|
||||
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");
|
||||
const result = await signInWithInjectedWallet(preferredWallet);
|
||||
console.info("[wallet-login] injected verified", {
|
||||
|
||||
Reference in New Issue
Block a user