@getpara/react-sdk 2.0.0-alpha.3 → 2.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.mjs +23 -13
- package/dist/index.d.ts +0 -1
- package/dist/index.js +6 -6499
- package/dist/modal/ParaModal.js +301 -0
- package/dist/modal/components/Account/Account.js +148 -0
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfile.js +168 -0
- package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLink.js +206 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +111 -0
- package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
- package/dist/modal/components/AddFunds/AddFunds.d.ts +0 -2
- package/dist/modal/components/AddFunds/AddFunds.js +69 -0
- package/dist/modal/components/AddFunds/AddFundsAsset.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsAsset.js +125 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +78 -0
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +31 -0
- package/dist/modal/components/AddFunds/AddFundsContext.js +160 -0
- package/dist/modal/components/AddFunds/AddFundsDone.js +49 -0
- package/dist/modal/components/AddFunds/AddFundsProvider.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsProvider.js +109 -0
- package/dist/modal/components/AddFunds/AddFundsReceive.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsReceive.js +83 -0
- package/dist/modal/components/AddFunds/AddFundsSettings.d.ts +1 -0
- package/dist/modal/components/AddFunds/AddFundsSettings.js +237 -0
- package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
- package/dist/modal/components/AddFunds/common.d.ts +19 -0
- package/dist/modal/components/AddFunds/common.js +24 -0
- package/dist/modal/components/AddFunds/index.js +4 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
- package/dist/modal/components/AuthInput/AuthInput.js +277 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
- package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +50 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +164 -0
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +85 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +49 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +62 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +48 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +350 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +95 -0
- package/dist/modal/components/ChainSwitch/config.js +17 -0
- package/dist/modal/components/Controls/Controls.js +78 -0
- package/dist/modal/components/Controls/Selects.js +173 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +1 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +75 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +175 -0
- package/dist/modal/components/ExternalWalletStep/config.js +17 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +39 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +184 -0
- package/dist/modal/components/Footer/Footer.js +95 -0
- package/dist/modal/components/Header/Header.js +43 -0
- package/dist/modal/components/Header/hooks/useStepTitle.js +61 -0
- package/dist/modal/components/Hero/Hero.js +116 -0
- package/dist/modal/components/IFrameStep/IFrameStep.js +59 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +4 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +44 -0
- package/dist/modal/components/ModalContent/ModalContent.js +88 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +31 -0
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +79 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +74 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +107 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +132 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +27 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +160 -0
- package/dist/modal/components/Waiting/Waiting.js +17 -0
- package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
- package/dist/modal/components/WalletCard/WalletCard.d.ts +3 -3
- package/dist/modal/components/WalletCard/WalletCard.js +128 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +83 -0
- package/dist/modal/components/common.d.ts +49 -13
- package/dist/modal/components/common.js +261 -0
- package/dist/modal/components/index.js +2 -0
- package/dist/modal/constants/constants.d.ts +10 -2
- package/dist/modal/constants/constants.js +142 -0
- package/dist/modal/constants/defaults.js +10 -0
- package/dist/modal/constants/oAuthLogos.d.ts +15 -6
- package/dist/modal/constants/oAuthLogos.js +158 -0
- package/dist/modal/constants/walletTypeConfig.d.ts +6 -0
- package/dist/modal/constants/walletTypeConfig.js +13 -0
- package/dist/modal/hooks/useGoBack.js +43 -0
- package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
- package/dist/modal/hooks/useTelegramLogin.js +65 -0
- package/dist/modal/index.d.ts +1 -2
- package/dist/modal/index.js +29 -0
- package/dist/modal/stores/index.js +2 -0
- package/dist/modal/stores/modal/actions.js +135 -0
- package/dist/modal/stores/modal/useModalStore.d.ts +15 -6
- package/dist/modal/stores/modal/useModalStore.js +73 -0
- package/dist/modal/types/commonTypes.d.ts +0 -47
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/modalProps.d.ts +15 -2
- package/dist/modal/types/modalProps.js +12 -0
- package/dist/modal/utils/authInputHelpers.d.ts +5 -0
- package/dist/modal/utils/authInputHelpers.js +41 -0
- package/dist/modal/utils/authLayoutHelpers.js +8 -0
- package/dist/modal/utils/countryCodes.js +45 -0
- package/dist/modal/utils/getMailtoLink.js +10 -0
- package/dist/modal/utils/getTileButtonFlex.js +20 -0
- package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
- package/dist/modal/utils/getWalletDisplayName.js +22 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.js +60 -0
- package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
- package/dist/modal/utils/steps.d.ts +21 -2
- package/dist/modal/utils/steps.js +273 -0
- package/dist/modal/utils/stringFormatters.d.ts +1 -0
- package/dist/modal/utils/stringFormatters.js +19 -0
- package/dist/modal/utils/validateOnRampConfig.js +32 -0
- package/dist/package.json +6 -0
- package/dist/provider/ParaProvider.js +117 -0
- package/dist/provider/actions/getEmbeddedAccount.d.ts +26 -0
- package/dist/provider/actions/getEmbeddedAccount.js +52 -0
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/getWallet.js +18 -0
- package/dist/provider/actions/index.d.ts +22 -0
- package/dist/provider/actions/index.js +79 -0
- package/dist/provider/actions/utils.d.ts +4 -3
- package/dist/provider/actions/utils.js +34 -0
- package/dist/provider/components/CosmosWalletWrapper.js +43 -0
- package/dist/provider/components/EvmWalletWrapper.js +43 -0
- package/dist/provider/components/ExternalWalletWrapper.js +140 -0
- package/dist/provider/components/SolanaWalletWrapper.js +44 -0
- package/dist/provider/external/getParaCosmosConnector.js +19 -0
- package/dist/provider/external/getParaCosmosLib.d.ts +4 -0
- package/dist/provider/external/getParaCosmosLib.js +16 -0
- package/dist/provider/external/getParaEvmConnector.js +19 -0
- package/dist/provider/external/getParaEvmLib.d.ts +4 -0
- package/dist/provider/external/getParaEvmLib.js +16 -0
- package/dist/provider/external/getParaSolanaConnector.js +19 -0
- package/dist/provider/external/getParaSolanaLib.d.ts +4 -0
- package/dist/provider/external/getParaSolanaLib.js +16 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +1 -11
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +8 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +1 -2
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +1 -7
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +8 -0
- package/dist/provider/hooks/index.js +4 -0
- package/dist/provider/hooks/mutations/core.d.ts +27 -0
- package/dist/provider/hooks/mutations/core.js +66 -0
- package/dist/provider/hooks/mutations/index.d.ts +3 -25
- package/dist/provider/hooks/mutations/index.js +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
- package/dist/provider/hooks/mutations/utils.d.ts +11 -3
- package/dist/provider/hooks/mutations/utils.js +90 -0
- package/dist/provider/hooks/queries/core.d.ts +4 -0
- package/dist/provider/hooks/queries/core.js +16 -0
- package/dist/provider/hooks/queries/index.d.ts +2 -0
- package/dist/provider/hooks/queries/index.js +11 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +91 -2
- package/dist/provider/hooks/queries/useAccount.js +138 -0
- package/dist/provider/hooks/queries/useIsFullyLoggedIn.d.ts +5 -0
- package/dist/provider/hooks/queries/useIsFullyLoggedIn.js +24 -0
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWallet.js +26 -0
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +6 -0
- package/dist/provider/hooks/queries/useWalletBalance.js +55 -0
- package/dist/provider/hooks/queries/utils.d.ts +7 -0
- package/dist/provider/hooks/queries/utils.js +25 -0
- package/dist/provider/hooks/utils/index.js +10 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
- package/dist/provider/hooks/utils/useClient.d.ts +1 -1
- package/dist/provider/hooks/utils/useClient.js +10 -0
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +157 -0
- package/dist/provider/hooks/utils/useFormattedBiometricHints.d.ts +4 -0
- package/dist/provider/hooks/utils/useFormattedBiometricHints.js +27 -0
- package/dist/provider/hooks/utils/useInternalClient.js +10 -0
- package/dist/provider/hooks/utils/useModal.d.ts +4 -1
- package/dist/provider/hooks/utils/useModal.js +27 -0
- package/dist/provider/hooks/utils/useWalletState.d.ts +3 -3
- package/dist/provider/hooks/utils/useWalletState.js +48 -0
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +11 -0
- package/dist/provider/providers/AccountLinkProvider.d.ts +47 -0
- package/dist/provider/providers/AccountLinkProvider.js +452 -0
- package/dist/provider/providers/AuthProvider.d.ts +12 -6
- package/dist/provider/providers/AuthProvider.js +523 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +21 -35
- package/dist/provider/providers/ExternalWalletProvider.js +596 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +1 -1
- package/dist/provider/stores/getters.js +13 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/analytics.d.ts +3 -0
- package/dist/provider/stores/slices/analytics.js +9 -0
- package/dist/provider/stores/slices/client.js +9 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.js +46 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +6 -0
- package/dist/provider/stores/slices/modal.js +18 -0
- package/dist/provider/stores/slices/wallet.js +13 -0
- package/dist/provider/stores/types.d.ts +20 -5
- package/dist/provider/stores/types.js +1 -0
- package/dist/provider/stores/useStore.js +34 -0
- package/dist/provider/types/externalWalletProviders.d.ts +2 -2
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +25 -5
- package/dist/provider/types/provider.js +1 -0
- package/dist/provider/types/query.js +1 -0
- package/dist/provider/types/utils.d.ts +28 -5
- package/dist/provider/types/utils.js +1 -0
- package/dist/provider/utils/constants.d.ts +5 -0
- package/dist/provider/utils/constants.js +10 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +2 -2
- package/dist/provider/utils/renameMutations.js +18 -0
- package/package.json +40 -39
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/StripeComponents/StripeComponents.d.ts +0 -16
- package/dist/modal/types/externalWallets.d.ts +0 -31
- package/dist/provider/actions/getAccount.d.ts +0 -19
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__objRest,
|
|
5
|
+
__spreadProps,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
|
9
|
+
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
10
|
+
import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
|
|
11
|
+
import { useStore } from "../../stores/useStore.js";
|
|
12
|
+
import { useContext } from "react";
|
|
13
|
+
import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
|
|
14
|
+
const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
|
|
15
|
+
function pickSolanaAdapter(adapter) {
|
|
16
|
+
if (!adapter) return { isConnected: false };
|
|
17
|
+
const { connected, connecting, publicKey, name, icon, readyState, supportedTransactionVersions, url } = adapter;
|
|
18
|
+
return {
|
|
19
|
+
isConnected: connected,
|
|
20
|
+
isConnecting: connecting,
|
|
21
|
+
publicKey,
|
|
22
|
+
name,
|
|
23
|
+
icon,
|
|
24
|
+
readyState,
|
|
25
|
+
supportedTransactionVersions,
|
|
26
|
+
url
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function pickCosmosAccount(account) {
|
|
30
|
+
if (!account) return { isConnected: false };
|
|
31
|
+
const _a = account, { reconnect: _ } = _a, rest = __objRest(_a, ["reconnect"]);
|
|
32
|
+
return rest;
|
|
33
|
+
}
|
|
34
|
+
const useAccount = ({ cosmos } = {}) => {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
36
|
+
const client = useInternalClient();
|
|
37
|
+
const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
|
|
38
|
+
const evmContext = useStore((state) => state.evmContext);
|
|
39
|
+
const { useAccount: useEvmAccount } = useContext(evmContext);
|
|
40
|
+
const evmAccount = useEvmAccount();
|
|
41
|
+
const evmQueryKeys = [evmAccount == null ? void 0 : evmAccount.status, evmAccount == null ? void 0 : evmAccount.addresses, evmAccount == null ? void 0 : evmAccount.chainId];
|
|
42
|
+
const cosmosContext = useStore((state) => state.cosmosContext);
|
|
43
|
+
const { useAccount: useCosmosAccount } = useContext(cosmosContext);
|
|
44
|
+
const cosmosAccount = useCosmosAccount(cosmos);
|
|
45
|
+
const cosmosQueryKeys = [cosmosAccount == null ? void 0 : cosmosAccount.status, cosmosAccount == null ? void 0 : cosmosAccount.data];
|
|
46
|
+
const solanaContext = useStore((state) => state.solanaContext);
|
|
47
|
+
const { useWallet: useSolanaWallet } = useContext(solanaContext);
|
|
48
|
+
const solanaWallet = useSolanaWallet();
|
|
49
|
+
const solanaQueryKeys = [
|
|
50
|
+
(_b = (_a = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a.adapter) == null ? void 0 : _b.connected,
|
|
51
|
+
(_d = (_c = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _c.adapter) == null ? void 0 : _d.connecting,
|
|
52
|
+
(_f = (_e = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _e.adapter) == null ? void 0 : _f.publicKey
|
|
53
|
+
];
|
|
54
|
+
const solanaAdapter = (_g = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _g.adapter;
|
|
55
|
+
const { data, isLoading } = useQuery({
|
|
56
|
+
enabled: isSuccess && !!client,
|
|
57
|
+
queryKey: [ACCOUNT_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null, client == null ? void 0 : client.userId, evmQueryKeys, cosmosQueryKeys, solanaQueryKeys],
|
|
58
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
59
|
+
const isReady = client.isReady;
|
|
60
|
+
const paraAccount = yield getEmbeddedAccount(client);
|
|
61
|
+
let connectionType = "none";
|
|
62
|
+
if (paraAccount.isConnected) {
|
|
63
|
+
connectionType = "embedded";
|
|
64
|
+
if (paraAccount.wallets.some((w) => w.isExternal)) {
|
|
65
|
+
connectionType = "both";
|
|
66
|
+
}
|
|
67
|
+
if (paraAccount.wallets.every((w) => w.isExternal) && ((evmAccount == null ? void 0 : evmAccount.isConnected) || (cosmosAccount == null ? void 0 : cosmosAccount.isConnected) || (solanaAdapter == null ? void 0 : solanaAdapter.connected))) {
|
|
68
|
+
connectionType = "external";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const isEmbeddedConnected = paraAccount.isConnected && (!!paraAccount.userId || paraAccount.isGuestMode);
|
|
72
|
+
const connectedNetworks = [];
|
|
73
|
+
if (evmAccount == null ? void 0 : evmAccount.isConnected) {
|
|
74
|
+
connectedNetworks.push("evm");
|
|
75
|
+
}
|
|
76
|
+
if (cosmosAccount == null ? void 0 : cosmosAccount.isConnected) {
|
|
77
|
+
connectedNetworks.push("cosmos");
|
|
78
|
+
}
|
|
79
|
+
if (solanaAdapter == null ? void 0 : solanaAdapter.connected) {
|
|
80
|
+
connectedNetworks.push("solana");
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
isReady,
|
|
84
|
+
isConnected: paraAccount.isConnected,
|
|
85
|
+
connectionType,
|
|
86
|
+
embedded: __spreadProps(__spreadValues({}, paraAccount), { isConnected: isEmbeddedConnected }),
|
|
87
|
+
external: {
|
|
88
|
+
connectedNetworks,
|
|
89
|
+
evm: evmAccount != null ? evmAccount : {
|
|
90
|
+
address: void 0,
|
|
91
|
+
addresses: void 0,
|
|
92
|
+
chain: void 0,
|
|
93
|
+
chainId: void 0,
|
|
94
|
+
connector: void 0,
|
|
95
|
+
isConnected: false,
|
|
96
|
+
isReconnecting: false,
|
|
97
|
+
isConnecting: false,
|
|
98
|
+
isDisconnected: true,
|
|
99
|
+
status: "disconnected"
|
|
100
|
+
},
|
|
101
|
+
cosmos: pickCosmosAccount(cosmosAccount),
|
|
102
|
+
solana: pickSolanaAdapter(solanaAdapter)
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
const defaultResp = {
|
|
108
|
+
isReady: false,
|
|
109
|
+
isConnected: false,
|
|
110
|
+
connectionType: "none",
|
|
111
|
+
isLoading,
|
|
112
|
+
embedded: {
|
|
113
|
+
isConnected: false
|
|
114
|
+
},
|
|
115
|
+
external: {
|
|
116
|
+
connectedNetworks: [],
|
|
117
|
+
evm: {
|
|
118
|
+
address: void 0,
|
|
119
|
+
addresses: void 0,
|
|
120
|
+
chain: void 0,
|
|
121
|
+
chainId: void 0,
|
|
122
|
+
connector: void 0,
|
|
123
|
+
isConnected: false,
|
|
124
|
+
isReconnecting: false,
|
|
125
|
+
isConnecting: false,
|
|
126
|
+
isDisconnected: true,
|
|
127
|
+
status: "disconnected"
|
|
128
|
+
},
|
|
129
|
+
cosmos: { isConnected: false },
|
|
130
|
+
solana: { isConnected: false }
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), { isLoading });
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
ACCOUNT_BASE_KEY,
|
|
137
|
+
useAccount
|
|
138
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
7
|
+
const IS_FULLY_LOGGED_IN_BASE_KEY = "PARA_FULLY_LOGGED_IN";
|
|
8
|
+
const useIsFullyLoggedIn = () => {
|
|
9
|
+
var _a;
|
|
10
|
+
const client = useInternalClient();
|
|
11
|
+
return useQuery({
|
|
12
|
+
enabled: !!client,
|
|
13
|
+
staleTime: 5e3,
|
|
14
|
+
queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY, (_a = client == null ? void 0 : client.userId) != null ? _a : null],
|
|
15
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
16
|
+
var _a2;
|
|
17
|
+
return (_a2 = yield client == null ? void 0 : client.isFullyLoggedIn()) != null ? _a2 : false;
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
IS_FULLY_LOGGED_IN_BASE_KEY,
|
|
23
|
+
useIsFullyLoggedIn
|
|
24
|
+
};
|
|
@@ -2,4 +2,4 @@ export declare const WALLET_BASE_KEY = "PARA_WALLET";
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook for retrieving the selected wallet
|
|
4
4
|
*/
|
|
5
|
-
export declare const useWallet: () => import("@tanstack/react-query").UseQueryResult<Omit<import("@getpara/core-sdk").Wallet, "signer"> | null
|
|
5
|
+
export declare const useWallet: () => import("@tanstack/react-query").UseQueryResult<Omit<import("@getpara/core-sdk").Wallet, "signer"> | null, Error>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useClient, useWalletState } from "../index.js";
|
|
7
|
+
import { getWallet } from "../../actions/getWallet.js";
|
|
8
|
+
import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
|
|
9
|
+
const WALLET_BASE_KEY = "PARA_WALLET";
|
|
10
|
+
const useWallet = () => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const { selectedWallet } = useWalletState();
|
|
14
|
+
const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
|
|
15
|
+
return useQuery({
|
|
16
|
+
enabled: !!client && !!selectedWallet && isSuccess,
|
|
17
|
+
queryKey: [WALLET_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null, (_a = selectedWallet.id) != null ? _a : null, (_b = selectedWallet.type) != null ? _b : null],
|
|
18
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
19
|
+
return yield getWallet(client, selectedWallet, isFullyLoggedIn);
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
WALLET_BASE_KEY,
|
|
25
|
+
useWallet
|
|
26
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GetWalletBalanceParams } from '@getpara/web-sdk';
|
|
2
|
+
export declare const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
|
|
3
|
+
/**
|
|
4
|
+
* Hook for retrieving a wallet balance
|
|
5
|
+
*/
|
|
6
|
+
export declare const useWalletBalance: (args?: Partial<GetWalletBalanceParams>) => import("@tanstack/react-query").UseQueryResult<string | null, Error>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { useAccount, useClient, useWallet, useWalletState } from "../index.js";
|
|
8
|
+
import { useStore } from "../../stores/useStore.js";
|
|
9
|
+
import { getWalletBalance } from "../../actions/index.js";
|
|
10
|
+
import { useExternalWallets } from "../../providers/ExternalWalletProvider.js";
|
|
11
|
+
import { useCallback } from "react";
|
|
12
|
+
const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
|
|
13
|
+
const useWalletBalance = (args) => {
|
|
14
|
+
const client = useClient();
|
|
15
|
+
const { data: selectedWallet } = useWallet();
|
|
16
|
+
const {
|
|
17
|
+
selectedWallet: { type: selectedWalletType }
|
|
18
|
+
} = useWalletState();
|
|
19
|
+
const { embedded } = useAccount();
|
|
20
|
+
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
21
|
+
const { getWalletBalance: getExternalWalletBalance, chainId } = useExternalWallets();
|
|
22
|
+
const queryFn = useCallback(() => __async(void 0, null, function* () {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
const skipGetBalance = !selectedWallet || selectedWalletType && ["COSMOS", "SOLANA"].includes(selectedWalletType);
|
|
25
|
+
if (skipGetBalance) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
if (selectedWallet.isExternal) {
|
|
30
|
+
return (_a = yield getExternalWalletBalance()) != null ? _a : null;
|
|
31
|
+
} else {
|
|
32
|
+
const completeArgs = __spreadValues({ walletId: (_b = selectedWallet == null ? void 0 : selectedWallet.id) != null ? _b : "", rpcUrl }, args);
|
|
33
|
+
return (_c = yield getWalletBalance(client, completeArgs)) != null ? _c : null;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error("Error fetching wallet balance: ", err);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}), [embedded, selectedWallet, selectedWalletType, rpcUrl, getExternalWalletBalance]);
|
|
40
|
+
return useQuery({
|
|
41
|
+
queryKey: [
|
|
42
|
+
WALLET_BALANCE_BASE_KEY,
|
|
43
|
+
client == null ? void 0 : client.userId,
|
|
44
|
+
selectedWallet == null ? void 0 : selectedWallet.id,
|
|
45
|
+
selectedWallet == null ? void 0 : selectedWallet.type,
|
|
46
|
+
(selectedWallet == null ? void 0 : selectedWallet.isExternal) ? chainId : ""
|
|
47
|
+
],
|
|
48
|
+
queryFn,
|
|
49
|
+
enabled: !!client && !!selectedWallet && !!rpcUrl && !!(embedded == null ? void 0 : embedded.isConnected)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
WALLET_BALANCE_BASE_KEY,
|
|
54
|
+
useWalletBalance
|
|
55
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CoreMethodName, CoreMethodParams, CoreMethods } from '@getpara/web-sdk';
|
|
2
|
+
import { CoreMethodQueryHook } from '../../types/utils.js';
|
|
3
|
+
import { CoreAction } from '../../actions/utils.js';
|
|
4
|
+
export declare function generateCoreQueryHook<const method extends CoreMethodName & keyof CoreMethods>(method: method, action: CoreAction<method>, { isGetter, defaultParams }?: {
|
|
5
|
+
isGetter?: boolean;
|
|
6
|
+
defaultParams?: CoreMethodParams<method>;
|
|
7
|
+
}): (params?: CoreMethodParams<method>) => CoreMethodQueryHook<method>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useClient } from "../utils/index.js";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
function generateCoreQueryHook(method, action, { isGetter = false, defaultParams } = {}) {
|
|
8
|
+
return (params = defaultParams) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const para = useClient();
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: [method, params != null ? params : null, isGetter ? (_a = para == null ? void 0 : para[method]) != null ? _a : null : null],
|
|
13
|
+
queryFn: (_0) => __async(this, [_0], function* ({ queryKey: [_, params2] }) {
|
|
14
|
+
if (!para) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const result = params2 ? yield action(para, params2) : defaultParams ? yield action(para, defaultParams) : yield action(para);
|
|
18
|
+
return result != null ? result : null;
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
generateCoreQueryHook
|
|
25
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
6
|
+
import { useAccount, useKeepSessionAlive, useLogout } from "../index.js";
|
|
7
|
+
import { useInternalClient } from "./useInternalClient.js";
|
|
8
|
+
const SESSION_CHECK_INTERVAL = 6e4;
|
|
9
|
+
const SESSION_REFRESH_THRESHOLD = 3e5;
|
|
10
|
+
const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
11
|
+
const client = useInternalClient();
|
|
12
|
+
const { embedded } = useAccount();
|
|
13
|
+
const { logoutAsync } = useLogout();
|
|
14
|
+
const { keepSessionAliveAsync } = useKeepSessionAlive();
|
|
15
|
+
const sessionCheckInterval = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!client || disabled) {
|
|
18
|
+
clearSessionMonitoring();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if ((embedded == null ? void 0 : embedded.isConnected) && !embedded.isGuestMode && client.externalWalletConnectionType !== "CONNECTION_ONLY") {
|
|
22
|
+
setupSessionMonitoring();
|
|
23
|
+
} else {
|
|
24
|
+
clearSessionMonitoring();
|
|
25
|
+
}
|
|
26
|
+
return () => clearSessionMonitoring();
|
|
27
|
+
}, [client, embedded, disabled]);
|
|
28
|
+
const getSessionExpiry = () => __async(void 0, null, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const sessionCookie = yield client == null ? void 0 : client.retrieveSessionCookie();
|
|
31
|
+
if (!sessionCookie) return null;
|
|
32
|
+
const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
|
|
33
|
+
return expiresMatch ? new Date(expiresMatch[1]) : null;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const setupSessionMonitoring = () => {
|
|
39
|
+
clearSessionMonitoring();
|
|
40
|
+
sessionCheckInterval.current = setInterval(() => __async(void 0, null, function* () {
|
|
41
|
+
const expiry = yield getSessionExpiry();
|
|
42
|
+
if (!expiry) {
|
|
43
|
+
yield logoutAsync({});
|
|
44
|
+
clearSessionMonitoring();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const timeUntilExpiry = expiry.getTime() - Date.now();
|
|
48
|
+
if (timeUntilExpiry <= 0) {
|
|
49
|
+
yield logoutAsync({});
|
|
50
|
+
clearSessionMonitoring();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (timeUntilExpiry <= SESSION_REFRESH_THRESHOLD) {
|
|
54
|
+
try {
|
|
55
|
+
yield keepSessionAliveAsync();
|
|
56
|
+
setupSessionMonitoring();
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error("Failed to keep session alive:", err);
|
|
59
|
+
yield logoutAsync({});
|
|
60
|
+
clearSessionMonitoring();
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}), SESSION_CHECK_INTERVAL);
|
|
65
|
+
};
|
|
66
|
+
const clearSessionMonitoring = () => {
|
|
67
|
+
if (sessionCheckInterval.current) {
|
|
68
|
+
clearInterval(sessionCheckInterval.current);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
useAutoSessionKeepAlive
|
|
74
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Callbacks } from '../../types/provider.js';
|
|
2
|
-
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }?: Callbacks) => void;
|
|
2
|
+
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, onGuestWalletsCreated, }?: Callbacks) => void;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useCallback, useEffect } from "react";
|
|
5
|
+
import { useWalletState } from "../index.js";
|
|
6
|
+
import {
|
|
7
|
+
ParaEvent
|
|
8
|
+
} from "@getpara/web-sdk";
|
|
9
|
+
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
10
|
+
import { useStore } from "../../stores/useStore.js";
|
|
11
|
+
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
12
|
+
import { WALLET_BALANCE_BASE_KEY } from "../queries/useWalletBalance.js";
|
|
13
|
+
import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../queries/useIsFullyLoggedIn.js";
|
|
14
|
+
const useEventListeners = ({
|
|
15
|
+
onLogin,
|
|
16
|
+
onLogout,
|
|
17
|
+
onAccountSetup,
|
|
18
|
+
onAccountCreation,
|
|
19
|
+
onSignMessage,
|
|
20
|
+
onSignTransaction,
|
|
21
|
+
onWalletCreated,
|
|
22
|
+
onPregenWalletClaimed,
|
|
23
|
+
onExternalWalletChange,
|
|
24
|
+
onWalletsChange,
|
|
25
|
+
onGuestWalletsCreated
|
|
26
|
+
} = {}) => {
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
29
|
+
const { updateSelectedWallet } = useWalletState();
|
|
30
|
+
const loginOrSetupListener = useCallback(() => {
|
|
31
|
+
queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
32
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
33
|
+
queryClient.refetchQueries({ queryKey: [WALLET_BASE_KEY] });
|
|
34
|
+
queryClient.invalidateQueries({ queryKey: [WALLET_BALANCE_BASE_KEY], exact: false });
|
|
35
|
+
}, [queryClient]);
|
|
36
|
+
const loginListener = useCallback(
|
|
37
|
+
(event) => {
|
|
38
|
+
loginOrSetupListener();
|
|
39
|
+
onLogin == null ? void 0 : onLogin(event);
|
|
40
|
+
},
|
|
41
|
+
[loginOrSetupListener, onLogin]
|
|
42
|
+
);
|
|
43
|
+
const accountSetupListener = useCallback(
|
|
44
|
+
(event) => {
|
|
45
|
+
loginOrSetupListener();
|
|
46
|
+
onAccountSetup == null ? void 0 : onAccountSetup(event);
|
|
47
|
+
},
|
|
48
|
+
[loginOrSetupListener, onAccountSetup]
|
|
49
|
+
);
|
|
50
|
+
const accountCreationListener = useCallback(
|
|
51
|
+
(event) => {
|
|
52
|
+
onAccountCreation == null ? void 0 : onAccountCreation(event);
|
|
53
|
+
},
|
|
54
|
+
[onAccountCreation]
|
|
55
|
+
);
|
|
56
|
+
const logoutListener = useCallback(
|
|
57
|
+
(event) => {
|
|
58
|
+
queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
59
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
60
|
+
clearSelectedWallet();
|
|
61
|
+
onLogout == null ? void 0 : onLogout(event);
|
|
62
|
+
},
|
|
63
|
+
[queryClient, clearSelectedWallet, onLogout]
|
|
64
|
+
);
|
|
65
|
+
const signMessageListener = useCallback(
|
|
66
|
+
(event) => {
|
|
67
|
+
onSignMessage == null ? void 0 : onSignMessage(event);
|
|
68
|
+
},
|
|
69
|
+
[onSignMessage]
|
|
70
|
+
);
|
|
71
|
+
const signTransactionListener = useCallback(
|
|
72
|
+
(event) => {
|
|
73
|
+
onSignTransaction == null ? void 0 : onSignTransaction(event);
|
|
74
|
+
},
|
|
75
|
+
[onSignTransaction]
|
|
76
|
+
);
|
|
77
|
+
const walletChangeListener = useCallback(
|
|
78
|
+
(event) => {
|
|
79
|
+
queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
80
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
81
|
+
updateSelectedWallet();
|
|
82
|
+
onWalletsChange == null ? void 0 : onWalletsChange(event);
|
|
83
|
+
},
|
|
84
|
+
[queryClient, updateSelectedWallet, onWalletsChange]
|
|
85
|
+
);
|
|
86
|
+
const externalWalletChangeListener = useCallback(
|
|
87
|
+
(event) => {
|
|
88
|
+
queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
89
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
90
|
+
updateSelectedWallet();
|
|
91
|
+
onExternalWalletChange == null ? void 0 : onExternalWalletChange(event);
|
|
92
|
+
},
|
|
93
|
+
[queryClient, updateSelectedWallet, onExternalWalletChange]
|
|
94
|
+
);
|
|
95
|
+
const walletCreatedListener = useCallback(
|
|
96
|
+
(event) => {
|
|
97
|
+
onWalletCreated == null ? void 0 : onWalletCreated(event);
|
|
98
|
+
},
|
|
99
|
+
[onWalletCreated]
|
|
100
|
+
);
|
|
101
|
+
const pregenWalletClaimedListener = useCallback(
|
|
102
|
+
(event) => {
|
|
103
|
+
onPregenWalletClaimed == null ? void 0 : onPregenWalletClaimed(event);
|
|
104
|
+
},
|
|
105
|
+
[onPregenWalletClaimed]
|
|
106
|
+
);
|
|
107
|
+
const guestWalletsCreatedListener = useCallback(
|
|
108
|
+
(event) => {
|
|
109
|
+
queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
110
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
111
|
+
updateSelectedWallet();
|
|
112
|
+
onGuestWalletsCreated == null ? void 0 : onGuestWalletsCreated(event);
|
|
113
|
+
},
|
|
114
|
+
[queryClient, updateSelectedWallet, onGuestWalletsCreated]
|
|
115
|
+
);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
118
|
+
window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
119
|
+
window.addEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
|
|
120
|
+
window.addEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
|
|
121
|
+
window.addEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
|
|
122
|
+
window.addEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
|
|
123
|
+
window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
|
|
124
|
+
window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
|
|
125
|
+
window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
126
|
+
window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
127
|
+
window.addEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
128
|
+
return () => {
|
|
129
|
+
window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
130
|
+
window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
131
|
+
window.removeEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
|
|
132
|
+
window.removeEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
|
|
133
|
+
window.removeEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
|
|
134
|
+
window.removeEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
|
|
135
|
+
window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
|
|
136
|
+
window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
|
|
137
|
+
window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
138
|
+
window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
139
|
+
window.removeEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
140
|
+
};
|
|
141
|
+
}, [
|
|
142
|
+
loginListener,
|
|
143
|
+
accountSetupListener,
|
|
144
|
+
accountCreationListener,
|
|
145
|
+
logoutListener,
|
|
146
|
+
signMessageListener,
|
|
147
|
+
signTransactionListener,
|
|
148
|
+
walletChangeListener,
|
|
149
|
+
externalWalletChangeListener,
|
|
150
|
+
walletCreatedListener,
|
|
151
|
+
pregenWalletClaimedListener,
|
|
152
|
+
guestWalletsCreatedListener
|
|
153
|
+
]);
|
|
154
|
+
};
|
|
155
|
+
export {
|
|
156
|
+
useEventListeners
|
|
157
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useModalStore } from "../../../modal/stores/index.js";
|
|
7
|
+
import { formatBiometricHints } from "@getpara/react-common";
|
|
8
|
+
import { useClient } from "./useClient.js";
|
|
9
|
+
const queryKey = ["FORMATTED_BIOMETRIC_HINTS"];
|
|
10
|
+
const useFormattedBiometricHints = () => {
|
|
11
|
+
var _a;
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const loginState = useModalStore((state) => state.getLoginState());
|
|
14
|
+
return useQuery({
|
|
15
|
+
queryKey: [...queryKey, (_a = loginState == null ? void 0 : loginState.biometricHints) != null ? _a : "undefined"],
|
|
16
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
17
|
+
if (!client || !(loginState == null ? void 0 : loginState.biometricHints)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const isPasskeySupported = yield client.isPasskeySupported();
|
|
21
|
+
return formatBiometricHints(loginState.biometricHints, isPasskeySupported);
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
useFormattedBiometricHints
|
|
27
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { ModalStep } from '../../../modal/index.js';
|
|
1
2
|
/**
|
|
2
3
|
* Hook for controlling the Para modal
|
|
3
4
|
*/
|
|
4
5
|
export declare const useModal: () => {
|
|
5
6
|
isOpen: boolean;
|
|
6
|
-
openModal: (
|
|
7
|
+
openModal: ({ step }?: {
|
|
8
|
+
step?: ModalStep;
|
|
9
|
+
}) => void;
|
|
7
10
|
closeModal: () => void;
|
|
8
11
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useModalStore } from "../../../modal/stores/index.js";
|
|
4
|
+
import { useStore } from "../../stores/useStore.js";
|
|
5
|
+
const useModal = () => {
|
|
6
|
+
const isOpen = useStore((state) => state.isOpen);
|
|
7
|
+
const setIsOpen = useStore((state) => state.setIsOpen);
|
|
8
|
+
const openedToStep = useStore((state) => state.openedToStep);
|
|
9
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
10
|
+
const openModal = ({ step } = {}) => {
|
|
11
|
+
if (step) {
|
|
12
|
+
openedToStep.current = step;
|
|
13
|
+
setStep(step);
|
|
14
|
+
}
|
|
15
|
+
if (!isOpen) {
|
|
16
|
+
setIsOpen(true);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const closeModal = () => {
|
|
20
|
+
openedToStep.current = null;
|
|
21
|
+
setIsOpen(false);
|
|
22
|
+
};
|
|
23
|
+
return { isOpen, openModal, closeModal };
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
useModal
|
|
27
|
+
};
|