@getpara/react-common 2.3.0 → 2.4.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.
- package/dist/components/MoonPayEmbed.js +11 -17
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "../chunk-MMUBH76A.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { OnRampProvider } from "@getpara/web-sdk";
|
|
7
|
-
import { lazy, useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { reverseCurrencyLookup, getCurrencyCode, safeStyled } from "../utils/index.js";
|
|
9
9
|
const MOONPAY_PUBLISHABLE_KEY = "pk_live_EQva4LydtNDE0Rwd9X7SG9w58wqOzbux";
|
|
10
10
|
const MOONPAY_PUBLISHABLE_KEY_TEST = "pk_test_HYobzemmTBXxcSStVA4dSED6jT";
|
|
@@ -19,6 +19,7 @@ const MoonPayEmbed = ({
|
|
|
19
19
|
onUrlSignatureRequest
|
|
20
20
|
}) => {
|
|
21
21
|
const [components, setComponents] = useState(null);
|
|
22
|
+
const widgetEmbedRef = useRef(null);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
const _LazyMoonPayBuyWidget = lazy(
|
|
24
25
|
() => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayBuyWidget }))
|
|
@@ -75,7 +76,10 @@ const MoonPayEmbed = ({
|
|
|
75
76
|
}),
|
|
76
77
|
[]
|
|
77
78
|
);
|
|
78
|
-
const
|
|
79
|
+
const widgetEmbed = useMemo(() => {
|
|
80
|
+
if (widgetEmbedRef.current) {
|
|
81
|
+
return widgetEmbedRef.current;
|
|
82
|
+
}
|
|
79
83
|
if (!components) {
|
|
80
84
|
return null;
|
|
81
85
|
}
|
|
@@ -84,7 +88,7 @@ const MoonPayEmbed = ({
|
|
|
84
88
|
asset: onRampPurchase.asset,
|
|
85
89
|
provider: OnRampProvider.MOONPAY
|
|
86
90
|
});
|
|
87
|
-
|
|
91
|
+
const widget = /* @__PURE__ */ jsx(components.MoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
|
|
88
92
|
components.MoonPayBuyWidget,
|
|
89
93
|
{
|
|
90
94
|
variant: "embedded",
|
|
@@ -127,20 +131,10 @@ const MoonPayEmbed = ({
|
|
|
127
131
|
onUrlSignatureRequested: onUrlSignatureRequest
|
|
128
132
|
}
|
|
129
133
|
) });
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
onRampPurchase.address,
|
|
135
|
-
onRampPurchase.walletId,
|
|
136
|
-
onRampPurchase.walletType,
|
|
137
|
-
onRampPurchase.asset,
|
|
138
|
-
onRampPurchase.testMode,
|
|
139
|
-
onTransactionCompleted,
|
|
140
|
-
isDark,
|
|
141
|
-
components
|
|
142
|
-
]);
|
|
143
|
-
return /* @__PURE__ */ jsx(Container, { isEmbedded, children: embed });
|
|
134
|
+
widgetEmbedRef.current = widget;
|
|
135
|
+
return widget;
|
|
136
|
+
}, [components]);
|
|
137
|
+
return /* @__PURE__ */ jsx(Container, { isEmbedded, children: widgetEmbed });
|
|
144
138
|
};
|
|
145
139
|
var MoonPayEmbed_default = MoonPayEmbed;
|
|
146
140
|
const Container = safeStyled.div`
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/react-components": "2.
|
|
6
|
-
"@getpara/web-sdk": "2.
|
|
7
|
-
"@moonpay/moonpay-react": "^1.
|
|
5
|
+
"@getpara/react-components": "2.4.0",
|
|
6
|
+
"@getpara/web-sdk": "2.4.0",
|
|
7
|
+
"@moonpay/moonpay-react": "^1.10.6",
|
|
8
8
|
"@ramp-network/ramp-instant-sdk": "^4.0.5",
|
|
9
9
|
"libphonenumber-js": "^1.11.7",
|
|
10
10
|
"styled-components": "^6.1.8",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
],
|
|
41
41
|
"type": "module",
|
|
42
42
|
"types": "dist/index.d.ts",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "971eba7723b162809178c742f9a3651a35d51fd3"
|
|
44
44
|
}
|