@getpara/react-sdk 1.11.0 → 1.12.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.
@@ -12,15 +12,19 @@ import { useState } from "react";
12
12
  import { ModalStep } from "../../utils/steps.js";
13
13
  import { useWalletBalance } from "../../hooks/useWalletBalance.js";
14
14
  import { formatBalanceString } from "../../utils/stringFormatters.js";
15
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
15
16
  const Account = ({ onClose }) => {
16
17
  const onRampConfig = useModalStore((state) => state.onRampConfig);
17
18
  const setStep = useModalStore((state) => state.setStep);
19
+ const setFlow = useModalStore((state) => state.setFlow);
18
20
  const setOnRampStep = useModalStore((state) => state.setOnRampStep);
19
21
  const hideWallets = useThemeStore((state) => state.hideWallets);
20
22
  const { disconnectExternalWallet } = useExternalWallets();
21
23
  const { balance, isLoading: isBalanceLoading } = useWalletBalance();
24
+ const para = useInternalClient();
22
25
  const [isDisconnecting, setIsDisconnecting] = useState(false);
23
26
  const isOnRampLoaded = !!onRampConfig;
27
+ const canBuyAndWithdraw = !!para.userId;
24
28
  const handleBuyClick = () => {
25
29
  setOnRampStep(OnRampStep.SETTINGS);
26
30
  setStep(ModalStep.ADD_FUNDS_BUY);
@@ -37,14 +41,15 @@ const Account = ({ onClose }) => {
37
41
  yield disconnectExternalWallet();
38
42
  onClose();
39
43
  setStep(ModalStep.AUTH_MAIN);
44
+ setFlow(void 0);
40
45
  setIsDisconnecting(false);
41
46
  });
42
47
  return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
43
48
  isBalanceLoading ? /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, { size: 39 }) }) : balance !== void 0 && /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslText, { variant: "headingS", weight: "medium", children: formatBalanceString(balance) }) }),
44
49
  /* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
45
- onRampConfig.isBuyEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
50
+ canBuyAndWithdraw && onRampConfig.isBuyEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
46
51
  onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
47
- onRampConfig.isWithdrawEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
52
+ canBuyAndWithdraw && onRampConfig.isWithdrawEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
48
53
  ] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
49
54
  /* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
50
55
  hideWallets ? "Logout" : "Disconnect Wallet",
@@ -15,14 +15,19 @@ import { AddFundsReceive } from "./AddFundsReceive.js";
15
15
  import { AddFundsContextProvider, TABS } from "./AddFundsContext.js";
16
16
  import { AnimatePresence } from "framer-motion";
17
17
  import { AddFundsSettings } from "./AddFundsSettings.js";
18
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
18
19
  const AddFunds = () => {
19
20
  const onRampConfig = useModalStore((state) => state.onRampConfig);
20
21
  const onRampStep = useModalStore((state) => state.onRampStep);
21
22
  const storedTab = useModalStore((state) => state.accountAddFundTab);
22
23
  const setModalStep = useModalStore((state) => state.setStep);
23
24
  const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
25
+ const para = useInternalClient();
24
26
  const activeWallet = useActiveWallet();
25
- const tabs = TABS.filter(([, key]) => !!onRampConfig[key]);
27
+ const canBuyAndWithdraw = !!para.userId;
28
+ const tabs = TABS.filter(
29
+ ([, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (["isBuyEnabled", "isWithdrawEnabled"].includes(key) && canBuyAndWithdraw || !["isBuyEnabled", "isWithdrawEnabled"].includes(key))
30
+ );
26
31
  const tab = storedTab != null ? storedTab : tabs[0][0];
27
32
  const isMultiFlow = tabs.length > 1;
28
33
  const onSetTab = (event) => {
@@ -96,6 +96,10 @@ const AssetList = styled.ul`
96
96
  flex-direction: column;
97
97
  width: 100%;
98
98
  gap: 8px;
99
+ list-style: none;
100
+ padding-inline-start: 0;
101
+ margin: 0;
102
+ padding: 0px;
99
103
  `;
100
104
  const AssetButton = styled(comp.CpslButton)`
101
105
  display: flex;
@@ -27,11 +27,13 @@ function useWalletBalance() {
27
27
  setBalance(externalWalletBalance);
28
28
  } else {
29
29
  try {
30
- const balance2 = yield client.getWalletBalance({
31
- walletId: wallet.id,
32
- rpcUrl
33
- });
34
- setBalance(balance2);
30
+ if (rpcUrl) {
31
+ const balance2 = yield client.getWalletBalance({
32
+ walletId: wallet.id,
33
+ rpcUrl
34
+ });
35
+ setBalance(balance2);
36
+ }
35
37
  } catch (err) {
36
38
  console.error("Error fetching wallet balance: ", err);
37
39
  }
@@ -283,7 +283,7 @@ function ExternalWalletProvider({
283
283
  return;
284
284
  }
285
285
  } else if (address) {
286
- if (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase())) {
286
+ if (!para.externalWalletConnectionOnly && (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase()))) {
287
287
  yield completeFullAuth(address, wallet2.type, userExists, isVerified, bufferAddress);
288
288
  } else {
289
289
  setStep(ModalStep.LOGIN_DONE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,9 +12,9 @@
12
12
  "*.css"
13
13
  ],
14
14
  "dependencies": {
15
- "@getpara/react-common": "1.11.0",
16
- "@getpara/react-components": "1.11.0",
17
- "@getpara/web-sdk": "1.11.0",
15
+ "@getpara/react-common": "1.12.0",
16
+ "@getpara/react-components": "1.12.0",
17
+ "@getpara/web-sdk": "1.12.0",
18
18
  "@tanstack/react-query": "^5.0.0",
19
19
  "date-fns": "^3.6.0",
20
20
  "framer-motion": "11.3.28",
@@ -51,5 +51,5 @@
51
51
  "resolutions": {
52
52
  "styled-components": "^6"
53
53
  },
54
- "gitHead": "91b68e4ead22e2104307c934f2a582245b176619"
54
+ "gitHead": "748afcf08c9d307a2d3eaf0716f73132f3eb8529"
55
55
  }