@getpara/react-sdk 2.0.0-alpha.10 → 2.0.0-alpha.12

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.
@@ -15,7 +15,7 @@ import { DEFAULTS } from "./constants/defaults.js";
15
15
  import { useGoBack } from "./hooks/useGoBack.js";
16
16
  import styled from "styled-components";
17
17
  import { hasEmbeddedAuth, hasExternalWallet } from "./utils/authLayoutHelpers.js";
18
- import { useModal, useWalletState } from "../provider/index.js";
18
+ import { useAccount, useModal, useWalletState } from "../provider/index.js";
19
19
  import { useInternalClient } from "../provider/hooks/utils/useInternalClient.js";
20
20
  import { useExternalWallets } from "../provider/providers/ExternalWalletProvider.js";
21
21
  import { useStore } from "../provider/stores/useStore.js";
@@ -26,13 +26,14 @@ defineCustomElements();
26
26
  const ParaModal = forwardRef((props, ref) => {
27
27
  const storedModalConfig = useStore((state) => state.modalConfig);
28
28
  const modalContentRef = useRef(null);
29
+ const refs = useModalStore((state) => state.refs);
30
+ const flow = useModalStore((state) => state.flow);
29
31
  const currentStep = useModalStore((state) => state.step);
30
32
  const setAuthState = useModalStore((state) => state.setAuthState);
31
33
  const setOnModalStepChange = useModalStore((state) => state.setOnModalStepChange);
32
34
  const setStep = useModalStore((state) => state.setStep);
33
35
  const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
34
36
  const setFlow = useModalStore((state) => state.setFlow);
35
- const setIsFullyLoggedIn = useModalStore((state) => state.setIsFullyLoggedIn);
36
37
  const goBack = useGoBack();
37
38
  const setAuthLayout = useModalStore((state) => state.setAuthLayout);
38
39
  const storedAuthLayout = useModalStore((state) => state.authLayout);
@@ -44,6 +45,7 @@ const ParaModal = forwardRef((props, ref) => {
44
45
  const { setSelectedWallet, updateSelectedWallet } = useWalletState();
45
46
  const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
46
47
  const { signUpOrLogIn, isCreateGuestWalletsPending } = useAuthActions();
48
+ const { data: account } = useAccount();
47
49
  const [isModalMounted, setIsModalMounted] = useState(false);
48
50
  const [isInit, setIsInit] = useState(false);
49
51
  const externalWallets = useStore((state) => state.externalWallets);
@@ -106,12 +108,10 @@ const ParaModal = forwardRef((props, ref) => {
106
108
  case isGuest:
107
109
  setFlow("guest");
108
110
  setStep(isCreateGuestWalletsPending ? ModalStep.AWAITING_GUEST_WALLET_CREATION : ModalStep.ACCOUNT_MAIN);
109
- setIsFullyLoggedIn(true);
110
111
  break;
111
112
  case isAccount:
112
113
  setFlow("account");
113
114
  setStep(ModalStep.ACCOUNT_MAIN);
114
- setIsFullyLoggedIn(true);
115
115
  break;
116
116
  default:
117
117
  if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
@@ -122,7 +122,6 @@ const ParaModal = forwardRef((props, ref) => {
122
122
  }
123
123
  yield disconnectExternalWallet();
124
124
  setSelectedWallet({ id: void 0, type: void 0 });
125
- setIsFullyLoggedIn(false);
126
125
  if (shouldAutoLogin) {
127
126
  if (defaultAuthIdentifier && ((_a2 = para.authInfo) == null ? void 0 : _a2.identifier) !== defaultAuthIdentifier) {
128
127
  const number = parsePhoneNumberFromString(defaultAuthIdentifier);
@@ -178,6 +177,11 @@ const ParaModal = forwardRef((props, ref) => {
178
177
  useEffect(() => {
179
178
  updateSelectedWallet();
180
179
  }, [para]);
180
+ useEffect(() => {
181
+ if (bareModal && account && !account.isConnected && !["signup", "login"].includes(flow != null ? flow : "") && refs.currentStep.current !== ModalStep.AUTH_MAIN) {
182
+ setStep(ModalStep.AUTH_MAIN);
183
+ }
184
+ }, [bareModal, flow, account]);
181
185
  const handleClose = () => {
182
186
  closeModal();
183
187
  onClose == null ? void 0 : onClose();
@@ -144,9 +144,10 @@ const GuestMode = styled.a`
144
144
  width: 100%;
145
145
  height: 50px;
146
146
  color: ${({ isDark }) => isDark ? "white" : "black"};
147
- text-decoration: underline;
147
+ text-decoration: none;
148
148
  font-size: 16px;
149
149
  font-weight: 500;
150
+ font-family: var(--cpsl-font-family);
150
151
 
151
152
  &:hover {
152
153
  text-decoration: underline;
@@ -7,8 +7,7 @@ import { OAuth } from "../OAuth/OAuth.js";
7
7
  import { AuthInput } from "../AuthInput/AuthInput.js";
8
8
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
9
9
  import { useModalStore } from "../../stores/index.js";
10
- import { CpslIcon } from "@getpara/react-components";
11
- import { useStore } from "../../../provider/stores/useStore.js";
10
+ import { CpslIcon, CpslText } from "@getpara/react-components";
12
11
  const AuthOptions = ({
13
12
  oAuthMethods,
14
13
  disableEmailLogin,
@@ -16,10 +15,6 @@ const AuthOptions = ({
16
15
  isGuestModeEnabled = false
17
16
  }) => {
18
17
  const { wallets } = useExternalWallets();
19
- const isDark = useStore((state) => {
20
- var _a, _b;
21
- return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
22
- });
23
18
  const guestAddFundsTab = useModalStore((state) => state.guestAddFundsTab);
24
19
  const Content = useMemo(() => {
25
20
  const Methods = [];
@@ -32,12 +27,14 @@ const AuthOptions = ({
32
27
  return /* @__PURE__ */ jsx(Fragment, { children: Methods });
33
28
  }, [oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, wallets]);
34
29
  return /* @__PURE__ */ jsxs(Container, { children: [
35
- guestAddFundsTab && /* @__PURE__ */ jsxs(CompleteAccountSetup, { isDark, children: [
36
- /* @__PURE__ */ jsx(CpslIcon, { icon: "stars02", size: "16px" }),
37
- "Complete account setup to",
38
- " ",
39
- guestAddFundsTab === "BUY" ? "buy assets" : guestAddFundsTab === "WITHDRAW" ? "sell assets" : "continue",
40
- "."
30
+ guestAddFundsTab && /* @__PURE__ */ jsxs(CompleteAccountSetup, { children: [
31
+ /* @__PURE__ */ jsx(CompleteAccountIcon, { icon: "stars02", size: "16px" }),
32
+ /* @__PURE__ */ jsxs(CpslText, { variant: "bodyS", weight: "bold", children: [
33
+ "Complete account setup to",
34
+ " ",
35
+ guestAddFundsTab === "BUY" ? "buy assets" : guestAddFundsTab === "WITHDRAW" ? "sell assets" : "continue",
36
+ "."
37
+ ] })
41
38
  ] }),
42
39
  Content
43
40
  ] });
@@ -52,9 +49,11 @@ const CompleteAccountSetup = styled.div`
52
49
  align-items: center;
53
50
  justify-content: center;
54
51
  gap: 4px;
55
- color: ${({ isDark }) => isDark ? "white" : "black"};
56
- font-weight: 500;
57
- font-size: 14px;
52
+ color: var(--cpsl-color-text-primary);
53
+ margin-bottom: 8px;
54
+ `;
55
+ const CompleteAccountIcon = styled(CpslIcon)`
56
+ --icon-color: var(--cpsl-color-text-primary);
58
57
  `;
59
58
  export {
60
59
  AuthOptions
@@ -9,6 +9,7 @@ import { AccountSelect, ChainSelect } from "./Selects.js";
9
9
  import { ModalStep } from "../../utils/steps.js";
10
10
  import { HeaderButton } from "@getpara/react-common";
11
11
  import { useStore } from "../../../provider/stores/useStore.js";
12
+ import { useAccount } from "../../../provider/index.js";
12
13
  const Controls = ({ onClose }) => {
13
14
  const bareModal = useStore((state) => {
14
15
  var _a;
@@ -16,8 +17,8 @@ const Controls = ({ onClose }) => {
16
17
  });
17
18
  const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
18
19
  const step = useModalStore((state) => state.step);
19
- const isFullyLoggedIn = useModalStore((state) => state.isFullyLoggedIn);
20
20
  const goBack = useGoBack();
21
+ const { data: account } = useAccount();
21
22
  const shouldShowSelects = [
22
23
  ModalStep.ACCOUNT_MAIN,
23
24
  ModalStep.CHAIN_SWITCH,
@@ -40,7 +41,7 @@ const Controls = ({ onClose }) => {
40
41
  children: /* @__PURE__ */ jsx(CpslIcon, { icon: "arrow" })
41
42
  }
42
43
  ),
43
- /* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects && isFullyLoggedIn && /* @__PURE__ */ jsxs(Fragment, { children: [
44
+ /* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects && (account == null ? void 0 : account.isConnected) && /* @__PURE__ */ jsxs(Fragment, { children: [
44
45
  /* @__PURE__ */ jsx(ChainSelect, {}),
45
46
  /* @__PURE__ */ jsx(AccountSelect, {})
46
47
  ] }) }),
@@ -6,16 +6,29 @@ import { Heading, HeroIcon, StepContainer } from "../common.js";
6
6
  import { ExternalWalletCard, WalletCard, WalletCards } from "../WalletCard/WalletCard.js";
7
7
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
8
8
  import { useStore } from "../../../provider/stores/useStore.js";
9
+ import { useModalStore } from "../../stores/index.js";
10
+ import { ModalStep } from "../../utils/steps.js";
9
11
  const LoginDoneStep = ({ onClose }) => {
10
12
  var _a, _b;
11
13
  const para = useInternalClient();
14
+ const bareModal = useStore((state) => {
15
+ var _a2;
16
+ return (_a2 = state.modalConfig) == null ? void 0 : _a2.bareModal;
17
+ });
18
+ const setStep = useModalStore((state) => state.setStep);
19
+ const setFlow = useModalStore((state) => state.setFlow);
12
20
  const hideWallets = useStore((state) => {
13
21
  var _a2;
14
22
  return (_a2 = state.modalConfig) == null ? void 0 : _a2.hideWallets;
15
23
  });
16
24
  useEffect(() => {
17
25
  setTimeout(() => {
18
- onClose();
26
+ if (bareModal) {
27
+ setFlow("account");
28
+ setStep(ModalStep.ACCOUNT_MAIN);
29
+ } else {
30
+ onClose();
31
+ }
19
32
  }, 1600);
20
33
  }, []);
21
34
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
@@ -19,7 +19,12 @@ const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
19
19
  var _a;
20
20
  return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
21
21
  });
22
+ const bareModal = useStore((state) => {
23
+ var _a;
24
+ return (_a = state.modalConfig) == null ? void 0 : _a.bareModal;
25
+ });
22
26
  const setStep = useModalStore((state) => state.setStep);
27
+ const setFlow = useModalStore((state) => state.setFlow);
23
28
  const isLogin = useModalStore((state) => state.isLogin());
24
29
  const twoFactorStatus = useModalStore((state) => state.twoFactorStatus);
25
30
  const onRampConfig = useModalStore((state) => state.onRampConfig);
@@ -30,7 +35,12 @@ const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
30
35
  if (isLogin) {
31
36
  setStep(ModalStep.LOGIN_DONE);
32
37
  } else {
33
- onClose();
38
+ if (bareModal) {
39
+ setFlow("account");
40
+ setStep(ModalStep.ACCOUNT_MAIN);
41
+ } else {
42
+ onClose();
43
+ }
34
44
  }
35
45
  };
36
46
  const handleNext = () => __async(void 0, null, function* () {
@@ -64,7 +64,7 @@ const getActions = (set, get) => ({
64
64
  if ([ModalStep.ADD_FUNDS_BUY, ModalStep.ADD_FUNDS_WITHDRAW].includes(currentStep) && onRampStep > 0) {
65
65
  return true;
66
66
  }
67
- return !!flow && !!getPreviousStep(flow, currentStep);
67
+ return !!getPreviousStep(flow, currentStep);
68
68
  },
69
69
  setFlow: (flow) => set({ flow }),
70
70
  isLogin: () => get().flow === "login",
@@ -103,7 +103,7 @@ const useEventListeners = ({
103
103
  updateSelectedWallet();
104
104
  onGuestWalletsCreated == null ? void 0 : onGuestWalletsCreated(event);
105
105
  },
106
- [onGuestWalletsCreated]
106
+ [queryClient, updateSelectedWallet, onGuestWalletsCreated]
107
107
  );
108
108
  useEffect(() => {
109
109
  window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
@@ -69,7 +69,12 @@ function AuthProvider({
69
69
  const para = useInternalClient();
70
70
  const onLoginRef = useStore((state) => state.onLoginRef);
71
71
  const setIsOpen = useStore((state) => state.setIsOpen);
72
+ const bareModal = useStore((state) => {
73
+ var _a;
74
+ return (_a = state.modalConfig) == null ? void 0 : _a.bareModal;
75
+ });
72
76
  const refs = useModalStore((state) => state.refs);
77
+ const setFlow = useModalStore((state) => state.setFlow);
73
78
  const currentStep = useModalStore((state) => state.step);
74
79
  const setStep = useModalStore((state) => state.setStep);
75
80
  const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
@@ -416,7 +421,12 @@ function AuthProvider({
416
421
  }
417
422
  }), [para, isRecoverySecretStepEnabled, overrides == null ? void 0 : overrides.createWallets]);
418
423
  const createGuestWallets = () => {
419
- setIsOpen(false);
424
+ if (bareModal) {
425
+ setFlow("guest");
426
+ setStep(ModalStep.AWAITING_GUEST_WALLET_CREATION);
427
+ } else {
428
+ setIsOpen(false);
429
+ }
420
430
  mutateCreateGuestWallets(void 0, {
421
431
  onSuccess: () => {
422
432
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "2.0.0-alpha.10",
3
+ "version": "2.0.0-alpha.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,9 +15,9 @@
15
15
  "*.css"
16
16
  ],
17
17
  "dependencies": {
18
- "@getpara/react-common": "2.0.0-alpha.10",
19
- "@getpara/react-components": "2.0.0-alpha.10",
20
- "@getpara/web-sdk": "2.0.0-alpha.10",
18
+ "@getpara/react-common": "2.0.0-alpha.12",
19
+ "@getpara/react-components": "2.0.0-alpha.12",
20
+ "@getpara/web-sdk": "2.0.0-alpha.12",
21
21
  "date-fns": "^3.6.0",
22
22
  "framer-motion": "11.3.28",
23
23
  "libphonenumber-js": "^1.11.1",
@@ -33,9 +33,9 @@
33
33
  "cli": "node ./dist/cli/cli.mjs"
34
34
  },
35
35
  "devDependencies": {
36
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.10",
37
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.10",
38
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.10",
36
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.12",
37
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.12",
38
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.12",
39
39
  "@testing-library/dom": "^10.4.0",
40
40
  "@testing-library/react": "^16.3.0",
41
41
  "@testing-library/react-hooks": "^8.0.1",
@@ -48,9 +48,9 @@
48
48
  "wagmi": "^2.14.16"
49
49
  },
50
50
  "peerDependencies": {
51
- "@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.10",
52
- "@getpara/evm-wallet-connectors": "^2.0.0-alpha.10",
53
- "@getpara/solana-wallet-connectors": "^2.0.0-alpha.10",
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
54
  "@tanstack/react-query": ">=5.0.0",
55
55
  "react": "*",
56
56
  "react-dom": "*"
@@ -63,5 +63,5 @@
63
63
  "resolutions": {
64
64
  "styled-components": "^6"
65
65
  },
66
- "gitHead": "92904c321f1dd8101046d8d2d70aa341bac99842"
66
+ "gitHead": "3a1284d5bb57c48fe53f651872da9a6e6903400a"
67
67
  }