@particle-network/connectkit
Version:
74 lines (71 loc) • 2.33 kB
JavaScript
"use client";
import {
init_useIsMobile,
useIsMobile
} from "./chunk-PKYZZXB3.mjs";
import {
init_useConnectors,
useConnector
} from "./chunk-QGF3ZKLH.mjs";
import {
hasPCDownloadUrl,
init_useRouter,
init_utils,
openMobileUrl,
useRouter
} from "./chunk-ODGVUXUQ.mjs";
import {
__esm
} from "./chunk-Y7A564BU.mjs";
// src/hooks/useConnectWithWallet.ts
var useConnectWithWallet;
var init_useConnectWithWallet = __esm({
"src/hooks/useConnectWithWallet.ts"() {
"use strict";
init_utils();
init_useConnectors();
init_useIsMobile();
init_useRouter();
useConnectWithWallet = () => {
const { navigate } = useRouter();
const isMobile = useIsMobile();
const connector = useConnector("walletConnect");
const connectWallet = (walletProps, params) => {
if (walletProps.isInstalled) {
navigate("connecting" /* Connecting */, {
wallet: walletProps,
passkeyParams: params?.passkeyParams,
authParams: params?.authParams
});
} else if (walletProps.connector.id === "walletConnect") {
if (isMobile) {
navigate("connecting" /* Connecting */, { wallet: walletProps });
} else {
navigate("walletconnect" /* Walletconnect */, { wallet: walletProps });
}
} else if (walletProps.connector.chainType === "evm" && walletProps.getWalletConnectDeeplink && connector) {
if (isMobile) {
navigate("connecting" /* Connecting */, { wallet: walletProps });
} else {
navigate("walletconnect" /* Walletconnect */, { wallet: walletProps });
}
} else {
if (walletProps.getDAppBrowserDeeplink && isMobile) {
const url = walletProps.getDAppBrowserDeeplink(window.location.href);
openMobileUrl(url);
} else if (!isMobile && (hasPCDownloadUrl(walletProps) || walletProps.id === "braveWallet")) {
navigate("download-app" /* DownloadApp */, { wallet: walletProps });
} else {
navigate("connecting" /* Connecting */, { wallet: walletProps });
}
}
};
return connectWallet;
};
}
});
export {
useConnectWithWallet,
init_useConnectWithWallet
};
//# sourceMappingURL=chunk-OKYNVRZW.mjs.map