@getpara/react-sdk-lite 2.8.0 → 2.9.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.
Files changed (40) hide show
  1. package/dist/modal/ParaModal.js +1 -1
  2. package/dist/modal/components/Account/Account.js +17 -7
  3. package/dist/modal/components/Account/AccountProfile.js +30 -9
  4. package/dist/modal/components/Account/AccountSend/AccountSendForm.js +7 -1
  5. package/dist/modal/components/Account/AccountWallet.js +2 -0
  6. package/dist/modal/components/AddFunds/AddFunds.js +1 -4
  7. package/dist/modal/components/AddFunds/AddFundsAsset.js +25 -88
  8. package/dist/modal/components/AddFunds/AddFundsContext.d.ts +6 -2
  9. package/dist/modal/components/AddFunds/AddFundsContext.js +97 -15
  10. package/dist/modal/components/AddFunds/AddFundsNetwork.d.ts +1 -0
  11. package/dist/modal/components/AddFunds/AddFundsNetwork.js +31 -0
  12. package/dist/modal/components/AddFunds/AddFundsProvider.js +50 -65
  13. package/dist/modal/components/AddFunds/AddFundsReceive.js +4 -1
  14. package/dist/modal/components/AddFunds/AddFundsSettings.js +126 -143
  15. package/dist/modal/components/AuthInput/AuthInput.js +12 -1
  16. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +32 -11
  17. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +17 -8
  18. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +25 -9
  19. package/dist/modal/components/Body/Body.js +3 -51
  20. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +25 -8
  21. package/dist/modal/components/ExternalWallets/ExternalWallets.js +33 -13
  22. package/dist/modal/components/IFrameStep/IFrameStep.js +1 -1
  23. package/dist/modal/components/OAuth/OAuth.js +5 -3
  24. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +15 -24
  25. package/dist/modal/components/QuantityInput.js +62 -9
  26. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +4 -4
  27. package/dist/modal/components/SearchableButtonList.d.ts +2 -1
  28. package/dist/modal/components/SearchableButtonList.js +3 -1
  29. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +6 -5
  30. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +4 -2
  31. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +2 -2
  32. package/dist/modal/components/common.d.ts +1 -1
  33. package/dist/modal/stores/modal/actions.js +2 -1
  34. package/dist/modal/stores/modal/useModalStore.d.ts +2 -0
  35. package/dist/modal/stores/modal/useModalStore.js +2 -1
  36. package/dist/modal/utils/validatePortalOrigin.js +6 -0
  37. package/dist/provider/ParaProviderMin.js +3 -0
  38. package/package.json +8 -8
  39. package/dist/modal/components/AddFunds/common.d.ts +0 -5
  40. package/dist/modal/components/AddFunds/common.js +0 -17
@@ -110,7 +110,7 @@ const ParaModal = forwardRef((props, ref) => {
110
110
  onClose,
111
111
  defaultAuthIdentifier
112
112
  }), rest),
113
- reactSdkVersion: "2.8.0"
113
+ reactSdkVersion: "2.9.0"
114
114
  });
115
115
  } catch (e) {
116
116
  }
@@ -66,11 +66,11 @@ const Account = () => {
66
66
  useEffect(() => {
67
67
  setGuestAddFundsTab();
68
68
  }, []);
69
- return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs($InnerStepContainer, { children: [
69
+ return /* @__PURE__ */ jsx(StepContainer, { $wide: true, "data-testid": "para-account-main", children: /* @__PURE__ */ jsxs($InnerStepContainer, { children: [
70
70
  /* @__PURE__ */ jsx(AccountHeader, { withBalance: true }),
71
71
  /* @__PURE__ */ jsxs(LowerContainer, { children: [
72
72
  isGuestMode && /* @__PURE__ */ jsxs(Fragment, { children: [
73
- profileBalance && profileBalance.value && profileBalance.value.value > 0 && /* @__PURE__ */ jsxs(Alert, { children: [
73
+ profileBalance && profileBalance.value && profileBalance.value.value > 0 && /* @__PURE__ */ jsxs(Alert, { "data-testid": "para-guest-warning", children: [
74
74
  /* @__PURE__ */ jsx(CpslIcon, { icon: "alertTriangle", size: "24px", style: { color: "var(--cpsl-color-utility-yellow)" } }),
75
75
  "You've funded this account - complete account setup to maintain access."
76
76
  ] }),
@@ -82,6 +82,7 @@ const Account = () => {
82
82
  onClick: () => {
83
83
  setStep(ModalStep.AUTH_GUEST_SIGNUP);
84
84
  },
85
+ "data-testid": "para-complete-setup",
85
86
  children: [
86
87
  /* @__PURE__ */ jsx(CpslIcon, { icon: "stars02" }),
87
88
  "Complete Account Setup"
@@ -89,15 +90,24 @@ const Account = () => {
89
90
  }
90
91
  )
91
92
  ] }),
92
- !!(sendTx == null ? void 0 : sendTx.explorerUrl) && /* @__PURE__ */ jsxs(MonitorLink, { target: "_blank", href: sendTx.explorerUrl, rel: "noopener noreferrer", children: [
93
+ !!(sendTx == null ? void 0 : sendTx.explorerUrl) && /* @__PURE__ */ jsxs(MonitorLink, { target: "_blank", href: sendTx.explorerUrl, rel: "noopener noreferrer", "data-testid": "para-monitor-tx", children: [
93
94
  /* @__PURE__ */ jsx("span", { children: "Monitor Transaction" }),
94
95
  /* @__PURE__ */ jsx(CpslIcon, { icon: "externalLink", size: "16px", style: { marginLeft: "6px" } })
95
96
  ] }),
96
97
  /* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
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
- embedded.authType !== "externalWallet" && /* @__PURE__ */ jsx(OptionButton, { icon: "send", onClick: handleSendClick, disabled: !profileBalance, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Send" }) }),
99
- onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleDown", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
100
- /* @__PURE__ */ jsx(OptionButton, { icon: "user01", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
98
+ (onRampConfig.isBuyEnabled || onRampConfig.isReceiveEnabled) && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "plusCircle", onClick: handleBuyClick, "data-testid": "para-add-funds-tile", children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Add Funds" }) }),
99
+ embedded.authType !== "externalWallet" && /* @__PURE__ */ jsx(
100
+ OptionButton,
101
+ {
102
+ icon: "send",
103
+ onClick: handleSendClick,
104
+ disabled: !profileBalance,
105
+ "data-testid": "para-send-tile",
106
+ children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Send" })
107
+ }
108
+ ),
109
+ onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleDown", onClick: handleSellClick, "data-testid": "para-withdraw-tile", children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
110
+ /* @__PURE__ */ jsx(OptionButton, { icon: "user01", onClick: handleProfileClick, "data-testid": "para-profile-tile", children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
101
111
  ] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) })
102
112
  ] })
103
113
  ] }) });
@@ -66,10 +66,20 @@ const AccountProfile = ({
66
66
  /* @__PURE__ */ jsx(Content, { children: wallets.map((wallet) => /* @__PURE__ */ jsx(WalletEntry, { wallet, isSelectable: true }, `${wallet.address}-${wallet.type}`)) })
67
67
  ] }, partner.id);
68
68
  }),
69
- !embedded.isGuestMode && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: switchWallets, disabled: isSwitchWalletsPending, children: isSwitchWalletsPending ? "Please Wait..." : /* @__PURE__ */ jsxs(Fragment, { children: [
70
- /* @__PURE__ */ jsx(CpslIcon, { icon: "shuffle", slot: "start", size: "16px" }),
71
- para.isMultiWallet ? "Switch Wallets" : "Switch Wallet"
72
- ] }) })
69
+ !embedded.isGuestMode && /* @__PURE__ */ jsx(
70
+ CpslButton,
71
+ {
72
+ fullWidth: true,
73
+ variant: "tertiary",
74
+ onClick: switchWallets,
75
+ disabled: isSwitchWalletsPending,
76
+ "data-testid": "para-switch-wallets",
77
+ children: isSwitchWalletsPending ? "Please Wait..." : /* @__PURE__ */ jsxs(Fragment, { children: [
78
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "shuffle", slot: "start", size: "16px" }),
79
+ para.isMultiWallet ? "Switch Wallets" : "Switch Wallet"
80
+ ] })
81
+ }
82
+ )
73
83
  ] }),
74
84
  !embedded.isGuestMode && /* @__PURE__ */ jsxs(Section, { children: [
75
85
  /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Connected Wallets" }),
@@ -85,6 +95,7 @@ const AccountProfile = ({
85
95
  onClick: () => {
86
96
  setStep(ModalStep.ADD_EX_WALLET_MORE);
87
97
  },
98
+ "data-testid": "para-add-wallet",
88
99
  children: [
89
100
  /* @__PURE__ */ jsx(CpslIcon, { icon: "plus", slot: "start" }),
90
101
  "Add Wallet"
@@ -108,16 +119,26 @@ const AccountProfile = ({
108
119
  linkedAccount.id
109
120
  );
110
121
  }) }),
111
- /* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, variant: "tertiary", onClick: () => linkAccount(void 0), children: [
122
+ /* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, variant: "tertiary", onClick: () => linkAccount(void 0), "data-testid": "para-link-account", children: [
112
123
  /* @__PURE__ */ jsx(CpslIcon, { icon: "userPlus", slot: "start", size: "16px" }),
113
124
  "Link an account"
114
125
  ] })
115
126
  ] })
116
127
  ] }),
117
- /* @__PURE__ */ jsxs(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: onDisconnect, disabled: isDisconnecting, children: [
118
- hideWallets ? "Logout" : "Disconnect Wallet",
119
- /* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
120
- ] })
128
+ /* @__PURE__ */ jsxs(
129
+ DisconnectButton,
130
+ {
131
+ variant: "destructive",
132
+ fullWidth: true,
133
+ onClick: onDisconnect,
134
+ disabled: isDisconnecting,
135
+ "data-testid": "para-disconnect",
136
+ children: [
137
+ hideWallets ? "Logout" : "Disconnect Wallet",
138
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "logOut", slot: "end" })
139
+ ]
140
+ }
141
+ )
121
142
  ] });
122
143
  };
123
144
  const Section = safeStyled.div`
@@ -175,7 +175,8 @@ function AccountSendForm() {
175
175
  }
176
176
  },
177
177
  symbol: inputMode === "VALUE" ? "$" : void 0,
178
- size: "56px"
178
+ size: "56px",
179
+ "data-testid": "para-send-amount"
179
180
  }
180
181
  ),
181
182
  !!assetPrice && assetPrice.value > 0 && !isTestnet && /* @__PURE__ */ jsxs(
@@ -190,6 +191,7 @@ function AccountSendForm() {
190
191
  cursor: "pointer"
191
192
  },
192
193
  onClick: () => setInputMode((prev) => prev === "VALUE" ? "AMOUNT" : "VALUE"),
194
+ "data-testid": "para-send-toggle-mode",
193
195
  children: [
194
196
  /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: inputMode === "VALUE" ? formatAssetQuantity({
195
197
  quantity: isMax && assetAmountOnNetwork ? assetAmountOnNetwork : transferAmount,
@@ -218,6 +220,7 @@ function AccountSendForm() {
218
220
  alignItems: "center",
219
221
  justifyContent: "space-between"
220
222
  },
223
+ "data-testid": "para-send-asset-select",
221
224
  children: [
222
225
  /* @__PURE__ */ jsxs(
223
226
  "div",
@@ -303,6 +306,7 @@ function AccountSendForm() {
303
306
  e.stopPropagation();
304
307
  setIsMax(true);
305
308
  },
309
+ "data-testid": "para-send-max",
306
310
  children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "primary", children: "Max" })
307
311
  }
308
312
  ),
@@ -320,6 +324,7 @@ function AccountSendForm() {
320
324
  value: inputDestinationAddress,
321
325
  onCpslInput: (e) => setInputDestinationAddress(e.detail.value),
322
326
  style: { width: "100%" },
327
+ "data-testid": "para-send-recipient",
323
328
  children: /* @__PURE__ */ jsx(WalletTypeIcon, { walletType: selectedWallet.type, size: "24px", slot: "start" })
324
329
  }
325
330
  ),
@@ -336,6 +341,7 @@ function AccountSendForm() {
336
341
  pending: estimateIsPending || broadcastIsPending,
337
342
  disabled: estimateIsPending || broadcastIsPending || !((_l = estimate == null ? void 0 : estimate.result) == null ? void 0 : _l.txSerialized) || !!(estimate == null ? void 0 : estimate.error),
338
343
  onClick: onSubmit,
344
+ "data-testid": "para-send-confirm",
339
345
  children: "Confirm Send"
340
346
  }
341
347
  )
@@ -71,6 +71,7 @@ const AccountWallet = () => {
71
71
  onClick: () => {
72
72
  window.open(url(profileWallet.address), "_blank");
73
73
  },
74
+ "data-testid": "para-view-explorer",
74
75
  children: [
75
76
  "View wallet on ",
76
77
  name,
@@ -103,6 +104,7 @@ const AccountWallet = () => {
103
104
  setProfileWallet(void 0);
104
105
  setStep(ModalStep.ACCOUNT_PROFILE);
105
106
  }),
107
+ "data-testid": "para-disconnect-wallet",
106
108
  children: [
107
109
  /* @__PURE__ */ jsx(CpslIcon, { icon: "key", slot: "start" }),
108
110
  "Disconnect"
@@ -7,7 +7,7 @@ import { CpslIcon, CpslSpinner, CpslTab, CpslTabs } from "@getpara/react-compone
7
7
  import { OnRampStep } from "../../stores/index.js";
8
8
  import { useModalStore } from "../../stores/modal/useModalStore.js";
9
9
  import { useEffect, useMemo } from "react";
10
- import { getAddFundsStep, ModalStep } from "../../utils/steps.js";
10
+ import { getAddFundsStep } from "../../utils/steps.js";
11
11
  import { safeStyled } from "@getpara/react-common";
12
12
  import { useAccount, useWallet } from "../../../provider/index.js";
13
13
  import { AddFundsProvider } from "./AddFundsProvider.js";
@@ -15,10 +15,8 @@ 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 { WalletSelectOld } from "../WalletSelectOld/WalletSelectOld.js";
19
18
  const AddFunds = () => {
20
19
  var _a;
21
- const step = useModalStore((state) => state.step);
22
20
  const onRampConfig = useModalStore((state) => state.onRampConfig);
23
21
  const onRampStep = useModalStore((state) => state.onRampStep);
24
22
  const storedTab = useModalStore((state) => state.accountAddFundTab);
@@ -61,7 +59,6 @@ const AddFunds = () => {
61
59
  /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon }),
62
60
  title
63
61
  ] }, tab2)) }) }),
64
- (step === ModalStep.ADD_FUNDS_RECEIVE || (embedded == null ? void 0 : embedded.wallets) && embedded.wallets.length > 1) && /* @__PURE__ */ jsx(WalletSelectOld, {}),
65
62
  /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx(AddFundsContextProvider, { "data-testid": "add-funds", tab, children: Content }) })
66
63
  ] });
67
64
  };
@@ -1,99 +1,36 @@
1
1
  "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../../../chunk-MMUBH76A.js";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
8
4
  import * as comp from "@getpara/react-components";
9
- import { formatCurrency, getOnRampNetworks } from "@getpara/web-sdk";
10
- import { safeStyled, getAssetCode, getAssetName, ON_RAMP_ASSETS } from "@getpara/react-common";
11
- import { useModalStore } from "../../stores/index.js";
12
- import { useState } from "react";
5
+ import { formatCurrency } from "@getpara/web-sdk";
6
+ import { getAssetCode, getAssetName, ON_RAMP_ASSETS } from "@getpara/react-common";
13
7
  import { useAddFunds } from "./AddFundsContext.js";
14
- import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
15
- import { AssetIcon, contentMotionProps, GradientScroll } from "../common.js";
16
- import { AnimatePresence, motion } from "framer-motion";
8
+ import { AssetIcon, SearchableButtonList } from "../common.js";
17
9
  import { useAssets } from "../../../provider/providers/AssetsProvider.js";
18
10
  function AddFundsAsset() {
19
- const onRampConfig = useModalStore((state) => state.onRampConfig);
20
- const { assets, setAsset, network, setNetwork } = useAddFunds();
21
- const { data: activeWallet } = useWallet();
11
+ const { assets, setAsset } = useAddFunds();
22
12
  const { assetMetadata } = useAssets();
23
- const [searchStr, setSearchStr] = useState("");
24
- const onSelect = (_asset) => __async(this, null, function* () {
25
- yield setAsset(_asset);
26
- if (!network && !!onRampConfig && !!activeWallet) {
27
- yield setNetwork(
28
- getOnRampNetworks(onRampConfig.assetInfo, {
29
- walletType: activeWallet.type,
30
- assets: [_asset]
31
- })[0]
32
- );
33
- }
34
- });
35
- return /* @__PURE__ */ jsxs(Fragment, { children: [
36
- /* @__PURE__ */ jsx(AnimatePresence, { mode: "sync", children: assets.length >= 4 && /* @__PURE__ */ jsx(motion.div, __spreadProps(__spreadValues({}, contentMotionProps), { children: /* @__PURE__ */ jsx(
37
- SearchInput,
38
- {
39
- placeholder: "Search for an asset",
40
- value: searchStr,
41
- onCpslInput: (e) => {
42
- setSearchStr(e.detail.value);
43
- },
44
- children: /* @__PURE__ */ jsx(comp.CpslIcon, { icon: "search", slot: "start" })
45
- }
46
- ) })) }),
47
- /* @__PURE__ */ jsx(GradientScroll, { height: "calc(100% - 56px)", gap: "8px", children: /* @__PURE__ */ jsx(AssetList, { children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "sync", children: assets.filter((asset) => {
48
- return searchStr === "" || getAssetCode(asset).toLowerCase().startsWith(searchStr.toLowerCase()) || getAssetName(asset).toLowerCase().startsWith(searchStr.toLowerCase());
49
- }).map((asset) => /* @__PURE__ */ jsx(
50
- motion.li,
51
- {
52
- style: { width: "100%" },
53
- initial: { opacity: 0 },
54
- animate: { opacity: 1 },
55
- exit: { opacity: 0 },
56
- transition: { duration: 0.2 },
57
- children: /* @__PURE__ */ jsxs(AssetButton, { fullWidth: true, variant: "secondary", onClick: () => onSelect(asset), children: [
58
- /* @__PURE__ */ jsx(AssetIcon, { asset, size: "48px" }),
59
- /* @__PURE__ */ jsxs(Info, { children: [
60
- /* @__PURE__ */ jsx(Code, { color: "contrast", variant: "bodyL", children: ON_RAMP_ASSETS[asset].code }),
61
- /* @__PURE__ */ jsx(Name, { color: "contrast", variant: "bodyS", children: ON_RAMP_ASSETS[asset].name })
62
- ] }),
63
- (assetMetadata == null ? void 0 : assetMetadata[asset]) && /* @__PURE__ */ jsx(comp.CpslText, { variant: "bodyM", children: formatCurrency(assetMetadata[asset].price) })
64
- ] }, asset)
13
+ return /* @__PURE__ */ jsx(
14
+ SearchableButtonList,
15
+ {
16
+ height: 300,
17
+ items: assets,
18
+ transformItem: (asset) => {
19
+ return {
20
+ key: asset,
21
+ icon: /* @__PURE__ */ jsx(AssetIcon, { asset, size: "48px" }),
22
+ text: ON_RAMP_ASSETS[asset].code,
23
+ endText: (assetMetadata == null ? void 0 : assetMetadata[asset]) ? /* @__PURE__ */ jsx(comp.CpslText, { variant: "bodyM", children: formatCurrency(assetMetadata[asset].price) }) : null
24
+ };
25
+ },
26
+ searchPlaceholder: "Search for an asset",
27
+ searchFilter: ({ item, searchStr }) => {
28
+ return searchStr === "" || getAssetCode(item).toLowerCase().startsWith(searchStr.toLowerCase()) || getAssetName(item).toLowerCase().startsWith(searchStr.toLowerCase());
65
29
  },
66
- asset
67
- )) }) }) })
68
- ] });
30
+ onSelect: (asset) => setAsset(asset)
31
+ }
32
+ );
69
33
  }
70
- const AssetList = safeStyled.ul`
71
- display: flex;
72
- flex-direction: column;
73
- width: 100%;
74
- gap: 8px;
75
- list-style: none;
76
- padding-inline-start: 0;
77
- margin: 0;
78
- padding: 0px;
79
- `;
80
- const AssetButton = safeStyled(comp.CpslButton)`
81
- display: flex;
82
- justify-content: center;
83
- align-items: center;
84
- gap: 8px;
85
- --button-secondary-background-color: var(--cpsl-color-background-8);
86
- --button-secondary-border-color: var(--cpsl-color-background-8);
87
- --button-secondary-hover-background-color: var(--cpsl-color-background-16);
88
- --button-secondary-hover-border-color: var(--cpsl-color-background-16);
89
- `;
90
- const Info = safeStyled(comp.CpslCol)`
91
- text-align: left;
92
- `, Code = comp.CpslText, Name = comp.CpslText;
93
- const SearchInput = safeStyled(comp.CpslInput)`
94
- --container-background-color: var(--cpsl-color-background-8);
95
- --input-background-color: transparent;
96
- `;
97
34
  export {
98
35
  AddFundsAsset
99
36
  };
@@ -9,19 +9,23 @@ export declare const TABS: [
9
9
  IconType,
10
10
  ReactNode
11
11
  ][];
12
+ type SettingsStep = 'FORM' | 'ASSETS' | 'NETWORKS' | 'NO_PROVIDERS';
12
13
  type Value = {
13
- network: TNetwork | undefined;
14
+ network: TNetwork | null;
14
15
  setNetwork: Dispatch<SetStateAction<Value['network']>>;
15
- asset: TOnRampAsset | undefined;
16
+ asset: TOnRampAsset | null;
16
17
  setAsset: Dispatch<SetStateAction<Value['asset']>>;
17
18
  fiatQuantity: string | undefined;
18
19
  setFiatQuantity: Dispatch<SetStateAction<Value['fiatQuantity']>>;
19
20
  networks: TNetwork[];
21
+ narrowedNetworks: TNetwork[];
20
22
  assets: TOnRampAsset[];
21
23
  isProviderAllowed: Partial<Record<OnRampProvider, boolean>>;
22
24
  tab: Tab;
23
25
  activeWallet: ReturnType<typeof useWallet>['data'];
24
26
  onRampConfig: OnRampConfig;
27
+ settingsStep: SettingsStep | null;
28
+ TestModeAlert: ReactNode;
25
29
  };
26
30
  export declare const AddFundsContext: import("react").Context<Value>;
27
31
  export declare function AddFundsContextProvider({ tab, children }: PropsWithChildren<{
@@ -3,7 +3,7 @@ import {
3
3
  __spreadProps,
4
4
  __spreadValues
5
5
  } from "../../../chunk-MMUBH76A.js";
6
- import { jsx } from "react/jsx-runtime";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import {
8
8
  createContext,
9
9
  useContext,
@@ -20,7 +20,9 @@ import {
20
20
  getOnRampNetworks,
21
21
  OnRampPurchaseType
22
22
  } from "@getpara/web-sdk";
23
- import { getNetworkFromChainId, getNetworkOrMainNetEquivalent } from "@getpara/react-common";
23
+ import { getNetworkFromChainId, getNetworkOrMainNetEquivalent, safeStyled } from "@getpara/react-common";
24
+ import { CpslAlert, CpslIcon } from "@getpara/react-components";
25
+ import { useStore } from "../../../provider/stores/useStore.js";
24
26
  const TABS = [
25
27
  [EnabledFlow.BUY, "isBuyEnabled", "creditCard", "Buy"],
26
28
  [EnabledFlow.RECEIVE, "isReceiveEnabled", "qrCode", "Receive"],
@@ -28,20 +30,23 @@ const TABS = [
28
30
  ];
29
31
  const DEFAULT = {
30
32
  networks: [],
33
+ narrowedNetworks: [],
31
34
  assets: [],
32
35
  isProviderAllowed: {},
33
36
  tab: TABS[0][0],
34
- network: void 0,
37
+ network: null,
35
38
  setNetwork: () => {
36
39
  },
37
- asset: void 0,
40
+ asset: null,
38
41
  setAsset: () => {
39
42
  },
40
43
  fiatQuantity: "25.00",
41
44
  setFiatQuantity: () => {
42
45
  },
43
46
  onRampConfig: {},
44
- activeWallet: {}
47
+ activeWallet: {},
48
+ settingsStep: "FORM",
49
+ TestModeAlert: null
45
50
  };
46
51
  function isValid(onRampConfig, walletType, network, asset) {
47
52
  var _a, _b;
@@ -50,9 +55,12 @@ function isValid(onRampConfig, walletType, network, asset) {
50
55
  const AddFundsContext = createContext(DEFAULT);
51
56
  function AddFundsContextProvider({ tab, children }) {
52
57
  var _a, _b;
58
+ const appName = useStore((state) => state.appName);
53
59
  const onRampConfig = useModalStore((state) => state.onRampConfig);
54
60
  const onRampStep = useModalStore((state) => state.onRampStep);
55
61
  const setOnRampStep = useModalStore((state) => state.setOnRampStep);
62
+ const isTestModeAlertDismissed = useModalStore((state) => state.isTestModeAlertDismissed);
63
+ const setIsTestModeAlertDismissed = useModalStore((state) => state.setIsTestModeAlertDismissed);
56
64
  const { chainId } = useExternalWallets();
57
65
  const { data: activeWallet } = useWallet();
58
66
  const [fiatQuantity, setFiatQuantity] = useState((_b = (_a = onRampConfig == null ? void 0 : onRampConfig.defaultBuyAmount) == null ? void 0 : _a[0]) != null ? _b : "25.00");
@@ -94,12 +102,17 @@ function AddFundsContextProvider({ tab, children }) {
94
102
  )
95
103
  ];
96
104
  }, [networks, onRampConfig, activeWallet, tab]);
97
- const [network, setNetwork] = useState(
98
- !!(activeWallet == null ? void 0 : activeWallet.type) && !!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampNetwork) && !!onRampConfig.assetInfo[activeWallet.type][onRampConfig.defaultOnRampNetwork] ? onRampConfig.defaultOnRampNetwork : void 0
99
- );
100
- const [asset, setAsset] = useState(
101
- !!network && !!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampAsset) && assets.includes(onRampConfig.defaultOnRampAsset) ? onRampConfig.defaultOnRampAsset : void 0
102
- );
105
+ const [network, setNetwork] = useState(null);
106
+ const [asset, setAsset] = useState(null);
107
+ const narrowedNetworks = useMemo(() => {
108
+ return !asset || !onRampConfig ? networks : getOnRampNetworks(onRampConfig.assetInfo, {
109
+ walletType: activeWallet == null ? void 0 : activeWallet.type,
110
+ allowed: onRampConfig.allowedAssets ? Object.entries(onRampConfig.allowedAssets).filter(([_, value2]) => value2 === true || value2.includes(asset)).map(([key]) => key) : void 0,
111
+ assets: [asset],
112
+ providers: onRampConfig.providers,
113
+ action: tab === EnabledFlow.BUY ? OnRampPurchaseType.BUY : OnRampPurchaseType.SELL
114
+ });
115
+ }, [networks, asset, activeWallet == null ? void 0 : activeWallet.type, onRampConfig, tab]);
103
116
  const isProviderAllowed = useMemo(
104
117
  () => onRampConfig && !!(activeWallet == null ? void 0 : activeWallet.type) ? onRampConfig.providers.reduce(
105
118
  (acc, id) => {
@@ -112,6 +125,37 @@ function AddFundsContextProvider({ tab, children }) {
112
125
  ) : {},
113
126
  [onRampConfig, network, asset, activeWallet, tab]
114
127
  );
128
+ const settingsStep = useMemo(() => {
129
+ switch (true) {
130
+ case (assets.length === 0 && networks.length === 0):
131
+ return "NO_PROVIDERS";
132
+ case (!!asset && !!network):
133
+ return "FORM";
134
+ case !asset:
135
+ return "ASSETS";
136
+ case !network:
137
+ return "NETWORKS";
138
+ default:
139
+ return null;
140
+ }
141
+ }, [asset, network, assets.length, networks.length]);
142
+ const TestModeAlert = useMemo(() => {
143
+ return (onRampConfig == null ? void 0 : onRampConfig.testMode) && !isTestModeAlertDismissed ? /* @__PURE__ */ jsx(CpslAlert, { variant: "error", filled: true, children: /* @__PURE__ */ jsxs(Fragment, { children: [
144
+ /* @__PURE__ */ jsxs("span", { children: [
145
+ "This Para Modal is configured to run on-ramp services in ",
146
+ /* @__PURE__ */ jsx("b", { children: "test mode" }),
147
+ " only, for development purposes. If you are a user of ",
148
+ appName,
149
+ ", please contact support."
150
+ ] }),
151
+ /* @__PURE__ */ jsx(CloseButton, { onClick: () => setIsTestModeAlertDismissed(true), children: /* @__PURE__ */ jsx(CloseX, { icon: "x" }) })
152
+ ] }) }) : null;
153
+ }, [isTestModeAlertDismissed, appName, onRampConfig == null ? void 0 : onRampConfig.testMode, setIsTestModeAlertDismissed]);
154
+ useEffect(() => {
155
+ if (!!asset && !network && narrowedNetworks.length === 1) {
156
+ setNetwork(narrowedNetworks[0]);
157
+ }
158
+ }, [asset, network, narrowedNetworks]);
115
159
  const value = useMemo(() => {
116
160
  if (!onRampConfig || !activeWallet) {
117
161
  return DEFAULT;
@@ -119,6 +163,7 @@ function AddFundsContextProvider({ tab, children }) {
119
163
  return {
120
164
  tab,
121
165
  networks,
166
+ narrowedNetworks,
122
167
  assets,
123
168
  isProviderAllowed,
124
169
  asset,
@@ -128,22 +173,39 @@ function AddFundsContextProvider({ tab, children }) {
128
173
  fiatQuantity,
129
174
  setFiatQuantity,
130
175
  activeWallet,
131
- onRampConfig
176
+ onRampConfig,
177
+ settingsStep,
178
+ TestModeAlert
132
179
  };
133
180
  }, [
134
181
  tab,
135
182
  networks,
183
+ narrowedNetworks,
136
184
  assets,
137
185
  isProviderAllowed,
138
186
  asset,
139
- setAsset,
140
187
  network,
141
- setNetwork,
142
188
  fiatQuantity,
143
189
  setFiatQuantity,
144
190
  activeWallet,
145
- onRampConfig
191
+ onRampConfig,
192
+ settingsStep,
193
+ TestModeAlert
146
194
  ]);
195
+ useEffect(() => {
196
+ const newNetwork = !!(activeWallet == null ? void 0 : activeWallet.type) && !!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampNetwork) && !!onRampConfig.assetInfo[activeWallet.type][onRampConfig.defaultOnRampNetwork] ? onRampConfig.defaultOnRampNetwork : networks.find(
197
+ (network2) => (activeWallet == null ? void 0 : activeWallet.type) === "COSMOS" ? network2 === "COSMOS" : (activeWallet == null ? void 0 : activeWallet.type) === "SOLANA" ? network2 === "SOLANA" : network2 === "ETHEREUM"
198
+ ) || networks[0] || null;
199
+ const newAsset = !!network && !!(onRampConfig == null ? void 0 : onRampConfig.defaultOnRampAsset) && assets.includes(onRampConfig.defaultOnRampAsset) ? onRampConfig.defaultOnRampAsset : assets.find(
200
+ (asset2) => (activeWallet == null ? void 0 : activeWallet.type) === "COSMOS" ? asset2 === "ATOM" : (activeWallet == null ? void 0 : activeWallet.type) === "SOLANA" ? asset2 === "SOLANA" : asset2 === "ETHEREUM"
201
+ ) || assets[0] || null;
202
+ if (newAsset !== asset) {
203
+ setAsset(newAsset);
204
+ }
205
+ if (newNetwork !== network) {
206
+ setNetwork(newNetwork);
207
+ }
208
+ }, [activeWallet == null ? void 0 : activeWallet.type, assets, networks]);
147
209
  useEffect(() => {
148
210
  if (!!activeWallet && onRampStep === OnRampStep.PROVIDER && !isValid(onRampConfig, activeWallet.type, network, asset)) {
149
211
  setOnRampStep(OnRampStep.SETTINGS);
@@ -152,6 +214,26 @@ function AddFundsContextProvider({ tab, children }) {
152
214
  return /* @__PURE__ */ jsx(AddFundsContext.Provider, { value, children });
153
215
  }
154
216
  const useAddFunds = () => useContext(AddFundsContext);
217
+ const CloseButton = safeStyled.button`
218
+ background-color: transparent;
219
+ border: none;
220
+ padding: 0;
221
+ cursor: pointer;
222
+ flex-shrink: 0;
223
+ display: flex;
224
+ align-items: center;
225
+ justify-content: center;
226
+ width: 20px;
227
+ height: 20px;
228
+ position: absolute;
229
+ top: 8px;
230
+ right: 8px;
231
+ `;
232
+ const CloseX = safeStyled(CpslIcon)`
233
+ --icon-color: var(--cpsl-color-utility-yellow-dark, #92400e);
234
+ --height: 18px;
235
+ --width: 18px;
236
+ `;
155
237
  export {
156
238
  AddFundsContext,
157
239
  AddFundsContextProvider,
@@ -0,0 +1 @@
1
+ export declare function AddFundsNetwork(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { getNetworkName } from "@getpara/react-common";
5
+ import { useAddFunds } from "./AddFundsContext.js";
6
+ import { Heading, NetworkIcon, SearchableButtonList } from "../common.js";
7
+ import { CpslRow } from "@getpara/react-components";
8
+ function AddFundsNetwork() {
9
+ const { narrowedNetworks, setNetwork } = useAddFunds();
10
+ return /* @__PURE__ */ jsxs(CpslRow, { col: true, gap: "8px", style: { width: "100%" }, children: [
11
+ /* @__PURE__ */ jsx(Heading, { children: "Choose Network" }),
12
+ /* @__PURE__ */ jsx(
13
+ SearchableButtonList,
14
+ {
15
+ height: 300,
16
+ items: narrowedNetworks,
17
+ transformItem: (network) => {
18
+ return {
19
+ key: network,
20
+ icon: /* @__PURE__ */ jsx(NetworkIcon, { network, size: "48px" }),
21
+ text: getNetworkName(network)
22
+ };
23
+ },
24
+ onSelect: (network) => setNetwork(network)
25
+ }
26
+ )
27
+ ] });
28
+ }
29
+ export {
30
+ AddFundsNetwork
31
+ };