@getpara/react-sdk-lite 2.0.0 → 2.2.0

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.
@@ -95,7 +95,15 @@ const Account = () => {
95
95
  ] }),
96
96
  /* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
97
97
  (onRampConfig.isBuyEnabled || onRampConfig.isReceiveEnabled) && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "plusCircle", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Add Funds" }) }),
98
- /* @__PURE__ */ jsx(OptionButton, { icon: "send", onClick: handleSendClick, disabled: !profileBalance, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Send" }) }),
98
+ /* @__PURE__ */ jsx(
99
+ OptionButton,
100
+ {
101
+ icon: "send",
102
+ onClick: handleSendClick,
103
+ disabled: !profileBalance || embedded.authType === "externalWallet",
104
+ children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Send" })
105
+ }
106
+ ),
99
107
  onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleDown", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
100
108
  /* @__PURE__ */ jsx(OptionButton, { icon: "user01", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
101
109
  ] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) })
@@ -44,7 +44,7 @@ const AccountHeader = ({ withBalance = false } = {}) => {
44
44
  src
45
45
  }
46
46
  ),
47
- connectionType === "both" ? /* @__PURE__ */ jsx(AccountWalletSelect, {}) : /* @__PURE__ */ jsx(CpslText, { variant: "headingXS", weight: "semiBold", color: "contrast", children: name }),
47
+ connectionType === "both" ? /* @__PURE__ */ jsx(AccountWalletSelect, {}) : /* @__PURE__ */ jsx(StyledName, { variant: "headingXS", weight: "semiBold", color: "contrast", children: name }),
48
48
  withBalance && typeof totalBalance === "string" && totalBalance !== "" && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", weight: "medium", style: { visibility: profileBalance ? "visible" : "hidden" }, children: totalBalance })
49
49
  ] });
50
50
  };
@@ -55,6 +55,9 @@ const AccountContainer = safeStyled.div`
55
55
  gap: 8px;
56
56
  align-items: center;
57
57
  `;
58
+ const StyledName = safeStyled(CpslText)`
59
+ text-align: center;
60
+ `;
58
61
  export {
59
62
  AccountHeader
60
63
  };
@@ -1,5 +1,8 @@
1
1
  "use client";
2
- import "../../../chunk-MMUBH76A.js";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../../../chunk-MMUBH76A.js";
3
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
7
  import { useMemo } from "react";
5
8
  import { ACCOUNT_TYPES, safeStyled, useCopyToClipboard, WalletTypeIcon } from "@getpara/react-common";
@@ -19,7 +22,6 @@ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvid
19
22
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
20
23
  const AccountProfileEntry = ({
21
24
  icon,
22
- key,
23
25
  text,
24
26
  textSecondary,
25
27
  textTertiary,
@@ -27,7 +29,8 @@ const AccountProfileEntry = ({
27
29
  accessory,
28
30
  style,
29
31
  className,
30
- onSelect
32
+ onSelect,
33
+ dataTestId
31
34
  }) => {
32
35
  const [isCopied, copy] = useCopyToClipboard();
33
36
  const Copy = copyString ? /* @__PURE__ */ jsx(
@@ -43,7 +46,7 @@ const AccountProfileEntry = ({
43
46
  children: /* @__PURE__ */ jsx(CopyIcon, { id: "ignore-click", slot: "start", isCopied, icon: isCopied ? "check" : "copy" })
44
47
  }
45
48
  ) : null;
46
- return /* @__PURE__ */ jsxs(EntryContainer, { onClick: onSelect, className, style, children: [
49
+ return /* @__PURE__ */ jsxs(EntryContainer, { onClick: onSelect, className, style, "data-testid": dataTestId, children: [
47
50
  icon,
48
51
  /* @__PURE__ */ jsx(EntryDisplayName, { variant: "bodyM", color: "contrast", children: text }),
49
52
  /* @__PURE__ */ jsx(EntryFlex, { children: textSecondary ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -53,7 +56,7 @@ const AccountProfileEntry = ({
53
56
  textTertiary && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "contrast", children: textTertiary }),
54
57
  accessory,
55
58
  onSelect && /* @__PURE__ */ jsx(CpslIcon, { color: "var(--cpsl-color-foreground-32)", icon: "chevronRight", size: "16px" })
56
- ] }, key);
59
+ ] });
57
60
  };
58
61
  const WalletEntry = ({
59
62
  wallet,
@@ -109,12 +112,13 @@ const WalletEntry = ({
109
112
  textSecondary: withAddressShort ? wallet.addressShort : void 0,
110
113
  textTertiary: balance,
111
114
  copyString: wallet.address,
112
- style,
115
+ style: __spreadProps(__spreadValues({}, style || {}), { zIndex: 2 }),
113
116
  className,
114
117
  onSelect: isSelectable ? () => {
115
118
  setProfileWallet(wallet);
116
119
  setStep(ModalStep.ACCOUNT_WALLET);
117
- } : void 0
120
+ } : void 0,
121
+ dataTestId: `wallet-entry-${wallet.type}-${wallet.address}`
118
122
  },
119
123
  wallet.address
120
124
  );
@@ -176,13 +180,16 @@ const AccountLinkEntry = ({
176
180
  identifier
177
181
  );
178
182
  };
179
- const EntryContainer = safeStyled.div`
183
+ const EntryContainer = safeStyled.button`
180
184
  overflow: hidden;
181
185
  position: relative;
182
186
  width: 100%;
183
187
  display: flex;
184
188
  gap: 8px;
185
189
  align-items: center;
190
+ background: transparent;
191
+ border: none;
192
+ padding: 0;
186
193
  ${({ onClick }) => onClick ? "cursor: pointer;" : ""}
187
194
  `;
188
195
  const EntryDisplayName = safeStyled(CpslText)``;
@@ -26,12 +26,15 @@ const getDefaultSendMetadata = (balances, wallet) => {
26
26
  return { asset: null, network: null };
27
27
  }
28
28
  const walletBalance = balances.wallets.find(({ address }) => address === (wallet == null ? void 0 : wallet.address));
29
- if (!walletBalance) {
29
+ if (!walletBalance || walletBalance.assets.length === 0) {
30
30
  return { asset: null, network: null };
31
31
  }
32
- const defaultAsset = walletBalance.assets.find(
32
+ let defaultAsset = walletBalance.assets.find(
33
33
  ({ metadata }) => (metadata == null ? void 0 : metadata.symbol) === ((wallet == null ? void 0 : wallet.type) === "EVM" ? "ETH" : "SOL")
34
34
  );
35
+ if (!defaultAsset) {
36
+ defaultAsset = walletBalance.assets[0];
37
+ }
35
38
  if (!defaultAsset) {
36
39
  return { asset: null, network: null };
37
40
  }
@@ -84,6 +84,7 @@ const AccountWallet = () => {
84
84
  variant: "destructive",
85
85
  fullWidth: true,
86
86
  onClick: () => exportPrivateKey({ walletId: profileWallet.id, shouldOpenPopup: true }),
87
+ "data-testid": "export-private-key-button",
87
88
  children: [
88
89
  /* @__PURE__ */ jsx(CpslIcon, { icon: "key", slot: "start" }),
89
90
  "Export private key"
@@ -29,11 +29,12 @@ const Controls = ({ onClose }) => {
29
29
  visibility: hasPreviousStep ? "visible" : "hidden"
30
30
  },
31
31
  onClick: handleBackClick,
32
+ "data-testid": "modal-back-button",
32
33
  children: /* @__PURE__ */ jsx(CpslIcon, { icon: "arrow" })
33
34
  }
34
35
  ),
35
36
  /* @__PURE__ */ jsx(MiddleContainer, { children: isControls && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ChainSelect, {}) }) }),
36
- /* @__PURE__ */ jsx(CloseButton, { bareModal, variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx(CpslIcon, { icon: "close" }) })
37
+ /* @__PURE__ */ jsx(CloseButton, { bareModal, variant: "ghost", onClick: onClose, "data-testid": "modal-close-button", children: /* @__PURE__ */ jsx(CpslIcon, { icon: "close" }) })
37
38
  ] });
38
39
  };
39
40
  const Container = safeStyled.div`
@@ -38,7 +38,7 @@ const Header = () => {
38
38
  return /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", initial: false, custom: stepDirection, children: /* @__PURE__ */ jsx(
39
39
  Container,
40
40
  {
41
- isVisible: !isControls,
41
+ $isVisible: !isControls,
42
42
  custom: stepDirection,
43
43
  variants: BODY_MOTION_VARIANTS,
44
44
  initial: "enter",
@@ -61,7 +61,7 @@ const Container = safeStyled(motion.div)`
61
61
  gap: 8px;
62
62
  flex-wrap: wrap;
63
63
  height: 24px;
64
- visibility: ${({ isVisible }) => isVisible ? "visible" : "hidden"};
64
+ visibility: ${({ $isVisible }) => $isVisible ? "visible" : "hidden"};
65
65
  `;
66
66
  const AuthDisplay = safeStyled.div`
67
67
  display: flex;
@@ -4,7 +4,8 @@ import { getPortalBaseURL } from "@getpara/web-sdk";
4
4
  const validatePortalOrigin = (event, paraCtx) => {
5
5
  const portalBase = getPortalBaseURL(paraCtx);
6
6
  const portalLocalBase = getPortalBaseURL(paraCtx, true);
7
- if (event.origin !== portalBase && event.origin !== portalLocalBase) {
7
+ const normalizedOrigin = event.origin.replace("usecapsule", "getpara");
8
+ if (normalizedOrigin !== portalBase && normalizedOrigin !== portalLocalBase) {
8
9
  return false;
9
10
  }
10
11
  return true;
@@ -4,11 +4,11 @@ import {
4
4
  } from "../../../chunk-MMUBH76A.js";
5
5
  import { useMutation, useQueryClient } from "@tanstack/react-query";
6
6
  import { useClient } from "../utils/index.js";
7
- import { getPortalBaseURL } from "@getpara/web-sdk";
8
7
  import { renameMutations } from "../../utils/renameMutations.js";
9
8
  import { addCredential } from "../../actions/index.js";
10
9
  import { openPopup as openPopupFn } from "../../../modal/index.js";
11
10
  import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
11
+ import { validatePortalOrigin } from "../../../modal/utils/validatePortalOrigin.js";
12
12
  const ADD_CREDENTIAL_KEY = "ADD_CREDENTIAL";
13
13
  const useAddAuthMethod = ({ openPopup } = { openPopup: true }) => {
14
14
  const para = useClient();
@@ -23,9 +23,7 @@ const useAddAuthMethod = ({ openPopup } = { openPopup: true }) => {
23
23
  if (typeof window !== "undefined" && para) {
24
24
  const handleMessage = (event) => {
25
25
  var _a;
26
- const portalBase = getPortalBaseURL(para.ctx);
27
- const portalLocalBase = getPortalBaseURL(para.ctx, true);
28
- if (!event.origin.startsWith(portalBase) && !event.origin.startsWith(portalLocalBase)) {
26
+ if (!validatePortalOrigin(event, para.ctx)) {
29
27
  return;
30
28
  }
31
29
  if (((_a = event.data) == null ? void 0 : _a.type) === "CLOSE_WINDOW") {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.0.0",
9
- "@getpara/react-components": "2.0.0",
10
- "@getpara/web-sdk": "2.0.0",
8
+ "@getpara/react-common": "2.2.0",
9
+ "@getpara/react-components": "2.2.0",
10
+ "@getpara/web-sdk": "2.2.0",
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",
20
- "@getpara/evm-wallet-connectors": "2.0.0",
21
- "@getpara/solana-wallet-connectors": "2.0.0",
19
+ "@getpara/cosmos-wallet-connectors": "2.2.0",
20
+ "@getpara/evm-wallet-connectors": "2.2.0",
21
+ "@getpara/solana-wallet-connectors": "2.2.0",
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": "a64b6aa9b3c481a2d955022f621e495fb55e549e",
41
+ "gitHead": "51765cf39b1667e0283b3906a8f8ef91e447e347",
42
42
  "main": "dist/index.js",
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": ">=5.0.0",