@getpara/react-sdk 1.13.0 → 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.
@@ -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(() => {
@@ -119,7 +119,7 @@ const BODY_MOTION_VARIANTS = {
119
119
  const BODY_TRANSITION = {
120
120
  duration: 0.2
121
121
  };
122
- const SDK_VERSION = "1.13.0";
122
+ const SDK_VERSION = "1.13.1";
123
123
  export {
124
124
  BODY_MOTION_VARIANTS,
125
125
  BODY_TRANSITION,
@@ -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.13.0",
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.13.0",
16
- "@getpara/react-components": "1.13.0",
17
- "@getpara/web-sdk": "1.13.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",
@@ -41,13 +41,7 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "*",
44
- "react-dom": "*",
45
- "styled-components": "^6"
46
- },
47
- "peerDependenciesMeta": {
48
- "styled-components": {
49
- "optional": true
50
- }
44
+ "react-dom": "*"
51
45
  },
52
46
  "files": [
53
47
  "dist",
@@ -57,5 +51,5 @@
57
51
  "resolutions": {
58
52
  "styled-components": "^6"
59
53
  },
60
- "gitHead": "cfc12a88a622907b3fbde326c891060fa53a2d32"
54
+ "gitHead": "6bac76c23aee8c182077ff43bda38d2cfd7c9027"
61
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
- };