@getpara/react-sdk 1.12.1-dev.2 → 1.13.1

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.
@@ -22,6 +22,7 @@ import { useStore } from "../provider/stores/useStore.js";
22
22
  import { getExternalWalletDisplayName } from "@getpara/react-common";
23
23
  import { useInternalClient } from "../provider/hooks/utils/useInternalClient.js";
24
24
  import { useExternalWalletProviderStore } from "./stores/externalWalletProvider/useExternalWalletProviderStore.js";
25
+ import { SDK_VERSION } from "./constants/constants.js";
25
26
  defineCustomElements();
26
27
  const ParaModal = forwardRef(
27
28
  (_a, ref) => {
@@ -33,6 +34,21 @@ const ParaModal = forwardRef(
33
34
  const setRpcUrl = useStore((state) => state.setRpcUrl);
34
35
  const { closeModal, openModal } = useModal();
35
36
  const updateExternalWalletProviderState = useExternalWalletProviderStore((state) => state.updateState);
37
+ useEffect(() => {
38
+ const trackAnalytics = () => __async(void 0, null, function* () {
39
+ try {
40
+ yield para.ctx.client.trackReactSdkAnalytics({
41
+ props: __spreadValues({
42
+ externalWalletsWithParaAuth,
43
+ rpcUrlFromProps
44
+ }, rest),
45
+ reactSdkVersion: SDK_VERSION
46
+ });
47
+ } catch (_) {
48
+ }
49
+ });
50
+ trackAnalytics();
51
+ }, []);
36
52
  useEffect(() => {
37
53
  updateExternalWalletProviderState({ fullAuthWallets: externalWalletsWithParaAuth });
38
54
  }, [externalWalletsWithParaAuth]);
@@ -8,7 +8,7 @@ import { OnRampProvider } from "@getpara/web-sdk";
8
8
  import { useModalStore, useThemeStore } from "../../stores/index.js";
9
9
  import { lazy, useEffect, useMemo, useState } from "react";
10
10
  import { ModalStep } from "../../utils/steps.js";
11
- import { RampEmbed, StripeEmbed } from "@getpara/react-common";
11
+ import { RampEmbed } from "@getpara/react-common";
12
12
  import styled from "styled-components";
13
13
  import { useGoBack } from "../../hooks/useGoBack.js";
14
14
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
@@ -45,12 +45,12 @@ const AddFundsAwaiting = () => {
45
45
  return null;
46
46
  }
47
47
  switch (onRampPurchase == null ? void 0 : onRampPurchase.provider) {
48
- case OnRampProvider.STRIPE:
49
- return /* @__PURE__ */ jsx(StripeEmbed, __spreadValues({}, props));
50
48
  case OnRampProvider.MOONPAY:
51
49
  return !MoonPayEmbed || typeof window === "undefined" ? null : /* @__PURE__ */ jsx(MoonPayEmbed, __spreadValues({}, props));
52
50
  case OnRampProvider.RAMP:
53
51
  return /* @__PURE__ */ jsx(RampEmbed, __spreadValues({ apiKey: onRampConfig.rampApiKey }, props));
52
+ default:
53
+ return null;
54
54
  }
55
55
  }, [onRampPurchase == null ? void 0 : onRampPurchase.provider, MoonPayEmbed]);
56
56
  useEffect(() => {
@@ -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 = "1.13.1";
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,7 +1,6 @@
1
1
  import ParaWeb from '@getpara/web-sdk';
2
2
  export declare const getAccount: (para?: ParaWeb) => Promise<{
3
3
  isConnected: boolean;
4
- isGuestMode: boolean;
5
4
  email: any;
6
5
  phone: any;
7
6
  wallets: any;
@@ -6,7 +6,6 @@ const getAccount = (para) => __async(void 0, null, function* () {
6
6
  const isLoggedIn = yield para == null ? void 0 : para.isFullyLoggedIn();
7
7
  const resp = {
8
8
  isConnected: !!isLoggedIn,
9
- isGuestMode: para == null ? void 0 : para.isGuestMode,
10
9
  email: void 0,
11
10
  phone: void 0,
12
11
  wallets: void 0
@@ -8,4 +8,3 @@ export { useLogout } from './useLogout.js';
8
8
  export { useKeepSessionAlive } from './useKeepSessionAlive.js';
9
9
  export { useSignMessage } from './useSignMessage.js';
10
10
  export { useSignTransaction } from './useSignTransaction.js';
11
- export { useCreateGuestWallets } from './useCreateGuestWallets.js';
@@ -10,10 +10,8 @@ import { useLogout } from "./useLogout.js";
10
10
  import { useKeepSessionAlive } from "./useKeepSessionAlive.js";
11
11
  import { useSignMessage } from "./useSignMessage.js";
12
12
  import { useSignTransaction } from "./useSignTransaction.js";
13
- import { useCreateGuestWallets } from "./useCreateGuestWallets.js";
14
13
  export {
15
14
  useCheckIfUserExists,
16
- useCreateGuestWallets,
17
15
  useCreateUser,
18
16
  useInitiateLogin,
19
17
  useKeepSessionAlive,
@@ -4,7 +4,6 @@ export declare const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
4
4
  */
5
5
  export declare const useAccount: () => import("@tanstack/react-query").UseQueryResult<{
6
6
  isConnected: boolean;
7
- isGuestMode: boolean;
8
7
  email: any;
9
8
  phone: any;
10
9
  wallets: any;
@@ -14,6 +14,7 @@ const useWalletBalance = (args, queryOptions) => {
14
14
  const rpcUrl = useStore((state) => state.rpcUrl);
15
15
  const completeArgs = __spreadValues({ walletId: selectedWallet.id, rpcUrl }, args);
16
16
  return useQuery(__spreadValues({
17
+ enabled: !!client && !!selectedWallet.id,
17
18
  queryKey: [WALLET_BALANCE_BASE_KEY, client == null ? void 0 : client.getUserId(), completeArgs],
18
19
  queryFn: () => __async(void 0, null, function* () {
19
20
  return yield getWalletBalance(client, completeArgs);
@@ -9,6 +9,7 @@ import {
9
9
  import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
10
10
  import { useStore } from "../../stores/useStore.js";
11
11
  import { WALLET_BASE_KEY } from "../../hooks/queries/useWallet.js";
12
+ import { WALLET_BALANCE_BASE_KEY } from "../queries/useWalletBalance.js";
12
13
  const useEventListeners = ({
13
14
  onLogin,
14
15
  onLogout,
@@ -36,6 +37,7 @@ const useEventListeners = ({
36
37
  const loginOrSetupListener = () => {
37
38
  queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
38
39
  queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
40
+ queryClient.invalidateQueries({ queryKey: [WALLET_BALANCE_BASE_KEY], exact: false });
39
41
  };
40
42
  const accountCreationListener = (event) => {
41
43
  onAccountCreation == null ? void 0 : onAccountCreation(event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "1.12.1-dev.2",
3
+ "version": "1.13.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,9 +12,9 @@
12
12
  "*.css"
13
13
  ],
14
14
  "dependencies": {
15
- "@getpara/react-common": "1.12.1-dev.0",
16
- "@getpara/react-components": "1.12.0",
17
- "@getpara/web-sdk": "1.12.0",
15
+ "@getpara/react-common": "1.13.1",
16
+ "@getpara/react-components": "1.13.1",
17
+ "@getpara/web-sdk": "1.13.1",
18
18
  "@tanstack/react-query": "^5.0.0",
19
19
  "date-fns": "^3.6.0",
20
20
  "framer-motion": "11.3.28",
@@ -23,6 +23,12 @@
23
23
  "zustand": "^4.5.2",
24
24
  "zustand-sync-tabs": "^0.2.2"
25
25
  },
26
+ "scripts": {
27
+ "post-build": "./scripts/post-build.sh",
28
+ "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
29
+ "typegen": "tsc --emitDeclarationOnly",
30
+ "test": "vitest run --coverage"
31
+ },
26
32
  "devDependencies": {
27
33
  "@testing-library/dom": "^10.4.0",
28
34
  "@testing-library/react": "^16.3.0",
@@ -35,13 +41,7 @@
35
41
  },
36
42
  "peerDependencies": {
37
43
  "react": "*",
38
- "react-dom": "*",
39
- "styled-components": "^6"
40
- },
41
- "peerDependenciesMeta": {
42
- "styled-components": {
43
- "optional": true
44
- }
44
+ "react-dom": "*"
45
45
  },
46
46
  "files": [
47
47
  "dist",
@@ -51,11 +51,5 @@
51
51
  "resolutions": {
52
52
  "styled-components": "^6"
53
53
  },
54
- "gitHead": "e6e791d4e4f9afd94f2093d6045d686b85e5a682",
55
- "scripts": {
56
- "post-build": "./scripts/post-build.sh",
57
- "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
58
- "typegen": "tsc --emitDeclarationOnly",
59
- "test": "vitest run --coverage"
60
- }
61
- }
54
+ "gitHead": "6bac76c23aee8c182077ff43bda38d2cfd7c9027"
55
+ }
@@ -1,16 +0,0 @@
1
- import { OnrampSessionResult } from '@stripe/crypto';
2
- export declare const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
3
- export declare const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
4
- export declare const CryptoElements: ({ stripeOnramp, children }: {
5
- stripeOnramp: any;
6
- children: any;
7
- }) => import("react/jsx-runtime").JSX.Element;
8
- export declare const useStripeOnramp: () => any;
9
- export declare const OnrampElement: ({ clientSecret, appearance, onReady, onSessionChange, ...props }: {
10
- clientSecret: string;
11
- appearance: "dark" | "light";
12
- onReady?: () => void;
13
- onSessionChange: (_: {
14
- session: OnrampSessionResult;
15
- }) => void;
16
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,88 +0,0 @@
1
- "use client";
2
- import {
3
- __objRest,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../../../chunk-MMUBH76A.js";
7
- import { jsx } from "react/jsx-runtime";
8
- import React from "react";
9
- const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
10
- const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
11
- const CryptoElementsContext = React.createContext(null);
12
- CryptoElementsContext.displayName = "CryptoElementsContext";
13
- const CryptoElements = ({ stripeOnramp, children }) => {
14
- const [ctx, setContext] = React.useState(() => ({
15
- onramp: null
16
- }));
17
- React.useEffect(() => {
18
- let isMounted = true;
19
- Promise.resolve(stripeOnramp).then((onramp) => {
20
- if (onramp && isMounted) {
21
- setContext((ctx2) => ctx2.onramp ? ctx2 : { onramp });
22
- }
23
- });
24
- return () => {
25
- isMounted = false;
26
- };
27
- }, [stripeOnramp]);
28
- return /* @__PURE__ */ jsx(CryptoElementsContext.Provider, { value: ctx, children });
29
- };
30
- const useStripeOnramp = () => {
31
- const context = React.useContext(CryptoElementsContext);
32
- return context == null ? void 0 : context.onramp;
33
- };
34
- const useOnrampSessionListener = (type, session, callback) => {
35
- React.useEffect(() => {
36
- if (session && callback) {
37
- const listener = (e) => callback(e.payload);
38
- session.addEventListener(type, listener);
39
- return () => {
40
- session.removeEventListener(type, listener);
41
- };
42
- }
43
- return () => {
44
- };
45
- }, [session, callback, type]);
46
- };
47
- const OnrampElement = (_a) => {
48
- var _b = _a, {
49
- clientSecret,
50
- appearance,
51
- onReady = () => {
52
- },
53
- onSessionChange
54
- } = _b, props = __objRest(_b, [
55
- "clientSecret",
56
- "appearance",
57
- "onReady",
58
- "onSessionChange"
59
- ]);
60
- const stripeOnramp = useStripeOnramp();
61
- const onrampElementRef = React.useRef(null);
62
- const [session, setSession] = React.useState();
63
- const appearanceJSON = JSON.stringify(appearance);
64
- React.useEffect(() => {
65
- const containerRef = onrampElementRef.current;
66
- if (containerRef) {
67
- containerRef.innerHTML = "";
68
- if (clientSecret && stripeOnramp) {
69
- setSession(
70
- stripeOnramp.createSession({
71
- clientSecret,
72
- appearance: { theme: appearance }
73
- }).mount(containerRef)
74
- );
75
- }
76
- }
77
- }, [appearanceJSON, clientSecret, stripeOnramp]);
78
- useOnrampSessionListener("onramp_ui_loaded", session, onReady);
79
- useOnrampSessionListener("onramp_session_updated", session, onSessionChange);
80
- return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, props), { ref: onrampElementRef }));
81
- };
82
- export {
83
- CryptoElements,
84
- OnrampElement,
85
- STRIPE_PUBLISHABLE_KEY,
86
- STRIPE_PUBLISHABLE_KEY_TEST,
87
- useStripeOnramp
88
- };
@@ -1,2 +0,0 @@
1
- import ParaWeb, { CreateGuestWalletsParams } from '@getpara/web-sdk';
2
- export declare const createGuestWallets: (para?: ParaWeb, args?: CreateGuestWalletsParams) => Promise<import("@getpara/web-sdk").Wallet[]>;
@@ -1,13 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../chunk-MMUBH76A.js";
5
- const createGuestWallets = (para, args) => __async(void 0, null, function* () {
6
- if (!para) {
7
- throw new Error("no para instance");
8
- }
9
- return yield para.createGuestWallets(args);
10
- });
11
- export {
12
- createGuestWallets
13
- };
@@ -1,15 +0,0 @@
1
- import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
- import { createGuestWallets } from '../../actions/createGuestWallets.js';
3
- import { Compute } from '../../types/utils.js';
4
- import { UseMutationReturnType } from '../../types/query.js';
5
- import { CreateGuestWalletsParams } from '@getpara/web-sdk';
6
- type Data = Awaited<ReturnType<typeof createGuestWallets>>;
7
- type UseCreateGuestWalletsReturnType<TData = Data, TError = Error, TVariables = CreateGuestWalletsParams, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
8
- createGuestWallets: UseMutateFunction<TData, TError, TVariables, TContext>;
9
- createGuestWalletsAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
10
- }>;
11
- /**
12
- * Hook for creating guest mode wallets
13
- */
14
- export declare const useCreateGuestWallets: () => UseCreateGuestWalletsReturnType<import("@getpara/web-sdk").Wallet[], Error, CreateGuestWalletsParams, unknown>;
15
- export {};
@@ -1,23 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { createGuestWallets } from "../../actions/createGuestWallets.js";
8
- import { renameMutations } from "../../utils/renameMutations.js";
9
- const useCreateGuestWallets = () => {
10
- const client = useClient();
11
- const mutation = useMutation({
12
- mutationFn: (args) => __async(void 0, null, function* () {
13
- return yield createGuestWallets(client, args);
14
- })
15
- });
16
- return renameMutations(
17
- mutation,
18
- "createGuestWallets"
19
- );
20
- };
21
- export {
22
- useCreateGuestWallets
23
- };