@getpara/react-sdk-lite 2.0.0-alpha.70 → 2.0.0-alpha.72

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.
@@ -49,9 +49,6 @@ import { AccountWallet } from "../Account/AccountWallet.js";
49
49
  const MIN_HEIGHT = {
50
50
  [ModalStep.ADD_FUNDS_AWAITING]: "680px"
51
51
  };
52
- const PADDING_TOP = {
53
- [ModalStep.TELEGRAM_OAUTH]: "36px"
54
- };
55
52
  const Body = ({
56
53
  oAuthMethods,
57
54
  twoFactorAuthEnabled,
@@ -340,14 +337,7 @@ const InnerContainer = safeStyled.div`
340
337
  }};
341
338
 
342
339
  @media (max-width: ${MOBILE_SIZE}px) {
343
- padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
344
- var _a;
345
- return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} 16px 0px`;
346
- }};
347
- }
348
-
349
- cpsl-auth-modal.force-mobile-media & {
350
- padding: 72px 16px 0px;
340
+ padding: ${({ $embeddedModal, $isIFrameStep }) => $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : "0px"};
351
341
  }
352
342
  `;
353
343
  const TestModeAlert = safeStyled(CpslAlert)`
@@ -63,7 +63,7 @@ const OuterContainer = safeStyled.div`
63
63
  justify-content: center;
64
64
 
65
65
  @media (max-width: ${MOBILE_SIZE}px) {
66
- padding: ${({ $embeddedModal, $isVisible }) => !$isVisible ? "0px" : $embeddedModal ? "12px 0px 0px" : "72px 16px 0px"};
66
+ padding: ${({ $embeddedModal, $isVisible }) => !$isVisible ? "0px" : $embeddedModal ? "12px 0px 0px" : "0px"};
67
67
  }
68
68
  `;
69
69
  const Container = safeStyled.div`
@@ -5,11 +5,11 @@ import {
5
5
  __spreadProps,
6
6
  __spreadValues
7
7
  } from "../../../chunk-MMUBH76A.js";
8
- import { useQuery } from "@tanstack/react-query";
8
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
9
9
  import { useInternalClient } from "../utils/useInternalClient.js";
10
10
  import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
11
11
  import { useStore } from "../../stores/useStore.js";
12
- import { useContext } from "react";
12
+ import { useContext, useEffect, useMemo } from "react";
13
13
  import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
14
14
  const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
15
15
  function pickSolanaAdapter(adapter) {
@@ -31,38 +31,69 @@ function pickCosmosAccount(account) {
31
31
  const _a = account, { reconnect: _ } = _a, rest = __objRest(_a, ["reconnect"]);
32
32
  return rest;
33
33
  }
34
+ let lastConnectionState = "";
35
+ let invalidationTimeoutId = null;
36
+ const useInvalidation = (connectionStates, queryKey) => {
37
+ const queryClient = useQueryClient();
38
+ useEffect(() => {
39
+ const connectionStateKey = `${connectionStates.evm}-${connectionStates.cosmos}-${connectionStates.solana}`;
40
+ if (connectionStateKey === lastConnectionState) {
41
+ return;
42
+ }
43
+ lastConnectionState = connectionStateKey;
44
+ if (invalidationTimeoutId) {
45
+ clearTimeout(invalidationTimeoutId);
46
+ }
47
+ invalidationTimeoutId = setTimeout(() => {
48
+ queryClient.invalidateQueries({ queryKey });
49
+ invalidationTimeoutId = null;
50
+ }, 0);
51
+ return () => {
52
+ if (invalidationTimeoutId) {
53
+ clearTimeout(invalidationTimeoutId);
54
+ invalidationTimeoutId = null;
55
+ }
56
+ };
57
+ }, [connectionStates, queryClient]);
58
+ };
34
59
  const useAccount = ({ cosmos } = {}) => {
35
- var _a, _b, _c, _d, _e, _f, _g, _h;
60
+ var _a, _b, _c, _d, _e, _f;
36
61
  const client = useInternalClient();
37
62
  const { data: isFullyLoggedIn, isSuccess, isLoading: isFullyLoggedInLoading } = useIsFullyLoggedIn();
38
63
  const evmContext = useStore((state) => state.evmContext);
39
64
  const { useAccount: useEvmAccount } = useContext(evmContext);
40
65
  const evmAccount = useEvmAccount();
41
- const evmQueryKeys = [evmAccount == null ? void 0 : evmAccount.status, evmAccount == null ? void 0 : evmAccount.addresses, evmAccount == null ? void 0 : evmAccount.chainId];
66
+ const evmQueryKeys = [evmAccount == null ? void 0 : evmAccount.addresses, evmAccount == null ? void 0 : evmAccount.chainId];
42
67
  const cosmosContext = useStore((state) => state.cosmosContext);
43
68
  const { useAccount: useCosmosAccount } = useContext(cosmosContext);
44
69
  const cosmosAccount = useCosmosAccount(cosmos);
45
- const cosmosQueryKeys = [cosmosAccount == null ? void 0 : cosmosAccount.status, cosmosAccount == null ? void 0 : cosmosAccount.data];
70
+ const cosmosQueryKeys = [cosmosAccount == null ? void 0 : cosmosAccount.data];
46
71
  const solanaContext = useStore((state) => state.solanaContext);
47
72
  const { useWallet: useSolanaWallet } = useContext(solanaContext);
48
73
  const solanaWallet = useSolanaWallet();
49
- const solanaQueryKeys = [
50
- (_b = (_a = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a.adapter) == null ? void 0 : _b.connected,
51
- (_d = (_c = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _c.adapter) == null ? void 0 : _d.connecting,
52
- (_f = (_e = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _e.adapter) == null ? void 0 : _f.publicKey
74
+ const solanaQueryKeys = [(_b = (_a = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a.adapter) == null ? void 0 : _b.publicKey];
75
+ const solanaAdapter = (_c = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _c.adapter;
76
+ const queryKey = [
77
+ ACCOUNT_BASE_KEY,
78
+ isFullyLoggedIn != null ? isFullyLoggedIn : null,
79
+ isFullyLoggedInLoading,
80
+ (_d = client == null ? void 0 : client.userId) != null ? _d : null,
81
+ evmQueryKeys,
82
+ cosmosQueryKeys,
83
+ solanaQueryKeys
53
84
  ];
54
- const solanaAdapter = (_g = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _g.adapter;
85
+ const connectionStates = useMemo(() => {
86
+ var _a2, _b2;
87
+ return {
88
+ evm: !!(evmAccount == null ? void 0 : evmAccount.isConnected),
89
+ cosmos: !!(cosmosAccount == null ? void 0 : cosmosAccount.isConnected),
90
+ solana: !!((_b2 = (_a2 = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a2.adapter) == null ? void 0 : _b2.connected)
91
+ };
92
+ }, [!!(evmAccount == null ? void 0 : evmAccount.isConnected), !!(cosmosAccount == null ? void 0 : cosmosAccount.isConnected), !!((_f = (_e = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _e.adapter) == null ? void 0 : _f.connected)]);
93
+ useInvalidation(connectionStates, queryKey);
55
94
  const { data, isLoading } = useQuery({
56
95
  enabled: isSuccess && !!client,
57
- queryKey: [
58
- ACCOUNT_BASE_KEY,
59
- isFullyLoggedIn != null ? isFullyLoggedIn : null,
60
- isFullyLoggedInLoading,
61
- (_h = client == null ? void 0 : client.userId) != null ? _h : null,
62
- evmQueryKeys,
63
- cosmosQueryKeys,
64
- solanaQueryKeys
65
- ],
96
+ queryKey,
66
97
  queryFn: () => __async(void 0, null, function* () {
67
98
  const paraAccount = yield getEmbeddedAccount(client, isFullyLoggedIn);
68
99
  let connectionType = "none";
@@ -135,7 +166,9 @@ const useAccount = ({ cosmos } = {}) => {
135
166
  solana: { isConnected: false }
136
167
  }
137
168
  };
138
- return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), { isLoading: isFullyLoggedInLoading || isLoading });
169
+ return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), {
170
+ isLoading: isFullyLoggedInLoading || isLoading
171
+ });
139
172
  };
140
173
  export {
141
174
  ACCOUNT_BASE_KEY,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.0.0-alpha.70",
3
+ "version": "2.0.0-alpha.72",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.0.0-alpha.70",
9
- "@getpara/react-components": "2.0.0-alpha.70",
10
- "@getpara/web-sdk": "2.0.0-alpha.70",
8
+ "@getpara/react-common": "2.0.0-alpha.72",
9
+ "@getpara/react-components": "2.0.0-alpha.72",
10
+ "@getpara/web-sdk": "2.0.0-alpha.72",
11
11
  "date-fns": "^3.6.0",
12
12
  "framer-motion": "^11.3.31",
13
13
  "libphonenumber-js": "^1.11.7",
@@ -16,9 +16,9 @@
16
16
  "zustand-sync-tabs": "^0.2.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.70",
20
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.70",
21
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.70",
19
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.72",
20
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.72",
21
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.72",
22
22
  "@tanstack/react-query": "^5.74.0",
23
23
  "@testing-library/dom": "^10.4.0",
24
24
  "@testing-library/react": "^16.3.0",
@@ -38,7 +38,7 @@
38
38
  "package.json",
39
39
  "styles.css"
40
40
  ],
41
- "gitHead": "99d44cff3c68c07dc1cd8c2709b6ca4cd57dca61",
41
+ "gitHead": "abb7dbb2e789d245750db2206afbb1db10e87ff9",
42
42
  "main": "dist/index.js",
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": ">=5.0.0",