@getpara/react-sdk-lite 2.10.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/modal/ParaModal.js +14 -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 +50 -110
  9. package/dist/modal/components/Account/AccountWallet.js +1 -6
  10. package/dist/modal/components/Account/AccountWalletSelect.js +5 -12
  11. package/dist/modal/components/AddFunds/AddFundsContext.js +70 -25
  12. package/dist/modal/components/AddFunds/AddFundsReceive.js +1 -1
  13. package/dist/modal/components/AddFunds/AddFundsSettings.js +134 -29
  14. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +1 -1
  15. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +25 -17
  16. package/dist/modal/components/AuthOptions/AuthOptions.js +1 -1
  17. package/dist/modal/components/Body/Body.js +4 -0
  18. package/dist/modal/components/Controls/ChainSelect.js +2 -3
  19. package/dist/modal/components/ErrorBoundary.d.ts +20 -0
  20. package/dist/modal/components/ErrorBoundary.js +27 -0
  21. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +1 -1
  22. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +3 -8
  23. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +6 -13
  24. package/dist/modal/components/common.d.ts +10 -1
  25. package/dist/modal/components/common.js +44 -11
  26. package/dist/modal/hooks/index.d.ts +1 -0
  27. package/dist/modal/hooks/index.js +1 -0
  28. package/dist/modal/hooks/useFarcasterLogin.js +1 -1
  29. package/dist/modal/hooks/useSendMutations.d.ts +51 -0
  30. package/dist/modal/hooks/useSendMutations.js +170 -0
  31. package/dist/modal/hooks/useTelegramLogin.js +1 -1
  32. package/dist/modal/hooks/useTransactionMonitoring.d.ts +1 -0
  33. package/dist/modal/hooks/useTransactionMonitoring.js +175 -0
  34. package/dist/modal/index.d.ts +1 -1
  35. package/dist/modal/index.js +1 -1
  36. package/dist/modal/stores/index.d.ts +1 -0
  37. package/dist/modal/stores/index.js +1 -0
  38. package/dist/modal/stores/modal/actions.js +0 -1
  39. package/dist/modal/stores/modal/useModalSessionStore.d.ts +28 -0
  40. package/dist/modal/stores/modal/useModalSessionStore.js +26 -0
  41. package/dist/modal/stores/modal/useModalStore.d.ts +2 -3
  42. package/dist/modal/stores/modal/useModalStore.js +2 -2
  43. package/dist/modal/utils/onramps.d.ts +61 -0
  44. package/dist/modal/utils/onramps.js +112 -0
  45. package/dist/modal/utils/steps.d.ts +4 -2
  46. package/dist/modal/utils/steps.js +6 -2
  47. package/dist/provider/hooks/mutations/utils.js +1 -1
  48. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +1 -1
  49. package/dist/provider/hooks/utils/useEventListeners.js +2 -2
  50. package/dist/provider/hooks/utils/useModal.d.ts +2 -1
  51. package/dist/provider/hooks/utils/useModal.js +10 -3
  52. package/dist/provider/providers/ExternalWalletProvider.js +2 -2
  53. package/package.json +9 -8
  54. package/dist/modal/utils/validateOnRampConfig.d.ts +0 -5
  55. package/dist/modal/utils/validateOnRampConfig.js +0 -32
@@ -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";
@@ -17,7 +17,7 @@ function generateInternalMutation(method, action, {
17
17
  mutationFn: (args) => __async(this, null, function* () {
18
18
  if (typeof delay === "number") yield new Promise((resolve) => setTimeout(resolve, delay));
19
19
  try {
20
- const result = yield action(para, args != null ? args : defaultParams);
20
+ const result = action(para, args != null ? args : defaultParams);
21
21
  return result;
22
22
  } catch (error) {
23
23
  throw error;
@@ -27,7 +27,7 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
27
27
  }, [client, embedded, disabled]);
28
28
  const getSessionExpiry = () => __async(void 0, null, function* () {
29
29
  try {
30
- const sessionCookie = yield client == null ? void 0 : client.retrieveSessionCookie();
30
+ const sessionCookie = client == null ? void 0 : client.retrieveSessionCookie();
31
31
  if (!sessionCookie) return null;
32
32
  const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
33
33
  return expiresMatch ? new Date(expiresMatch[1]) : null;
@@ -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] });
@@ -4,8 +4,9 @@ import { ModalStep } from '../../../modal/index.js';
4
4
  */
5
5
  export declare const useModal: () => {
6
6
  isOpen: boolean;
7
- openModal: ({ step }?: {
7
+ openModal: ({ step, defaultAuthIdentifier }?: {
8
8
  step?: ModalStep;
9
+ defaultAuthIdentifier?: string;
9
10
  }) => void;
10
11
  closeModal: () => void;
11
12
  };
@@ -1,13 +1,20 @@
1
1
  "use client";
2
- import "../../../chunk-MMUBH76A.js";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../../../chunk-MMUBH76A.js";
3
6
  import { useModalStore } from "../../../modal/stores/index.js";
4
- import { useStore } from "../../stores/useStore.js";
7
+ import { useStore, vanillaStore } from "../../stores/useStore.js";
5
8
  const useModal = () => {
6
9
  const isOpen = useStore((state) => state.isOpen);
7
10
  const setIsOpen = useStore((state) => state.setIsOpen);
8
11
  const refs = useStore((state) => state.refs);
9
12
  const setStep = useModalStore((state) => state.setStep);
10
- const openModal = ({ step } = {}) => {
13
+ const openModal = ({ step, defaultAuthIdentifier } = {}) => {
14
+ if (defaultAuthIdentifier !== void 0) {
15
+ const { modalConfig, setModalConfig } = vanillaStore.getState();
16
+ setModalConfig(__spreadProps(__spreadValues({}, modalConfig), { defaultAuthIdentifier }));
17
+ }
11
18
  if (step) {
12
19
  refs.openedToStep.current = step;
13
20
  setStep(step);
@@ -352,7 +352,7 @@ function ExternalWalletProvider({ children }) {
352
352
  const d = yield verifyExternalWalletAsync(verifyExternalWalletParams);
353
353
  yield queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
354
354
  if (wallet2 && isWithFullAuth(wallet2)) {
355
- yield onNewAuthState(d);
355
+ onNewAuthState(d);
356
356
  } else {
357
357
  setStep(ModalStep.LOGIN_DONE);
358
358
  }
@@ -500,7 +500,7 @@ function ExternalWalletProvider({ children }) {
500
500
  const serverAuthState = (_b = event.data) == null ? void 0 : _b.serverAuthState;
501
501
  if (serverAuthState && ((_c = serverAuthState.externalWallet) == null ? void 0 : _c.withFullParaAuth)) {
502
502
  const authState = yield para.verifyExternalWallet({ serverAuthState });
503
- yield onNewAuthState(authState);
503
+ onNewAuthState(authState);
504
504
  } else {
505
505
  setStep(ModalStep.LOGIN_DONE);
506
506
  }
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.12.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.12.0",
9
+ "@getpara/react-components": "2.12.0",
10
+ "@getpara/web-sdk": "2.12.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.12.0",
21
+ "@getpara/evm-wallet-connectors": "2.12.0",
22
+ "@getpara/solana-wallet-connectors": "2.12.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": "09c114d148f7a0c2ad250d6346a76aa3b332b2d4",
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
- };