- Remove forced BNB chain switch on injected login (signature is chain-agnostic) - Refine isMobileDevice so touch Macs stay on desktop flow - Wire RainbowKit/WalletConnect as a real MetaMask/imToken QR fallback, gated on a valid VITE_WALLETCONNECT_PROJECT_ID - Rebuild login modal: single desktop primary action, collapsible other methods, mobile open-app fallback feedback, brand icons - Add My Favorites entry points (header, mobile menu, wallet dropdown) - Favorites page: error retry, mobile filter drawer - Auto sign-out and re-login prompt on favorites 401 - Full native translations for all wallet strings across 7 locales Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
type WalletKind = "tokenPocket" | "metaMask" | "imToken";
|
|
|
|
function currentDappUrl(): string {
|
|
if (typeof window === "undefined") return "https://ark-library.com";
|
|
return window.location.href;
|
|
}
|
|
|
|
export function walletDeepLink(
|
|
kind: WalletKind,
|
|
dappUrl = currentDappUrl(),
|
|
): string {
|
|
switch (kind) {
|
|
case "tokenPocket":
|
|
return `tpdapp://open?params=${encodeURIComponent(
|
|
JSON.stringify({ url: dappUrl, chain: "BSC" }),
|
|
)}`;
|
|
case "metaMask":
|
|
return `https://metamask.app.link/dapp/${encodeURIComponent(
|
|
dappUrl.replace(/^https?:\/\//, ""),
|
|
)}`;
|
|
case "imToken":
|
|
return `imtokenv2://navigate/DappView?url=${encodeURIComponent(dappUrl)}`;
|
|
default:
|
|
return dappUrl;
|
|
}
|
|
}
|
|
|
|
export function openWalletDeepLink(kind: WalletKind): void {
|
|
if (typeof window === "undefined") return;
|
|
window.location.href = walletDeepLink(kind);
|
|
}
|
|
|
|
const downloadUrls: Record<WalletKind, string> = {
|
|
tokenPocket: "https://www.tokenpocket.pro/en/download/app",
|
|
metaMask: "https://metamask.io/download/",
|
|
imToken: "https://token.im/download",
|
|
};
|
|
|
|
export function walletDownloadUrl(kind: WalletKind): string {
|
|
return downloadUrls[kind];
|
|
}
|