@getpara/react-sdk-lite 2.10.0 → 2.11.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 +3 -1
  2. package/dist/modal/components/Account/Account.js +114 -22
  3. package/dist/modal/components/Account/AccountMonitorTx.d.ts +1 -0
  4. package/dist/modal/components/Account/AccountMonitorTx.js +256 -0
  5. package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +2 -2
  6. package/dist/modal/components/Account/AccountSend/AccountSendForm.js +68 -10
  7. package/dist/modal/components/Account/AccountSend/context.d.ts +2 -0
  8. package/dist/modal/components/Account/AccountSend/context.js +36 -109
  9. package/dist/modal/components/AddFunds/AddFundsContext.js +70 -25
  10. package/dist/modal/components/AddFunds/AddFundsReceive.js +1 -1
  11. package/dist/modal/components/AddFunds/AddFundsSettings.js +134 -29
  12. package/dist/modal/components/Body/Body.js +4 -0
  13. package/dist/modal/components/ErrorBoundary.d.ts +20 -0
  14. package/dist/modal/components/ErrorBoundary.js +27 -0
  15. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +3 -8
  16. package/dist/modal/components/common.d.ts +5 -1
  17. package/dist/modal/components/common.js +27 -1
  18. package/dist/modal/hooks/index.d.ts +1 -0
  19. package/dist/modal/hooks/index.js +1 -0
  20. package/dist/modal/hooks/useSendMutations.d.ts +51 -0
  21. package/dist/modal/hooks/useSendMutations.js +170 -0
  22. package/dist/modal/hooks/useTransactionMonitoring.d.ts +1 -0
  23. package/dist/modal/hooks/useTransactionMonitoring.js +175 -0
  24. package/dist/modal/index.d.ts +1 -1
  25. package/dist/modal/index.js +1 -1
  26. package/dist/modal/stores/index.d.ts +1 -0
  27. package/dist/modal/stores/index.js +1 -0
  28. package/dist/modal/stores/modal/actions.js +0 -1
  29. package/dist/modal/stores/modal/useModalSessionStore.d.ts +28 -0
  30. package/dist/modal/stores/modal/useModalSessionStore.js +26 -0
  31. package/dist/modal/stores/modal/useModalStore.d.ts +1 -3
  32. package/dist/modal/stores/modal/useModalStore.js +0 -1
  33. package/dist/modal/utils/onramps.d.ts +61 -0
  34. package/dist/modal/utils/onramps.js +112 -0
  35. package/dist/modal/utils/steps.d.ts +4 -2
  36. package/dist/modal/utils/steps.js +6 -2
  37. package/dist/provider/hooks/utils/useEventListeners.js +2 -2
  38. package/package.json +9 -8
  39. package/dist/modal/utils/validateOnRampConfig.d.ts +0 -5
  40. package/dist/modal/utils/validateOnRampConfig.js +0 -32
@@ -0,0 +1,61 @@
1
+ import { OnRampConfig, OnRampProvider, OnRampPurchaseType, TNetwork, TOnRampAsset, TWalletType } from '@getpara/web-sdk';
2
+ export declare class OnRampConfigError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * Provider-specific transaction amount limits (in USD).
7
+ * These limits are enforced client-side to prevent users from selecting
8
+ * providers that don't support their desired transaction amount.
9
+ *
10
+ * Last verified: February 2025
11
+ * Sources:
12
+ * - MoonPay: https://support.moonpay.com/customers/docs/moonpay-transaction-limits
13
+ * - Stripe: https://docs.stripe.com/crypto/using-the-dashboard#onramp-minimums-and-maximums
14
+ * - Ramp: https://support.ramp.network/en/articles/471-transaction-limits
15
+ */
16
+ export declare const PROVIDER_LIMITS: Record<OnRampProvider, Record<OnRampPurchaseType, {
17
+ min: number | null;
18
+ max: number | null;
19
+ }>>;
20
+ export declare function validateOnRampConfig(obj?: OnRampConfig): obj is OnRampConfig;
21
+ /**
22
+ * Gets a default asset and network combination that are guaranteed to work together.
23
+ *
24
+ * When preferredAsset is provided:
25
+ * - Locks in that asset and finds the best compatible network
26
+ * - Returns { asset: preferredAsset, network: <compatible network> }
27
+ *
28
+ * When preferredAsset is not provided:
29
+ * - Finds the best asset+network combination
30
+ * - Priority order:
31
+ * 1. Partner's defaults (if both are valid together)
32
+ * 2. Wallet-type-specific combo (COSMOS→ATOM on COSMOS, SOLANA→SOL on SOLANA, etc.)
33
+ * 3. First valid asset+network combination from available lists
34
+ *
35
+ * @param params - Configuration object
36
+ * @param params.walletType - The wallet type (EVM, SOLANA, COSMOS)
37
+ * @param params.onRampConfig - OnRamp configuration
38
+ * @param params.networks - Available networks (from getOnRampNetworks)
39
+ * @param params.assets - Available assets (from assets calculation)
40
+ * @param params.preferredAsset - Optional asset to lock in (will only find compatible network)
41
+ * @returns Object with asset and network, both null if no valid combination exists
42
+ */
43
+ export declare function getDefaultAssetAndNetwork({ walletType, onRampConfig, networks, assets, preferredAsset, }: {
44
+ walletType: TWalletType | undefined;
45
+ onRampConfig: OnRampConfig | undefined;
46
+ networks: TNetwork[];
47
+ assets: TOnRampAsset[];
48
+ preferredAsset?: TOnRampAsset | null;
49
+ }): {
50
+ asset: TOnRampAsset | null;
51
+ network: TNetwork | null;
52
+ };
53
+ /**
54
+ * Checks if an amount falls within the provider's limits for a given operation type.
55
+ * @param amount - The amount to check (can be undefined for invalid inputs)
56
+ * @param provider - The provider to check limits for
57
+ * @param type - The transaction type (BUY or SELL)
58
+ * @param limits - Optional provider limits object (defaults to PROVIDER_LIMITS)
59
+ * @returns true if the amount is within limits, false otherwise
60
+ */
61
+ export declare function isAmountWithinProviderLimits(amount: number | undefined, provider: OnRampProvider, type: OnRampPurchaseType, limits?: typeof PROVIDER_LIMITS): boolean;
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import "../../chunk-MMUBH76A.js";
3
+ import { OnRampProvider, OnRampPurchaseType } from "@getpara/web-sdk";
4
+ class OnRampConfigError extends Error {
5
+ constructor(message) {
6
+ super(`On-ramp configuration error: ${message}.`);
7
+ this.name = "OnRampConfigError";
8
+ }
9
+ }
10
+ const PROVIDER_LIMITS = {
11
+ [OnRampProvider.MOONPAY]: {
12
+ [OnRampPurchaseType.BUY]: { min: 20, max: 3e4 },
13
+ [OnRampPurchaseType.SELL]: { min: 20, max: 1e4 }
14
+ },
15
+ [OnRampProvider.STRIPE]: {
16
+ [OnRampPurchaseType.BUY]: { min: 0.5, max: null },
17
+ [OnRampPurchaseType.SELL]: { min: 0.5, max: null }
18
+ },
19
+ [OnRampProvider.RAMP]: {
20
+ [OnRampPurchaseType.BUY]: { min: null, max: null },
21
+ [OnRampPurchaseType.SELL]: { min: null, max: null }
22
+ }
23
+ };
24
+ function checkHasProviders({ providers }) {
25
+ if (!providers || providers.length < 1) {
26
+ throw new OnRampConfigError("No providers are configured");
27
+ }
28
+ }
29
+ function checkDuplicateProviders({ providers }) {
30
+ if (!providers) return;
31
+ providers.forEach((id, index) => {
32
+ if (providers.findIndex((p) => p === id) !== index) {
33
+ throw new OnRampConfigError(`Provider ${id} is configured more than once`);
34
+ }
35
+ });
36
+ }
37
+ function validateOnRampConfig(obj) {
38
+ if (!obj) {
39
+ return false;
40
+ }
41
+ checkHasProviders(obj);
42
+ checkDuplicateProviders(obj);
43
+ return true;
44
+ }
45
+ function getDefaultAssetAndNetwork({
46
+ walletType,
47
+ onRampConfig,
48
+ networks,
49
+ assets,
50
+ preferredAsset
51
+ }) {
52
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
53
+ if (!walletType || !onRampConfig || networks.length === 0 || assets.length === 0) {
54
+ return { asset: null, network: null };
55
+ }
56
+ if (preferredAsset && assets.includes(preferredAsset)) {
57
+ if (onRampConfig.defaultOnRampNetwork && networks.includes(onRampConfig.defaultOnRampNetwork) && ((_c = (_b = (_a = onRampConfig.assetInfo) == null ? void 0 : _a[walletType]) == null ? void 0 : _b[onRampConfig.defaultOnRampNetwork]) == null ? void 0 : _c[preferredAsset])) {
58
+ return { asset: preferredAsset, network: onRampConfig.defaultOnRampNetwork };
59
+ }
60
+ const preferredNetwork = walletType === "COSMOS" ? "COSMOS" : walletType === "SOLANA" ? "SOLANA" : "ETHEREUM";
61
+ if (networks.includes(preferredNetwork) && ((_f = (_e = (_d = onRampConfig.assetInfo) == null ? void 0 : _d[walletType]) == null ? void 0 : _e[preferredNetwork]) == null ? void 0 : _f[preferredAsset])) {
62
+ return { asset: preferredAsset, network: preferredNetwork };
63
+ }
64
+ const supportedNetwork = networks.find((network) => {
65
+ var _a2, _b2, _c2;
66
+ return !!((_c2 = (_b2 = (_a2 = onRampConfig.assetInfo) == null ? void 0 : _a2[walletType]) == null ? void 0 : _b2[network]) == null ? void 0 : _c2[preferredAsset]);
67
+ });
68
+ if (supportedNetwork) {
69
+ return { asset: preferredAsset, network: supportedNetwork };
70
+ }
71
+ return { asset: preferredAsset, network: null };
72
+ }
73
+ const partnerAsset = onRampConfig.defaultOnRampAsset;
74
+ const partnerNetwork = onRampConfig.defaultOnRampNetwork;
75
+ if (partnerAsset && partnerNetwork && assets.includes(partnerAsset) && networks.includes(partnerNetwork) && ((_i = (_h = (_g = onRampConfig.assetInfo) == null ? void 0 : _g[walletType]) == null ? void 0 : _h[partnerNetwork]) == null ? void 0 : _i[partnerAsset])) {
76
+ return { asset: partnerAsset, network: partnerNetwork };
77
+ }
78
+ const walletTypeAsset = walletType === "COSMOS" ? "ATOM" : walletType === "SOLANA" ? "SOLANA" : "ETHEREUM";
79
+ const walletTypeNetwork = walletType === "COSMOS" ? "COSMOS" : walletType === "SOLANA" ? "SOLANA" : "ETHEREUM";
80
+ if (assets.includes(walletTypeAsset) && networks.includes(walletTypeNetwork) && ((_l = (_k = (_j = onRampConfig.assetInfo) == null ? void 0 : _j[walletType]) == null ? void 0 : _k[walletTypeNetwork]) == null ? void 0 : _l[walletTypeAsset])) {
81
+ return { asset: walletTypeAsset, network: walletTypeNetwork };
82
+ }
83
+ for (const testAsset of assets) {
84
+ if (networks.includes(walletTypeNetwork) && ((_o = (_n = (_m = onRampConfig.assetInfo) == null ? void 0 : _m[walletType]) == null ? void 0 : _n[walletTypeNetwork]) == null ? void 0 : _o[testAsset])) {
85
+ return { asset: testAsset, network: walletTypeNetwork };
86
+ }
87
+ const validNetwork = networks.find((network) => {
88
+ var _a2, _b2, _c2;
89
+ return !!((_c2 = (_b2 = (_a2 = onRampConfig.assetInfo) == null ? void 0 : _a2[walletType]) == null ? void 0 : _b2[network]) == null ? void 0 : _c2[testAsset]);
90
+ });
91
+ if (validNetwork) {
92
+ return { asset: testAsset, network: validNetwork };
93
+ }
94
+ }
95
+ return { asset: null, network: null };
96
+ }
97
+ function isAmountWithinProviderLimits(amount, provider, type, limits = PROVIDER_LIMITS) {
98
+ if (typeof amount !== "number" || isNaN(amount)) {
99
+ return false;
100
+ }
101
+ const { min, max } = limits[provider][type];
102
+ if (min !== null && amount < min) return false;
103
+ if (max !== null && amount > max) return false;
104
+ return true;
105
+ }
106
+ export {
107
+ OnRampConfigError,
108
+ PROVIDER_LIMITS,
109
+ getDefaultAssetAndNetwork,
110
+ isAmountWithinProviderLimits,
111
+ validateOnRampConfig
112
+ };
@@ -50,7 +50,8 @@ export declare enum ModalStep {
50
50
  LINK_EX_WALLET_NETWORK_SELECT = "LINK_EX_WALLET_NETWORK_SELECT",
51
51
  ACCOUNT_SEND = "ACCOUNT_SEND",
52
52
  ACCOUNT_SEND_ASSET = "ACCOUNT_SEND_ASSET",
53
- ACCOUNT_SEND_NETWORK = "ACCOUNT_SEND_NETWORK"
53
+ ACCOUNT_SEND_NETWORK = "ACCOUNT_SEND_NETWORK",
54
+ ACCOUNT_MONITOR_TX = "ACCOUNT_MONITOR_TX"
54
55
  }
55
56
  export type ModalStepPropU = keyof typeof ModalStep | ModalStep;
56
57
  export type ModalStepPropL = Lowercase<ModalStepPropU>;
@@ -79,7 +80,8 @@ declare enum AccountStep {
79
80
  LINK_EX_WALLET_NETWORK_SELECT = "LINK_EX_WALLET_NETWORK_SELECT",
80
81
  ACCOUNT_SEND = "ACCOUNT_SEND",
81
82
  ACCOUNT_SEND_ASSET = "ACCOUNT_SEND_ASSET",
82
- ACCOUNT_SEND_NETWORK = "ACCOUNT_SEND_NETWORK"
83
+ ACCOUNT_SEND_NETWORK = "ACCOUNT_SEND_NETWORK",
84
+ ACCOUNT_MONITOR_TX = "ACCOUNT_MONITOR_TX"
83
85
  }
84
86
  export declare const RESET_TO_AUTH_STEPS: ModalStep[];
85
87
  export declare const RESET_TO_ACCOUNT_STEPS: ModalStep[];
@@ -52,6 +52,7 @@ var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
52
52
  ModalStep2["ACCOUNT_SEND"] = "ACCOUNT_SEND";
53
53
  ModalStep2["ACCOUNT_SEND_ASSET"] = "ACCOUNT_SEND_ASSET";
54
54
  ModalStep2["ACCOUNT_SEND_NETWORK"] = "ACCOUNT_SEND_NETWORK";
55
+ ModalStep2["ACCOUNT_MONITOR_TX"] = "ACCOUNT_MONITOR_TX";
55
56
  return ModalStep2;
56
57
  })(ModalStep || {});
57
58
  var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
@@ -79,6 +80,7 @@ var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
79
80
  AccountStep2["ACCOUNT_SEND"] = "ACCOUNT_SEND";
80
81
  AccountStep2["ACCOUNT_SEND_ASSET"] = "ACCOUNT_SEND_ASSET";
81
82
  AccountStep2["ACCOUNT_SEND_NETWORK"] = "ACCOUNT_SEND_NETWORK";
83
+ AccountStep2["ACCOUNT_MONITOR_TX"] = "ACCOUNT_MONITOR_TX";
82
84
  return AccountStep2;
83
85
  })(AccountStep || {});
84
86
  const RESET_TO_AUTH_STEPS = [
@@ -129,7 +131,8 @@ const RESET_TO_ACCOUNT_STEPS = [
129
131
  "ADD_EX_WALLET_SELECTED" /* ADD_EX_WALLET_SELECTED */,
130
132
  "ADD_EX_WALLET_NETWORK_SELECT" /* ADD_EX_WALLET_NETWORK_SELECT */,
131
133
  "LINK_EX_WALLET_NETWORK_SELECT" /* LINK_EX_WALLET_NETWORK_SELECT */,
132
- "EXTERNAL_WALLET_VERIFICATION" /* EXTERNAL_WALLET_VERIFICATION */
134
+ "EXTERNAL_WALLET_VERIFICATION" /* EXTERNAL_WALLET_VERIFICATION */,
135
+ "ACCOUNT_MONITOR_TX" /* ACCOUNT_MONITOR_TX */
133
136
  ];
134
137
  const AccountPreviousStep = {
135
138
  ["ACCOUNT_MAIN" /* ACCOUNT_MAIN */]: void 0,
@@ -155,7 +158,8 @@ const AccountPreviousStep = {
155
158
  ["LINK_EX_WALLET_NETWORK_SELECT" /* LINK_EX_WALLET_NETWORK_SELECT */]: "ACCOUNT_PROFILE_LIST" /* ACCOUNT_PROFILE_LIST */,
156
159
  ["ACCOUNT_SEND" /* ACCOUNT_SEND */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */,
157
160
  ["ACCOUNT_SEND_ASSET" /* ACCOUNT_SEND_ASSET */]: "ACCOUNT_SEND" /* ACCOUNT_SEND */,
158
- ["ACCOUNT_SEND_NETWORK" /* ACCOUNT_SEND_NETWORK */]: "ACCOUNT_SEND_ASSET" /* ACCOUNT_SEND_ASSET */
161
+ ["ACCOUNT_SEND_NETWORK" /* ACCOUNT_SEND_NETWORK */]: "ACCOUNT_SEND_ASSET" /* ACCOUNT_SEND_ASSET */,
162
+ ["ACCOUNT_MONITOR_TX" /* ACCOUNT_MONITOR_TX */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */
159
163
  };
160
164
  var SignUpModalStep = /* @__PURE__ */ ((SignUpModalStep2) => {
161
165
  SignUpModalStep2["AUTH_MAIN"] = "AUTH_MAIN";
@@ -11,7 +11,7 @@ import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
11
11
  import { WALLET_BASE_KEY } from "../queries/useWallet.js";
12
12
  import { WALLET_BALANCE_BASE_KEY } from "../queries/useWalletBalance.js";
13
13
  import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../queries/useIsFullyLoggedIn.js";
14
- import { useModalStore } from "../../../modal/stores/index.js";
14
+ import { useModalSessionStore } from "../../../modal/stores/index.js";
15
15
  const useEventListeners = ({
16
16
  onLogin,
17
17
  onLogout,
@@ -29,7 +29,7 @@ const useEventListeners = ({
29
29
  const refs = useStore((state) => state.refs);
30
30
  const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
31
31
  const { updateSelectedWallet } = useWalletState();
32
- const setSendTx = useModalStore((state) => state.setSendTx);
32
+ const setSendTx = useModalSessionStore((state) => state.setSendTx);
33
33
  const loginOrSetupListener = useCallback(() => {
34
34
  queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
35
35
  queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
package/package.json CHANGED
@@ -1,24 +1,25 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.10.0",
9
- "@getpara/react-components": "2.10.0",
10
- "@getpara/web-sdk": "2.10.0",
8
+ "@getpara/react-common": "2.11.0",
9
+ "@getpara/react-components": "2.11.0",
10
+ "@getpara/web-sdk": "2.11.0",
11
11
  "date-fns": "^3.6.0",
12
12
  "framer-motion": "^11.3.31",
13
13
  "libphonenumber-js": "^1.11.7",
14
+ "socket.io-client": "^4.5.1",
14
15
  "styled-components": "^6.1.8",
15
16
  "zustand": "^4.5.2",
16
17
  "zustand-sync-tabs": "^0.2.2"
17
18
  },
18
19
  "devDependencies": {
19
- "@getpara/cosmos-wallet-connectors": "2.10.0",
20
- "@getpara/evm-wallet-connectors": "2.10.0",
21
- "@getpara/solana-wallet-connectors": "2.10.0",
20
+ "@getpara/cosmos-wallet-connectors": "2.11.0",
21
+ "@getpara/evm-wallet-connectors": "2.11.0",
22
+ "@getpara/solana-wallet-connectors": "2.11.0",
22
23
  "@tanstack/react-query": "^5.74.0",
23
24
  "@testing-library/dom": "^10.4.0",
24
25
  "@testing-library/react": "^16.3.0",
@@ -38,7 +39,7 @@
38
39
  "package.json",
39
40
  "styles.css"
40
41
  ],
41
- "gitHead": "8da2c51cc91f021acbc2ec7373b9ca0638fc840a",
42
+ "gitHead": "1cce45857320460cca03c4a9d0a59db169b222d6",
42
43
  "main": "dist/index.js",
43
44
  "peerDependencies": {
44
45
  "@tanstack/react-query": ">=5.0.0",
@@ -1,5 +0,0 @@
1
- import { OnRampConfig } from '@getpara/web-sdk';
2
- export declare class OnRampConfigError extends Error {
3
- constructor(message: any);
4
- }
5
- export declare function validateOnRampConfig(obj?: OnRampConfig): obj is OnRampConfig;
@@ -1,32 +0,0 @@
1
- "use client";
2
- import "../../chunk-MMUBH76A.js";
3
- class OnRampConfigError extends Error {
4
- constructor(message) {
5
- super(`On-ramp configuration error: ${message}.`);
6
- this.name = "OnRampConfigError";
7
- }
8
- }
9
- function checkHasProviders({ providers }) {
10
- if (!providers || providers.length < 1) {
11
- throw new OnRampConfigError("No providers are configured");
12
- }
13
- }
14
- function checkDuplicateProviders({ providers }) {
15
- providers.forEach((id, index) => {
16
- if (providers.findIndex((p) => p === id) !== index) {
17
- throw new OnRampConfigError(`Provider ${id} is configured more than once`);
18
- }
19
- });
20
- }
21
- function validateOnRampConfig(obj) {
22
- if (!obj) {
23
- return false;
24
- }
25
- checkHasProviders(obj);
26
- checkDuplicateProviders(obj);
27
- return true;
28
- }
29
- export {
30
- OnRampConfigError,
31
- validateOnRampConfig
32
- };