@getpara/react-sdk-lite 2.0.0-alpha.72 → 2.0.0-alpha.73

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 (47) hide show
  1. package/dist/cli/cli.mjs +26 -1
  2. package/dist/modal/components/Account/Account.js +39 -2
  3. package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +1 -0
  4. package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +94 -0
  5. package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +1 -0
  6. package/dist/modal/components/Account/AccountSend/AccountSendForm.js +343 -0
  7. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +1 -0
  8. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.js +53 -0
  9. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +1 -0
  10. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.js +56 -0
  11. package/dist/modal/components/Account/AccountSend/AssetNetwork.d.ts +5 -0
  12. package/dist/modal/components/Account/AccountSend/AssetNetwork.js +36 -0
  13. package/dist/modal/components/Account/AccountSend/context.d.ts +38 -0
  14. package/dist/modal/components/Account/AccountSend/context.js +418 -0
  15. package/dist/modal/components/Account/AccountSend/index.d.ts +4 -0
  16. package/dist/modal/components/Account/AccountSend/index.js +67 -0
  17. package/dist/modal/components/AddFunds/AddFundsAsset.js +1 -2
  18. package/dist/modal/components/AddFunds/AddFundsProvider.js +1 -2
  19. package/dist/modal/components/AddFunds/AddFundsSettings.js +12 -52
  20. package/dist/modal/components/AddFunds/common.d.ts +0 -14
  21. package/dist/modal/components/AddFunds/common.js +1 -8
  22. package/dist/modal/components/Body/Body.js +12 -2
  23. package/dist/modal/components/Header/hooks/useStepTitle.js +4 -1
  24. package/dist/modal/components/QuantityInput.d.ts +9 -0
  25. package/dist/modal/components/QuantityInput.js +91 -0
  26. package/dist/modal/components/SearchableButtonList.d.ts +34 -0
  27. package/dist/modal/components/SearchableButtonList.js +223 -0
  28. package/dist/modal/components/WalletSelectOld/WalletSelectOld.d.ts +7 -1
  29. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +16 -7
  30. package/dist/modal/components/common.d.ts +4 -1
  31. package/dist/modal/components/common.js +14 -1
  32. package/dist/modal/hooks/index.d.ts +4 -0
  33. package/dist/modal/hooks/index.js +5 -0
  34. package/dist/modal/hooks/useDebounce.d.ts +4 -0
  35. package/dist/modal/hooks/useDebounce.js +16 -0
  36. package/dist/modal/stores/modal/actions.js +2 -1
  37. package/dist/modal/stores/modal/useModalStore.d.ts +3 -1
  38. package/dist/modal/stores/modal/useModalStore.js +2 -1
  39. package/dist/modal/utils/countryCodes.js +11 -1
  40. package/dist/modal/utils/steps.d.ts +8 -2
  41. package/dist/modal/utils/steps.js +13 -1
  42. package/dist/provider/hooks/queries/useProfileBalance.d.ts +4 -0
  43. package/dist/provider/hooks/queries/useProfileBalance.js +10 -5
  44. package/dist/provider/hooks/utils/useEventListeners.js +4 -1
  45. package/dist/provider/hooks/utils/useWalletState.d.ts +1 -0
  46. package/dist/provider/hooks/utils/useWalletState.js +2 -1
  47. package/package.json +8 -8
package/dist/cli/cli.mjs CHANGED
@@ -14,7 +14,32 @@ const PACKAGES_TO_STUB = [
14
14
  ];
15
15
 
16
16
  const checkForPackages = async () => {
17
- const pathToNodeModules = path.resolve('node_modules');
17
+ let pathToNodeModules = path.resolve('node_modules');
18
+
19
+ // Check if pnpm-lock.yaml actually exists
20
+ const pnpmLockPath = path.resolve(process.cwd(), 'pnpm-lock.yaml');
21
+ let isPNPM = false;
22
+
23
+ try {
24
+ await fs.access(pnpmLockPath);
25
+ isPNPM = true;
26
+ } catch {
27
+ isPNPM = false;
28
+ }
29
+
30
+ // If it's a PNPM project, adjust the node_modules path accordingly to account for virtual store
31
+ // NODE_PATH is set by PNPM to include the correct paths
32
+ if (isPNPM && process.env.NODE_PATH) {
33
+ const endingNodePathString = '@getpara/node_modules';
34
+ const nodePathSplit = process.env.NODE_PATH.split(path.delimiter);
35
+ const fullPath = nodePathSplit.find(p => p.endsWith(endingNodePathString));
36
+ if (fullPath) {
37
+ const newPath = fullPath.replace(endingNodePathString, '');
38
+ if (newPath) {
39
+ pathToNodeModules = newPath;
40
+ }
41
+ }
42
+ }
18
43
 
19
44
  for (let i = 0; i < PACKAGES_TO_STUB.length; i++) {
20
45
  const packageName = PACKAGES_TO_STUB[i];
@@ -8,7 +8,7 @@ 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 } from "../../../provider/index.js";
11
+ import { useAccount, useWalletState } from "../../../provider/index.js";
12
12
  import { EnabledFlow } from "@getpara/web-sdk";
13
13
  import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
14
14
  import { useAssets } from "../../../provider/providers/AssetsProvider.js";
@@ -18,13 +18,26 @@ const Account = () => {
18
18
  const setStep = useModalStore((state) => state.setStep);
19
19
  const setGuestAddFundsTab = useModalStore((state) => state.setGuestAddFundsTab);
20
20
  const setOnRampStep = useModalStore((state) => state.setOnRampStep);
21
+ const sendTx = useModalStore((state) => state.sendTx);
21
22
  const para = useInternalClient();
22
23
  const { embedded } = useAccount();
24
+ const { selectedWallet, setSelectedWallet } = useWalletState();
23
25
  const { isEnabled } = useAccountLinking();
24
26
  const { profileBalance } = useAssets();
25
27
  const isGuestMode = embedded.isConnected && embedded.isGuestMode;
26
28
  const cantBuyAndWithdraw = (para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION") && !para.userId;
27
29
  const isOnRampLoaded = !!onRampConfig;
30
+ const handleSendClick = () => {
31
+ var _a, _b;
32
+ if ((selectedWallet == null ? void 0 : selectedWallet.type) === "COSMOS" || ((_a = embedded.wallets) == null ? void 0 : _a.some((w) => w.id === (selectedWallet == null ? void 0 : selectedWallet.id) && w.isExternal))) {
33
+ const validWallet = (_b = embedded.wallets) == null ? void 0 : _b.find(({ type, isExternal }) => type !== "COSMOS" && !isExternal);
34
+ if (!validWallet) {
35
+ return;
36
+ }
37
+ setSelectedWallet({ id: validWallet.id, type: validWallet.type });
38
+ }
39
+ setStep(ModalStep.ACCOUNT_SEND);
40
+ };
28
41
  const handleBuyClick = () => {
29
42
  if (isGuestMode) {
30
43
  if (onRampConfig == null ? void 0 : onRampConfig.isReceiveEnabled) {
@@ -76,8 +89,13 @@ const Account = () => {
76
89
  }
77
90
  )
78
91
  ] }),
92
+ !!(sendTx == null ? void 0 : sendTx.explorerUrl) && /* @__PURE__ */ jsxs(MonitorLink, { target: "_blank", href: sendTx.explorerUrl, rel: "noopener noreferrer", children: [
93
+ /* @__PURE__ */ jsx("span", { children: "Monitor Transaction" }),
94
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "externalLink", size: "16px", style: { marginLeft: "6px" } })
95
+ ] }),
79
96
  /* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
80
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" }) }),
81
99
  onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleDown", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
82
100
  /* @__PURE__ */ jsx(OptionButton, { icon: "user01", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
83
101
  ] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) })
@@ -123,8 +141,27 @@ const Alert = safeStyled.div`
123
141
  const LowerContainer = safeStyled.div`
124
142
  display: flex;
125
143
  flex-direction: column;
126
- gap: 8px;
144
+ gap: 16px;
145
+ width: 100%;
146
+ `;
147
+ const MonitorLink = safeStyled.a`
148
+ font-family: var(--cpsl-font-family);
149
+ font-size: 14px;
150
+ position: relative;
151
+ display: flex;
152
+ align-items: center;
153
+ justify-content: center;
127
154
  width: 100%;
155
+ background: transparent;
156
+ border: none;
157
+ cursor: pointer;
158
+ color: var(--cpsl-color-text-primary);
159
+ --icon-color: var(--cpsl-color-text-primary);
160
+
161
+ &:hover {
162
+ color: var(--cpsl-color-text-contrast);
163
+ --icon-color: var(--cpsl-color-text-contrast);
164
+ }
128
165
  `;
129
166
  export {
130
167
  Account
@@ -0,0 +1 @@
1
+ export declare function AccountSendAsset(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,94 @@
1
+ "use client";
2
+ import "../../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useMemo, useCallback, memo } from "react";
5
+ import { useWalletState } from "../../../../provider/index.js";
6
+ import { useAssets } from "../../../../provider/providers/AssetsProvider.js";
7
+ import { SearchableButtonList } from "../../SearchableButtonList.js";
8
+ import { useSend } from "./context.js";
9
+ import { CpslIcon } from "@getpara/react-components";
10
+ import { formatAssetQuantity, formatCurrency } from "@getpara/web-sdk";
11
+ import { ModalStep } from "../../../utils/steps.js";
12
+ import { useModalStore } from "../../../stores/index.js";
13
+ import { AssetNetwork } from "./AssetNetwork.js";
14
+ const NetworkIcons = memo(({ networks }) => {
15
+ return /* @__PURE__ */ jsx("div", { style: { position: "relative", height: "12px" }, children: networks.slice(0, 3).map((network, index) => {
16
+ var _a;
17
+ return /* @__PURE__ */ jsx(
18
+ CpslIcon,
19
+ {
20
+ src: network.metadata.logoUrl,
21
+ size: "16px",
22
+ radius: "full",
23
+ style: {
24
+ borderRadius: "1000px",
25
+ backgroundColor: "var(--cpsl-color-primary)",
26
+ position: "absolute",
27
+ top: 0,
28
+ left: `${index * 8}px`,
29
+ zIndex: 3 - index
30
+ }
31
+ },
32
+ ((_a = network.metadata) == null ? void 0 : _a.logoUrl) || index
33
+ );
34
+ }) });
35
+ });
36
+ NetworkIcons.displayName = "NetworkIcons";
37
+ function AccountSendAsset() {
38
+ const setStep = useModalStore((state) => state.setStep);
39
+ const { profileBalance } = useAssets();
40
+ const { selectedWallet } = useWalletState();
41
+ const { setSendMetadata, setTransferAmount } = useSend();
42
+ const walletAssets = useMemo(() => {
43
+ var _a, _b;
44
+ return (_b = (_a = profileBalance == null ? void 0 : profileBalance.wallets.find((wallet) => wallet.address === (selectedWallet == null ? void 0 : selectedWallet.address))) == null ? void 0 : _a.assets) != null ? _b : [];
45
+ }, [profileBalance, selectedWallet == null ? void 0 : selectedWallet.address]);
46
+ const transformItem = useCallback((item) => {
47
+ var _a, _b;
48
+ const isValued = ((_a = item.value) == null ? void 0 : _a.value) && ((_b = item.value) == null ? void 0 : _b.value) >= 0.01;
49
+ const quantity = formatAssetQuantity({ quantity: item.quantity, symbol: item.metadata.symbol });
50
+ return {
51
+ key: item.metadata.zerionId,
52
+ icon: /* @__PURE__ */ jsx(
53
+ AssetNetwork,
54
+ {
55
+ assetSrc: item.metadata.logoUrl,
56
+ networkSrc: item.networks.length === 1 ? item.networks[0].metadata.logoUrl : void 0,
57
+ size: 48
58
+ }
59
+ ),
60
+ text: item.metadata.symbol,
61
+ textSecondary: item.networks.length > 0 ? item.networks.length === 1 ? item.networks[0].metadata.name : /* @__PURE__ */ jsx(NetworkIcons, { networks: item.networks }) : void 0,
62
+ endText: isValued ? formatCurrency(item.value) : quantity,
63
+ endTextSecondary: isValued ? quantity : void 0
64
+ };
65
+ }, []);
66
+ const searchFilter = useCallback(({ item, searchStr }) => {
67
+ if (!item.metadata) return false;
68
+ const lowerSearchStr = searchStr.toLowerCase();
69
+ return item.metadata.symbol.toLowerCase().includes(lowerSearchStr) || item.metadata.name.toLowerCase().includes(lowerSearchStr);
70
+ }, []);
71
+ const onSelect = useCallback(
72
+ (item) => {
73
+ setTransferAmount(0);
74
+ setSendMetadata({
75
+ asset: item,
76
+ network: item.networks[0]
77
+ });
78
+ setStep(item.networks.length > 1 ? ModalStep.ACCOUNT_SEND_NETWORK : ModalStep.ACCOUNT_SEND);
79
+ },
80
+ [setTransferAmount, setSendMetadata, setStep]
81
+ );
82
+ return /* @__PURE__ */ jsx("div", { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
83
+ SearchableButtonList,
84
+ {
85
+ items: walletAssets,
86
+ transformItem,
87
+ searchFilter,
88
+ onSelect
89
+ }
90
+ ) });
91
+ }
92
+ export {
93
+ AccountSendAsset
94
+ };
@@ -0,0 +1 @@
1
+ export declare function AccountSendForm(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,343 @@
1
+ "use client";
2
+ import "../../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslIcon, CpslInput, CpslText } from "@getpara/react-components";
5
+ import { QuantityInput } from "../../QuantityInput.js";
6
+ import { formatAssetQuantity, formatCurrency } from "@getpara/shared";
7
+ import { WalletTypeIcon } from "@getpara/react-common";
8
+ import { useSend } from "./context.js";
9
+ import { useModalStore } from "../../../stores/index.js";
10
+ import { ModalStep } from "../../../utils/steps.js";
11
+ import { useEffect, useMemo, useRef, useState } from "react";
12
+ import { useDebounce } from "../../../hooks/useDebounce.js";
13
+ import { AssetNetwork } from "./AssetNetwork.js";
14
+ import { useWalletState } from "../../../../provider/index.js";
15
+ function AccountSendForm() {
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
17
+ const { selectedWallet } = useWalletState();
18
+ const setStep = useModalStore((state) => state.setStep);
19
+ const onRampConfig = useModalStore((state) => state.onRampConfig);
20
+ const {
21
+ estimate,
22
+ broadcast,
23
+ onSubmit,
24
+ sendMetadata,
25
+ destinationAddress,
26
+ setDestinationAddress,
27
+ transferValue,
28
+ setTransferValue,
29
+ transferAmount,
30
+ setTransferAmount,
31
+ assetPrice,
32
+ assetValueOnNetwork,
33
+ assetAmountOnNetwork,
34
+ isMax,
35
+ setIsMax,
36
+ estimateIsPending,
37
+ broadcastIsPending,
38
+ optionsType
39
+ } = useSend();
40
+ const [inputDestinationAddress, setInputDestinationAddress] = useState(destinationAddress);
41
+ const dbInputDestinationAddress = useDebounce(inputDestinationAddress, 500);
42
+ const isTestnet = (_b = (_a = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _a.metadata) == null ? void 0 : _b.isTestnet;
43
+ const shouldUseAmountMode = !assetPrice || !!assetPrice && isTestnet;
44
+ const [inputMode, setInputMode] = useState(shouldUseAmountMode ? "AMOUNT" : "VALUE");
45
+ const [inputValue, setInputValue] = useState(
46
+ inputMode === "VALUE" ? transferValue.toFixed(2) : formatAssetQuantity({ quantity: transferAmount, symbol: "" })
47
+ );
48
+ const dbInputValue = useDebounce(inputValue, 500);
49
+ const isEditing = useRef(false);
50
+ const error = useMemo(() => {
51
+ var _a2;
52
+ const errorRef = (estimate == null ? void 0 : estimate.error) || (broadcast == null ? void 0 : broadcast.error);
53
+ if (!errorRef || estimateIsPending || broadcastIsPending) {
54
+ return null;
55
+ }
56
+ switch (errorRef == null ? void 0 : errorRef.code) {
57
+ case "INSUFFICIENT_NATIVE_BALANCE": {
58
+ const nativeSymbol = (selectedWallet == null ? void 0 : selectedWallet.type) === "EVM" ? "ETH" : "SOL";
59
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
60
+ /* @__PURE__ */ jsxs(CpslText, { variant: "bodyXS", color: "error", style: { textAlign: (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) ? "left" : "center" }, children: [
61
+ "You need ",
62
+ (_a2 = estimate == null ? void 0 : estimate.transferAmount) != null ? _a2 : nativeSymbol,
63
+ " to conduct this transaction"
64
+ ] }),
65
+ (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) && /* @__PURE__ */ jsxs(
66
+ "button",
67
+ {
68
+ style: {
69
+ background: "transparent",
70
+ border: "none",
71
+ cursor: "pointer",
72
+ color: "var(--cpsl-color-text-contrast)",
73
+ fontSize: "12px",
74
+ fontWeight: "500",
75
+ display: "flex",
76
+ alignItems: "center",
77
+ gap: "4px",
78
+ paddingRight: 0
79
+ },
80
+ onClick: () => setStep(ModalStep.ADD_FUNDS_BUY),
81
+ children: [
82
+ /* @__PURE__ */ jsxs("span", { children: [
83
+ "Buy ",
84
+ nativeSymbol
85
+ ] }),
86
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "chevronRight", size: "12px", color: "var(--cpsl-color-text-contrast)" })
87
+ ]
88
+ }
89
+ )
90
+ ] });
91
+ }
92
+ default: {
93
+ return /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "error", style: { textAlign: "center", width: "100%" }, children: errorRef == null ? void 0 : errorRef.message });
94
+ }
95
+ }
96
+ }, [
97
+ broadcast == null ? void 0 : broadcast.error,
98
+ estimate == null ? void 0 : estimate.error,
99
+ selectedWallet == null ? void 0 : selectedWallet.type,
100
+ estimateIsPending,
101
+ broadcastIsPending,
102
+ onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled
103
+ ]);
104
+ useEffect(() => {
105
+ var _a2, _b2;
106
+ const isTestnet2 = (_b2 = (_a2 = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _a2.metadata) == null ? void 0 : _b2.isTestnet;
107
+ const shouldUseAmountMode2 = !assetPrice || !!assetPrice && isTestnet2;
108
+ setInputMode(shouldUseAmountMode2 ? "AMOUNT" : "VALUE");
109
+ }, [assetPrice, (_d = (_c = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _c.metadata) == null ? void 0 : _d.isTestnet]);
110
+ useEffect(() => {
111
+ if (inputMode === "AMOUNT") {
112
+ setTransferAmount(Number(dbInputValue));
113
+ } else {
114
+ setTransferValue(Number(dbInputValue));
115
+ }
116
+ }, [dbInputValue]);
117
+ useEffect(() => {
118
+ setDestinationAddress(dbInputDestinationAddress);
119
+ }, [dbInputDestinationAddress]);
120
+ useEffect(() => {
121
+ if (inputMode === "VALUE" && !isEditing.current) {
122
+ const numValue = parseFloat(inputValue || "0");
123
+ const formattedValue = transferValue.toFixed(2);
124
+ if (Math.abs(numValue - transferValue) > 1e-3 || inputValue !== formattedValue) {
125
+ setInputValue(formattedValue);
126
+ }
127
+ }
128
+ }, [transferValue, inputMode, inputValue]);
129
+ useEffect(() => {
130
+ if (inputMode === "AMOUNT" && !isEditing.current && Number(inputValue) !== transferAmount) {
131
+ setInputValue(formatAssetQuantity({ quantity: transferAmount, symbol: "" }));
132
+ }
133
+ }, [transferAmount]);
134
+ useEffect(() => {
135
+ setInputDestinationAddress(destinationAddress);
136
+ }, [destinationAddress]);
137
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", width: "100%", flexDirection: "column", gap: "16px", alignItems: "center" }, children: [
138
+ /* @__PURE__ */ jsxs(
139
+ "div",
140
+ {
141
+ style: {
142
+ display: "flex",
143
+ width: "100%",
144
+ background: "var(--cpsl-color-background-4)",
145
+ borderRadius: "var(--cpsl-border-radius-input)",
146
+ padding: "32px 16px 16px",
147
+ flexDirection: "column",
148
+ gap: "32px",
149
+ alignItems: "center"
150
+ },
151
+ children: [
152
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", width: "100%", flexDirection: "column", gap: "4px", alignItems: "center" }, children: [
153
+ /* @__PURE__ */ jsx(
154
+ QuantityInput,
155
+ {
156
+ value: inputMode === "VALUE" ? isMax && !!assetValueOnNetwork ? assetValueOnNetwork.value.toFixed(2) : inputValue : isMax && !!assetAmountOnNetwork ? formatAssetQuantity({ quantity: assetAmountOnNetwork, symbol: "" }) : inputValue,
157
+ onChange: (value) => {
158
+ setIsMax(false);
159
+ setInputValue(value != null ? value : "");
160
+ },
161
+ onFocus: () => isEditing.current = true,
162
+ onBlur: () => {
163
+ isEditing.current = false;
164
+ if (inputMode === "VALUE" && inputValue) {
165
+ const numValue = parseFloat(inputValue);
166
+ if (!isNaN(numValue)) {
167
+ const formatted = numValue.toFixed(2);
168
+ if (inputValue !== formatted) {
169
+ setInputValue(formatted);
170
+ }
171
+ }
172
+ }
173
+ },
174
+ symbol: inputMode === "VALUE" ? "$" : void 0,
175
+ size: "56px"
176
+ }
177
+ ),
178
+ !!assetPrice && assetPrice.value > 0 && !isTestnet && /* @__PURE__ */ jsxs(
179
+ "button",
180
+ {
181
+ style: {
182
+ display: "flex",
183
+ alignItems: "center",
184
+ gap: "4px",
185
+ background: "transparent",
186
+ border: "none",
187
+ cursor: "pointer"
188
+ },
189
+ onClick: () => setInputMode((prev) => prev === "VALUE" ? "AMOUNT" : "VALUE"),
190
+ children: [
191
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: inputMode === "VALUE" ? formatAssetQuantity({
192
+ quantity: isMax && assetAmountOnNetwork ? assetAmountOnNetwork : transferAmount,
193
+ symbol: (_e = sendMetadata.asset.metadata) == null ? void 0 : _e.symbol
194
+ }) : formatCurrency({
195
+ value: isMax && assetValueOnNetwork ? assetValueOnNetwork.value : Number(transferValue),
196
+ currency: "USD"
197
+ }) }),
198
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "arrowUpDown", size: "16px", color: "var(--cpsl-color-text-secondary)" })
199
+ ]
200
+ }
201
+ )
202
+ ] }),
203
+ (sendMetadata == null ? void 0 : sendMetadata.asset) && (sendMetadata == null ? void 0 : sendMetadata.network) && /* @__PURE__ */ jsxs(
204
+ "button",
205
+ {
206
+ onClick: () => !["SINGLE_NETWORK", "NONE"].includes(optionsType) ? setStep(optionsType === "SINGLE_ASSET" ? ModalStep.ACCOUNT_SEND_NETWORK : ModalStep.ACCOUNT_SEND_ASSET) : void 0,
207
+ style: {
208
+ cursor: "pointer",
209
+ background: "transparent",
210
+ border: "none",
211
+ padding: 0,
212
+ display: "flex",
213
+ width: "100%",
214
+ height: "32px",
215
+ alignItems: "center",
216
+ justifyContent: "space-between"
217
+ },
218
+ children: [
219
+ /* @__PURE__ */ jsxs(
220
+ "div",
221
+ {
222
+ style: {
223
+ display: "flex",
224
+ alignItems: "flex-start",
225
+ justifyContent: "center",
226
+ gap: "8px",
227
+ flexGrow: 1,
228
+ height: "100%"
229
+ },
230
+ children: [
231
+ /* @__PURE__ */ jsx(
232
+ AssetNetwork,
233
+ {
234
+ assetSrc: sendMetadata.asset.metadata.logoUrl,
235
+ networkSrc: sendMetadata.network.metadata.logoUrl,
236
+ size: 32
237
+ }
238
+ ),
239
+ /* @__PURE__ */ jsxs(
240
+ "div",
241
+ {
242
+ style: {
243
+ display: "flex",
244
+ flexDirection: "column",
245
+ alignItems: "flex-start",
246
+ justifyContent: "space-between",
247
+ flexGrow: 1,
248
+ position: "relative",
249
+ height: "100%"
250
+ },
251
+ children: [
252
+ /* @__PURE__ */ jsx(
253
+ CpslText,
254
+ {
255
+ variant: "bodyM",
256
+ color: "contrast",
257
+ style: { position: "absolute", height: "16px", top: "-4px", left: 0 },
258
+ children: sendMetadata.asset.metadata.symbol
259
+ }
260
+ ),
261
+ /* @__PURE__ */ jsxs(
262
+ CpslText,
263
+ {
264
+ variant: "bodyS",
265
+ color: "secondary",
266
+ style: { position: "absolute", height: "14px", bottom: 0, left: 0 },
267
+ children: [
268
+ "Balance:",
269
+ " ",
270
+ formatAssetQuantity({
271
+ quantity: assetAmountOnNetwork,
272
+ symbol: ""
273
+ }),
274
+ !!assetValueOnNetwork && /* @__PURE__ */ jsxs("span", { style: { color: "var(--cpsl-color-text-tertiary) !important" }, children: [
275
+ " (",
276
+ formatCurrency(assetValueOnNetwork),
277
+ ")"
278
+ ] })
279
+ ]
280
+ }
281
+ )
282
+ ]
283
+ }
284
+ )
285
+ ]
286
+ }
287
+ ),
288
+ !isMax && /* @__PURE__ */ jsx(
289
+ "button",
290
+ {
291
+ style: {
292
+ background: "transparent",
293
+ cursor: "pointer",
294
+ border: "1px solid var(--cpsl-color-background-16)",
295
+ color: "var(--cpsl-color-text-primary)",
296
+ borderRadius: "4px",
297
+ padding: "4px"
298
+ },
299
+ onClick: (e) => {
300
+ e.stopPropagation();
301
+ setIsMax(true);
302
+ },
303
+ children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "primary", children: "Max" })
304
+ }
305
+ ),
306
+ optionsType !== "SINGLE_NETWORK" && /* @__PURE__ */ jsx(CpslIcon, { icon: "chevronRight", size: "24px", color: "var(--cpsl-color-text-contrast)" })
307
+ ]
308
+ }
309
+ )
310
+ ]
311
+ }
312
+ ),
313
+ /* @__PURE__ */ jsx(
314
+ CpslInput,
315
+ {
316
+ placeholder: "Enter recipient address",
317
+ value: inputDestinationAddress,
318
+ onCpslInput: (e) => setInputDestinationAddress(e.detail.value),
319
+ style: { width: "100%" },
320
+ children: /* @__PURE__ */ jsx(WalletTypeIcon, { walletType: selectedWallet.type, size: "24px", slot: "start" })
321
+ }
322
+ ),
323
+ ((estimate == null ? void 0 : estimate.feeValue) || (estimate == null ? void 0 : estimate.feeAmount) || estimateIsPending) && /* @__PURE__ */ jsxs("div", { style: { display: "flex", width: "100%", gap: "4px", alignItems: "center", justifyContent: "space-between" }, children: [
324
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: "Network Fee" }),
325
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "contrast", children: estimateIsPending ? "Estimating..." : (_i = (_h = ((_g = (_f = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _f.metadata) == null ? void 0 : _g.isTestnet) ? estimate == null ? void 0 : estimate.feeAmount : estimate == null ? void 0 : estimate.feeValue) != null ? _h : estimate == null ? void 0 : estimate.feeAmount) != null ? _i : "0" })
326
+ ] }),
327
+ error && /* @__PURE__ */ jsx("div", { style: { display: "flex", width: "100%", gap: "4px", alignItems: "center", justifyContent: "space-between" }, children: error }),
328
+ /* @__PURE__ */ jsx(
329
+ CpslButton,
330
+ {
331
+ variant: "primary",
332
+ fullWidth: true,
333
+ pending: estimateIsPending || broadcastIsPending,
334
+ disabled: estimateIsPending || broadcastIsPending || !((_j = estimate == null ? void 0 : estimate.result) == null ? void 0 : _j.txSerialized) || !!(estimate == null ? void 0 : estimate.error),
335
+ onClick: onSubmit,
336
+ children: "Confirm Send"
337
+ }
338
+ )
339
+ ] });
340
+ }
341
+ export {
342
+ AccountSendForm
343
+ };
@@ -0,0 +1 @@
1
+ export declare function AccountSendNetwork(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../../../../chunk-MMUBH76A.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { useMemo } from "react";
8
+ import { useAssets } from "../../../../provider/providers/AssetsProvider.js";
9
+ import { SearchableButtonList } from "../../SearchableButtonList.js";
10
+ import { useSend } from "./context.js";
11
+ import { formatAssetQuantity, formatCurrency } from "@getpara/web-sdk";
12
+ import { ModalStep } from "../../../utils/steps.js";
13
+ import { useModalStore } from "../../../stores/index.js";
14
+ import { AssetNetwork } from "./AssetNetwork.js";
15
+ function AccountSendNetwork() {
16
+ const setStep = useModalStore((state) => state.setStep);
17
+ const { profileBalance } = useAssets();
18
+ const { sendMetadata, setSendMetadata } = useSend();
19
+ const assetNetworks = useMemo(() => {
20
+ var _a, _b;
21
+ return (_b = (_a = sendMetadata.asset) == null ? void 0 : _a.networks) != null ? _b : [];
22
+ }, [profileBalance, sendMetadata.asset]);
23
+ return /* @__PURE__ */ jsx("div", { style: { width: "100%", maxHeight: "480px" }, children: /* @__PURE__ */ jsx(
24
+ SearchableButtonList,
25
+ {
26
+ items: assetNetworks,
27
+ transformItem: (item) => {
28
+ return {
29
+ key: item.metadata.zerionId,
30
+ icon: /* @__PURE__ */ jsx(AssetNetwork, { assetSrc: sendMetadata.asset.metadata.logoUrl, networkSrc: item.metadata.logoUrl, size: 48 }),
31
+ text: sendMetadata.asset.metadata.symbol,
32
+ textSecondary: item.metadata.name,
33
+ endText: formatAssetQuantity({ quantity: item.quantity, symbol: sendMetadata.asset.metadata.symbol }),
34
+ endTextSecondary: formatCurrency(item.value)
35
+ };
36
+ },
37
+ searchPlaceholder: "Search for a network",
38
+ searchFilter: ({ item, searchStr }) => {
39
+ var _a, _b, _c;
40
+ return (_c = (_b = (_a = item.metadata) == null ? void 0 : _a.name) == null ? void 0 : _b.toLowerCase().includes(searchStr.toLowerCase())) != null ? _c : false;
41
+ },
42
+ onSelect: (item) => {
43
+ setSendMetadata((prev) => __spreadProps(__spreadValues({}, prev), {
44
+ network: item
45
+ }));
46
+ setStep(ModalStep.ACCOUNT_SEND);
47
+ }
48
+ }
49
+ ) });
50
+ }
51
+ export {
52
+ AccountSendNetwork
53
+ };
@@ -0,0 +1 @@
1
+ export declare function AccountSendNoAssets(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import "../../../../chunk-MMUBH76A.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslText } from "@getpara/react-components";
5
+ import { useModalStore } from "../../../stores/index.js";
6
+ import { ModalStep } from "../../../utils/steps.js";
7
+ function AccountSendNoAssets() {
8
+ const onRampConfig = useModalStore((state) => state.onRampConfig);
9
+ const setStep = useModalStore((state) => state.setStep);
10
+ return /* @__PURE__ */ jsxs(
11
+ "div",
12
+ {
13
+ style: {
14
+ display: "flex",
15
+ flexDirection: "column",
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ height: "308px",
19
+ textAlign: "center"
20
+ },
21
+ children: [
22
+ /* @__PURE__ */ jsxs(
23
+ "div",
24
+ {
25
+ style: {
26
+ display: "flex",
27
+ flexDirection: "column",
28
+ alignItems: "center",
29
+ justifyContent: "center",
30
+ gap: "4px",
31
+ flexGrow: 1
32
+ },
33
+ children: [
34
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyL", color: "primary", weight: "semiBold", children: "No Funds Available" }),
35
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", children: "Switch to a wallet with funds or buy crypto with this wallet." })
36
+ ]
37
+ }
38
+ ),
39
+ (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) && /* @__PURE__ */ jsx(
40
+ CpslButton,
41
+ {
42
+ fullWidth: true,
43
+ variant: "primary",
44
+ onClick: () => {
45
+ setStep(ModalStep.ADD_FUNDS_BUY);
46
+ },
47
+ children: "Buy"
48
+ }
49
+ )
50
+ ]
51
+ }
52
+ );
53
+ }
54
+ export {
55
+ AccountSendNoAssets
56
+ };