@getpara/react-core 2.19.0

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.
Files changed (143) hide show
  1. package/dist/index.d.ts +37 -0
  2. package/dist/index.js +73 -0
  3. package/dist/mutations.d.ts +29 -0
  4. package/dist/mutations.js +60 -0
  5. package/dist/package.json +4 -0
  6. package/dist/provider/ParaProviderCore.d.ts +85 -0
  7. package/dist/provider/ParaProviderCore.js +124 -0
  8. package/dist/provider/actions/getEmbeddedAccount.d.ts +28 -0
  9. package/dist/provider/actions/getEmbeddedAccount.js +82 -0
  10. package/dist/provider/actions/getWallet.js +34 -0
  11. package/dist/provider/actions/index.d.ts +38 -0
  12. package/dist/provider/actions/index.js +75 -0
  13. package/dist/provider/actions/utils.d.ts +4 -0
  14. package/dist/provider/actions/utils.js +32 -0
  15. package/dist/provider/hooks/aa/alchemy.d.ts +22 -0
  16. package/dist/provider/hooks/aa/alchemy.js +47 -0
  17. package/dist/provider/hooks/aa/biconomy.d.ts +22 -0
  18. package/dist/provider/hooks/aa/biconomy.js +47 -0
  19. package/dist/provider/hooks/aa/cdp.d.ts +21 -0
  20. package/dist/provider/hooks/aa/cdp.js +47 -0
  21. package/dist/provider/hooks/aa/createSmartAccountHook.d.ts +18 -0
  22. package/dist/provider/hooks/aa/createSmartAccountHook.js +96 -0
  23. package/dist/provider/hooks/aa/gelato.d.ts +21 -0
  24. package/dist/provider/hooks/aa/gelato.js +47 -0
  25. package/dist/provider/hooks/aa/index.d.ts +12 -0
  26. package/dist/provider/hooks/aa/index.js +48 -0
  27. package/dist/provider/hooks/aa/pimlico.d.ts +22 -0
  28. package/dist/provider/hooks/aa/pimlico.js +47 -0
  29. package/dist/provider/hooks/aa/porto.d.ts +22 -0
  30. package/dist/provider/hooks/aa/porto.js +47 -0
  31. package/dist/provider/hooks/aa/rhinestone.d.ts +22 -0
  32. package/dist/provider/hooks/aa/rhinestone.js +47 -0
  33. package/dist/provider/hooks/aa/safe.d.ts +22 -0
  34. package/dist/provider/hooks/aa/safe.js +47 -0
  35. package/dist/provider/hooks/aa/thirdweb.d.ts +18 -0
  36. package/dist/provider/hooks/aa/thirdweb.js +47 -0
  37. package/dist/provider/hooks/aa/types.d.ts +34 -0
  38. package/dist/provider/hooks/aa/types.js +0 -0
  39. package/dist/provider/hooks/aa/zerodev.d.ts +22 -0
  40. package/dist/provider/hooks/aa/zerodev.js +47 -0
  41. package/dist/provider/hooks/index.d.ts +4 -0
  42. package/dist/provider/hooks/index.js +4 -0
  43. package/dist/provider/hooks/mutations/index.d.ts +30 -0
  44. package/dist/provider/hooks/mutations/index.js +92 -0
  45. package/dist/provider/hooks/mutations/useAuthenticateWithEmailOrPhone.d.ts +34 -0
  46. package/dist/provider/hooks/mutations/useAuthenticateWithEmailOrPhone.js +39 -0
  47. package/dist/provider/hooks/mutations/useAuthenticateWithOAuth.d.ts +34 -0
  48. package/dist/provider/hooks/mutations/useAuthenticateWithOAuth.js +39 -0
  49. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +34 -0
  50. package/dist/provider/hooks/mutations/useClaimPregenWallets.js +42 -0
  51. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +34 -0
  52. package/dist/provider/hooks/mutations/useCreateGuestWallets.js +42 -0
  53. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +34 -0
  54. package/dist/provider/hooks/mutations/useCreatePregenWallet.js +42 -0
  55. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +34 -0
  56. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.js +39 -0
  57. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +34 -0
  58. package/dist/provider/hooks/mutations/useCreateWallet.js +42 -0
  59. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +34 -0
  60. package/dist/provider/hooks/mutations/useCreateWalletPerType.js +39 -0
  61. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +34 -0
  62. package/dist/provider/hooks/mutations/useEnable2fa.js +39 -0
  63. package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +39 -0
  64. package/dist/provider/hooks/mutations/useExportPrivateKey.js +63 -0
  65. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +34 -0
  66. package/dist/provider/hooks/mutations/useHasPregenWallet.js +39 -0
  67. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +34 -0
  68. package/dist/provider/hooks/mutations/useIssueJwt.js +39 -0
  69. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +33 -0
  70. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +39 -0
  71. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +34 -0
  72. package/dist/provider/hooks/mutations/useLoginExternalWallet.js +42 -0
  73. package/dist/provider/hooks/mutations/useLogout.d.ts +34 -0
  74. package/dist/provider/hooks/mutations/useLogout.js +39 -0
  75. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +34 -0
  76. package/dist/provider/hooks/mutations/useResendVerificationCode.js +42 -0
  77. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +34 -0
  78. package/dist/provider/hooks/mutations/useSetup2fa.js +39 -0
  79. package/dist/provider/hooks/mutations/useSignMessage.d.ts +34 -0
  80. package/dist/provider/hooks/mutations/useSignMessage.js +39 -0
  81. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +34 -0
  82. package/dist/provider/hooks/mutations/useSignTransaction.js +42 -0
  83. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +34 -0
  84. package/dist/provider/hooks/mutations/useSignUpOrLogIn.js +42 -0
  85. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +34 -0
  86. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.js +42 -0
  87. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +34 -0
  88. package/dist/provider/hooks/mutations/useVerify2fa.js +39 -0
  89. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +34 -0
  90. package/dist/provider/hooks/mutations/useVerifyExternalWallet.js +42 -0
  91. package/dist/provider/hooks/mutations/useVerifyFarcaster.js +43 -0
  92. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +34 -0
  93. package/dist/provider/hooks/mutations/useVerifyNewAccount.js +42 -0
  94. package/dist/provider/hooks/mutations/useVerifyOAuth.js +40 -0
  95. package/dist/provider/hooks/mutations/useVerifyTelegram.js +40 -0
  96. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +34 -0
  97. package/dist/provider/hooks/mutations/useWaitForLogin.js +42 -0
  98. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +34 -0
  99. package/dist/provider/hooks/mutations/useWaitForSignup.js +39 -0
  100. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +34 -0
  101. package/dist/provider/hooks/mutations/useWaitForWalletCreation.js +39 -0
  102. package/dist/provider/hooks/queries/createAccountHook.d.ts +49 -0
  103. package/dist/provider/hooks/queries/createAccountHook.js +132 -0
  104. package/dist/provider/hooks/queries/index.d.ts +5 -0
  105. package/dist/provider/hooks/queries/index.js +20 -0
  106. package/dist/provider/hooks/queries/useAccount.d.ts +65 -0
  107. package/dist/provider/hooks/queries/useAccount.js +65 -0
  108. package/dist/provider/hooks/queries/useIsFullyLoggedIn.d.ts +7 -0
  109. package/dist/provider/hooks/queries/useIsFullyLoggedIn.js +49 -0
  110. package/dist/provider/hooks/queries/useParaStatus.d.ts +15 -0
  111. package/dist/provider/hooks/queries/useParaStatus.js +32 -0
  112. package/dist/provider/hooks/queries/useWallet.js +43 -0
  113. package/dist/provider/hooks/utils/index.d.ts +2 -0
  114. package/dist/provider/hooks/utils/index.js +6 -0
  115. package/dist/provider/hooks/utils/useClient.d.ts +7 -0
  116. package/dist/provider/hooks/utils/useClient.js +8 -0
  117. package/dist/provider/hooks/utils/useCoreWalletState.d.ts +17 -0
  118. package/dist/provider/hooks/utils/useCoreWalletState.js +47 -0
  119. package/dist/provider/index.d.ts +5 -0
  120. package/dist/provider/index.js +11 -0
  121. package/dist/provider/stores/CoreStoreContext.d.ts +13 -0
  122. package/dist/provider/stores/CoreStoreContext.js +14 -0
  123. package/dist/provider/stores/createCoreStore.d.ts +26 -0
  124. package/dist/provider/stores/createCoreStore.js +61 -0
  125. package/dist/provider/stores/index.d.ts +4 -0
  126. package/dist/provider/stores/index.js +9 -0
  127. package/dist/provider/stores/slices/client.d.ts +3 -0
  128. package/dist/provider/stores/slices/client.js +7 -0
  129. package/dist/provider/stores/slices/config.d.ts +3 -0
  130. package/dist/provider/stores/slices/config.js +9 -0
  131. package/dist/provider/stores/slices/index.d.ts +4 -0
  132. package/dist/provider/stores/slices/index.js +10 -0
  133. package/dist/provider/stores/slices/paraState.d.ts +3 -0
  134. package/dist/provider/stores/slices/paraState.js +7 -0
  135. package/dist/provider/stores/slices/wallet.d.ts +3 -0
  136. package/dist/provider/stores/slices/wallet.js +11 -0
  137. package/dist/provider/stores/types.d.ts +28 -0
  138. package/dist/provider/stores/types.js +0 -0
  139. package/dist/provider/utils/renameMutations.d.ts +11 -0
  140. package/dist/provider/utils/renameMutations.js +39 -0
  141. package/dist/queries.d.ts +2 -0
  142. package/dist/queries.js +6 -0
  143. package/package.json +73 -0
@@ -0,0 +1,39 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { useMutation } from "@tanstack/react-query";
22
+ import { useClient } from "../utils/index.js";
23
+ import { renameMutations } from "../../utils/renameMutations.js";
24
+ import { waitForSignup } from "../../actions/index.js";
25
+ const WAIT_FOR_SIGN_UP_KEY = "WAIT_FOR_SIGN_UP";
26
+ const useWaitForSignup = () => {
27
+ const para = useClient();
28
+ const mutation = useMutation({
29
+ mutationKey: [WAIT_FOR_SIGN_UP_KEY],
30
+ mutationFn: (..._0) => __async(void 0, [..._0], function* (args = {}) {
31
+ return waitForSignup(para, args);
32
+ })
33
+ });
34
+ return renameMutations(mutation, "waitForSignup");
35
+ };
36
+ export {
37
+ WAIT_FOR_SIGN_UP_KEY,
38
+ useWaitForSignup
39
+ };
@@ -0,0 +1,34 @@
1
+ import type { WaitForWalletCreationParams, WaitForWalletCreationResponse } from '@getpara/core-sdk';
2
+ export declare const WAIT_FOR_WALLET_CREATION_KEY = "WAIT_FOR_WALLET_CREATION";
3
+ /**
4
+ * React hook for the `waitForWalletCreation` mutation.
5
+ *
6
+ * Returns a mutation result object with all standard fields from `useMutation`, except:
7
+ * - `mutate` and `mutateAsync` are replaced by:
8
+ * - `waitForWalletCreation`: function to trigger the mutation (same as `mutate`)
9
+ * - `waitForWalletCreationAsync`: async function to trigger the mutation (same as `mutateAsync`)
10
+ *
11
+ * @example
12
+ * const { waitForWalletCreation, waitForWalletCreationAsync } = useWaitForWalletCreation();
13
+ * waitForWalletCreation({ ...params });
14
+ * // or
15
+ * await waitForWalletCreationAsync({ ...params });
16
+ */
17
+ export declare const useWaitForWalletCreation: () => {
18
+ error: Error;
19
+ isSuccess: boolean;
20
+ data: WaitForWalletCreationResponse;
21
+ variables: void | WaitForWalletCreationParams;
22
+ isError: boolean;
23
+ isIdle: boolean;
24
+ isPending: boolean;
25
+ status: "error" | "idle" | "pending" | "success";
26
+ reset: () => void;
27
+ context: unknown;
28
+ failureCount: number;
29
+ failureReason: Error;
30
+ isPaused: boolean;
31
+ submittedAt: number;
32
+ waitForWalletCreation: import("@tanstack/react-query").UseMutateFunction<WaitForWalletCreationResponse, Error, void | WaitForWalletCreationParams, unknown>;
33
+ waitForWalletCreationAsync: import("@tanstack/react-query").UseMutateAsyncFunction<WaitForWalletCreationResponse, Error, void | WaitForWalletCreationParams, unknown>;
34
+ };
@@ -0,0 +1,39 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { useMutation } from "@tanstack/react-query";
22
+ import { useClient } from "../utils/index.js";
23
+ import { renameMutations } from "../../utils/renameMutations.js";
24
+ import { waitForWalletCreation } from "../../actions/index.js";
25
+ const WAIT_FOR_WALLET_CREATION_KEY = "WAIT_FOR_WALLET_CREATION";
26
+ const useWaitForWalletCreation = () => {
27
+ const para = useClient();
28
+ const mutation = useMutation({
29
+ mutationKey: [WAIT_FOR_WALLET_CREATION_KEY],
30
+ mutationFn: (..._0) => __async(void 0, [..._0], function* (args = {}) {
31
+ return waitForWalletCreation(para, args);
32
+ })
33
+ });
34
+ return renameMutations(mutation, "waitForWalletCreation");
35
+ };
36
+ export {
37
+ WAIT_FOR_WALLET_CREATION_KEY,
38
+ useWaitForWalletCreation
39
+ };
@@ -0,0 +1,49 @@
1
+ import { type Account } from '../../actions/getEmbeddedAccount.js';
2
+ export declare const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
3
+ export type ConnectionType = 'embedded' | 'external' | 'both' | 'none';
4
+ /**
5
+ * External wallet state provided by a platform-specific enhancer hook.
6
+ * On web, this comes from wagmi/graz/solana-wallet-adapter contexts.
7
+ * On RN, this is not used (no external wallet support).
8
+ */
9
+ export interface ExternalWalletState {
10
+ /** Stable keys for query invalidation when external connection state changes. */
11
+ queryKeys: unknown[];
12
+ /** Whether each external network is connected. */
13
+ connections: Record<string, boolean>;
14
+ /** External wallet data to include in the returned account object. */
15
+ data: Record<string, unknown>;
16
+ }
17
+ export interface UseAccountReturn<TExternal = Record<string, unknown>> {
18
+ /** Whether any wallet is connected (embedded, external, or both). */
19
+ isConnected: boolean;
20
+ /** Whether the account is currently loading. */
21
+ isLoading: boolean;
22
+ /**
23
+ * The type of active connection:
24
+ * - `'embedded'` — only a Para MPC wallet is connected.
25
+ * - `'external'` — only an external wallet (MetaMask, etc.) is connected.
26
+ * - `'both'` — both embedded and external wallets are connected.
27
+ * - `'none'` — no wallets are connected.
28
+ */
29
+ connectionType: ConnectionType;
30
+ /** The embedded Para account. Use this instead of deprecated top-level properties. */
31
+ embedded: Omit<Account, 'isReady' | 'isFarcasterMiniApp' | 'isConnected' | 'isGuestMode'> & {
32
+ isConnected: boolean;
33
+ isGuestMode?: boolean;
34
+ };
35
+ /** Connected external wallet data, plus `connectedNetworks` listing active chains. */
36
+ external: TExternal & {
37
+ /** List of connected external networks (e.g. `['evm', 'solana']`). */
38
+ connectedNetworks: string[];
39
+ };
40
+ }
41
+ /**
42
+ * Factory that creates a `useAccount` hook. Accepts an optional enhancer
43
+ * that provides external wallet state (EVM/Cosmos/Solana on web).
44
+ *
45
+ * Without an enhancer, only embedded Para accounts are returned (RN use case).
46
+ */
47
+ export declare function createAccountHook<TExternal extends Record<string, unknown> = Record<string, unknown>>(useExternalWallets?: () => ExternalWalletState & {
48
+ data: TExternal;
49
+ }): () => UseAccountReturn<TExternal>;
@@ -0,0 +1,132 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
41
+ import { useEffect, useMemo, useRef } from "react";
42
+ import { useClient } from "../utils/useClient.js";
43
+ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
44
+ import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
45
+ const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
46
+ function useInvalidation(connections, queryKey) {
47
+ const queryClient = useQueryClient();
48
+ const lastConnectionStateRef = useRef("");
49
+ const invalidationTimeoutRef = useRef(null);
50
+ useEffect(() => {
51
+ const key = Object.entries(connections).map(([k, v]) => `${k}:${v}`).join(",");
52
+ if (key === lastConnectionStateRef.current) return;
53
+ lastConnectionStateRef.current = key;
54
+ if (invalidationTimeoutRef.current) clearTimeout(invalidationTimeoutRef.current);
55
+ invalidationTimeoutRef.current = setTimeout(() => {
56
+ queryClient.invalidateQueries({ queryKey });
57
+ invalidationTimeoutRef.current = null;
58
+ }, 0);
59
+ return () => {
60
+ if (invalidationTimeoutRef.current) {
61
+ clearTimeout(invalidationTimeoutRef.current);
62
+ invalidationTimeoutRef.current = null;
63
+ }
64
+ };
65
+ }, [connections, queryClient]);
66
+ }
67
+ function createAccountHook(useExternalWallets) {
68
+ return function useAccount() {
69
+ var _a, _b;
70
+ const client = useClient();
71
+ const { data: isFullyLoggedIn, isSuccess, isLoading: isFullyLoggedInLoading } = useIsFullyLoggedIn();
72
+ const external = (_a = useExternalWallets == null ? void 0 : useExternalWallets()) != null ? _a : {
73
+ queryKeys: [],
74
+ connections: {},
75
+ data: {}
76
+ };
77
+ const queryKey = [
78
+ ACCOUNT_BASE_KEY,
79
+ isFullyLoggedIn != null ? isFullyLoggedIn : null,
80
+ isFullyLoggedInLoading,
81
+ (_b = client == null ? void 0 : client.userId) != null ? _b : null,
82
+ ...external.queryKeys
83
+ ];
84
+ const connectionsKey = JSON.stringify(external.connections);
85
+ const connections = useMemo(() => external.connections, [connectionsKey]);
86
+ useInvalidation(connections, queryKey);
87
+ const { data, isLoading } = useQuery({
88
+ enabled: isSuccess && !!client,
89
+ queryKey,
90
+ queryFn: () => __async(this, null, function* () {
91
+ const paraAccount = yield getEmbeddedAccount(client, isFullyLoggedIn);
92
+ let connectionType = "none";
93
+ const hasExternalConnection = Object.values(external.connections).some(Boolean);
94
+ if (paraAccount.isConnected) {
95
+ connectionType = "embedded";
96
+ if (paraAccount.wallets.some((w) => w.isExternal)) {
97
+ connectionType = "both";
98
+ }
99
+ if (paraAccount.wallets.every((w) => w.isExternal) && hasExternalConnection) {
100
+ connectionType = "external";
101
+ }
102
+ }
103
+ const isEmbeddedConnected = connectionType === "embedded" || connectionType === "both";
104
+ const connectedNetworks = Object.entries(external.connections).filter(([, connected]) => connected).map(([network]) => network);
105
+ return {
106
+ isConnected: paraAccount.isConnected,
107
+ connectionType,
108
+ embedded: __spreadProps(__spreadValues({}, paraAccount), { isConnected: isEmbeddedConnected }),
109
+ external: __spreadProps(__spreadValues({}, external.data), {
110
+ connectedNetworks
111
+ })
112
+ };
113
+ })
114
+ });
115
+ const defaultResp = {
116
+ isConnected: false,
117
+ connectionType: "none",
118
+ isLoading,
119
+ embedded: { isConnected: false },
120
+ external: __spreadProps(__spreadValues({}, external.data), {
121
+ connectedNetworks: []
122
+ })
123
+ };
124
+ return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), {
125
+ isLoading: isFullyLoggedInLoading || isLoading
126
+ });
127
+ };
128
+ }
129
+ export {
130
+ ACCOUNT_BASE_KEY,
131
+ createAccountHook
132
+ };
@@ -0,0 +1,5 @@
1
+ export { useIsFullyLoggedIn, IS_FULLY_LOGGED_IN_BASE_KEY } from './useIsFullyLoggedIn.js';
2
+ export { useParaStatus, createParaStatusHook, type ParaStatusBase } from './useParaStatus.js';
3
+ export { useAccount, EMBEDDED_ACCOUNT_BASE_KEY, type Account } from './useAccount.js';
4
+ export { useWallet, WALLET_BASE_KEY } from './useWallet.js';
5
+ export { createAccountHook, ACCOUNT_BASE_KEY, type ConnectionType, type ExternalWalletState, type UseAccountReturn, } from './createAccountHook.js';
@@ -0,0 +1,20 @@
1
+ import { useIsFullyLoggedIn, IS_FULLY_LOGGED_IN_BASE_KEY } from "./useIsFullyLoggedIn.js";
2
+ import { useParaStatus, createParaStatusHook } from "./useParaStatus.js";
3
+ import { useAccount, EMBEDDED_ACCOUNT_BASE_KEY } from "./useAccount.js";
4
+ import { useWallet, WALLET_BASE_KEY } from "./useWallet.js";
5
+ import {
6
+ createAccountHook,
7
+ ACCOUNT_BASE_KEY
8
+ } from "./createAccountHook.js";
9
+ export {
10
+ ACCOUNT_BASE_KEY,
11
+ EMBEDDED_ACCOUNT_BASE_KEY,
12
+ IS_FULLY_LOGGED_IN_BASE_KEY,
13
+ WALLET_BASE_KEY,
14
+ createAccountHook,
15
+ createParaStatusHook,
16
+ useAccount,
17
+ useIsFullyLoggedIn,
18
+ useParaStatus,
19
+ useWallet
20
+ };
@@ -0,0 +1,65 @@
1
+ import { type Account } from '../../actions/getEmbeddedAccount.js';
2
+ export declare const EMBEDDED_ACCOUNT_BASE_KEY = "PARA_EMBEDDED_ACCOUNT";
3
+ export type { Account };
4
+ /**
5
+ * Platform-agnostic hook for the embedded (Para) account only.
6
+ * Does not include external wallet accounts (EVM/Cosmos/Solana).
7
+ * Web SDK's `useAccount()` extends this with external wallet data
8
+ * via `createAccountHook`.
9
+ */
10
+ export declare const useAccount: () => {
11
+ isLoading: boolean;
12
+ isConnected: false;
13
+ isGuestMode?: false;
14
+ auth?: undefined;
15
+ authType?: undefined;
16
+ identifier?: undefined;
17
+ email?: undefined;
18
+ phone?: undefined;
19
+ farcasterUsername?: undefined;
20
+ telegramUserId?: undefined;
21
+ externalWalletAddress?: undefined;
22
+ wallets?: undefined;
23
+ userId?: undefined;
24
+ authMethods?: undefined;
25
+ } | {
26
+ isLoading: boolean;
27
+ isConnected: true;
28
+ isGuestMode: true;
29
+ wallets: import("@getpara/core-sdk").default["availableWallets"];
30
+ email?: undefined;
31
+ phone?: undefined;
32
+ userId?: undefined;
33
+ auth?: undefined;
34
+ authType?: undefined;
35
+ identifier?: undefined;
36
+ farcasterUsername?: undefined;
37
+ telegramUserId?: undefined;
38
+ externalWalletAddress?: undefined;
39
+ authMethods?: undefined;
40
+ } | {
41
+ isLoading: boolean;
42
+ isConnected: true;
43
+ isGuestMode: false;
44
+ auth: {
45
+ email: string;
46
+ } | {
47
+ phone: import("@getpara/shared").AuthIdentifier<"phone">;
48
+ } | {
49
+ farcasterUsername: import("@getpara/shared").AuthIdentifier<"farcaster">;
50
+ } | {
51
+ telegramUserId: import("@getpara/shared").AuthIdentifier<"telegram">;
52
+ } | {
53
+ externalWalletAddress: import("@getpara/shared").AuthIdentifier<"externalWallet">;
54
+ };
55
+ authType: import("@getpara/shared").PrimaryAuthType;
56
+ identifier: string;
57
+ email?: string;
58
+ phone?: `+${number}`;
59
+ farcasterUsername?: string;
60
+ telegramUserId?: string;
61
+ externalWalletAddress?: string;
62
+ wallets: import("@getpara/core-sdk").default["availableWallets"];
63
+ userId?: string;
64
+ authMethods?: Set<import("@getpara/shared").AuthMethod>;
65
+ };
@@ -0,0 +1,65 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import { useQuery } from "@tanstack/react-query";
41
+ import { useClient } from "../utils/useClient.js";
42
+ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
43
+ import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
44
+ const EMBEDDED_ACCOUNT_BASE_KEY = "PARA_EMBEDDED_ACCOUNT";
45
+ const useAccount = () => {
46
+ var _a;
47
+ const client = useClient();
48
+ const { data: isFullyLoggedIn, isSuccess, isLoading: isFullyLoggedInLoading } = useIsFullyLoggedIn();
49
+ const queryKey = [EMBEDDED_ACCOUNT_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null, isFullyLoggedInLoading, (_a = client == null ? void 0 : client.userId) != null ? _a : null];
50
+ const { data, isLoading } = useQuery({
51
+ enabled: isSuccess && !!client,
52
+ queryKey,
53
+ queryFn: () => __async(void 0, null, function* () {
54
+ return getEmbeddedAccount(client, isFullyLoggedIn);
55
+ })
56
+ });
57
+ const defaultResp = { isConnected: false };
58
+ return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), {
59
+ isLoading: isFullyLoggedInLoading || isLoading
60
+ });
61
+ };
62
+ export {
63
+ EMBEDDED_ACCOUNT_BASE_KEY,
64
+ useAccount
65
+ };
@@ -0,0 +1,7 @@
1
+ export declare const IS_FULLY_LOGGED_IN_BASE_KEY = "PARA_FULLY_LOGGED_IN";
2
+ /**
3
+ * Hook for returning whether the user is fully logged in with Para.
4
+ * Uses the core state machine phase as a reactive query key so the query
5
+ * automatically refetches on state transitions (login, logout, etc.).
6
+ */
7
+ export declare const useIsFullyLoggedIn: () => import("@tanstack/react-query").UseQueryResult<boolean, Error>;
@@ -0,0 +1,49 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { useQuery } from "@tanstack/react-query";
22
+ import { useClient } from "../utils/useClient.js";
23
+ import { useCoreStore } from "../../stores/CoreStoreContext.js";
24
+ const IS_FULLY_LOGGED_IN_BASE_KEY = "PARA_FULLY_LOGGED_IN";
25
+ const useIsFullyLoggedIn = () => {
26
+ var _a;
27
+ const client = useClient();
28
+ const isReady = useCoreStore((state) => {
29
+ var _a2, _b;
30
+ return (_b = (_a2 = state.paraState) == null ? void 0 : _a2.isReady) != null ? _b : false;
31
+ });
32
+ const corePhase = useCoreStore((state) => {
33
+ var _a2;
34
+ return (_a2 = state.paraState) == null ? void 0 : _a2.corePhase;
35
+ });
36
+ const phaseKey = corePhase === "authenticated" || corePhase === "guest_mode" ? "authenticated" : "incomplete";
37
+ return useQuery({
38
+ enabled: isReady && !!client,
39
+ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY, phaseKey, (_a = client == null ? void 0 : client.userId) != null ? _a : null],
40
+ queryFn: () => __async(void 0, null, function* () {
41
+ var _a2;
42
+ return (_a2 = yield client == null ? void 0 : client.isFullyLoggedIn()) != null ? _a2 : false;
43
+ })
44
+ });
45
+ };
46
+ export {
47
+ IS_FULLY_LOGGED_IN_BASE_KEY,
48
+ useIsFullyLoggedIn
49
+ };
@@ -0,0 +1,15 @@
1
+ export type ParaStatusBase = {
2
+ /** Whether the Para client's first-time setup is complete. */
3
+ isReady: boolean;
4
+ };
5
+ /**
6
+ * Factory that creates a `useParaStatus` hook. Accepts an optional enhancer
7
+ * that reads platform-specific properties from the client (e.g. `isFarcasterMiniApp`
8
+ * on web via ParaWeb).
9
+ */
10
+ export declare function createParaStatusHook<TExtra extends Record<string, unknown> = Record<string, never>>(useExtra?: () => TExtra): () => ParaStatusBase & TExtra;
11
+ /**
12
+ * Platform-agnostic hook for reading the Para SDK's current status.
13
+ * Returns `{ isReady }`. Web extends this with `isFarcasterMiniApp` etc.
14
+ */
15
+ export declare const useParaStatus: () => ParaStatusBase & Record<string, never>;
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { useCoreStore } from "../../stores/CoreStoreContext.js";
18
+ function createParaStatusHook(useExtra) {
19
+ return function useParaStatus2() {
20
+ var _a, _b;
21
+ const paraState = useCoreStore((state) => state.paraState);
22
+ const extra = (_a = useExtra == null ? void 0 : useExtra()) != null ? _a : {};
23
+ return __spreadValues({
24
+ isReady: (_b = paraState == null ? void 0 : paraState.isReady) != null ? _b : false
25
+ }, extra);
26
+ };
27
+ }
28
+ const useParaStatus = createParaStatusHook();
29
+ export {
30
+ createParaStatusHook,
31
+ useParaStatus
32
+ };
@@ -0,0 +1,43 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { useQuery } from "@tanstack/react-query";
22
+ import { useClient } from "../utils/useClient.js";
23
+ import { useCoreWalletState } from "../utils/useCoreWalletState.js";
24
+ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
25
+ import { getWallet } from "../../actions/getWallet.js";
26
+ const WALLET_BASE_KEY = "PARA_WALLET";
27
+ const useWallet = () => {
28
+ var _a, _b;
29
+ const client = useClient();
30
+ const { selectedWallet } = useCoreWalletState();
31
+ const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
32
+ return useQuery({
33
+ enabled: !!client && !!selectedWallet && isSuccess,
34
+ queryKey: [WALLET_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null, (_a = selectedWallet.id) != null ? _a : null, (_b = selectedWallet.type) != null ? _b : null],
35
+ queryFn: () => __async(void 0, null, function* () {
36
+ return yield getWallet(client, selectedWallet, isFullyLoggedIn);
37
+ })
38
+ });
39
+ };
40
+ export {
41
+ WALLET_BASE_KEY,
42
+ useWallet
43
+ };
@@ -0,0 +1,2 @@
1
+ export { useClient } from './useClient.js';
2
+ export { useCoreWalletState } from './useCoreWalletState.js';
@@ -0,0 +1,6 @@
1
+ import { useClient } from "./useClient.js";
2
+ import { useCoreWalletState } from "./useCoreWalletState.js";
3
+ export {
4
+ useClient,
5
+ useCoreWalletState
6
+ };
@@ -0,0 +1,7 @@
1
+ import type ParaCore from '@getpara/core-sdk';
2
+ /**
3
+ * Hook for retrieving the Para client from the core store.
4
+ * The generic parameter allows platform SDKs to narrow the type
5
+ * (e.g. `useClient<ParaWeb>()` on web, `useClient<ParaMobile>()` on RN).
6
+ */
7
+ export declare const useClient: <Para extends ParaCore = ParaCore>() => Para | undefined;
@@ -0,0 +1,8 @@
1
+ import { useCoreStore } from "../../stores/CoreStoreContext.js";
2
+ const useClient = () => {
3
+ const client = useCoreStore((state) => state.client);
4
+ return client;
5
+ };
6
+ export {
7
+ useClient
8
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Platform-agnostic wallet selection state.
3
+ * Does not depend on external wallet providers (EVM/Cosmos/Solana).
4
+ * Web SDK extends this with external wallet switching via `useWalletState()`.
5
+ */
6
+ export declare const useCoreWalletState: () => {
7
+ selectedWallet: {
8
+ id: string;
9
+ type: "EVM" | "SOLANA" | "COSMOS";
10
+ address: string;
11
+ };
12
+ setSelectedWallet: ({ id, type }: {
13
+ id?: string;
14
+ type?: import("@getpara/core-sdk").TWalletType;
15
+ }) => void;
16
+ updateSelectedWallet: () => void;
17
+ };