@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
@@ -27,9 +27,9 @@ import { SDK_VERSION } from "./constants/constants.js";
27
27
  defineCustomElements();
28
28
  const ParaModal = forwardRef((props, ref) => {
29
29
  const storedModalConfig = useStore((state) => state.modalConfig);
30
- const openedToStep = useStore((state) => state.openedToStep);
30
+ const refs = useStore((state) => state.refs);
31
31
  const modalContentRef = useRef(null);
32
- const refs = useModalStore((state) => state.refs);
32
+ const modalRefs = useModalStore((state) => state.refs);
33
33
  const flow = useModalStore((state) => state.flow);
34
34
  const currentStep = useModalStore((state) => state.step);
35
35
  const setAuthState = useModalStore((state) => state.setAuthState);
@@ -153,7 +153,7 @@ const ParaModal = forwardRef((props, ref) => {
153
153
  break;
154
154
  case isAccount:
155
155
  setFlow("account");
156
- if (!openedToStep.current) {
156
+ if (!refs.openedToStep.current) {
157
157
  setStep(ModalStep.ACCOUNT_MAIN);
158
158
  }
159
159
  break;
@@ -223,7 +223,7 @@ const ParaModal = forwardRef((props, ref) => {
223
223
  updateSelectedWallet();
224
224
  }, [para]);
225
225
  useEffect(() => {
226
- if (bareModal && !isAccountLoading && !isConnected && !["signup", "login"].includes(flow != null ? flow : "") && refs.currentStep.current !== ModalStep.AUTH_MAIN) {
226
+ if (bareModal && !isAccountLoading && !isConnected && !["signup", "login"].includes(flow != null ? flow : "") && modalRefs.currentStep.current !== ModalStep.AUTH_MAIN) {
227
227
  setStep(ModalStep.AUTH_MAIN);
228
228
  }
229
229
  }, [bareModal, flow, isConnected, isAccountLoading]);
@@ -256,7 +256,7 @@ const ParaModal = forwardRef((props, ref) => {
256
256
  setIsModalMounted(true);
257
257
  };
258
258
  const handleModalExited = () => __async(void 0, null, function* () {
259
- openedToStep.current = null;
259
+ refs.openedToStep.current = null;
260
260
  setIsModalMounted(false);
261
261
  if (RESET_TO_AUTH_STEPS.includes(currentStep)) {
262
262
  resetModalState();
@@ -8,9 +8,10 @@ import { OnRampStep, useModalStore } from "../../stores/index.js";
8
8
  import { useEffect } from "react";
9
9
  import { ModalStep } from "../../utils/steps.js";
10
10
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
- import { useAccount, useWalletBalance } from "../../../provider/index.js";
11
+ import { useAccount } from "../../../provider/index.js";
12
12
  import { EnabledFlow } from "@getpara/web-sdk";
13
13
  import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
14
+ import { useAssets } from "../../../provider/providers/AssetsProvider.js";
14
15
  import { AccountHeader } from "./AccountHeader.js";
15
16
  const Account = () => {
16
17
  const onRampConfig = useModalStore((state) => state.onRampConfig);
@@ -19,8 +20,8 @@ const Account = () => {
19
20
  const setOnRampStep = useModalStore((state) => state.setOnRampStep);
20
21
  const para = useInternalClient();
21
22
  const { embedded } = useAccount();
22
- const { data: balance } = useWalletBalance();
23
23
  const { isEnabled } = useAccountLinking();
24
+ const { profileBalance } = useAssets();
24
25
  const isGuestMode = embedded.isConnected && embedded.isGuestMode;
25
26
  const cantBuyAndWithdraw = (para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION") && !para.userId;
26
27
  const isOnRampLoaded = !!onRampConfig;
@@ -56,7 +57,7 @@ const Account = () => {
56
57
  /* @__PURE__ */ jsx(AccountHeader, { withBalance: true }),
57
58
  /* @__PURE__ */ jsxs(LowerContainer, { children: [
58
59
  isGuestMode && /* @__PURE__ */ jsxs(Fragment, { children: [
59
- balance && parseFloat(balance) > 0 && /* @__PURE__ */ jsxs(Alert, { children: [
60
+ profileBalance && profileBalance.value && profileBalance.value.value > 0 && /* @__PURE__ */ jsxs(Alert, { children: [
60
61
  /* @__PURE__ */ jsx(CpslIcon, { icon: "alertTriangle", size: "24px", style: { color: "var(--cpsl-color-utility-yellow)" } }),
61
62
  "You've funded this account - complete account setup to maintain access."
62
63
  ] }),
@@ -2,32 +2,26 @@
2
2
  import "../../../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { getExternalWalletIcon, safeStyled } from "@getpara/react-common";
5
- import { formatBalanceString } from "../../utils/stringFormatters.js";
6
5
  import { CpslIcon, CpslText } from "@getpara/react-components";
7
6
  import { useMemo } from "react";
8
7
  import { truncateAddress } from "@getpara/web-sdk";
9
8
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
10
- import { useAccount, useWallet, useWalletBalance } from "../../../provider/index.js";
9
+ import { useAssets } from "../../../provider/providers/AssetsProvider.js";
10
+ import { useAccount } from "../../../provider/index.js";
11
11
  import { WalletSelect } from "../WalletSelect/WalletSelect.js";
12
- const Balance = () => {
13
- const { data: balance } = useWalletBalance();
14
- return /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", weight: "medium", style: { visibility: !!balance ? "visible" : "hidden" }, children: balance ? formatBalanceString(balance) : "0" });
15
- };
16
12
  const AccountHeader = ({ withBalance = false } = {}) => {
17
13
  const para = useInternalClient();
18
14
  const { connectionType } = useAccount();
19
- const { data: activeWallet } = useWallet();
15
+ const { profileBalance, totalBalance } = useAssets();
16
+ const externalWallet = Object.keys(para == null ? void 0 : para.externalWallets).length > 0 ? Object.values(para.externalWallets)[0] : void 0;
20
17
  const { name, icon, src } = useMemo(() => {
21
18
  var _a;
22
19
  let name2, icon2, src2;
23
20
  switch (true) {
24
- case (activeWallet == null ? void 0 : activeWallet.isExternal):
25
- {
26
- const wallet = Object.values(para.externalWallets)[0];
27
- name2 = (_a = wallet.ensName) != null ? _a : truncateAddress(wallet.address, wallet.type, { prefix: para.cosmosPrefix });
28
- src2 = wallet.ensAvatar;
29
- icon2 = getExternalWalletIcon(wallet.externalProviderId);
30
- }
21
+ case !!externalWallet:
22
+ name2 = (_a = externalWallet.ensName) != null ? _a : truncateAddress(externalWallet.address, externalWallet.type, { prefix: para.cosmosPrefix });
23
+ src2 = externalWallet.ensAvatar;
24
+ icon2 = getExternalWalletIcon(externalWallet.externalProviderId);
31
25
  break;
32
26
  default:
33
27
  name2 = `${para.partnerName} Wallet`;
@@ -36,7 +30,7 @@ const AccountHeader = ({ withBalance = false } = {}) => {
36
30
  break;
37
31
  }
38
32
  return { name: name2, icon: icon2, src: src2 };
39
- }, [activeWallet, para.partnerName, para.partnerLogo, para.externalWallets]);
33
+ }, [para.partnerName, para.partnerLogo, externalWallet]);
40
34
  return /* @__PURE__ */ jsxs(AccountContainer, { children: [
41
35
  /* @__PURE__ */ jsx(
42
36
  CpslIcon,
@@ -51,7 +45,7 @@ const AccountHeader = ({ withBalance = false } = {}) => {
51
45
  }
52
46
  ),
53
47
  connectionType === "both" ? /* @__PURE__ */ jsx(WalletSelect, {}) : /* @__PURE__ */ jsx(CpslText, { variant: "headingXS", weight: "semiBold", color: "contrast", children: name }),
54
- withBalance && /* @__PURE__ */ jsx(Balance, {})
48
+ withBalance && typeof totalBalance === "string" && totalBalance !== "" && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", weight: "medium", style: { visibility: profileBalance ? "visible" : "hidden" }, children: totalBalance })
55
49
  ] });
56
50
  };
57
51
  const AccountContainer = safeStyled.div`
@@ -9,21 +9,47 @@ import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
9
9
  import { useAccount, useClient } from "../../../provider/index.js";
10
10
  import { useLinkedAccounts } from "../../../provider/hooks/index.js";
11
11
  import { getWalletDisplayName } from "../../utils/getWalletDisplayName.js";
12
- import { truncateAddress } from "@getpara/web-sdk";
12
+ import {
13
+ formatAssetQuantity,
14
+ formatCurrency,
15
+ truncateAddress
16
+ } from "@getpara/web-sdk";
13
17
  import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
18
+ import { useMemo } from "react";
14
19
  import { ACCOUNT_TYPES, safeStyled, useCopyToClipboard } from "@getpara/react-common";
15
20
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
16
21
  import { useStore } from "../../../provider/stores/useStore.js";
17
22
  import { AccountHeader } from "./AccountHeader.js";
23
+ import { useAssets } from "../../../provider/providers/AssetsProvider.js";
18
24
  const Entry = ({
19
25
  identifier,
20
26
  icon,
21
27
  name,
22
28
  address,
23
29
  addressShort,
30
+ balance: walletBalance,
24
31
  onUnlink
25
32
  }) => {
33
+ const balancesConfig = useStore((state) => {
34
+ var _a;
35
+ return (_a = state.modalConfig) == null ? void 0 : _a.balances;
36
+ });
26
37
  const [isCopied, copy] = useCopyToClipboard();
38
+ const balance = useMemo(() => {
39
+ var _a;
40
+ switch (true) {
41
+ case !balancesConfig:
42
+ case (balancesConfig == null ? void 0 : balancesConfig.displayType) === "AGGREGATED":
43
+ return formatCurrency(walletBalance == null ? void 0 : walletBalance.value);
44
+ default:
45
+ return formatAssetQuantity({
46
+ quantity: (_a = walletBalance == null ? void 0 : walletBalance.assets.find(
47
+ ({ metadata }) => !!metadata && metadata.symbol === balancesConfig.asset.symbol
48
+ )) == null ? void 0 : _a.quantity,
49
+ symbol: balancesConfig.asset.symbol
50
+ });
51
+ }
52
+ }, [balancesConfig, walletBalance]);
27
53
  return /* @__PURE__ */ jsxs(EntryContainer, { children: [
28
54
  icon,
29
55
  /* @__PURE__ */ jsx(EntryDisplayName, { variant: "bodyM", color: "contrast", children: name }),
@@ -43,6 +69,7 @@ const Entry = ({
43
69
  }
44
70
  )
45
71
  ] }) : null }),
72
+ typeof balance === "string" && balance !== "" && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "contrast", children: balance }),
46
73
  onUnlink && /* @__PURE__ */ jsx(EntryUnlink, { href: "#", onClick: onUnlink, children: "Unlink" })
47
74
  ] }, address != null ? address : identifier);
48
75
  };
@@ -60,13 +87,14 @@ const AccountProfile = ({
60
87
  var _a2;
61
88
  return (_a2 = state.modalConfig) == null ? void 0 : _a2.hideWallets;
62
89
  });
90
+ const { profileBalance } = useAssets();
63
91
  if (!para) {
64
92
  return null;
65
93
  }
66
94
  const externalWallet = (_a = para.authInfo) == null ? void 0 : _a.externalWallet;
67
95
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
68
- /* @__PURE__ */ jsx(AccountHeader, {}),
69
- /* @__PURE__ */ jsxs(ParaConnect, { target: "_blank", href: "https://connect.getpara.com", rel: "noreferrer noopener", children: [
96
+ /* @__PURE__ */ jsx(AccountHeader, { withBalance: true }),
97
+ connectionType !== "external" && /* @__PURE__ */ jsxs(ParaConnect, { target: "_blank", href: "https://connect.getpara.com", rel: "noreferrer noopener", children: [
70
98
  /* @__PURE__ */ jsx(ParaIcon, { icon: "paraIconBrand", size: "40px", inset: "8px", background: "white" }),
71
99
  /* @__PURE__ */ jsxs("div", { children: [
72
100
  "Do even more with your wallet",
@@ -106,7 +134,8 @@ const AccountProfile = ({
106
134
  icon: /* @__PURE__ */ jsx(WalletTypeIcon, { walletType: wallet.type, externalWallet: wallet.externalProviderId, size: "24px" }),
107
135
  name: getWalletDisplayName(para, wallet),
108
136
  address: wallet.address,
109
- addressShort: truncateAddress(wallet.address, wallet.type)
137
+ addressShort: truncateAddress(wallet.address, wallet.type),
138
+ balance: profileBalance == null ? void 0 : profileBalance.wallets.find((w) => w.address === wallet.address)
110
139
  },
111
140
  wallet.address
112
141
  )) })
@@ -9,7 +9,7 @@ import { useEffect, useMemo } from "react";
9
9
  import { HeroAccountTypeIcon, HeroSuccessIcon } from "../common.js";
10
10
  import { VerificationCode } from "../VerificationCodeStep/VerificationCodeStep.js";
11
11
  import { extractAuthInfo } from "@getpara/user-management-client";
12
- import { FarcasterConnectQR } from "../OAuth/FarcasterOAuthStep.js";
12
+ import { FarcasterLink } from "../OAuth/FarcasterLink.js";
13
13
  import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
14
14
  import { TelegramIFrame } from "../OAuth/TelegramOAuthStep.js";
15
15
  import { AuthInput } from "../AuthInput/AuthInput.js";
@@ -35,7 +35,7 @@ function AccountProfileLink() {
35
35
  isLoaded,
36
36
  setIsLoaded
37
37
  } = useTelegramLogin(
38
- isTelegram ? { isActive: isTelegram, status: linkAccountStatus, onSubmit: verifyTelegramLink } : { isActive: false }
38
+ isTelegram ? { isActive: isTelegram, status: linkAccountStatus, onSubmit: verifyTelegramLink, isLinking: true } : { isActive: false, isLinking: true }
39
39
  ), status = (accountLinkInProgress == null ? void 0 : accountLinkInProgress.isComplete) ? "success" : isTelegram ? telegramStatus : linkAccountStatus, commonWallet = useMemo(() => {
40
40
  const wallet = wallets.find(
41
41
  (w) => [w.name, w.internalId, w.id].includes(externalWalletProvider != null ? externalWalletProvider : "") && w.type === externalWalletType
@@ -140,7 +140,7 @@ function AccountProfileLink() {
140
140
  break;
141
141
  // Farcaster Connect QR
142
142
  case (accountLinkType === "FARCASTER" && status !== "success"):
143
- lower2 = /* @__PURE__ */ jsx(FarcasterConnectQR, {});
143
+ lower2 = /* @__PURE__ */ jsx(FarcasterLink, {});
144
144
  break;
145
145
  // OAuth, External Wallet, Telegram
146
146
  default:
@@ -6,7 +6,7 @@ import {
6
6
  } from "../../../chunk-MMUBH76A.js";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import * as comp from "@getpara/react-components";
9
- import { getOnRampNetworks } from "@getpara/web-sdk";
9
+ import { formatCurrency, getOnRampNetworks } from "@getpara/web-sdk";
10
10
  import { safeStyled } from "@getpara/react-common";
11
11
  import { getAssetCode, getAssetName, ON_RAMP_ASSETS } from "../../constants/constants.js";
12
12
  import { useModalStore } from "../../stores/index.js";
@@ -16,10 +16,12 @@ import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
16
16
  import { AssetIcon, GradientScroll } from "../common.js";
17
17
  import { AnimatePresence, motion } from "framer-motion";
18
18
  import { contentMotionProps } from "./common.js";
19
+ import { useAssets } from "../../../provider/providers/AssetsProvider.js";
19
20
  function AddFundsAsset() {
20
21
  const onRampConfig = useModalStore((state) => state.onRampConfig);
21
22
  const { assets, setAsset, network, setNetwork } = useAddFunds();
22
23
  const { data: activeWallet } = useWallet();
24
+ const { assetMetadata } = useAssets();
23
25
  const [searchStr, setSearchStr] = useState("");
24
26
  const onSelect = (_asset) => __async(this, null, function* () {
25
27
  yield setAsset(_asset);
@@ -59,7 +61,8 @@ function AddFundsAsset() {
59
61
  /* @__PURE__ */ jsxs(Info, { children: [
60
62
  /* @__PURE__ */ jsx(Code, { color: "contrast", variant: "bodyL", children: ON_RAMP_ASSETS[asset].code }),
61
63
  /* @__PURE__ */ jsx(Name, { color: "contrast", variant: "bodyS", children: ON_RAMP_ASSETS[asset].name })
62
- ] })
64
+ ] }),
65
+ (assetMetadata == null ? void 0 : assetMetadata[asset]) && /* @__PURE__ */ jsx(comp.CpslText, { variant: "bodyM", children: formatCurrency(assetMetadata[asset].price) })
63
66
  ] }, asset)
64
67
  },
65
68
  asset
@@ -0,0 +1 @@
1
+ export declare const AwaitingAccountStep: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useModalStore } from "../../stores/index.js";
5
+ import { Waiting } from "../Waiting/Waiting.js";
6
+ const AwaitingAccountStep = () => {
7
+ const isLogin = useModalStore((state) => state.isLogin());
8
+ const verifyState = useModalStore((state) => state.getVerifyState());
9
+ const isSLOPopup = !!(verifyState == null ? void 0 : verifyState.isWalletSelectionNeeded);
10
+ return /* @__PURE__ */ jsx(
11
+ Waiting,
12
+ {
13
+ heading: isLogin ? "Logging you in..." : "Creating your account...",
14
+ subheading: isSLOPopup ? "Follow the prompts presented by your browser." : void 0
15
+ }
16
+ );
17
+ };
18
+ export {
19
+ AwaitingAccountStep
20
+ };
@@ -18,7 +18,7 @@ import { TwoFactorDoneStep } from "../TwoFactorDoneStep/TwoFactorDoneStep.js";
18
18
  import { BiometricCreationStep } from "../BiometricCreationStep/BiometricCreationStep.js";
19
19
  import { AwaitingOAuthStep } from "../AwaitingOAuthStep/AwaitingOAuthStep.js";
20
20
  import { AddFundsAwaiting, AddFundsDone, AddFunds } from "../AddFunds/index.js";
21
- import FarcasterOAuthStep from "../OAuth/FarcasterOAuthStep.js";
21
+ import { FarcasterOAuthStep } from "../OAuth/FarcasterOAuthStep.js";
22
22
  import { Header } from "../Header/Header.js";
23
23
  import { AuthMainStep } from "../AuthMainStep/AuthMainStep.js";
24
24
  import { BODY_MOTION_VARIANTS, BODY_TRANSITION, MOBILE_SIZE } from "../../constants/constants.js";
@@ -42,7 +42,7 @@ import { AccountProfileLinkOptions } from "../Account/AccountProfileLinkOptions.
42
42
  import { AccountProfileLink } from "../Account/AccountProfileLink.js";
43
43
  import { AccountProfileUnlink } from "../Account/AccountProfileUnlink.js";
44
44
  import { ExternalWalletNetworkSelectStep } from "../ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js";
45
- import { AwaitingIFrameStep } from "../AwaitingIFrameStep/AwaitingIFrameStep.js";
45
+ import { AwaitingAccountStep } from "../AwaitingAccountStep/AwaitingAccountStep.js";
46
46
  import { Footer } from "../Footer/Footer.js";
47
47
  import { renderTextWithLinks } from "../../utils/renderTextWithLinks.js";
48
48
  const MIN_HEIGHT = {
@@ -192,8 +192,8 @@ const Body = ({
192
192
  case ModalStep.EX_WALLET_NETWORK_SELECT: {
193
193
  return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, {});
194
194
  }
195
- case ModalStep.AWAITING_IFRAME: {
196
- return /* @__PURE__ */ jsx(AwaitingIFrameStep, {});
195
+ case ModalStep.AWAITING_ACCOUNT: {
196
+ return /* @__PURE__ */ jsx(AwaitingAccountStep, {});
197
197
  }
198
198
  default: {
199
199
  if (IFrameSteps.includes(currentStep)) {
@@ -42,6 +42,7 @@ const useStepTitle = () => {
42
42
  [ModalStep.VERIFICATIONS]: "Sign Up",
43
43
  [ModalStep.AWAITING_OAUTH]: signUpOrLogInTitle,
44
44
  [ModalStep.FARCASTER_OAUTH]: signUpOrLogInTitle,
45
+ [ModalStep.TELEGRAM_OAUTH]: signUpOrLogInTitle,
45
46
  [ModalStep.BIOMETRIC_CREATION]: "Sign Up",
46
47
  [ModalStep.PASSWORD_CREATION]: "Sign Up",
47
48
  [ModalStep.AWAITING_BIOMETRIC_CREATION]: "Sign Up",
@@ -69,7 +70,7 @@ const useStepTitle = () => {
69
70
  [ModalStep.ACCOUNT_PROFILE_LIST]: "Link Account",
70
71
  [ModalStep.ACCOUNT_PROFILE_ADD]: "Link Account",
71
72
  [ModalStep.ACCOUNT_PROFILE_REMOVE]: "Unlink Account",
72
- [ModalStep.AWAITING_IFRAME]: isLogin ? "Login" : "Sign Up"
73
+ [ModalStep.AWAITING_ACCOUNT]: isLogin ? "Login" : "Sign Up"
73
74
  }),
74
75
  [isLogin, chainId, hideWallets, authStepTitle]
75
76
  );
@@ -0,0 +1,2 @@
1
+ export declare function FarcasterConnectQR(): import("react/jsx-runtime").JSX.Element;
2
+ export declare const FarcasterLink: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
5
+ import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
6
+ import { useModalStore } from "../../stores/index.js";
7
+ import { isMobile } from "@getpara/web-sdk";
8
+ function FarcasterConnectQR() {
9
+ const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
10
+ return /* @__PURE__ */ jsx(Fragment, { children: isMobile() ? /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
11
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: `Don\u2019t have Farcaster` }),
12
+ /* @__PURE__ */ jsxs(CpslButton, { as: "a", href: "https://link.warpcast.com/download-qr", target: "_blank", variant: "secondary", children: [
13
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "linkExternal" }),
14
+ `Get Farcaster`
15
+ ] })
16
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
17
+ /* @__PURE__ */ jsx(Heading, { children: "Sign in using Farcaster" }),
18
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
19
+ /* @__PURE__ */ jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }),
20
+ /* @__PURE__ */ jsx(QRContainer, { children: !farcasterConnectUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: farcasterConnectUri }) })
21
+ ] })
22
+ ] }) });
23
+ }
24
+ const FarcasterLink = () => {
25
+ return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsx(FarcasterConnectQR, {}) });
26
+ };
27
+ export {
28
+ FarcasterConnectQR,
29
+ FarcasterLink
30
+ };
@@ -1,3 +1 @@
1
- export declare function FarcasterConnectQR(): import("react/jsx-runtime").JSX.Element;
2
- declare const FarcasterOAuthStep: () => import("react/jsx-runtime").JSX.Element;
3
- export default FarcasterOAuthStep;
1
+ export declare function FarcasterOAuthStep(): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +1,52 @@
1
1
  "use client";
2
2
  import "../../../chunk-MMUBH76A.js";
3
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
5
- import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
6
- import { useModalStore } from "../../stores/index.js";
7
- import { isMobile } from "@getpara/web-sdk";
8
- function FarcasterConnectQR() {
9
- const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
10
- return /* @__PURE__ */ jsx(Fragment, { children: isMobile() ? /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
11
- /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: `Don\u2019t have Farcaster` }),
12
- /* @__PURE__ */ jsxs(CpslButton, { as: "a", href: "https://link.warpcast.com/download-qr", target: "_blank", variant: "secondary", children: [
13
- /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "linkExternal" }),
14
- `Get Farcaster`
15
- ] })
16
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
17
- /* @__PURE__ */ jsx(Heading, { children: "Sign in using Farcaster" }),
18
- /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
19
- /* @__PURE__ */ jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }),
20
- /* @__PURE__ */ jsx(QRContainer, { children: !farcasterConnectUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: farcasterConnectUri }) })
21
- ] })
22
- ] }) });
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslSpinner } from "@getpara/react-components";
5
+ import { useFarcasterLogin } from "../../hooks/useFarcasterLogin.js";
6
+ import { safeStyled } from "@getpara/react-common";
7
+ import { useEffect, useState } from "react";
8
+ import { getPortalBaseURL } from "@getpara/web-sdk";
9
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
10
+ function FarcasterOAuthStep() {
11
+ const { url, isLoaded, setIsLoaded } = useFarcasterLogin({
12
+ isActive: true
13
+ });
14
+ const para = useInternalClient();
15
+ const [height, setHeight] = useState(0);
16
+ useEffect(() => {
17
+ const handleMessage = (event) => {
18
+ if (!url) {
19
+ return;
20
+ }
21
+ const portalBase = getPortalBaseURL(para.ctx);
22
+ if (!event.origin.startsWith(portalBase)) {
23
+ return;
24
+ }
25
+ if (event.data) {
26
+ if (event.data.type === "HEIGHT") {
27
+ setHeight(event.data.height);
28
+ }
29
+ }
30
+ };
31
+ window.addEventListener("message", handleMessage);
32
+ return () => window.removeEventListener("message", handleMessage);
33
+ }, [url]);
34
+ return /* @__PURE__ */ jsxs(Container, { children: [
35
+ url && /* @__PURE__ */ jsx(IFrame, { style: { display: isLoaded ? "block" : "none", height }, src: url, onLoad: () => setIsLoaded(true) }),
36
+ (!url || !isLoaded) && /* @__PURE__ */ jsx(CpslSpinner, {})
37
+ ] });
23
38
  }
24
- const FarcasterOAuthStep = () => {
25
- return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsx(FarcasterConnectQR, {}) });
26
- };
27
- var FarcasterOAuthStep_default = FarcasterOAuthStep;
39
+ const Container = safeStyled.div`
40
+ display: flex;
41
+ flex-direction: column;
42
+ align-items: center;
43
+ justify-content: center;
44
+ width: 100%;
45
+ `;
46
+ const IFrame = safeStyled.iframe`
47
+ width: 100%;
48
+ border: none;
49
+ `;
28
50
  export {
29
- FarcasterConnectQR,
30
- FarcasterOAuthStep_default as default
51
+ FarcasterOAuthStep
31
52
  };
@@ -16,7 +16,7 @@ const OAuth = ({ methods }) => {
16
16
  const isDark = useStore((state) => state.isDarkTheme);
17
17
  const setStep = useModalStore((state) => state.setStep);
18
18
  const showAll = useModalStore((state) => state.step === ModalStep.AUTH_MORE || state.step === ModalStep.AUTH_GUEST_SIGNUP);
19
- const { verifyFarcaster, verifyOAuth } = useAuthActions();
19
+ const { verifyOAuth } = useAuthActions();
20
20
  const hasMore = methods.length > HAS_MORE_LENGTH;
21
21
  const methodsToShow = showAll || !hasMore ? methods : methods.slice(0, HAS_MORE_LENGTH - 1);
22
22
  const handleShowAll = () => {
@@ -25,7 +25,7 @@ const OAuth = ({ methods }) => {
25
25
  const handleMethodClick = (method) => () => __async(void 0, null, function* () {
26
26
  switch (method) {
27
27
  case "FARCASTER":
28
- verifyFarcaster();
28
+ setStep(ModalStep.FARCASTER_OAUTH);
29
29
  break;
30
30
  case "TELEGRAM":
31
31
  setStep(ModalStep.TELEGRAM_OAUTH);
@@ -2,30 +2,53 @@
2
2
  import "../../../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { safeStyled } from "@getpara/react-common";
5
- import { HeroSpinner } from "@getpara/react-common";
6
5
  import { CpslSpinner } from "@getpara/react-components";
7
6
  import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
7
+ import { useEffect, useState } from "react";
8
8
  import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
9
- import { AccountTypeIcon } from "../common.js";
10
9
  import { useModalStore } from "../../stores/index.js";
10
+ import { getPortalBaseURL } from "@getpara/web-sdk";
11
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
12
  function TelegramOAuthStep() {
12
13
  const { verifyTelegramStatus, verifyTelegram } = useAuthActions();
13
- const { url, status, isLoaded, setIsLoaded } = useTelegramLogin({
14
+ const { url, isLoaded, setIsLoaded } = useTelegramLogin({
14
15
  isActive: true,
15
16
  status: verifyTelegramStatus,
16
- onSubmit: verifyTelegram
17
+ onSubmit: verifyTelegram,
18
+ isLinking: false
17
19
  });
18
- const isError = status === "error", isPending = status === "pending";
20
+ const refs = useModalStore((state) => state.refs);
21
+ const para = useInternalClient();
22
+ const [height, setHeight] = useState(0);
23
+ useEffect(() => {
24
+ const handleMessage = (event) => {
25
+ if (!url) {
26
+ return;
27
+ }
28
+ const portalBase = getPortalBaseURL(para.ctx, true);
29
+ if (!event.origin.startsWith(portalBase)) {
30
+ return;
31
+ }
32
+ if (event.data) {
33
+ if (event.data.type === "HEIGHT") {
34
+ setHeight(event.data.height);
35
+ }
36
+ }
37
+ };
38
+ window.addEventListener("message", handleMessage);
39
+ return () => window.removeEventListener("message", handleMessage);
40
+ }, [url]);
19
41
  return /* @__PURE__ */ jsxs(Container, { children: [
20
- /* @__PURE__ */ jsx(HeroContainer, { children: /* @__PURE__ */ jsx(
21
- HeroSpinner,
42
+ url && /* @__PURE__ */ jsx(
43
+ IFrame,
22
44
  {
23
- icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: "TELEGRAM", size: "48px" }),
24
- status: isPending ? "pending" : isError ? "error" : "idle",
25
- text: isPending ? "Follow the on-screen prompts." : isError ? "Login Failed" : void 0
45
+ ref: refs.telegramIFrame,
46
+ style: { display: isLoaded ? "block" : "none", height },
47
+ src: url,
48
+ onLoad: () => setIsLoaded(true)
26
49
  }
27
- ) }),
28
- /* @__PURE__ */ jsx(TelegramIFrame, { url, isLoaded, setIsLoaded, isVisible: isLoaded })
50
+ ),
51
+ (!url || !isLoaded) && /* @__PURE__ */ jsx(CpslSpinner, {})
29
52
  ] });
30
53
  }
31
54
  function TelegramIFrame({
@@ -56,13 +79,6 @@ const Container = safeStyled.div`
56
79
  justify-content: center;
57
80
  width: 100%;
58
81
  `;
59
- const HeroContainer = safeStyled.div`
60
- display: flex;
61
- flex-direction: column;
62
- align-items: center;
63
- gap: 16px;
64
- flex: 1;
65
- `;
66
82
  const IFrame = safeStyled.iframe`
67
83
  width: 100%;
68
84
  height: 52px;
@@ -126,7 +126,7 @@ const BODY_MOTION_VARIANTS = {
126
126
  const BODY_TRANSITION = {
127
127
  duration: 0.2
128
128
  };
129
- const SDK_VERSION = "2.0.0-alpha.53";
129
+ const SDK_VERSION = "2.0.0-alpha.55";
130
130
  export {
131
131
  BODY_MOTION_VARIANTS,
132
132
  BODY_TRANSITION,
@@ -0,0 +1,9 @@
1
+ import { MutationStatus } from '@tanstack/react-query';
2
+ export declare const useFarcasterLogin: ({ isActive, }?: {
3
+ isActive?: boolean;
4
+ }) => {
5
+ url: string | undefined;
6
+ isLoaded: boolean;
7
+ setIsLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
8
+ status: MutationStatus;
9
+ };