@getpara/react-sdk-lite 2.0.0-alpha.53 → 2.0.0-alpha.55

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 (49) hide show
  1. package/dist/modal/ParaModal.js +5 -5
  2. package/dist/modal/components/Account/Account.js +4 -3
  3. package/dist/modal/components/Account/AccountHeader.js +10 -16
  4. package/dist/modal/components/Account/AccountProfile.js +33 -4
  5. package/dist/modal/components/Account/AccountProfileLink.js +3 -3
  6. package/dist/modal/components/AddFunds/AddFundsAsset.js +5 -2
  7. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.d.ts +1 -0
  8. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +20 -0
  9. package/dist/modal/components/Body/Body.js +4 -4
  10. package/dist/modal/components/Header/hooks/useStepTitle.js +2 -1
  11. package/dist/modal/components/OAuth/FarcasterLink.d.ts +2 -0
  12. package/dist/modal/components/OAuth/FarcasterLink.js +30 -0
  13. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -3
  14. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +47 -26
  15. package/dist/modal/components/OAuth/OAuth.js +2 -2
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +35 -19
  17. package/dist/modal/constants/constants.js +1 -1
  18. package/dist/modal/hooks/useFarcasterLogin.d.ts +9 -0
  19. package/dist/modal/hooks/useFarcasterLogin.js +70 -0
  20. package/dist/modal/hooks/useTelegramLogin.d.ts +4 -3
  21. package/dist/modal/hooks/useTelegramLogin.js +11 -3
  22. package/dist/modal/types/modalProps.d.ts +5 -1
  23. package/dist/modal/utils/steps.d.ts +6 -3
  24. package/dist/modal/utils/steps.js +14 -8
  25. package/dist/modal/utils/stringFormatters.d.ts +0 -1
  26. package/dist/modal/utils/stringFormatters.js +0 -5
  27. package/dist/provider/ParaProviderMin.js +3 -2
  28. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +3 -3
  29. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +6 -3
  30. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +3 -3
  31. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +9 -6
  32. package/dist/provider/hooks/queries/index.d.ts +1 -0
  33. package/dist/provider/hooks/queries/index.js +2 -0
  34. package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
  35. package/dist/provider/hooks/queries/useProfileBalance.d.ts +25 -0
  36. package/dist/provider/hooks/queries/useProfileBalance.js +60 -0
  37. package/dist/provider/hooks/utils/useAssetInfo.d.ts +3 -0
  38. package/dist/provider/hooks/utils/useAssetInfo.js +21 -0
  39. package/dist/provider/hooks/utils/useEventListeners.js +11 -1
  40. package/dist/provider/hooks/utils/useModal.js +3 -3
  41. package/dist/provider/providers/AssetsProvider.d.ts +14 -0
  42. package/dist/provider/providers/AssetsProvider.js +68 -0
  43. package/dist/provider/providers/AuthProvider.d.ts +6 -4
  44. package/dist/provider/providers/AuthProvider.js +120 -52
  45. package/dist/provider/stores/slices/modal.js +4 -1
  46. package/dist/provider/stores/types.d.ts +4 -1
  47. package/package.json +8 -8
  48. package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.d.ts +0 -1
  49. package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.js +0 -12
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { useEffect, useState } from "react";
6
+ import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
7
+ import { useModalStore } from "../stores/index.js";
8
+ import { useAuthActions } from "../../provider/providers/AuthProvider.js";
9
+ const useFarcasterLogin = ({
10
+ isActive = false
11
+ } = {}) => {
12
+ const para = useInternalClient();
13
+ const refs = useModalStore((state) => state.refs);
14
+ const { verifyFarcasterStatus, verifyFarcaster } = useAuthActions();
15
+ const [url, setUrl] = useState();
16
+ const [isLoaded, setIsLoaded] = useState(false);
17
+ const [msgStatus, setMsgStatus] = useState("idle");
18
+ const status = msgStatus === "success" ? verifyFarcasterStatus : msgStatus;
19
+ useEffect(() => {
20
+ const setup = () => __async(void 0, null, function* () {
21
+ if (!url) {
22
+ yield para.logout();
23
+ yield para.touchSession(true);
24
+ para.constructPortalUrl("loginFarcaster").then(setUrl);
25
+ }
26
+ });
27
+ if (isActive) {
28
+ setup();
29
+ }
30
+ }, [isActive, url]);
31
+ useEffect(() => {
32
+ const updateState = (event) => __async(void 0, null, function* () {
33
+ var _a, _b;
34
+ switch (event.data.type) {
35
+ case "FARCASTER_LOGIN":
36
+ setMsgStatus("pending");
37
+ break;
38
+ case "FARCASTER_FAILED":
39
+ setMsgStatus("error");
40
+ break;
41
+ case "FARCASTER_SUCCESS":
42
+ setMsgStatus("success");
43
+ if (!!event.data.payload) {
44
+ const authObject = event.data.payload;
45
+ try {
46
+ yield verifyFarcaster(authObject);
47
+ } catch (e) {
48
+ (_b = (_a = refs.telegramIFrame.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage({ type: "FARCASTER_RETRY" }, "*");
49
+ }
50
+ }
51
+ break;
52
+ }
53
+ });
54
+ if (isActive) {
55
+ window == null ? void 0 : window.addEventListener("message", updateState, false);
56
+ }
57
+ return () => {
58
+ window == null ? void 0 : window.removeEventListener("message", updateState, false);
59
+ };
60
+ }, [isActive]);
61
+ return {
62
+ url,
63
+ isLoaded,
64
+ setIsLoaded,
65
+ status
66
+ };
67
+ };
68
+ export {
69
+ useFarcasterLogin
70
+ };
@@ -1,9 +1,10 @@
1
- import { TelegramAuthResponse } from '@getpara/user-management-client';
1
+ import { TelegramAuthResponse, VerifyThirdPartyAuth } from '@getpara/user-management-client';
2
2
  import { MutationStatus } from '@tanstack/react-query';
3
- export declare const useTelegramLogin: ({ isActive, onSubmit, status: propsStatus, }?: {
3
+ export declare const useTelegramLogin: ({ isActive, onSubmit, status: propsStatus, isLinking, }?: {
4
4
  isActive?: boolean;
5
- onSubmit?: (_: TelegramAuthResponse) => void;
5
+ onSubmit?: (_: VerifyThirdPartyAuth | TelegramAuthResponse) => void;
6
6
  status?: MutationStatus;
7
+ isLinking?: boolean;
7
8
  }) => {
8
9
  url: string | undefined;
9
10
  isLoaded: boolean;
@@ -8,7 +8,8 @@ import { useModalStore } from "../stores/index.js";
8
8
  const useTelegramLogin = ({
9
9
  isActive = false,
10
10
  onSubmit,
11
- status: propsStatus
11
+ status: propsStatus,
12
+ isLinking
12
13
  } = {}) => {
13
14
  const para = useInternalClient();
14
15
  const refs = useModalStore((state) => state.refs);
@@ -17,10 +18,17 @@ const useTelegramLogin = ({
17
18
  const [msgStatus, setMsgStatus] = useState("idle");
18
19
  const status = msgStatus === "success" ? propsStatus : msgStatus;
19
20
  useEffect(() => {
20
- if (isActive) {
21
+ const setup = () => __async(void 0, null, function* () {
21
22
  if (!url) {
22
- para.constructPortalUrl("telegramLogin").then(setUrl);
23
+ if (!isLinking) {
24
+ yield para.logout();
25
+ yield para.touchSession(true);
26
+ }
27
+ para.constructPortalUrl(!isLinking ? "telegramLoginVerify" : "telegramLogin").then(setUrl);
23
28
  }
29
+ });
30
+ if (isActive) {
31
+ setup();
24
32
  }
25
33
  }, [isActive, url]);
26
34
  useEffect(() => {
@@ -1,4 +1,4 @@
1
- import ParaWeb, { CurrentWalletIds, SupportedAccountLinks, TOAuthMethod } from '@getpara/web-sdk';
1
+ import ParaWeb, { BalancesConfig, CurrentWalletIds, SupportedAccountLinks, TOAuthMethod } from '@getpara/web-sdk';
2
2
  import { Theme } from '@getpara/react-components';
3
3
  import { OnModalStepChangeValue } from '../stores/index.js';
4
4
  import { ModalStep, ModalStepProp } from '../utils/steps.js';
@@ -126,4 +126,8 @@ export interface ParaModalProps {
126
126
  * If not provided, will default to your Developer Portal configuration or to all available account types.
127
127
  */
128
128
  supportedAccountLinks?: SupportedAccountLinks;
129
+ /**
130
+ * Configuration for the profile balances displayed in the Para Modal.
131
+ */
132
+ balances?: BalancesConfig;
129
133
  }
@@ -39,7 +39,8 @@ export declare enum ModalStep {
39
39
  ACCOUNT_PROFILE_ADD = "ACCOUNT_PROFILE_ADD",
40
40
  ACCOUNT_PROFILE_LIST = "ACCOUNT_PROFILE_LIST",
41
41
  ACCOUNT_PROFILE_REMOVE = "ACCOUNT_PROFILE_REMOVE",
42
- AWAITING_IFRAME = "AWAITING_IFRAME"
42
+ AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
43
+ OTP = "OTP"
43
44
  }
44
45
  export type ModalStepPropU = keyof typeof ModalStep | ModalStep;
45
46
  export type ModalStepPropL = Lowercase<ModalStepPropU>;
@@ -91,7 +92,8 @@ declare enum SignUpModalStep {
91
92
  ADD_FUNDS_AWAITING = "ADD_FUNDS_AWAITING",
92
93
  ADD_FUNDS_SUCCESS = "ADD_FUNDS_SUCCESS",
93
94
  ADD_FUNDS_FAILURE = "ADD_FUNDS_FAILURE",
94
- AWAITING_IFRAME = "AWAITING_IFRAME"
95
+ AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
96
+ OTP = "OTP"
95
97
  }
96
98
  export declare const SignUpPreviousStep: {
97
99
  [key in SignUpModalStep]: ModalStep | undefined;
@@ -125,7 +127,8 @@ declare enum LoginModalStep {
125
127
  ADD_FUNDS_AWAITING = "ADD_FUNDS_AWAITING",
126
128
  ADD_FUNDS_SUCCESS = "ADD_FUNDS_SUCCESS",
127
129
  ADD_FUNDS_FAILURE = "ADD_FUNDS_FAILURE",
128
- AWAITING_IFRAME = "AWAITING_IFRAME"
130
+ AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
131
+ OTP = "OTP"
129
132
  }
130
133
  export declare const LoginPreviousStep: {
131
134
  [key in LoginModalStep]: ModalStep | undefined;
@@ -40,7 +40,8 @@ var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
40
40
  ModalStep2["ACCOUNT_PROFILE_ADD"] = "ACCOUNT_PROFILE_ADD";
41
41
  ModalStep2["ACCOUNT_PROFILE_LIST"] = "ACCOUNT_PROFILE_LIST";
42
42
  ModalStep2["ACCOUNT_PROFILE_REMOVE"] = "ACCOUNT_PROFILE_REMOVE";
43
- ModalStep2["AWAITING_IFRAME"] = "AWAITING_IFRAME";
43
+ ModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
44
+ ModalStep2["OTP"] = "OTP";
44
45
  return ModalStep2;
45
46
  })(ModalStep || {});
46
47
  var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
@@ -72,7 +73,7 @@ const RESET_TO_AUTH_STEPS = [
72
73
  "AWAITING_BIOMETRIC_CREATION" /* AWAITING_BIOMETRIC_CREATION */,
73
74
  "PASSWORD_CREATION" /* PASSWORD_CREATION */,
74
75
  "AWAITING_PASSWORD_CREATION" /* AWAITING_PASSWORD_CREATION */,
75
- "AWAITING_IFRAME" /* AWAITING_IFRAME */,
76
+ "AWAITING_ACCOUNT" /* AWAITING_ACCOUNT */,
76
77
  "BIOMETRIC_LOGIN" /* BIOMETRIC_LOGIN */,
77
78
  "EMBEDDED_PASSWORD_LOGIN" /* EMBEDDED_PASSWORD_LOGIN */,
78
79
  "AWAITING_BIOMETRIC_LOGIN" /* AWAITING_BIOMETRIC_LOGIN */,
@@ -83,7 +84,8 @@ const RESET_TO_AUTH_STEPS = [
83
84
  "SETUP_2FA" /* SETUP_2FA */,
84
85
  "VERIFY_2FA" /* VERIFY_2FA */,
85
86
  "TWO_FACTOR_DONE" /* TWO_FACTOR_DONE */,
86
- "LOGIN_DONE" /* LOGIN_DONE */
87
+ "LOGIN_DONE" /* LOGIN_DONE */,
88
+ "OTP" /* OTP */
87
89
  ];
88
90
  const RESET_TO_ACCOUNT_STEPS = [
89
91
  "AUTH_GUEST_SIGNUP" /* AUTH_GUEST_SIGNUP */,
@@ -141,7 +143,8 @@ var SignUpModalStep = /* @__PURE__ */ ((SignUpModalStep2) => {
141
143
  SignUpModalStep2["ADD_FUNDS_AWAITING"] = "ADD_FUNDS_AWAITING";
142
144
  SignUpModalStep2["ADD_FUNDS_SUCCESS"] = "ADD_FUNDS_SUCCESS";
143
145
  SignUpModalStep2["ADD_FUNDS_FAILURE"] = "ADD_FUNDS_FAILURE";
144
- SignUpModalStep2["AWAITING_IFRAME"] = "AWAITING_IFRAME";
146
+ SignUpModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
147
+ SignUpModalStep2["OTP"] = "OTP";
145
148
  return SignUpModalStep2;
146
149
  })(SignUpModalStep || {});
147
150
  const SignUpPreviousStep = {
@@ -171,7 +174,8 @@ const SignUpPreviousStep = {
171
174
  ["ADD_FUNDS_AWAITING" /* ADD_FUNDS_AWAITING */]: "ADD_FUNDS_BUY" /* ADD_FUNDS_BUY */,
172
175
  ["ADD_FUNDS_SUCCESS" /* ADD_FUNDS_SUCCESS */]: void 0,
173
176
  ["ADD_FUNDS_FAILURE" /* ADD_FUNDS_FAILURE */]: void 0,
174
- ["AWAITING_IFRAME" /* AWAITING_IFRAME */]: "AUTH_MAIN" /* AUTH_MAIN */
177
+ ["AWAITING_ACCOUNT" /* AWAITING_ACCOUNT */]: "AUTH_MAIN" /* AUTH_MAIN */,
178
+ ["OTP" /* OTP */]: "AUTH_MAIN" /* AUTH_MAIN */
175
179
  };
176
180
  const GuestPreviousStep = Object.fromEntries([
177
181
  ...Object.entries(SignUpPreviousStep).map(([key, value]) => {
@@ -208,7 +212,8 @@ var LoginModalStep = /* @__PURE__ */ ((LoginModalStep2) => {
208
212
  LoginModalStep2["ADD_FUNDS_AWAITING"] = "ADD_FUNDS_AWAITING";
209
213
  LoginModalStep2["ADD_FUNDS_SUCCESS"] = "ADD_FUNDS_SUCCESS";
210
214
  LoginModalStep2["ADD_FUNDS_FAILURE"] = "ADD_FUNDS_FAILURE";
211
- LoginModalStep2["AWAITING_IFRAME"] = "AWAITING_IFRAME";
215
+ LoginModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
216
+ LoginModalStep2["OTP"] = "OTP";
212
217
  return LoginModalStep2;
213
218
  })(LoginModalStep || {});
214
219
  const LoginPreviousStep = {
@@ -237,7 +242,8 @@ const LoginPreviousStep = {
237
242
  ["ADD_FUNDS_AWAITING" /* ADD_FUNDS_AWAITING */]: "ADD_FUNDS_BUY" /* ADD_FUNDS_BUY */,
238
243
  ["ADD_FUNDS_SUCCESS" /* ADD_FUNDS_SUCCESS */]: void 0,
239
244
  ["ADD_FUNDS_FAILURE" /* ADD_FUNDS_FAILURE */]: void 0,
240
- ["AWAITING_IFRAME" /* AWAITING_IFRAME */]: "AUTH_MAIN" /* AUTH_MAIN */
245
+ ["AWAITING_ACCOUNT" /* AWAITING_ACCOUNT */]: "AUTH_MAIN" /* AUTH_MAIN */,
246
+ ["OTP" /* OTP */]: "AUTH_MAIN" /* AUTH_MAIN */
241
247
  };
242
248
  const getStepHasFooter = (step) => {
243
249
  switch (step) {
@@ -264,7 +270,7 @@ function getAddFundsStep(currentTab) {
264
270
  return "ADD_FUNDS_WITHDRAW" /* ADD_FUNDS_WITHDRAW */;
265
271
  }
266
272
  }
267
- const IFrameSteps = ["PASSWORD_CREATION" /* PASSWORD_CREATION */, "EMBEDDED_PASSWORD_LOGIN" /* EMBEDDED_PASSWORD_LOGIN */];
273
+ const IFrameSteps = ["PASSWORD_CREATION" /* PASSWORD_CREATION */, "EMBEDDED_PASSWORD_LOGIN" /* EMBEDDED_PASSWORD_LOGIN */, "OTP" /* OTP */];
268
274
  export {
269
275
  AccountPreviousStep,
270
276
  GuestPreviousStep,
@@ -2,4 +2,3 @@ import { TNetwork } from '@getpara/web-sdk';
2
2
  export declare const formatNetworkList: (networks: TNetwork[]) => string;
3
3
  export declare const formatWalletCreatedDate: (date: string) => string;
4
4
  export declare const camelToSnakeCase: (str: string) => string;
5
- export declare const formatBalanceString: (str: string) => string;
@@ -7,13 +7,8 @@ const formatNetworkList = (networks) => {
7
7
  };
8
8
  const formatWalletCreatedDate = (date) => `${format(new Date(date), "M/d/y")}`;
9
9
  const camelToSnakeCase = (str) => str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
10
- const formatBalanceString = (str) => {
11
- const numericBalance = parseFloat(str);
12
- return `$${numericBalance.toLocaleString(void 0, { maximumFractionDigits: 2 })}`;
13
- };
14
10
  export {
15
11
  camelToSnakeCase,
16
- formatBalanceString,
17
12
  formatNetworkList,
18
13
  formatWalletCreatedDate
19
14
  };
@@ -16,6 +16,7 @@ import ParaWeb from "@getpara/web-sdk";
16
16
  import { EXTERNAL_WALLET_TYPES } from "@getpara/web-sdk";
17
17
  import { AuthProvider } from "./providers/AuthProvider.js";
18
18
  import { AccountLinkProvider } from "./providers/AccountLinkProvider.js";
19
+ import { AssetsProvider } from "./providers/AssetsProvider.js";
19
20
  const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, config, externalWalletConfig, paraModalConfig }, ref) => {
20
21
  useEventListeners(callbacks);
21
22
  useAutoSessionKeepAlive({ disabled: config.disableAutoSessionKeepAlive });
@@ -129,10 +130,10 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
129
130
  login: paraModalConfig == null ? void 0 : paraModalConfig.loginTransitionOverride,
130
131
  createWallets: paraModalConfig == null ? void 0 : paraModalConfig.createWalletOverride
131
132
  },
132
- children: /* @__PURE__ */ jsx(ExternalWalletWrapper, { config: externalWalletConfig, children: /* @__PURE__ */ jsxs(AccountLinkProvider, { children: [
133
+ children: /* @__PURE__ */ jsx(AssetsProvider, { children: /* @__PURE__ */ jsx(ExternalWalletWrapper, { config: externalWalletConfig, children: /* @__PURE__ */ jsxs(AccountLinkProvider, { children: [
133
134
  children,
134
135
  !config.disableEmbeddedModal && client.isReady && /* @__PURE__ */ jsx(ParaModal, { ref })
135
- ] }) })
136
+ ] }) }) })
136
137
  }
137
138
  );
138
139
  });
@@ -16,7 +16,7 @@ export declare const SIGN_UP_LOG_IN_KEY = "SIGN_UP_LOG_IN";
16
16
  */
17
17
  export declare const useSignUpOrLogIn: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/shared").ServerAuthStateVerify> | undefined;
19
+ data: Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
@@ -33,12 +33,12 @@ export declare const useSignUpOrLogIn: () => {
33
33
  failureReason: Error | null;
34
34
  isPaused: boolean;
35
35
  submittedAt: number;
36
- signUpOrLogIn: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/shared").ServerAuthStateVerify>, Error, {
36
+ signUpOrLogIn: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify>, Error, {
37
37
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
38
38
  useShortUrls?: boolean | undefined;
39
39
  auth: import("@getpara/web-sdk").VerifiedAuth;
40
40
  }, unknown>;
41
- signUpOrLogInAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/shared").ServerAuthStateVerify>, Error, {
41
+ signUpOrLogInAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify>, Error, {
42
42
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
43
43
  useShortUrls?: boolean | undefined;
44
44
  auth: import("@getpara/web-sdk").VerifiedAuth;
@@ -16,7 +16,7 @@ export declare const VERIFY_FARCASTER_KEY = "VERIFY_FARCASTER";
16
16
  */
17
17
  export declare const useVerifyFarcaster: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin> | undefined;
19
+ data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: void | {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
@@ -25,6 +25,7 @@ export declare const useVerifyFarcaster: () => {
25
25
  onCancel?: (() => void) | undefined;
26
26
  isCanceled?: (() => boolean) | undefined;
27
27
  onConnectUri?: ((uri: string) => void) | undefined;
28
+ serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
28
29
  } | undefined;
29
30
  error: Error | null;
30
31
  isError: boolean;
@@ -36,20 +37,22 @@ export declare const useVerifyFarcaster: () => {
36
37
  failureReason: Error | null;
37
38
  isPaused: boolean;
38
39
  submittedAt: number;
39
- verifyFarcaster: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, void | {
40
+ verifyFarcaster: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
40
41
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
41
42
  useShortUrls?: boolean | undefined;
42
43
  onPoll?: (() => void) | undefined;
43
44
  onCancel?: (() => void) | undefined;
44
45
  isCanceled?: (() => boolean) | undefined;
45
46
  onConnectUri?: ((uri: string) => void) | undefined;
47
+ serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
46
48
  }, unknown>;
47
- verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, void | {
49
+ verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
48
50
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
49
51
  useShortUrls?: boolean | undefined;
50
52
  onPoll?: (() => void) | undefined;
51
53
  onCancel?: (() => void) | undefined;
52
54
  isCanceled?: (() => boolean) | undefined;
53
55
  onConnectUri?: ((uri: string) => void) | undefined;
56
+ serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
54
57
  }, unknown>;
55
58
  };
@@ -16,7 +16,7 @@ export declare const VERIFY_OAUTH_KEY = "VERIFY_OAUTH";
16
16
  */
17
17
  export declare const useVerifyOAuth: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin> | undefined;
19
+ data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
@@ -39,7 +39,7 @@ export declare const useVerifyOAuth: () => {
39
39
  failureReason: Error | null;
40
40
  isPaused: boolean;
41
41
  submittedAt: number;
42
- verifyOAuth: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
42
+ verifyOAuth: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
43
43
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
44
44
  useShortUrls?: boolean | undefined;
45
45
  method: Exclude<import("@getpara/web-sdk").TOAuthMethod, "TELEGRAM" | "FARCASTER">;
@@ -50,7 +50,7 @@ export declare const useVerifyOAuth: () => {
50
50
  onOAuthUrl?: ((url: string) => void) | undefined;
51
51
  onOAuthPopup?: ((popup: Window) => void) | undefined;
52
52
  }, unknown>;
53
- verifyOAuthAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
53
+ verifyOAuthAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
54
54
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
55
55
  useShortUrls?: boolean | undefined;
56
56
  method: Exclude<import("@getpara/web-sdk").TOAuthMethod, "TELEGRAM" | "FARCASTER">;
@@ -16,12 +16,13 @@ export declare const VERIFY_TELEGRAM_KEY = "VERIFY_TELEGRAM";
16
16
  */
17
17
  export declare const useVerifyTelegram: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin> | undefined;
19
+ data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
23
23
  useShortUrls?: boolean | undefined;
24
- telegramAuthResponse: import("@getpara/web-sdk").TelegramAuthResponse;
24
+ telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
25
+ serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
25
26
  } | undefined;
26
27
  error: Error | null;
27
28
  isError: boolean;
@@ -33,14 +34,16 @@ export declare const useVerifyTelegram: () => {
33
34
  failureReason: Error | null;
34
35
  isPaused: boolean;
35
36
  submittedAt: number;
36
- verifyTelegram: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
37
+ verifyTelegram: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
37
38
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
38
39
  useShortUrls?: boolean | undefined;
39
- telegramAuthResponse: import("@getpara/web-sdk").TelegramAuthResponse;
40
+ telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
41
+ serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
40
42
  }, unknown>;
41
- verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
43
+ verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
42
44
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
43
45
  useShortUrls?: boolean | undefined;
44
- telegramAuthResponse: import("@getpara/web-sdk").TelegramAuthResponse;
46
+ telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
47
+ serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
45
48
  }, unknown>;
46
49
  };
@@ -4,3 +4,4 @@ export { useWallet } from './useWallet.js';
4
4
  export { useWalletBalance } from './useWalletBalance.js';
5
5
  export { useLinkedAccounts } from './useLinkedAccounts.js';
6
6
  export { useAccountLinkInProgress } from './useAccountLinkInProgress.js';
7
+ export { useProfileBalance } from './useProfileBalance.js';
@@ -6,11 +6,13 @@ import { useWallet } from "./useWallet.js";
6
6
  import { useWalletBalance } from "./useWalletBalance.js";
7
7
  import { useLinkedAccounts } from "./useLinkedAccounts.js";
8
8
  import { useAccountLinkInProgress } from "./useAccountLinkInProgress.js";
9
+ import { useProfileBalance } from "./useProfileBalance.js";
9
10
  export {
10
11
  useAccount,
11
12
  useAccountLinkInProgress,
12
13
  useLinkedAccounts,
13
14
  useParaStatus,
15
+ useProfileBalance,
14
16
  useWallet,
15
17
  useWalletBalance
16
18
  };
@@ -5,13 +5,15 @@ import {
5
5
  import { useQuery } from "@tanstack/react-query";
6
6
  import { useInternalClient } from "../utils/useInternalClient.js";
7
7
  import { getLinkedAccounts } from "../../actions/index.js";
8
+ import { useAccount } from "./useAccount.js";
8
9
  const LINKED_ACCOUNTS_BASE_KEY = "PARA_LINKED_ACCOUNTS";
9
10
  const useLinkedAccounts = (params = { withMetadata: false }) => {
10
11
  var _a;
11
12
  const client = useInternalClient();
13
+ const { connectionType } = useAccount();
12
14
  return useQuery({
13
- enabled: !!(client == null ? void 0 : client.isReady),
14
- queryKey: [LINKED_ACCOUNTS_BASE_KEY, (_a = client == null ? void 0 : client.userId) != null ? _a : null, params],
15
+ enabled: !!(client == null ? void 0 : client.isReady) && ["both", "embedded"].includes(connectionType),
16
+ queryKey: [LINKED_ACCOUNTS_BASE_KEY, (_a = client == null ? void 0 : client.userId) != null ? _a : null, connectionType, params],
15
17
  queryFn: () => __async(void 0, null, function* () {
16
18
  var _a2;
17
19
  return (_a2 = yield getLinkedAccounts(client, params)) != null ? _a2 : [];
@@ -0,0 +1,25 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ import { ProfileBalance } from '@getpara/web-sdk';
3
+ /**
4
+ * Options for the useProfileBalance hook.
5
+ */
6
+ type UseProfileBalanceOptions = {
7
+ /**
8
+ * A value that, when changed, will recalculate the current profile's balances.
9
+ *
10
+ * Use a counter (increment when you want to refetch) or timestamp for one-time refetches.
11
+ *
12
+ * When not provided, internal SDK events (like asset transfers) will still trigger refetches via React Query invalidation.
13
+ */
14
+ refetchTrigger?: number | string;
15
+ };
16
+ /**
17
+ * React Query hook for retrieving the asset balance for your currently connected wallets.
18
+ *
19
+ * @returns {ProfileBalance}
20
+ * The profile balance object, containing the aggregated balance for all wallets and entries for each wallet, further divided by various assets and networks.
21
+ *
22
+ * The profile balance will be denoted in USD or in a custom asset you specify, depending on your ParaProvider configuration.
23
+ */
24
+ export declare const useProfileBalance: (options?: UseProfileBalanceOptions) => UseQueryResult<ProfileBalance>;
25
+ export {};
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { useQuery } from "@tanstack/react-query";
6
+ import { useRef, useEffect } from "react";
7
+ import { useStore } from "../../stores/useStore.js";
8
+ import { useInternalClient } from "../utils/useInternalClient.js";
9
+ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
10
+ const useProfileBalance = (options) => {
11
+ var _a, _b;
12
+ const client = useInternalClient();
13
+ const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
14
+ const config = useStore((state) => {
15
+ var _a2;
16
+ return (_a2 = state.modalConfig) == null ? void 0 : _a2.balances;
17
+ });
18
+ const refs = useStore((state) => state.refs);
19
+ const previousTriggerRef = useRef(options == null ? void 0 : options.refetchTrigger);
20
+ const shouldRefetchRef = useRef(false);
21
+ const lastQueryTimeRef = useRef(0);
22
+ useEffect(() => {
23
+ if ((options == null ? void 0 : options.refetchTrigger) !== previousTriggerRef.current) {
24
+ shouldRefetchRef.current = true;
25
+ previousTriggerRef.current = options == null ? void 0 : options.refetchTrigger;
26
+ }
27
+ }, [options == null ? void 0 : options.refetchTrigger]);
28
+ return useQuery({
29
+ enabled: isSuccess && !!client,
30
+ queryKey: [
31
+ "useProfileBalance",
32
+ isFullyLoggedIn != null ? isFullyLoggedIn : null,
33
+ (_a = client == null ? void 0 : client.userId) != null ? _a : null,
34
+ (_b = client == null ? void 0 : client.availableWallets.map(({ address }) => address)) != null ? _b : null,
35
+ config != null ? config : null
36
+ // Note: refetchTrigger is NOT in query key to allow cache sharing
37
+ ],
38
+ staleTime: 3e4,
39
+ retry: 3,
40
+ queryFn: () => __async(void 0, null, function* () {
41
+ var _a2;
42
+ if (!client || !isFullyLoggedIn) {
43
+ return null;
44
+ }
45
+ const isInvalidationRefetch = ((_a2 = refs.balancesInvalidationTime.current) != null ? _a2 : 0) > lastQueryTimeRef.current;
46
+ const profileBalance = yield client == null ? void 0 : client.getProfileBalance({
47
+ config,
48
+ refetch: shouldRefetchRef.current || isInvalidationRefetch
49
+ });
50
+ lastQueryTimeRef.current = Date.now();
51
+ shouldRefetchRef.current = false;
52
+ return profileBalance;
53
+ }),
54
+ // We handle refetch manually
55
+ refetchOnWindowFocus: false
56
+ });
57
+ };
58
+ export {
59
+ useProfileBalance
60
+ };
@@ -0,0 +1,3 @@
1
+ import { AssetMetadataIndexed } from '@getpara/web-sdk';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ export declare const useAssetInfo: () => UseQueryResult<AssetMetadataIndexed>;
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { useInternalClient } from "../utils/useInternalClient.js";
6
+ import { useQuery } from "@tanstack/react-query";
7
+ const useAssetInfo = () => {
8
+ const client = useInternalClient();
9
+ return useQuery({
10
+ enabled: !!client,
11
+ queryKey: ["useAssetInfo"],
12
+ staleTime: 15e3,
13
+ queryFn: () => __async(void 0, null, function* () {
14
+ const { assets } = yield client == null ? void 0 : client.ctx.client.getAssetInfo();
15
+ return assets;
16
+ })
17
+ });
18
+ };
19
+ export {
20
+ useAssetInfo
21
+ };
@@ -3,11 +3,11 @@ import "../../../chunk-MMUBH76A.js";
3
3
  import { useQueryClient } from "@tanstack/react-query";
4
4
  import { useCallback, useEffect } from "react";
5
5
  import { useWalletState } from "../index.js";
6
+ import { useStore } from "../../stores/useStore.js";
6
7
  import {
7
8
  ParaEvent
8
9
  } from "@getpara/web-sdk";
9
10
  import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
10
- import { useStore } from "../../stores/useStore.js";
11
11
  import { WALLET_BASE_KEY } from "../queries/useWallet.js";
12
12
  import { WALLET_BALANCE_BASE_KEY } from "../queries/useWalletBalance.js";
13
13
  import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../queries/useIsFullyLoggedIn.js";
@@ -25,6 +25,7 @@ const useEventListeners = ({
25
25
  onGuestWalletsCreated
26
26
  } = {}) => {
27
27
  const queryClient = useQueryClient();
28
+ const refs = useStore((state) => state.refs);
28
29
  const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
29
30
  const { updateSelectedWallet } = useWalletState();
30
31
  const loginOrSetupListener = useCallback(() => {
@@ -113,6 +114,13 @@ const useEventListeners = ({
113
114
  },
114
115
  [queryClient, updateSelectedWallet, onGuestWalletsCreated]
115
116
  );
117
+ const assetTransferListener = useCallback(() => {
118
+ refs.balancesInvalidationTime.current = Date.now();
119
+ queryClient.invalidateQueries({
120
+ queryKey: ["useProfileBalance"],
121
+ refetchType: "active"
122
+ });
123
+ }, [queryClient, refs.balancesInvalidationTime]);
116
124
  useEffect(() => {
117
125
  window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
118
126
  window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
@@ -125,6 +133,7 @@ const useEventListeners = ({
125
133
  window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
126
134
  window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
127
135
  window.addEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
136
+ window.addEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
128
137
  return () => {
129
138
  window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
130
139
  window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
@@ -137,6 +146,7 @@ const useEventListeners = ({
137
146
  window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
138
147
  window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
139
148
  window.removeEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
149
+ window.removeEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
140
150
  };
141
151
  }, [
142
152
  loginListener,
@@ -5,11 +5,11 @@ import { useStore } from "../../stores/useStore.js";
5
5
  const useModal = () => {
6
6
  const isOpen = useStore((state) => state.isOpen);
7
7
  const setIsOpen = useStore((state) => state.setIsOpen);
8
- const openedToStep = useStore((state) => state.openedToStep);
8
+ const refs = useStore((state) => state.refs);
9
9
  const setStep = useModalStore((state) => state.setStep);
10
10
  const openModal = ({ step } = {}) => {
11
11
  if (step) {
12
- openedToStep.current = step;
12
+ refs.openedToStep.current = step;
13
13
  setStep(step);
14
14
  }
15
15
  if (!isOpen) {
@@ -17,7 +17,7 @@ const useModal = () => {
17
17
  }
18
18
  };
19
19
  const closeModal = () => {
20
- openedToStep.current = null;
20
+ refs.openedToStep.current = null;
21
21
  setIsOpen(false);
22
22
  };
23
23
  return { isOpen, openModal, closeModal };