@getpara/react-sdk-lite 2.0.0-dev.6 → 2.0.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 (172) hide show
  1. package/dist/cli/cli.mjs +26 -1
  2. package/dist/modal/ParaModal.js +16 -11
  3. package/dist/modal/components/Account/Account.js +42 -4
  4. package/dist/modal/components/Account/AccountHeader.js +10 -16
  5. package/dist/modal/components/Account/AccountProfile.d.ts +1 -1
  6. package/dist/modal/components/Account/AccountProfile.js +82 -210
  7. package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
  8. package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
  9. package/dist/modal/components/Account/AccountProfileLinkOptions.js +15 -4
  10. package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +1 -0
  11. package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +94 -0
  12. package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +1 -0
  13. package/dist/modal/components/Account/AccountSend/AccountSendForm.js +343 -0
  14. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +1 -0
  15. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.js +53 -0
  16. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +1 -0
  17. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.js +56 -0
  18. package/dist/modal/components/Account/AccountSend/AssetNetwork.d.ts +5 -0
  19. package/dist/modal/components/Account/AccountSend/AssetNetwork.js +36 -0
  20. package/dist/modal/components/Account/AccountSend/context.d.ts +38 -0
  21. package/dist/modal/components/Account/AccountSend/context.js +418 -0
  22. package/dist/modal/components/Account/AccountSend/index.d.ts +4 -0
  23. package/dist/modal/components/Account/AccountSend/index.js +67 -0
  24. package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
  25. package/dist/modal/components/Account/AccountWallet.js +133 -0
  26. package/dist/modal/components/{WalletSelect/WalletSelect.d.ts → Account/AccountWalletSelect.d.ts} +1 -1
  27. package/dist/modal/components/{WalletSelect/WalletSelect.js → Account/AccountWalletSelect.js} +20 -6
  28. package/dist/modal/components/AddFunds/AddFunds.js +3 -2
  29. package/dist/modal/components/AddFunds/AddFundsAsset.js +7 -6
  30. package/dist/modal/components/AddFunds/AddFundsContext.d.ts +5 -5
  31. package/dist/modal/components/AddFunds/AddFundsProvider.js +1 -2
  32. package/dist/modal/components/AddFunds/AddFundsSettings.js +13 -54
  33. package/dist/modal/components/AddFunds/common.d.ts +0 -14
  34. package/dist/modal/components/AddFunds/common.js +1 -8
  35. package/dist/modal/components/AuthInput/AuthInput.js +2 -2
  36. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +10 -1
  37. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +8 -33
  38. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +5 -2
  39. package/dist/modal/components/Body/Body.js +81 -48
  40. package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -5
  41. package/dist/modal/components/Controls/ChainSelect.js +1 -2
  42. package/dist/modal/components/Controls/Controls.js +1 -0
  43. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +5 -1
  44. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +48 -19
  45. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +5 -2
  46. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +63 -33
  47. package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +3 -1
  48. package/dist/modal/components/ExternalWallets/ExternalWallets.js +22 -12
  49. package/dist/modal/components/Footer/Footer.js +4 -5
  50. package/dist/modal/components/Header/Header.js +1 -2
  51. package/dist/modal/components/Header/hooks/useStepTitle.js +53 -37
  52. package/dist/modal/components/Hero/Hero.js +5 -3
  53. package/dist/modal/components/IFrameStep/IFrameStep.js +13 -12
  54. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +4 -1
  55. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
  56. package/dist/modal/components/OAuth/TelegramOAuthStep.js +34 -18
  57. package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
  58. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +1 -2
  59. package/dist/modal/components/QuantityInput.d.ts +9 -0
  60. package/dist/modal/components/QuantityInput.js +91 -0
  61. package/dist/modal/components/SearchableButtonList.d.ts +34 -0
  62. package/dist/modal/components/SearchableButtonList.js +223 -0
  63. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -1
  64. package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.d.ts +1 -0
  65. package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.js +10 -0
  66. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +13 -2
  67. package/dist/modal/components/Waiting/Waiting.d.ts +1 -1
  68. package/dist/modal/components/Waiting/Waiting.js +7 -2
  69. package/dist/modal/components/WalletCard/WalletCard.js +2 -3
  70. package/dist/modal/components/WalletSelectOld/WalletSelectOld.d.ts +7 -1
  71. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +33 -12
  72. package/dist/modal/components/common.d.ts +8 -10
  73. package/dist/modal/components/common.js +16 -36
  74. package/dist/modal/hooks/index.d.ts +4 -0
  75. package/dist/modal/hooks/index.js +5 -0
  76. package/dist/modal/hooks/useDebounce.d.ts +4 -0
  77. package/dist/modal/hooks/useDebounce.js +16 -0
  78. package/dist/modal/hooks/useFarcasterLogin.js +8 -1
  79. package/dist/modal/hooks/useTelegramLogin.js +4 -0
  80. package/dist/modal/index.d.ts +1 -1
  81. package/dist/modal/index.js +1 -1
  82. package/dist/modal/stores/modal/actions.js +9 -2
  83. package/dist/modal/stores/modal/useModalStore.d.ts +9 -1
  84. package/dist/modal/stores/modal/useModalStore.js +6 -2
  85. package/dist/modal/types/modalProps.d.ts +5 -1
  86. package/dist/modal/utils/authInputHelpers.js +1 -1
  87. package/dist/modal/utils/countryCodes.js +50 -1
  88. package/dist/modal/utils/getWalletDisplayName.js +1 -1
  89. package/dist/modal/utils/openPopup.d.ts +1 -1
  90. package/dist/modal/utils/openPopup.js +6 -2
  91. package/dist/modal/utils/renderTextWithLinks.d.ts +2 -0
  92. package/dist/modal/utils/renderTextWithLinks.js +34 -0
  93. package/dist/modal/utils/steps.d.ts +24 -3
  94. package/dist/modal/utils/steps.js +51 -5
  95. package/dist/modal/utils/stringFormatters.d.ts +2 -3
  96. package/dist/modal/utils/stringFormatters.js +11 -7
  97. package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
  98. package/dist/modal/utils/validatePortalOrigin.js +14 -0
  99. package/dist/provider/ParaProviderMin.js +13 -5
  100. package/dist/provider/actions/getEmbeddedAccount.d.ts +3 -2
  101. package/dist/provider/actions/getEmbeddedAccount.js +13 -4
  102. package/dist/provider/actions/index.d.ts +11 -9
  103. package/dist/provider/actions/index.js +4 -0
  104. package/dist/provider/components/CosmosWalletWrapper.js +3 -3
  105. package/dist/provider/components/EvmWalletWrapper.js +3 -3
  106. package/dist/provider/components/ExternalWalletWrapper.js +7 -1
  107. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
  108. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
  109. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
  110. package/dist/provider/hooks/mutations/index.d.ts +2 -0
  111. package/dist/provider/hooks/mutations/index.js +4 -0
  112. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +42 -0
  113. package/dist/provider/hooks/mutations/useAddAuthMethod.js +59 -0
  114. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
  115. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
  116. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +5 -5
  117. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
  118. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
  119. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
  120. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
  121. package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +15 -0
  122. package/dist/provider/hooks/mutations/useExportPrivateKey.js +32 -0
  123. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
  124. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
  125. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
  126. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
  127. package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
  128. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
  129. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
  130. package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
  131. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
  132. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
  133. package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +57 -0
  134. package/dist/provider/hooks/mutations/useSwitchWallets.js +30 -0
  135. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
  136. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
  137. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -27
  138. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +5 -5
  139. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +14 -11
  140. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
  141. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +5 -5
  142. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
  143. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
  144. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
  145. package/dist/provider/hooks/queries/index.d.ts +1 -0
  146. package/dist/provider/hooks/queries/index.js +2 -0
  147. package/dist/provider/hooks/queries/useAccount.js +58 -24
  148. package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
  149. package/dist/provider/hooks/queries/useProfileBalance.d.ts +29 -0
  150. package/dist/provider/hooks/queries/useProfileBalance.js +65 -0
  151. package/dist/provider/hooks/utils/useAssetInfo.d.ts +3 -0
  152. package/dist/provider/hooks/utils/useAssetInfo.js +21 -0
  153. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +1 -1
  154. package/dist/provider/hooks/utils/useEventListeners.js +22 -5
  155. package/dist/provider/hooks/utils/useModal.js +3 -3
  156. package/dist/provider/hooks/utils/useWalletState.d.ts +2 -1
  157. package/dist/provider/hooks/utils/useWalletState.js +2 -1
  158. package/dist/provider/providers/AccountLinkProvider.js +18 -11
  159. package/dist/provider/providers/AssetsProvider.d.ts +14 -0
  160. package/dist/provider/providers/AssetsProvider.js +68 -0
  161. package/dist/provider/providers/AuthProvider.d.ts +6 -1
  162. package/dist/provider/providers/AuthProvider.js +204 -44
  163. package/dist/provider/providers/ExternalWalletProvider.d.ts +19 -5
  164. package/dist/provider/providers/ExternalWalletProvider.js +363 -44
  165. package/dist/provider/stores/getters.d.ts +2 -2
  166. package/dist/provider/stores/slices/modal.js +4 -1
  167. package/dist/provider/stores/types.d.ts +6 -3
  168. package/package.json +8 -8
  169. package/dist/modal/constants/constants.d.ts +0 -35
  170. package/dist/modal/constants/constants.js +0 -148
  171. package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
  172. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
@@ -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
+ };
@@ -0,0 +1,5 @@
1
+ export declare function AssetNetwork({ size, assetSrc, networkSrc, }: {
2
+ size?: number;
3
+ assetSrc?: string;
4
+ networkSrc?: string;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import "../../../../chunk-MMUBH76A.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslIcon } from "@getpara/react-components";
5
+ function AssetNetwork({
6
+ size = 40,
7
+ assetSrc,
8
+ networkSrc
9
+ }) {
10
+ return /* @__PURE__ */ jsxs("div", { style: { position: "relative", width: `${size}px`, height: `${size}px` }, children: [
11
+ assetSrc ? /* @__PURE__ */ jsx(CpslIcon, { radius: "full", src: assetSrc, size: `${size}px` }) : /* @__PURE__ */ jsx(
12
+ CpslIcon,
13
+ {
14
+ icon: "coins",
15
+ radius: "full",
16
+ size: `${size}px`,
17
+ inset: `${size / 8}px`,
18
+ color: "var(--cpsl-color-text-contrast)",
19
+ background: "var(--cpsl-color-accent-64)"
20
+ }
21
+ ),
22
+ networkSrc && /* @__PURE__ */ jsx(
23
+ CpslIcon,
24
+ {
25
+ radius: "full",
26
+ src: networkSrc,
27
+ size: `${2 + size * 3 / 8}px`,
28
+ border: "1px solid var(--cpsl-color-background-4)",
29
+ style: { position: "absolute", bottom: 0, right: 0 }
30
+ }
31
+ )
32
+ ] });
33
+ }
34
+ export {
35
+ AssetNetwork
36
+ };
@@ -0,0 +1,38 @@
1
+ import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
2
+ import { AssetValue, BroadcastTransactionResult, EstimateTransactionResult, WalletBalance } from '@getpara/shared';
3
+ export type SendStep = 'SEND_FORM' | 'SEND_ASSET' | 'SEND_NETWORK';
4
+ type SendMetadata = {
5
+ asset: WalletBalance['assets'][number] | null;
6
+ network: WalletBalance['assets'][number]['networks'][number] | null;
7
+ };
8
+ type OptionsType = 'MULTIPLE' | 'SINGLE_ASSET' | 'SINGLE_NETWORK' | 'NONE';
9
+ type Value = {
10
+ step: SendStep;
11
+ sendMetadata: SendMetadata;
12
+ setSendMetadata: Dispatch<SetStateAction<SendMetadata>>;
13
+ assetPrice: AssetValue | null;
14
+ assetValueOnNetwork: AssetValue | null;
15
+ assetAmountOnNetwork: number;
16
+ destinationAddress: string;
17
+ setDestinationAddress: Dispatch<SetStateAction<string>>;
18
+ transferValue: number;
19
+ setTransferValue: Dispatch<SetStateAction<number>>;
20
+ transferAmount: number;
21
+ setTransferAmount: Dispatch<SetStateAction<number>>;
22
+ estimate: EstimateTransactionResult | null;
23
+ isMax: boolean;
24
+ setIsMax: Dispatch<SetStateAction<boolean>>;
25
+ estimateIsPending: boolean;
26
+ estimateIsError: boolean;
27
+ onSubmit: () => void;
28
+ broadcast: BroadcastTransactionResult | null;
29
+ broadcastIsPending: boolean;
30
+ broadcastIsError: boolean;
31
+ optionsType: OptionsType;
32
+ };
33
+ export declare const AccountSendContext: import("react").Context<Value>;
34
+ export declare function AccountSendProvider({ children, step }: PropsWithChildren<{
35
+ step: SendStep;
36
+ }>): import("react/jsx-runtime").JSX.Element;
37
+ export declare const useSend: () => Value;
38
+ export {};