@getpara/react-sdk 2.0.0-alpha.12 → 2.0.0-alpha.13

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.
@@ -2,6 +2,7 @@
2
2
  import {
3
3
  __async,
4
4
  __objRest,
5
+ __spreadProps,
5
6
  __spreadValues
6
7
  } from "../chunk-MMUBH76A.js";
7
8
  import { jsx } from "react/jsx-runtime";
@@ -22,6 +23,7 @@ import { useStore } from "../provider/stores/useStore.js";
22
23
  import parsePhoneNumberFromString from "libphonenumber-js";
23
24
  import { useAuthActions } from "../provider/providers/AuthProvider.js";
24
25
  import { validateAuth } from "./utils/authInputHelpers.js";
26
+ import { SDK_VERSION } from "./constants/constants.js";
25
27
  defineCustomElements();
26
28
  const ParaModal = forwardRef((props, ref) => {
27
29
  const storedModalConfig = useStore((state) => state.modalConfig);
@@ -49,6 +51,7 @@ const ParaModal = forwardRef((props, ref) => {
49
51
  const [isModalMounted, setIsModalMounted] = useState(false);
50
52
  const [isInit, setIsInit] = useState(false);
51
53
  const externalWallets = useStore((state) => state.externalWallets);
54
+ const providerProps = useStore((state) => state.providerProps);
52
55
  const _a = __spreadValues(__spreadValues({}, storedModalConfig), props), {
53
56
  isOpen: configIsOpen,
54
57
  theme,
@@ -80,6 +83,32 @@ const ParaModal = forwardRef((props, ref) => {
80
83
  "onClose",
81
84
  "defaultAuthIdentifier"
82
85
  ]);
86
+ useEffect(() => {
87
+ const trackAnalytics = () => __async(void 0, null, function* () {
88
+ try {
89
+ yield para.ctx.client.trackReactSdkAnalytics({
90
+ props: __spreadValues(__spreadProps(__spreadValues({}, providerProps), {
91
+ theme,
92
+ disableEmailLogin,
93
+ disablePhoneLogin,
94
+ isGuestModeEnabled,
95
+ oAuthMethods,
96
+ bareModal,
97
+ className,
98
+ currentStepOverride,
99
+ authLayout,
100
+ embeddedModal,
101
+ onModalStepChange,
102
+ onClose,
103
+ defaultAuthIdentifier
104
+ }), rest),
105
+ reactSdkVersion: SDK_VERSION
106
+ });
107
+ } catch (_) {
108
+ }
109
+ });
110
+ trackAnalytics();
111
+ }, []);
83
112
  const isOpen = configIsOpen != null ? configIsOpen : storedIsOpen;
84
113
  useImperativeHandle(ref, () => {
85
114
  return {
@@ -21,9 +21,9 @@ import { useAddFunds } from "./AddFundsContext.js";
21
21
  import { formatNetworkList } from "../../utils/stringFormatters.js";
22
22
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
23
23
  const GENERIC_WALLET = {
24
- EVM: "Ethereum or EVM-based L2s",
25
- SOLANA: "Solana",
26
- COSMOS: "Cosmos"
24
+ EVM: "Ethereum or EVM-based networks",
25
+ SOLANA: "Solana or SVM-based networks",
26
+ COSMOS: "Cosmos networks"
27
27
  };
28
28
  function AddFundsReceive() {
29
29
  const [isCopied, copy] = useCopyToClipboard();
@@ -36,4 +36,5 @@ export declare const NETWORK_NOT_SUPPORTED_ERROR = "network not supported";
36
36
  export declare const EMAIL_REGEX: RegExp;
37
37
  export declare const BODY_MOTION_VARIANTS: Variants;
38
38
  export declare const BODY_TRANSITION: Transition;
39
+ export declare const SDK_VERSION: string;
39
40
  export {};
@@ -119,6 +119,7 @@ const BODY_MOTION_VARIANTS = {
119
119
  const BODY_TRANSITION = {
120
120
  duration: 0.2
121
121
  };
122
+ const SDK_VERSION = "2.0.0-alpha.13";
122
123
  export {
123
124
  BODY_MOTION_VARIANTS,
124
125
  BODY_TRANSITION,
@@ -130,6 +131,7 @@ export {
130
131
  ON_RAMP_PROVIDERS,
131
132
  PARA_CONNECT,
132
133
  PARA_TERMS_AND_CONDITIONS,
134
+ SDK_VERSION,
133
135
  getAssetCode,
134
136
  getAssetIcon,
135
137
  getAssetName,
@@ -1,5 +1,8 @@
1
1
  "use client";
2
- import "../chunk-MMUBH76A.js";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../chunk-MMUBH76A.js";
3
6
  import { jsx, jsxs } from "react/jsx-runtime";
4
7
  import { forwardRef, useEffect } from "react";
5
8
  import { useStore } from "./stores/useStore.js";
@@ -26,6 +29,13 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
26
29
  const appName = useStore((state) => state.appName);
27
30
  const rpcUrl = useStore((state) => state.rpcUrl);
28
31
  const setRpcUrl = useStore((state) => state.setRpcUrl);
32
+ const setProviderProps = useStore((state) => state.setProviderProps);
33
+ useEffect(() => {
34
+ setProviderProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, config), externalWalletConfig), paraModalConfig), {
35
+ // Redacting walletConnect to avoid exposing project id
36
+ walletConnect: void 0
37
+ }));
38
+ }, [config, externalWalletConfig, paraModalConfig]);
29
39
  useEffect(() => {
30
40
  if (rpcUrl !== config.rpcUrl) setRpcUrl(config.rpcUrl);
31
41
  }, [config.rpcUrl]);
@@ -43,15 +53,17 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
43
53
  }, [externalWalletConfig == null ? void 0 : externalWalletConfig.wallets]);
44
54
  useEffect(() => {
45
55
  var _a, _b;
46
- if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.walletsWithParaAuth)) {
56
+ if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets)) {
47
57
  if (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly) {
48
- console.warn("walletsWithParaAuth has no effect when using externalWalletConnectionOnly");
58
+ console.warn("createLinkedEmbeddedForExternalWallets has no effect when using externalWalletConnectionOnly");
49
59
  setExternalWalletsWithFullAuth([]);
50
60
  } else {
51
- setExternalWalletsWithFullAuth((_b = externalWalletConfig == null ? void 0 : externalWalletConfig.walletsWithParaAuth) != null ? _b : []);
61
+ setExternalWalletsWithFullAuth(
62
+ (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets) === "ALL" ? Object.values(ExternalWallet) : (_b = externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets) != null ? _b : []
63
+ );
52
64
  }
53
65
  }
54
- }, [externalWalletConfig == null ? void 0 : externalWalletConfig.walletsWithParaAuth]);
66
+ }, [externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets]);
55
67
  useEffect(() => {
56
68
  if (!isConfigType(paraClientConfig) && !isParaWeb(paraClientConfig)) {
57
69
  throw new Error("Invalid Para config");
@@ -0,0 +1,3 @@
1
+ import { StateCreator } from 'zustand';
2
+ import { AnalyticsSlice, Store } from '../types.js';
3
+ export declare const createAnalyticsSlice: StateCreator<Store, [], [], AnalyticsSlice>;
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ const createAnalyticsSlice = (set) => ({
4
+ providerProps: {},
5
+ setProviderProps: (providerProps) => set({ providerProps })
6
+ });
7
+ export {
8
+ createAnalyticsSlice
9
+ };
@@ -2,3 +2,4 @@ export * from './client.js';
2
2
  export * from './modal.js';
3
3
  export * from './wallet.js';
4
4
  export * from './externalWallets.js';
5
+ export * from './analytics.js';
@@ -3,3 +3,4 @@ export * from "./client.js";
3
3
  export * from "./modal.js";
4
4
  export * from "./wallet.js";
5
5
  export * from "./externalWallets.js";
6
+ export * from "./analytics.js";
@@ -14,6 +14,10 @@ export interface ConfigSlice {
14
14
  appName: string;
15
15
  setAppName: (_: string) => void;
16
16
  }
17
+ export interface AnalyticsSlice {
18
+ providerProps: object;
19
+ setProviderProps: (_: object) => void;
20
+ }
17
21
  export interface ModalSlice {
18
22
  modalConfig?: ParaModalProps;
19
23
  setModalConfig: (_?: ParaModalProps) => void;
@@ -61,4 +65,4 @@ export interface ExternalWalletsSlice {
61
65
  setIsLoadingSolanaLib: (_: boolean) => void;
62
66
  onLoginRef: MutableRefObject<(() => Promise<void>) | null>;
63
67
  }
64
- export type Store = ClientSlice & ModalSlice & WalletSlice & ExternalWalletsSlice & ConfigSlice;
68
+ export type Store = ClientSlice & ModalSlice & WalletSlice & ExternalWalletsSlice & ConfigSlice & AnalyticsSlice;
@@ -3,12 +3,18 @@ import {
3
3
  __spreadValues
4
4
  } from "../../chunk-MMUBH76A.js";
5
5
  import { createStore, useStore as useZustandStore } from "zustand";
6
- import { createClientSlice, createExternalWalletsSlice, createModalSlice, createWalletSlice } from "./slices/index.js";
6
+ import {
7
+ createAnalyticsSlice,
8
+ createClientSlice,
9
+ createExternalWalletsSlice,
10
+ createModalSlice,
11
+ createWalletSlice
12
+ } from "./slices/index.js";
7
13
  import { createJSONStorage, persist } from "zustand/middleware";
8
14
  import { createConfigSlice } from "./slices/config.js";
9
15
  const vanillaStore = createStore()(
10
16
  persist(
11
- (...a) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)), createExternalWalletsSlice(...a)), createConfigSlice(...a)),
17
+ (...a) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)), createExternalWalletsSlice(...a)), createConfigSlice(...a)), createAnalyticsSlice(...a)),
12
18
  {
13
19
  version: 1,
14
20
  name: "@PARA/provider-state",
@@ -107,9 +107,11 @@ export type ExternalWalletConfig<chains extends readonly [Chain, ...Chain[]], tr
107
107
  */
108
108
  wallets?: TExternalWallet[];
109
109
  /**
110
- * Which external wallets will include full verification and Para auth.
110
+ * Array of external wallets that will also include linked embedded wallets.
111
+ *
112
+ * You can also pass `ALL` to include linked embedded wallets for all external wallets.
111
113
  */
112
- walletsWithParaAuth?: TExternalWallet[];
114
+ createLinkedEmbeddedForExternalWallets?: TExternalWallet[] | 'ALL';
113
115
  };
114
116
  export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends PropsWithChildren {
115
117
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "2.0.0-alpha.12",
3
+ "version": "2.0.0-alpha.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,9 +15,9 @@
15
15
  "*.css"
16
16
  ],
17
17
  "dependencies": {
18
- "@getpara/react-common": "2.0.0-alpha.12",
19
- "@getpara/react-components": "2.0.0-alpha.12",
20
- "@getpara/web-sdk": "2.0.0-alpha.12",
18
+ "@getpara/react-common": "2.0.0-alpha.13",
19
+ "@getpara/react-components": "2.0.0-alpha.13",
20
+ "@getpara/web-sdk": "2.0.0-alpha.13",
21
21
  "date-fns": "^3.6.0",
22
22
  "framer-motion": "11.3.28",
23
23
  "libphonenumber-js": "^1.11.1",
@@ -33,9 +33,9 @@
33
33
  "cli": "node ./dist/cli/cli.mjs"
34
34
  },
35
35
  "devDependencies": {
36
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.12",
37
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.12",
38
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.12",
36
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.13",
37
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.13",
38
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.13",
39
39
  "@testing-library/dom": "^10.4.0",
40
40
  "@testing-library/react": "^16.3.0",
41
41
  "@testing-library/react-hooks": "^8.0.1",
@@ -63,5 +63,5 @@
63
63
  "resolutions": {
64
64
  "styled-components": "^6"
65
65
  },
66
- "gitHead": "3a1284d5bb57c48fe53f651872da9a6e6903400a"
66
+ "gitHead": "fbd9384b1b3fb8577f9d6c323d4e41d0de1ac83b"
67
67
  }