@getpara/react-sdk 2.0.0-alpha.25 → 2.0.0-alpha.27

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.
@@ -48,12 +48,12 @@ const ParaModal = forwardRef((props, ref) => {
48
48
  const { setSelectedWallet, updateSelectedWallet } = useWalletState();
49
49
  const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
50
50
  const { signUpOrLogIn, isCreateGuestWalletsPending } = useAuthActions();
51
- const { data: account } = useAccount();
51
+ const { data: account, status: statusAccount } = useAccount();
52
52
  const [isModalMounted, setIsModalMounted] = useState(false);
53
- const [isInit, setIsInit] = useState(false);
54
53
  const externalWallets = useStore((state) => state.externalWallets);
55
54
  const providerProps = useStore((state) => state.providerProps);
56
55
  const setAccountLinkOptions = useModalStore((state) => state.setAccountLinkOptions);
56
+ const isInitialized = useRef(false);
57
57
  const _a = __spreadValues(__spreadValues({}, storedModalConfig), props), {
58
58
  isOpen: configIsOpen,
59
59
  theme,
@@ -133,7 +133,7 @@ const ParaModal = forwardRef((props, ref) => {
133
133
  }, [hasPreviousStep, currentStep]);
134
134
  const initModal = (shouldAutoLogin) => __async(void 0, null, function* () {
135
135
  var _a2;
136
- const isAccount = yield para.isFullyLoggedIn(), isGuest = isAccount && para.isGuestMode || isCreateGuestWalletsPending;
136
+ const isAccount = account == null ? void 0 : account.isConnected, isGuest = isAccount && para.isGuestMode || isCreateGuestWalletsPending;
137
137
  switch (true) {
138
138
  case !!currentStepOverride:
139
139
  setStep(ModalStep[currentStepOverride.toUpperCase()]);
@@ -175,8 +175,17 @@ const ParaModal = forwardRef((props, ref) => {
175
175
  }
176
176
  break;
177
177
  }
178
- setIsInit(true);
179
178
  });
179
+ useEffect(() => {
180
+ if (para && isOpen && statusAccount === "success" && !isInitialized.current) {
181
+ initModal(isOpen);
182
+ isInitialized.current = true;
183
+ }
184
+ if (para && !isOpen && isInitialized.current) {
185
+ initModal();
186
+ isInitialized.current = false;
187
+ }
188
+ }, [para, isOpen, account, statusAccount]);
180
189
  useEffect(() => {
181
190
  let _authLayout = authLayout;
182
191
  if (!(externalWallets == null ? void 0 : externalWallets.length) && hasExternalWallet(authLayout)) {
@@ -197,18 +206,6 @@ const ParaModal = forwardRef((props, ref) => {
197
206
  useEffect(() => {
198
207
  setOnModalStepChange(onModalStepChange);
199
208
  }, [onModalStepChange]);
200
- useEffect(() => {
201
- if (para) {
202
- initModal();
203
- } else {
204
- console.error("A Para instance must be provided.");
205
- }
206
- }, []);
207
- useEffect(() => {
208
- if (isOpen && para) {
209
- initModal(true);
210
- }
211
- }, [isOpen]);
212
209
  useEffect(() => {
213
210
  updateSelectedWallet();
214
211
  }, [para]);
@@ -236,10 +233,6 @@ const ParaModal = forwardRef((props, ref) => {
236
233
  } else if (RESET_TO_ACCOUNT_STEPS.includes(currentStep)) {
237
234
  setStep(ModalStep.LOGIN_DONE);
238
235
  }
239
- if (para) {
240
- yield initModal();
241
- }
242
- setIsInit(false);
243
236
  });
244
237
  if (!para) {
245
238
  console.error("A Para instance is required.");
@@ -275,7 +268,7 @@ const ParaModal = forwardRef((props, ref) => {
275
268
  className,
276
269
  "data-testid": "modal",
277
270
  $embeddedModal: !!embeddedModal,
278
- children: isModalMounted && ((embeddedModal || bareModal) && isInit || !embeddedModal && !bareModal) && /* @__PURE__ */ jsx(
271
+ children: isModalMounted && ((embeddedModal || bareModal) && isInitialized.current || !embeddedModal && !bareModal) && /* @__PURE__ */ jsx(
279
272
  ModalContent,
280
273
  __spreadValues({
281
274
  oAuthMethods,
@@ -1 +1,5 @@
1
+ interface LoginDoneStep {
2
+ onClose: () => void;
3
+ }
1
4
  export declare const LoginDoneStep: ({ onClose }: LoginDoneStep) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import {
3
- __async,
4
3
  __spreadProps,
5
4
  __spreadValues
6
5
  } from "../../../chunk-MMUBH76A.js";
@@ -63,12 +62,6 @@ const ModalContent = forwardRef(
63
62
  }
64
63
  }, [onRampTestMode]);
65
64
  useEffect(() => {
66
- const init = () => __async(void 0, null, function* () {
67
- if (!(yield para.isFullyLoggedIn())) {
68
- yield disconnectExternalWallet();
69
- }
70
- });
71
- init();
72
65
  return () => {
73
66
  var _a;
74
67
  window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
@@ -30,7 +30,7 @@ export declare function getNetworkName(str: Network | string): string;
30
30
  export declare function getNetworkIcon(str: Network | string): IconType;
31
31
  export declare function getAssetCode(str: OnRampAsset | string): string;
32
32
  export declare function getAssetName(str: OnRampAsset | string): string;
33
- export declare function getAssetIcon(str: OnRampAsset | string): "key" | "phone" | "farcaster" | "telegram" | "discord" | "x" | "search" | "para" | "walletConnect" | "wallet" | "close" | "copy" | "safe" | "cosmos" | "alertCircle" | "alertTriangle" | "alignVerticalCenter" | "angelListBrand" | "angelList" | "appleBrand" | "apple" | "arbitrumBrand" | "arrowCircleBrokenDownLeft" | "arrowCircleDownFilled" | "arrowNarrow" | "arrow" | "asterisk" | "backpack" | "backupKit" | "bank" | "baseBrand" | "brush" | "celoBrand" | "checkCircleFilled" | "checkCircle" | "checkSquare" | "check" | "chevronDown" | "chevronRight" | "chevronSelectorVertical" | "chevronUp" | "clock" | "clubhouseBrand" | "clubhouse" | "code" | "coinbase" | "copy07" | "cosmosCircle" | "cosmostation" | "creditCard02" | "creditCard" | "cube03" | "cubeOutline" | "cube" | "currencyDollar" | "decentBrand" | "decent" | "dell" | "discordBrand" | "dot" | "dots" | "downloadCloud" | "download" | "dribbbleBrand" | "dribbble" | "earth" | "edit02" | "emptyCircle" | "ethCircle" | "ethereum" | "eyeOff" | "eye" | "facebookBrand" | "facebook" | "farcasterBrand" | "figmaBrand" | "figma" | "file" | "folder" | "githubBrand" | "github" | "globe" | "glow" | "googleBrand" | "google" | "gridDots" | "haha" | "helpCircle" | "heroAlertCircle" | "heroCheckmarkCapsule" | "heroCheckmark" | "heroEmail" | "heroExternalConnection" | "heroLock" | "heroPasskey" | "heroPhone" | "heroPlusCircleCapsule" | "heroPlusCircle" | "heroWallet" | "home" | "hp" | "image" | "infoCircle" | "instagramBrand" | "instagram" | "keplr" | "laptop" | "leap" | "lenovo" | "lg" | "lightning01" | "lightning" | "linkExternal" | "linkedinBrand" | "linkedin" | "lockKeyholeCircle" | "logOut" | "mail" | "menu" | "metamask" | "monitor" | "moonpayBrand" | "moreLoginOptions" | "motorola" | "nobleBrand" | "okx" | "optimismBrand" | "paraBlackBg" | "paraBrand" | "paraIconBrand" | "paraIconQr" | "paraIcon" | "paraLogo" | "paraRingsDark" | "paraRings" | "passcode" | "phantom" | "pintrestBrand" | "pintrest" | "plusCircle" | "plus" | "polygonBrand" | "polygon" | "puzzlePiece" | "qrCode02" | "qrCode" | "rabby" | "rainbow" | "rampNetworkBrand" | "rampNetwork" | "redditBrand" | "reddit" | "refresh" | "samsung" | "send" | "settings" | "share" | "shield" | "signalBrand" | "signal" | "sliders" | "snapchatBrand" | "snapchat" | "solanaCircle" | "solana" | "solflare" | "spacingHeight" | "star04Filled" | "star05" | "stars01Filled" | "stars02" | "stars" | "stopSquare" | "stripeBrand" | "telegramBrand" | "tetherBrand" | "tikTokBrand" | "tikTok" | "trash" | "tumblrBrand" | "tumblr" | "twitterBrand" | "twitter" | "usdcBrand" | "userCircle" | "userPlus" | "user" | "youtubeBrand" | "youtube" | "zerion" | "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BQ2" | "BQ3" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CD2" | "CF" | "CH" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DS" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB2" | "GB" | "GD" | "GE" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GQ" | "GR" | "GT" | "GU" | "GW" | "GY" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SE" | "SG" | "SI" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WS" | "YE" | "ZA" | "ZM" | "ZW";
33
+ export declare function getAssetIcon(str: OnRampAsset | string): "key" | "phone" | "farcaster" | "telegram" | "discord" | "x" | "search" | "para" | "walletConnect" | "wallet" | "close" | "copy" | "safe" | "cosmos" | "alertCircle" | "alertTriangle" | "alignVerticalCenter" | "angelListBrand" | "angelList" | "appleBrand" | "apple" | "arbitrumBrand" | "arrowCircleBrokenDownLeft" | "arrowCircleDownFilled" | "arrowNarrow" | "arrow" | "asterisk" | "backpack" | "backupKit" | "bank" | "baseBrand" | "brush" | "celoBrand" | "checkCircleFilled" | "checkCircle" | "checkSquare" | "check" | "chevronDown" | "chevronRight" | "chevronSelectorVertical" | "chevronUp" | "clock" | "clubhouseBrand" | "clubhouse" | "code" | "coinbase" | "copy07" | "cosmosCircle" | "cosmostation" | "creditCard02" | "creditCard" | "cube03" | "cubeOutline" | "cube" | "currencyDollar" | "decentBrand" | "decent" | "dell" | "discordBrand" | "dot" | "dots" | "downloadCloud" | "download" | "dribbbleBrand" | "dribbble" | "earth" | "edit02" | "emptyCircle" | "ethCircle" | "ethereum" | "eyeOff" | "eye" | "facebookBrand" | "facebook" | "farcasterBrand" | "figmaBrand" | "figma" | "file" | "folder" | "githubBrand" | "github" | "globe" | "glow" | "googleBrand" | "google" | "gridDots" | "haha" | "helpCircle" | "heroAlertCircle" | "heroCheckmarkCapsule" | "heroCheckmark" | "heroEmail" | "heroExternalConnection" | "heroLock" | "heroPasskey" | "heroPhone" | "heroPlusCircleCapsule" | "heroPlusCircle" | "heroWallet" | "home" | "hp" | "image" | "infoCircle" | "instagramBrand" | "instagram" | "keplr" | "laptop" | "leap" | "lenovo" | "lg" | "lightning01" | "lightning" | "linkExternal" | "linkedinBrand" | "linkedin" | "lockKeyholeCircle" | "logOut" | "mail" | "menu" | "metamask" | "monitor" | "moonpayBrand" | "moreLoginOptions" | "motorola" | "nobleBrand" | "okx" | "optimismBrand" | "paraBlackBg" | "paraBrand" | "paraIconBrand" | "paraIconQr" | "paraIcon" | "paraLogo" | "paraRingsDark" | "paraRings" | "passcode" | "phantom" | "pintrestBrand" | "pintrest" | "plusCircle" | "plus" | "polygonBrand" | "polygon" | "puzzlePiece" | "qrCode02" | "qrCode" | "rabby" | "rainbow" | "rampNetworkBrand" | "rampNetwork" | "redditBrand" | "reddit" | "refresh" | "samsung" | "send" | "settings" | "share" | "shield" | "signalBrand" | "signal" | "sliders" | "snapchatBrand" | "snapchat" | "solanaCircle" | "solana" | "solflare" | "spacingHeight" | "star04Filled" | "star05" | "stars01Filled" | "stars02" | "stars" | "stopSquare" | "stripeBrand" | "telegramBrand" | "tetherBrand" | "tikTokBrand" | "tikTok" | "trash" | "tumblrBrand" | "tumblr" | "twitterBrand" | "twitter" | "usdcBrand" | "userCircle" | "userPlus" | "user" | "valora" | "youtubeBrand" | "youtube" | "zerion" | "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BQ2" | "BQ3" | "BR" | "BS" | "BT" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CD2" | "CF" | "CH" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DS" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB2" | "GB" | "GD" | "GE" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GQ" | "GR" | "GT" | "GU" | "GW" | "GY" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SE" | "SG" | "SI" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "US" | "UY" | "UZ" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WS" | "YE" | "ZA" | "ZM" | "ZW";
34
34
  export declare const MOBILE_SIZE = 480;
35
35
  export declare const NETWORK_NOT_SUPPORTED_ERROR = "network not supported";
36
36
  export declare const EMAIL_REGEX: RegExp;
@@ -119,7 +119,7 @@ const BODY_MOTION_VARIANTS = {
119
119
  const BODY_TRANSITION = {
120
120
  duration: 0.2
121
121
  };
122
- const SDK_VERSION = "2.0.0-alpha.24";
122
+ const SDK_VERSION = "2.0.0-alpha.27";
123
123
  export {
124
124
  BODY_MOTION_VARIANTS,
125
125
  BODY_TRANSITION,
@@ -136,6 +136,11 @@ const ACCOUNT_TYPES = {
136
136
  logo: "solflare",
137
137
  name: "Solflare",
138
138
  isExternalWallet: true
139
+ },
140
+ VALORA: {
141
+ logo: "valora",
142
+ name: "Valora",
143
+ isExternalWallet: true
139
144
  }
140
145
  };
141
146
  function getAccountTypeName(type, { inline = false } = {}) {
@@ -22,5 +22,5 @@ export type Account = ({
22
22
  isConnected: true;
23
23
  isGuestMode: false;
24
24
  } & AccountValue);
25
- export declare const getAccount: (para?: ParaWeb) => Promise<Account>;
25
+ export declare const getAccount: (para?: ParaWeb, isConnected?: boolean) => Promise<Account>;
26
26
  export {};
@@ -4,16 +4,19 @@ import {
4
4
  __spreadProps,
5
5
  __spreadValues
6
6
  } from "../../chunk-MMUBH76A.js";
7
- const getAccount = (para) => __async(void 0, null, function* () {
8
- if (!!para && para.isGuestMode) {
7
+ const getAccount = (para, isConnected) => __async(void 0, null, function* () {
8
+ if (!para) {
9
+ return { isConnected: false };
10
+ }
11
+ if (para.isGuestMode) {
9
12
  return {
10
13
  isConnected: true,
11
14
  isGuestMode: true,
12
15
  wallets: para.availableWallets
13
16
  };
14
17
  }
15
- const isConnected = !!para && (yield para == null ? void 0 : para.isFullyLoggedIn());
16
- if (isConnected) {
18
+ const _isConnected = isConnected != null ? isConnected : yield para == null ? void 0 : para.isFullyLoggedIn();
19
+ if (_isConnected) {
17
20
  const authInfo = para.authInfo;
18
21
  const value = __spreadProps(__spreadValues({}, authInfo || {}), {
19
22
  userId: para.userId,
@@ -2,4 +2,4 @@ import ParaWeb, { TWalletType } from '@getpara/web-sdk';
2
2
  export declare const getWallet: (para?: ParaWeb, selectedWallet?: {
3
3
  id?: string;
4
4
  type?: TWalletType;
5
- }) => Promise<Omit<import("@getpara/web-sdk").Wallet, "signer"> | null | undefined>;
5
+ }, isConnected?: boolean) => Promise<Omit<import("@getpara/web-sdk").Wallet, "signer"> | null>;
@@ -2,12 +2,16 @@
2
2
  import {
3
3
  __async
4
4
  } from "../../chunk-MMUBH76A.js";
5
- const getWallet = (para, selectedWallet) => __async(void 0, null, function* () {
6
- const isLoggedIn = yield para == null ? void 0 : para.isFullyLoggedIn();
7
- if (!para || !isLoggedIn) {
5
+ const getWallet = (para, selectedWallet, isConnected) => __async(void 0, null, function* () {
6
+ var _a;
7
+ if (!para) {
8
8
  return null;
9
9
  }
10
- return para.findWallet(selectedWallet == null ? void 0 : selectedWallet.id, selectedWallet == null ? void 0 : selectedWallet.type);
10
+ const isLoggedIn = isConnected != null ? isConnected : yield para == null ? void 0 : para.isFullyLoggedIn();
11
+ if (!isLoggedIn) {
12
+ return null;
13
+ }
14
+ return (_a = para.findWallet(selectedWallet == null ? void 0 : selectedWallet.id, selectedWallet == null ? void 0 : selectedWallet.type)) != null ? _a : null;
11
15
  });
12
16
  export {
13
17
  getWallet
@@ -1,4 +1,4 @@
1
1
  import ParaWeb, { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods, InternalAction, InternalMethodName, InternalMethods } from '@getpara/web-sdk';
2
- export type CoreAction<method extends CoreMethodName & keyof CoreMethods> = (para?: ParaWeb, ...args: [CoreMethodParams<method>]) => Promise<Awaited<CoreMethodResponse<method>>>;
2
+ export type CoreAction<method extends CoreMethodName & keyof CoreMethods> = (para?: ParaWeb, ...args: [CoreMethodParams<method>] | []) => Promise<Awaited<CoreMethodResponse<method>>>;
3
3
  export declare function generateCoreAction<const method extends CoreMethodName & keyof CoreMethods>(method: method): CoreAction<method>;
4
4
  export declare function generateInternalAction<const method extends InternalMethodName & keyof InternalMethods>(method: method): InternalAction<method>;
@@ -1,2 +1,4 @@
1
- export declare const useLinkedAccounts: () => import("../../types/utils.js").CoreMethodQueryHook<"getLinkedAccounts">;
2
- export declare const useAccountLinkInProgress: () => import("../../types/utils.js").CoreMethodQueryHook<"accountLinkInProgress">;
1
+ export declare const useLinkedAccounts: (params?: {
2
+ withMetadata?: boolean;
3
+ } | undefined) => import("../../types/utils.js").CoreMethodQueryHook<"getLinkedAccounts">;
4
+ export declare const useAccountLinkInProgress: (params?: undefined) => import("../../types/utils.js").CoreMethodQueryHook<"accountLinkInProgress">;
@@ -2,10 +2,13 @@
2
2
  import "../../../chunk-MMUBH76A.js";
3
3
  import * as actions from "../../actions/index.js";
4
4
  import { generateCoreQueryHook } from "./utils.js";
5
- const useLinkedAccounts = generateCoreQueryHook("getLinkedAccounts", actions.getLinkedAccounts);
5
+ const useLinkedAccounts = generateCoreQueryHook("getLinkedAccounts", actions.getLinkedAccounts, {
6
+ defaultParams: { withMetadata: false }
7
+ });
6
8
  const useAccountLinkInProgress = generateCoreQueryHook(
7
9
  "accountLinkInProgress",
8
- actions.accountLinkInProgress
10
+ actions.accountLinkInProgress,
11
+ { isGetter: true }
9
12
  );
10
13
  export {
11
14
  useAccountLinkInProgress,
@@ -5,13 +5,17 @@ import {
5
5
  import { useQuery } from "@tanstack/react-query";
6
6
  import { getAccount } from "../../actions/getAccount.js";
7
7
  import { useInternalClient } from "../utils/useInternalClient.js";
8
+ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
8
9
  const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
9
10
  const useAccount = () => {
11
+ var _a, _b;
10
12
  const client = useInternalClient();
13
+ const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
11
14
  return useQuery({
12
- queryKey: [ACCOUNT_BASE_KEY, client == null ? void 0 : client.getUserId()],
15
+ enabled: isSuccess && !!client,
16
+ queryKey: [ACCOUNT_BASE_KEY, isFullyLoggedIn != null ? isFullyLoggedIn : null, (_a = client == null ? void 0 : client.userId) != null ? _a : null, (_b = client == null ? void 0 : client.isGuestMode) != null ? _b : null],
13
17
  queryFn: () => __async(void 0, null, function* () {
14
- return yield getAccount(client);
18
+ return yield getAccount(client, isFullyLoggedIn);
15
19
  })
16
20
  });
17
21
  };
@@ -0,0 +1,5 @@
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
+ */
5
+ export declare const useIsFullyLoggedIn: () => import("@tanstack/react-query").UseQueryResult<boolean, Error>;
@@ -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 | undefined, Error>;
5
+ export declare const useWallet: () => import("@tanstack/react-query").UseQueryResult<Omit<import("@getpara/core-sdk").Wallet, "signer"> | null, Error>;
@@ -5,14 +5,18 @@ import {
5
5
  import { useQuery } from "@tanstack/react-query";
6
6
  import { useClient, useWalletState } from "../index.js";
7
7
  import { getWallet } from "../../actions/getWallet.js";
8
+ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
8
9
  const WALLET_BASE_KEY = "PARA_WALLET";
9
10
  const useWallet = () => {
11
+ var _a, _b;
10
12
  const client = useClient();
11
13
  const { selectedWallet } = useWalletState();
14
+ const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
12
15
  return useQuery({
13
- queryKey: [WALLET_BASE_KEY, client == null ? void 0 : client.getUserId(), selectedWallet.id, selectedWallet.type],
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],
14
18
  queryFn: () => __async(void 0, null, function* () {
15
- return yield getWallet(client, selectedWallet);
19
+ return yield getWallet(client, selectedWallet, isFullyLoggedIn);
16
20
  })
17
21
  });
18
22
  };
@@ -1,4 +1,7 @@
1
- import ParaWeb, { CoreMethodName, CoreMethods } from '@getpara/web-sdk';
1
+ import { CoreMethodName, CoreMethodParams, CoreMethods } from '@getpara/web-sdk';
2
2
  import { CoreMethodQueryHook } from '../../types/utils.js';
3
3
  import { CoreAction } from '../../actions/utils.js';
4
- export declare function generateCoreQueryHook<const method extends CoreMethodName & keyof CoreMethods>(method: method, action: CoreAction<method> & ((_: ParaWeb) => Promise<unknown>)): () => CoreMethodQueryHook<method>;
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>;
@@ -4,16 +4,17 @@ import {
4
4
  } from "../../../chunk-MMUBH76A.js";
5
5
  import { useClient } from "../utils/index.js";
6
6
  import { useQuery } from "@tanstack/react-query";
7
- function generateCoreQueryHook(method, action) {
8
- return () => {
7
+ function generateCoreQueryHook(method, action, { isGetter = false, defaultParams } = {}) {
8
+ return (params = defaultParams) => {
9
+ var _a;
9
10
  const para = useClient();
10
11
  return useQuery({
11
- queryKey: [method],
12
- queryFn: () => __async(this, null, function* () {
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] }) {
13
14
  if (!para) {
14
15
  return null;
15
16
  }
16
- const result = yield action(para);
17
+ const result = params2 ? yield action(para, params2) : defaultParams ? yield action(para, defaultParams) : yield action(para);
17
18
  return result != null ? result : null;
18
19
  })
19
20
  });
@@ -10,6 +10,7 @@ import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
10
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
+ import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../queries/useIsFullyLoggedIn.js";
13
14
  const useEventListeners = ({
14
15
  onLogin,
15
16
  onLogout,
@@ -27,6 +28,7 @@ const useEventListeners = ({
27
28
  const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
28
29
  const { updateSelectedWallet } = useWalletState();
29
30
  const loginOrSetupListener = useCallback(() => {
31
+ queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
30
32
  queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
31
33
  queryClient.refetchQueries({ queryKey: [WALLET_BASE_KEY] });
32
34
  queryClient.invalidateQueries({ queryKey: [WALLET_BALANCE_BASE_KEY], exact: false });
@@ -53,6 +55,7 @@ const useEventListeners = ({
53
55
  );
54
56
  const logoutListener = useCallback(
55
57
  (event) => {
58
+ queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
56
59
  queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
57
60
  clearSelectedWallet();
58
61
  onLogout == null ? void 0 : onLogout(event);
@@ -73,6 +76,7 @@ const useEventListeners = ({
73
76
  );
74
77
  const walletChangeListener = useCallback(
75
78
  (event) => {
79
+ queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
76
80
  queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
77
81
  updateSelectedWallet();
78
82
  onWalletsChange == null ? void 0 : onWalletsChange(event);
@@ -81,6 +85,7 @@ const useEventListeners = ({
81
85
  );
82
86
  const externalWalletChangeListener = useCallback(
83
87
  (event) => {
88
+ queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
84
89
  queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
85
90
  updateSelectedWallet();
86
91
  onExternalWalletChange == null ? void 0 : onExternalWalletChange(event);
@@ -101,6 +106,7 @@ const useEventListeners = ({
101
106
  );
102
107
  const guestWalletsCreatedListener = useCallback(
103
108
  (event) => {
109
+ queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
104
110
  queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
105
111
  updateSelectedWallet();
106
112
  onGuestWalletsCreated == null ? void 0 : onGuestWalletsCreated(event);
@@ -112,7 +112,7 @@ const AccountLinkProvider = ({ children }) => {
112
112
  } = useVerifyExternalWalletLink();
113
113
  const isEnabled = !!(account == null ? void 0 : account.isConnected) && !(account == null ? void 0 : account.isGuestMode) && (!(account == null ? void 0 : account.externalWallet) || includeWalletVerification);
114
114
  const [accountLinkInProgress, setAccountLinkInProgress] = useState(
115
- coreAccountLinkInProgress
115
+ coreAccountLinkInProgress || void 0
116
116
  );
117
117
  const [unlinkingAccount, setUnlinkingAccount] = useState(void 0);
118
118
  const [linkAccountError, setLinkAccountError] = useState(null);
@@ -347,7 +347,7 @@ const AccountLinkProvider = ({ children }) => {
347
347
  };
348
348
  useEffect(() => {
349
349
  setAccountLinkInProgress((prev) => {
350
- return coreAccountLinkInProgress != null ? coreAccountLinkInProgress : prev;
350
+ return coreAccountLinkInProgress || prev;
351
351
  });
352
352
  }, [coreAccountLinkInProgress]);
353
353
  useEffect(() => {
@@ -34,6 +34,7 @@ import { isExternalWallet } from "@getpara/user-management-client";
34
34
  import { routeMobileExternalWallet } from "../../modal/utils/routeMobileExternalWallet.js";
35
35
  import { useStore } from "../stores/useStore.js";
36
36
  import { useFormattedBiometricHints } from "../hooks/utils/useFormattedBiometricHints.js";
37
+ import { useQueryClient } from "@tanstack/react-query";
37
38
  const AuthContext = createContext({
38
39
  signUpOrLogIn: () => {
39
40
  },
@@ -68,6 +69,7 @@ function AuthProvider({
68
69
  isRecoverySecretStepEnabled = false,
69
70
  overrides = {}
70
71
  }) {
72
+ const queryClient = useQueryClient();
71
73
  const para = useInternalClient();
72
74
  const userAgent = useUserAgent();
73
75
  const onLoginRef = useStore((state) => state.onLoginRef);
@@ -375,6 +377,7 @@ function AuthProvider({
375
377
  on2faNotSetup
376
378
  } = {}) {
377
379
  var _a;
380
+ yield queryClient.invalidateQueries({ queryKey: ["isFullyLoggedIn"] });
378
381
  setAuthState();
379
382
  yield (_a = onLoginRef.current) == null ? void 0 : _a.call(onLoginRef);
380
383
  if (is2faEnabled) {
@@ -24,7 +24,7 @@ export type CoreMethodQuery<method extends CoreMethodName & keyof CoreMethods> =
24
24
  export type CoreGetterQuery<name extends keyof typeof ParaWeb> = Query<(typeof ParaWeb)[name] | null, Error>;
25
25
  export type CoreMethodMutationState<method extends CoreMethodName & keyof CoreMethods> = MutationState<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
26
26
  export type CoreMethodMutationHook<method extends CoreMethodName & keyof CoreMethods> = Compute<CoreMethodUseMutationReturnType<method> & CoreSyncMutationHook<method> & CoreAsyncMutationHook<method>>;
27
- export type CoreMethodQueryHook<method extends CoreMethodName & keyof CoreMethods> = UseQueryResult<Awaited<CoreMethodResponse<method>>, Error>;
27
+ export type CoreMethodQueryHook<method extends CoreMethodName & keyof CoreMethods> = UseQueryResult<Awaited<CoreMethodResponse<method>> | null, Error>;
28
28
  export type CoreGetterQueryHook<name extends keyof typeof ParaWeb> = UseQueryResult<(typeof ParaWeb)[name] | null, Error>;
29
29
  export type CoreMethodMutationStateHook<method extends CoreMethodName & keyof CoreMethods> = () => Omit<CoreMethodUseMutationReturnType<method>, 'reset'>;
30
30
  type InternalSyncMutationHook<method extends InternalMethodName & keyof InternalMethods> = {
package/package.json CHANGED
@@ -1,41 +1,25 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "2.0.0-alpha.25",
4
- "type": "module",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "2.0.0-alpha.27",
7
4
  "bin": {
8
5
  "setup-para": "dist/cli/cli.mjs"
9
6
  },
10
- "exports": {
11
- ".": "./dist/index.js",
12
- "./styles.css": "./dist/css/modal.css"
13
- },
14
- "sideEffects": [
15
- "*.css"
16
- ],
17
7
  "dependencies": {
18
- "@getpara/react-common": "2.0.0-alpha.25",
19
- "@getpara/react-components": "2.0.0-alpha.25",
20
- "@getpara/web-sdk": "2.0.0-alpha.25",
8
+ "@getpara/react-common": "2.0.0-alpha.27",
9
+ "@getpara/react-components": "2.0.0-alpha.27",
10
+ "@getpara/web-sdk": "2.0.0-alpha.27",
21
11
  "date-fns": "^3.6.0",
22
- "framer-motion": "11.3.28",
23
- "libphonenumber-js": "^1.11.1",
12
+ "framer-motion": "^11.3.31",
13
+ "libphonenumber-js": "^1.11.7",
24
14
  "styled-components": "^6.1.8",
25
15
  "zustand": "^4.5.2",
26
16
  "zustand-sync-tabs": "^0.2.2"
27
17
  },
28
- "scripts": {
29
- "post-build": "./scripts/post-build.sh",
30
- "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
31
- "typegen": "tsc --emitDeclarationOnly",
32
- "test": "vitest run --coverage",
33
- "cli": "node ./dist/cli/cli.mjs"
34
- },
35
18
  "devDependencies": {
36
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.25",
37
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.25",
38
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.25",
19
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.27",
20
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.27",
21
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.27",
22
+ "@tanstack/react-query": "^5.74.0",
39
23
  "@testing-library/dom": "^10.4.0",
40
24
  "@testing-library/react": "^16.3.0",
41
25
  "@testing-library/react-hooks": "^8.0.1",
@@ -43,25 +27,40 @@
43
27
  "@types/chrome": "^0.0.237",
44
28
  "@types/react": "^18.0.31",
45
29
  "@types/react-dom": "^18.2.7",
46
- "typescript": "^5.4.3",
47
- "viem": "^2.24.2",
48
- "wagmi": "^2.14.16"
30
+ "typescript": "^5.8.3"
49
31
  },
50
- "peerDependencies": {
51
- "@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.12",
52
- "@getpara/evm-wallet-connectors": "^2.0.0-alpha.12",
53
- "@getpara/solana-wallet-connectors": "^2.0.0-alpha.12",
54
- "@tanstack/react-query": ">=5.0.0",
55
- "react": "*",
56
- "react-dom": "*"
32
+ "exports": {
33
+ ".": "./dist/index.js",
34
+ "./styles.css": "./dist/css/modal.css"
57
35
  },
58
36
  "files": [
59
37
  "dist",
60
38
  "package.json",
61
39
  "styles.css"
62
40
  ],
41
+ "gitHead": "a54f63445995abd13220eda3d63809728e4b5f7e",
42
+ "main": "dist/index.js",
43
+ "peerDependencies": {
44
+ "@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.26",
45
+ "@getpara/evm-wallet-connectors": "^2.0.0-alpha.26",
46
+ "@getpara/solana-wallet-connectors": "^2.0.0-alpha.26",
47
+ "@tanstack/react-query": ">=5.0.0",
48
+ "react": "*",
49
+ "react-dom": "*"
50
+ },
63
51
  "resolutions": {
64
52
  "styled-components": "^6"
65
53
  },
66
- "gitHead": "51f576cb7d3f0d55fdd5508f7445b2c7b48d0696"
54
+ "scripts": {
55
+ "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
56
+ "cli": "node ./dist/cli/cli.mjs",
57
+ "post-build": "./scripts/post-build.sh",
58
+ "test": "vitest run --coverage",
59
+ "typegen": "tsc --emitDeclarationOnly"
60
+ },
61
+ "sideEffects": [
62
+ "*.css"
63
+ ],
64
+ "type": "module",
65
+ "types": "dist/index.d.ts"
67
66
  }