chore: remove wallet code comments
This commit is contained in:
@@ -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 */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user