@coinflowlabs/react 5.9.1 → 5.10.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/README.md +8 -0
- package/build/cjs/CoinflowApplePayButton.d.ts +1 -1
- package/build/cjs/CoinflowApplePayButton.js +5 -6
- package/build/cjs/CoinflowApplePayButton.js.map +1 -1
- package/build/cjs/CoinflowGooglePayButton.js +4 -5
- package/build/cjs/CoinflowGooglePayButton.js.map +1 -1
- package/build/cjs/CoinflowIFrame.js +42 -53
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.js +55 -42
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowPurchaseHistory.js +20 -11
- package/build/cjs/CoinflowPurchaseHistory.js.map +1 -1
- package/build/cjs/CoinflowPurchaseProtection.d.ts +1 -1
- package/build/cjs/CoinflowPurchaseProtection.js +10 -11
- package/build/cjs/CoinflowPurchaseProtection.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.js +20 -11
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/CoinflowWithdrawHistory.js +20 -11
- package/build/cjs/CoinflowWithdrawHistory.js.map +1 -1
- package/build/cjs/MobileWalletButton.d.ts +1 -1
- package/build/cjs/MobileWalletButton.js +35 -26
- package/build/cjs/MobileWalletButton.js.map +1 -1
- package/build/cjs/card-form/CoinflowCardForm.js +42 -54
- package/build/cjs/card-form/CoinflowCardForm.js.map +1 -1
- package/build/cjs/card-form/CoinflowCardFormHeader.js +5 -5
- package/build/cjs/card-form/CoinflowCardFormHeader.js.map +1 -1
- package/build/cjs/card-form/useCardFormIframe.d.ts +5 -5
- package/build/cjs/card-form/useCardFormIframe.js +57 -57
- package/build/cjs/card-form/useCardFormIframe.js.map +1 -1
- package/build/cjs/common/CoinflowLibMessageHandlers.d.ts +2 -1
- package/build/cjs/common/CoinflowLibMessageHandlers.js +128 -193
- package/build/cjs/common/CoinflowLibMessageHandlers.js.map +1 -1
- package/build/cjs/common/CoinflowTypes.d.ts +19 -8
- package/build/cjs/common/CoinflowTypes.js +15 -16
- package/build/cjs/common/CoinflowTypes.js.map +1 -1
- package/build/cjs/common/CoinflowUtils.d.ts +2 -1
- package/build/cjs/common/CoinflowUtils.js +68 -64
- package/build/cjs/common/CoinflowUtils.js.map +1 -1
- package/build/cjs/common/EventBus.js +8 -11
- package/build/cjs/common/EventBus.js.map +1 -1
- package/build/cjs/common/NSure.js +2 -2
- package/build/cjs/common/NSure.js.map +1 -1
- package/build/cjs/common/NSure.native.js.map +1 -1
- package/build/cjs/common/SolanaPeerDeps.js +5 -5
- package/build/cjs/common/SolanaPeerDeps.js.map +1 -1
- package/build/cjs/common/card-form/TokenEx.js +7 -8
- package/build/cjs/common/card-form/TokenEx.js.map +1 -1
- package/build/cjs/common/card-form/tokenexHelpers.d.ts +1 -1
- package/build/cjs/common/card-form/tokenexHelpers.js +97 -150
- package/build/cjs/common/card-form/tokenexHelpers.js.map +1 -1
- package/build/cjs/common/index.js +1 -1
- package/build/cjs/common/types/Subtotal.js +175 -176
- package/build/cjs/common/types/Subtotal.js.map +1 -1
- package/build/cjs/common/types/nftCartItem.js +2 -2
- package/build/cjs/common/types/nftCartItem.js.map +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/useOverlay.js +13 -12
- package/build/cjs/useOverlay.js.map +1 -1
- package/build/esm/CoinflowApplePayButton.d.ts +1 -1
- package/build/esm/CoinflowApplePayButton.js +2 -3
- package/build/esm/CoinflowApplePayButton.js.map +1 -1
- package/build/esm/CoinflowGooglePayButton.js +1 -2
- package/build/esm/CoinflowGooglePayButton.js.map +1 -1
- package/build/esm/CoinflowIFrame.js +39 -51
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.js +50 -38
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowPurchaseHistory.js +16 -8
- package/build/esm/CoinflowPurchaseHistory.js.map +1 -1
- package/build/esm/CoinflowPurchaseProtection.d.ts +1 -1
- package/build/esm/CoinflowPurchaseProtection.js +6 -7
- package/build/esm/CoinflowPurchaseProtection.js.map +1 -1
- package/build/esm/CoinflowWithdraw.js +16 -8
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/CoinflowWithdrawHistory.js +16 -8
- package/build/esm/CoinflowWithdrawHistory.js.map +1 -1
- package/build/esm/MobileWalletButton.d.ts +1 -1
- package/build/esm/MobileWalletButton.js +30 -22
- package/build/esm/MobileWalletButton.js.map +1 -1
- package/build/esm/card-form/CoinflowCardForm.js +41 -54
- package/build/esm/card-form/CoinflowCardForm.js.map +1 -1
- package/build/esm/card-form/CoinflowCardFormHeader.js +3 -3
- package/build/esm/card-form/CoinflowCardFormHeader.js.map +1 -1
- package/build/esm/card-form/useCardFormIframe.d.ts +5 -5
- package/build/esm/card-form/useCardFormIframe.js +56 -56
- package/build/esm/card-form/useCardFormIframe.js.map +1 -1
- package/build/esm/common/CoinflowLibMessageHandlers.d.ts +2 -1
- package/build/esm/common/CoinflowLibMessageHandlers.js +126 -191
- package/build/esm/common/CoinflowLibMessageHandlers.js.map +1 -1
- package/build/esm/common/CoinflowTypes.d.ts +19 -8
- package/build/esm/common/CoinflowTypes.js +16 -17
- package/build/esm/common/CoinflowTypes.js.map +1 -1
- package/build/esm/common/CoinflowUtils.d.ts +2 -1
- package/build/esm/common/CoinflowUtils.js +63 -61
- package/build/esm/common/CoinflowUtils.js.map +1 -1
- package/build/esm/common/EventBus.js +8 -12
- package/build/esm/common/EventBus.js.map +1 -1
- package/build/esm/common/SolanaPeerDeps.js +2 -2
- package/build/esm/common/SolanaPeerDeps.js.map +1 -1
- package/build/esm/common/card-form/TokenEx.js +8 -9
- package/build/esm/common/card-form/TokenEx.js.map +1 -1
- package/build/esm/common/card-form/tokenexHelpers.d.ts +1 -1
- package/build/esm/common/card-form/tokenexHelpers.js +95 -148
- package/build/esm/common/card-form/tokenexHelpers.js.map +1 -1
- package/build/esm/common/types/Subtotal.js +175 -176
- package/build/esm/common/types/Subtotal.js.map +1 -1
- package/build/esm/common/types/nftCartItem.js +2 -2
- package/build/esm/common/types/nftCartItem.js.map +1 -1
- package/build/esm/useOverlay.js +11 -10
- package/build/esm/useOverlay.js.map +1 -1
- package/build/tsconfig.cjs.tsbuildinfo +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,81 +1,69 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
3
2
|
import { CoinflowUtils, handleIFrameMessage, } from './common';
|
|
4
3
|
export function useRandomHandleHeightChangeId() {
|
|
5
|
-
return useMemo(
|
|
4
|
+
return useMemo(() => Math.random().toString(16).substring(2), []);
|
|
6
5
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export const CoinflowIFrame = forwardRef((props, ref) => {
|
|
7
|
+
const IFrameRef = useRef(null);
|
|
8
|
+
const url = useMemo(() => {
|
|
10
9
|
return CoinflowUtils.getCoinflowUrl(props);
|
|
11
10
|
}, [props]);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!((_a = IFrameRef === null || IFrameRef === void 0 ? void 0 : IFrameRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow))
|
|
11
|
+
const sendMessage = useCallback((message) => {
|
|
12
|
+
if (!IFrameRef?.current?.contentWindow)
|
|
15
13
|
throw new Error('Iframe not defined');
|
|
16
14
|
IFrameRef.current.contentWindow.postMessage(message, '*');
|
|
17
15
|
}, []);
|
|
18
|
-
useImperativeHandle(ref,
|
|
19
|
-
listenForMessage
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
window.addEventListener('message', handler);
|
|
39
|
-
}).finally(function () {
|
|
40
|
-
window.removeEventListener('message', handler);
|
|
41
|
-
})];
|
|
42
|
-
});
|
|
16
|
+
useImperativeHandle(ref, () => ({
|
|
17
|
+
async listenForMessage(isResponseValid) {
|
|
18
|
+
let handler;
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
handler = ({ data, origin }) => {
|
|
21
|
+
if (!origin.includes(CoinflowUtils.getCoinflowBaseUrl(props.env)))
|
|
22
|
+
return;
|
|
23
|
+
if (data.startsWith('ERROR')) {
|
|
24
|
+
reject(new Error(data.replace('ERROR', '')));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!isResponseValid(data))
|
|
28
|
+
return;
|
|
29
|
+
resolve(data);
|
|
30
|
+
};
|
|
31
|
+
if (!window)
|
|
32
|
+
throw new Error('Window not defined');
|
|
33
|
+
window.addEventListener('message', handler);
|
|
34
|
+
}).finally(() => {
|
|
35
|
+
window.removeEventListener('message', handler);
|
|
43
36
|
});
|
|
44
37
|
},
|
|
45
|
-
sendAndReceiveMessage
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
sendMessage(message);
|
|
49
|
-
return [2 /*return*/, this.listenForMessage(isResponseValid)];
|
|
50
|
-
});
|
|
51
|
-
});
|
|
38
|
+
async sendAndReceiveMessage(message, isResponseValid) {
|
|
39
|
+
sendMessage(message);
|
|
40
|
+
return this.listenForMessage(isResponseValid);
|
|
52
41
|
},
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
var data = _a.data, origin = _a.origin;
|
|
42
|
+
}));
|
|
43
|
+
const handleIframeMessages = useCallback(({ data, origin }) => {
|
|
56
44
|
if (!origin.includes(CoinflowUtils.getCoinflowBaseUrl(props.env)))
|
|
57
45
|
return;
|
|
58
|
-
|
|
46
|
+
const promise = handleIFrameMessage(data, props, props.handleHeightChangeId);
|
|
59
47
|
if (!promise)
|
|
60
48
|
return;
|
|
61
|
-
promise.then(sendMessage).catch(
|
|
49
|
+
promise.then(sendMessage).catch(e => sendMessage('ERROR ' + e.message));
|
|
62
50
|
}, [props, sendMessage]);
|
|
63
|
-
useEffect(
|
|
51
|
+
useEffect(() => {
|
|
64
52
|
if (!window)
|
|
65
53
|
throw new Error('Window not defined');
|
|
66
54
|
window.addEventListener('message', handleIframeMessages);
|
|
67
|
-
return
|
|
55
|
+
return () => {
|
|
68
56
|
window.removeEventListener('message', handleIframeMessages);
|
|
69
57
|
};
|
|
70
58
|
}, [handleIframeMessages]);
|
|
71
|
-
useLayoutEffect(
|
|
59
|
+
useLayoutEffect(() => {
|
|
72
60
|
if (!IFrameRef.current)
|
|
73
61
|
return;
|
|
74
62
|
// @ts-expect-error TypeScript doesn't recognize credentialless as a valid attribute in its type definitions yet
|
|
75
63
|
IFrameRef.current.credentialless = true;
|
|
76
64
|
}, []);
|
|
77
|
-
|
|
78
|
-
return useMemo(
|
|
65
|
+
const { handleHeightChange } = props;
|
|
66
|
+
return useMemo(() => (React.createElement("iframe", { scrolling: handleHeightChange ? 'no' : 'yes', onLoad: () => {
|
|
79
67
|
if (IFrameRef.current)
|
|
80
68
|
IFrameRef.current.style.opacity = '1';
|
|
81
69
|
}, allow: 'payment;camera;clipboard-write', ref: IFrameRef, style: {
|
|
@@ -83,6 +71,6 @@ export var CoinflowIFrame = forwardRef(function (props, ref) {
|
|
|
83
71
|
height: '100%',
|
|
84
72
|
opacity: 0,
|
|
85
73
|
transition: 'opacity 300ms linear',
|
|
86
|
-
}, title: "withdraw", frameBorder: "0", src: url }))
|
|
74
|
+
}, title: "withdraw", frameBorder: "0", src: url })), [IFrameRef, handleHeightChange, url]);
|
|
87
75
|
});
|
|
88
76
|
//# sourceMappingURL=CoinflowIFrame.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src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AM;YACd,OAAO,EAAE,CAAC;YACV,UAAU,EAAE,sBAAsB;SACnC,EACD,KAAK,EAAC,UAAU,EAChB,WAAW,EAAC,GAAG,EACf,GAAG,EAAE,GAAG,GACR,CACH,EACD,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,CAAC,CACrC,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -1,40 +1,47 @@
|
|
|
1
|
-
import { __assign, __spreadArray } from "tslib";
|
|
2
1
|
import React, { useMemo, useRef } from 'react';
|
|
3
2
|
import { CoinflowUtils, getHandlers, getWalletPubkey, } from './common';
|
|
4
3
|
import { CoinflowIFrame, useRandomHandleHeightChangeId, } from './CoinflowIFrame';
|
|
5
4
|
import { useOverlay } from './useOverlay';
|
|
6
5
|
function useCoinflowPurchase(purchaseProps, version) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
6
|
+
const handleHeightChangeId = useRandomHandleHeightChangeId();
|
|
7
|
+
const iframeProps = useMemo(() => {
|
|
8
|
+
const walletPubkey = getWalletPubkey(purchaseProps);
|
|
9
|
+
return {
|
|
10
|
+
...purchaseProps,
|
|
11
|
+
walletPubkey,
|
|
12
|
+
route: `/purchase${version}/${purchaseProps.merchantId}`,
|
|
13
|
+
transaction: CoinflowUtils.getTransaction(purchaseProps),
|
|
14
|
+
handleHeightChangeId,
|
|
15
|
+
};
|
|
11
16
|
}, [handleHeightChangeId, purchaseProps, version]);
|
|
12
|
-
|
|
13
|
-
return
|
|
17
|
+
const messageHandlers = useMemo(() => {
|
|
18
|
+
return {
|
|
19
|
+
...getHandlers(purchaseProps),
|
|
20
|
+
handleHeightChange: purchaseProps.handleHeightChange,
|
|
21
|
+
};
|
|
14
22
|
}, [purchaseProps]);
|
|
15
|
-
return { iframeProps
|
|
23
|
+
return { iframeProps, messageHandlers };
|
|
16
24
|
}
|
|
17
25
|
export function CoinflowPurchase(purchaseProps) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
const iframeRef = useRef(null);
|
|
27
|
+
const { iframeProps, messageHandlers } = useCoinflowPurchase(purchaseProps, '-v2');
|
|
28
|
+
const { showOverlay } = useOverlay(iframeRef);
|
|
29
|
+
const loaderBackground = iframeProps.loaderBackground || '#ffffff'; // white default bg
|
|
30
|
+
const invertedColor = invertHexColor(loaderBackground);
|
|
23
31
|
return (React.createElement("div", { style: styles.container(loaderBackground) },
|
|
24
|
-
React.createElement(CoinflowIFrame,
|
|
32
|
+
React.createElement(CoinflowIFrame, { ref: iframeRef, ...iframeProps, ...messageHandlers }),
|
|
25
33
|
showOverlay && (React.createElement(LoaderOverlay, { loaderBackground: loaderBackground, invertedColor: invertedColor }))));
|
|
26
34
|
}
|
|
27
|
-
function LoaderOverlay(
|
|
28
|
-
var loaderBackground = _a.loaderBackground, invertedColor = _a.invertedColor;
|
|
35
|
+
function LoaderOverlay({ loaderBackground, invertedColor, }) {
|
|
29
36
|
return (React.createElement("div", { style: styles.overlay(loaderBackground) },
|
|
30
37
|
React.createElement(LoaderGrid, { columns: 2 },
|
|
31
38
|
React.createElement(Loader, { loaderBackground: invertedColor }),
|
|
32
39
|
React.createElement(Loader, { loaderBackground: invertedColor })),
|
|
33
40
|
React.createElement(LoaderGrid, { columns: 1 },
|
|
34
41
|
React.createElement(Loader, { height: 80, loaderBackground: invertedColor })),
|
|
35
|
-
|
|
42
|
+
[...Array(3)].map((_, index) => (React.createElement(LoaderRow, { key: index },
|
|
36
43
|
React.createElement(Loader, { width: index < 2 ? 80 : 120, height: index < 2 ? 15 : 20, loaderBackground: invertedColor }),
|
|
37
|
-
React.createElement(Loader, { width: index < 2 ? 60 : 100, height: index < 2 ? 15 : 20, loaderBackground: invertedColor })))
|
|
44
|
+
React.createElement(Loader, { width: index < 2 ? 60 : 100, height: index < 2 ? 15 : 20, loaderBackground: invertedColor })))),
|
|
38
45
|
React.createElement(LoaderGrid, { columns: 1 },
|
|
39
46
|
React.createElement(Loader, { height: 60, loaderBackground: invertedColor })),
|
|
40
47
|
React.createElement(LoaderGrid, { columns: 1, width: "50%" },
|
|
@@ -42,33 +49,33 @@ function LoaderOverlay(_a) {
|
|
|
42
49
|
React.createElement(LoaderGrid, { columns: 1, width: "40%" },
|
|
43
50
|
React.createElement(Loader, { height: 6, loaderBackground: invertedColor }))));
|
|
44
51
|
}
|
|
45
|
-
function LoaderGrid(
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
function LoaderGrid({ children, columns, width = '100%', }) {
|
|
53
|
+
return (React.createElement("div", { style: {
|
|
54
|
+
...styles.grid,
|
|
55
|
+
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
56
|
+
width,
|
|
57
|
+
} }, children));
|
|
48
58
|
}
|
|
49
|
-
function LoaderRow(
|
|
50
|
-
var children = _a.children;
|
|
59
|
+
function LoaderRow({ children }) {
|
|
51
60
|
return React.createElement("div", { style: styles.row }, children);
|
|
52
61
|
}
|
|
53
|
-
function Loader(
|
|
54
|
-
var loaderBackground = _a.loaderBackground, _b = _a.height, height = _b === void 0 ? 40 : _b, width = _a.width;
|
|
62
|
+
function Loader({ loaderBackground, height = 40, width, }) {
|
|
55
63
|
return (React.createElement(React.Fragment, null,
|
|
56
64
|
React.createElement("div", { style: styles.loader(loaderBackground, height, width) }),
|
|
57
65
|
React.createElement("style", null, styles.keyframes)));
|
|
58
66
|
}
|
|
59
67
|
function invertHexColor(hex) {
|
|
60
|
-
var _a;
|
|
61
68
|
hex = hex.replace(/^#/, '');
|
|
62
|
-
|
|
63
|
-
return
|
|
69
|
+
const rgb = hex.match(/.{2}/g)?.map(val => 255 - parseInt(val, 16)) || [];
|
|
70
|
+
return `#${rgb.map(val => val.toString(16).padStart(2, '0')).join('')}`;
|
|
64
71
|
}
|
|
65
|
-
|
|
66
|
-
container:
|
|
72
|
+
const styles = {
|
|
73
|
+
container: (bg) => ({
|
|
67
74
|
position: 'relative',
|
|
68
75
|
height: '100%',
|
|
69
76
|
backgroundColor: bg,
|
|
70
|
-
})
|
|
71
|
-
overlay:
|
|
77
|
+
}),
|
|
78
|
+
overlay: (bg) => ({
|
|
72
79
|
backgroundColor: bg,
|
|
73
80
|
display: 'flex',
|
|
74
81
|
color: 'gray',
|
|
@@ -83,7 +90,7 @@ var styles = {
|
|
|
83
90
|
gap: '20px',
|
|
84
91
|
zIndex: 10,
|
|
85
92
|
padding: '20px',
|
|
86
|
-
})
|
|
93
|
+
}),
|
|
87
94
|
grid: {
|
|
88
95
|
display: 'grid',
|
|
89
96
|
gap: '20px',
|
|
@@ -94,13 +101,18 @@ var styles = {
|
|
|
94
101
|
justifyContent: 'space-between',
|
|
95
102
|
width: '100%',
|
|
96
103
|
},
|
|
97
|
-
loader:
|
|
98
|
-
width: width ?
|
|
99
|
-
height:
|
|
104
|
+
loader: (bg, height, width) => ({
|
|
105
|
+
width: width ? `${width}px` : '100%',
|
|
106
|
+
height: `${height}px`,
|
|
100
107
|
backgroundColor: bg,
|
|
101
108
|
borderRadius: '4px',
|
|
102
109
|
animation: 'pulse 1.5s infinite',
|
|
103
|
-
})
|
|
104
|
-
keyframes:
|
|
110
|
+
}),
|
|
111
|
+
keyframes: `
|
|
112
|
+
@keyframes pulse {
|
|
113
|
+
0%, 100% { opacity: 0.07; }
|
|
114
|
+
50% { opacity: 0.03; }
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
105
117
|
};
|
|
106
118
|
//# sourceMappingURL=CoinflowPurchase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAGL,aAAa,EACb,WAAW,EACX,eAAe,GA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C;QACvD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM;QACpC,MAAM,EAAE,GAAG,MAAM,IAAI;QACrB,eAAe,EAAE,EAAE;QACnB,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,qBAAqB;KACjC,CAAC;IACF,SAAS,EAAE;;;;;GAKV;CACF,CAAC"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { CoinflowIFrame, useRandomHandleHeightChangeId } from './CoinflowIFrame';
|
|
3
2
|
import React, { useMemo } from 'react';
|
|
4
3
|
import { getHandlers, getWalletPubkey, } from './common';
|
|
5
4
|
export function CoinflowPurchaseHistory(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
5
|
+
const handleHeightChangeId = useRandomHandleHeightChangeId();
|
|
6
|
+
const iframeProps = useMemo(() => {
|
|
7
|
+
const walletPubkey = getWalletPubkey(props);
|
|
8
|
+
return {
|
|
9
|
+
...props,
|
|
10
|
+
walletPubkey,
|
|
11
|
+
route: `/history/purchase/${props.merchantId}`,
|
|
12
|
+
transaction: undefined,
|
|
13
|
+
handleHeightChangeId,
|
|
14
|
+
};
|
|
10
15
|
}, [handleHeightChangeId, props]);
|
|
11
|
-
|
|
12
|
-
return
|
|
16
|
+
const messageHandlers = useMemo(() => {
|
|
17
|
+
return {
|
|
18
|
+
...getHandlers(props),
|
|
19
|
+
handleHeightChange: props.handleHeightChange,
|
|
20
|
+
};
|
|
13
21
|
}, [props]);
|
|
14
|
-
return React.createElement(CoinflowIFrame,
|
|
22
|
+
return React.createElement(CoinflowIFrame, { ...iframeProps, ...messageHandlers });
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=CoinflowPurchaseHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,6BAA6B,EAAC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAGL,WAAW,EAEX,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,MAAM,UAAU,uBAAuB,CAAC,KAA2B;IACjE,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAsB,GAAG,EAAE;QACpD,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO;YACL,GAAG,KAAK;YACR,YAAY;YACZ,KAAK,EAAE,qBAAqB,KAAK,CAAC,UAAU,EAAE;YAC9C,WAAW,EAAE,SAAS;YACtB,oBAAoB;SACrB,CAAC;IACJ,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC;IAElC,MAAM,eAAe,GAAG,OAAO,CAAwB,GAAG,EAAE;QAC1D,OAAO;YACL,GAAG,WAAW,CAAC,KAAK,CAAC;YACrB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;SAC7C,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,oBAAC,cAAc,OAAK,WAAW,KAAM,eAAe,GAAI,CAAC;AAClE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CoinflowEnvs } from './common';
|
|
2
|
-
export declare function CoinflowPurchaseProtection({ coinflowEnv, merchantId
|
|
2
|
+
export declare function CoinflowPurchaseProtection({ coinflowEnv, merchantId }: {
|
|
3
3
|
coinflowEnv: CoinflowEnvs;
|
|
4
4
|
merchantId: string;
|
|
5
5
|
}): null;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { CoinflowUtils } from './common';
|
|
3
3
|
import nsureSDK from '@nsure-ai/web-client-sdk';
|
|
4
|
-
export function CoinflowPurchaseProtection(
|
|
5
|
-
|
|
6
|
-
var appId = useMemo(function () {
|
|
4
|
+
export function CoinflowPurchaseProtection({ coinflowEnv, merchantId, }) {
|
|
5
|
+
const appId = useMemo(() => {
|
|
7
6
|
return coinflowEnv === 'prod'
|
|
8
7
|
? '9JBW2RHC7JNJN8ZQ'
|
|
9
8
|
: 'SANDBOX_CTCE4XK53ZW0R7V1';
|
|
10
9
|
}, [coinflowEnv]);
|
|
11
|
-
|
|
12
|
-
useEffect(
|
|
10
|
+
const [partnerId, setPartnerId] = useState(undefined);
|
|
11
|
+
useEffect(() => {
|
|
13
12
|
new CoinflowUtils(coinflowEnv)
|
|
14
13
|
.getNSurePartnerId(merchantId)
|
|
15
|
-
.then(
|
|
14
|
+
.then(partnerId => setPartnerId(partnerId));
|
|
16
15
|
}, [merchantId, coinflowEnv]);
|
|
17
|
-
useEffect(
|
|
16
|
+
useEffect(() => {
|
|
18
17
|
if (partnerId) {
|
|
19
18
|
nsureSDK.init(appId, partnerId);
|
|
20
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchaseProtection.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseProtection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnD,OAAO,EAAe,aAAa,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAEhD,MAAM,UAAU,0BAA0B,CAAC,
|
|
1
|
+
{"version":3,"file":"CoinflowPurchaseProtection.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseProtection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnD,OAAO,EAAe,aAAa,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,QAAQ,MAAM,0BAA0B,CAAC;AAEhD,MAAM,UAAU,0BAA0B,CAAC,EACzC,WAAW,EACX,UAAU,GAIX;IACC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,OAAO,WAAW,KAAK,MAAM;YAC3B,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,0BAA0B,CAAC;IACjC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAClB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAC1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,aAAa,CAAC,WAAW,CAAC;aAC3B,iBAAiB,CAAC,UAAU,CAAC;aAC7B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;IAC9B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE,CAAC;YACd,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IACvB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import React, { useMemo } from 'react';
|
|
3
2
|
import { CoinflowIFrame, useRandomHandleHeightChangeId } from './CoinflowIFrame';
|
|
4
3
|
import { getHandlers, getWalletPubkey, } from './common';
|
|
5
4
|
export function CoinflowWithdraw(withdrawProps) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
5
|
+
const handleHeightChangeId = useRandomHandleHeightChangeId();
|
|
6
|
+
const iframeProps = useMemo(() => {
|
|
7
|
+
const walletPubkey = getWalletPubkey(withdrawProps);
|
|
8
|
+
return {
|
|
9
|
+
...withdrawProps,
|
|
10
|
+
walletPubkey,
|
|
11
|
+
route: `/withdraw/${withdrawProps.merchantId}`,
|
|
12
|
+
transaction: undefined,
|
|
13
|
+
handleHeightChangeId,
|
|
14
|
+
};
|
|
10
15
|
}, [handleHeightChangeId, withdrawProps]);
|
|
11
|
-
|
|
12
|
-
return
|
|
16
|
+
const messageHandlers = useMemo(() => {
|
|
17
|
+
return {
|
|
18
|
+
...getHandlers(withdrawProps),
|
|
19
|
+
handleHeightChange: withdrawProps.handleHeightChange,
|
|
20
|
+
};
|
|
13
21
|
}, [withdrawProps]);
|
|
14
|
-
return React.createElement(CoinflowIFrame,
|
|
22
|
+
return React.createElement(CoinflowIFrame, { ...iframeProps, ...messageHandlers });
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=CoinflowWithdraw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,cAAc,EAAE,6BAA6B,EAAC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAGL,WAAW,EAEX,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,MAAM,UAAU,gBAAgB,CAAC,aAAoC;IACnE,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAsB,GAAG,EAAE;QACpD,MAAM,YAAY,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;QACpD,OAAO;YACL,GAAG,aAAa;YAChB,YAAY;YACZ,KAAK,EAAE,aAAa,aAAa,CAAC,UAAU,EAAE;YAC9C,WAAW,EAAE,SAAS;YACtB,oBAAoB;SACrB,CAAC;IACJ,CAAC,EAAE,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;IAE1C,MAAM,eAAe,GAAG,OAAO,CAAwB,GAAG,EAAE;QAC1D,OAAO;YACL,GAAG,WAAW,CAAC,aAAa,CAAC;YAC7B,kBAAkB,EAAE,aAAa,CAAC,kBAAkB;SACrD,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,oBAAC,cAAc,OAAK,WAAW,KAAM,eAAe,GAAI,CAAC;AAClE,CAAC"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { CoinflowIFrame, useRandomHandleHeightChangeId } from './CoinflowIFrame';
|
|
3
2
|
import React, { useMemo } from 'react';
|
|
4
3
|
import { getWalletPubkey, getHandlers, } from './common';
|
|
5
4
|
export function CoinflowWithdrawHistory(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
5
|
+
const handleHeightChangeId = useRandomHandleHeightChangeId();
|
|
6
|
+
const iframeProps = useMemo(() => {
|
|
7
|
+
const walletPubkey = getWalletPubkey(props);
|
|
8
|
+
return {
|
|
9
|
+
...props,
|
|
10
|
+
walletPubkey,
|
|
11
|
+
route: `/history/withdraw/${props.merchantId}`,
|
|
12
|
+
transaction: undefined,
|
|
13
|
+
handleHeightChangeId,
|
|
14
|
+
};
|
|
10
15
|
}, [handleHeightChangeId, props]);
|
|
11
|
-
|
|
12
|
-
return
|
|
16
|
+
const messageHandlers = useMemo(() => {
|
|
17
|
+
return {
|
|
18
|
+
...getHandlers(props),
|
|
19
|
+
handleHeightChange: props.handleHeightChange,
|
|
20
|
+
};
|
|
13
21
|
}, [props]);
|
|
14
|
-
return React.createElement(CoinflowIFrame,
|
|
22
|
+
return React.createElement(CoinflowIFrame, { ...iframeProps, ...messageHandlers });
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=CoinflowWithdrawHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,6BAA6B,EAAC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAEL,eAAe,EAEf,WAAW,GAEZ,MAAM,UAAU,CAAC;AAElB,MAAM,UAAU,uBAAuB,CAAC,KAA2B;IACjE,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAsB,GAAG,EAAE;QACpD,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO;YACL,GAAG,KAAK;YACR,YAAY;YACZ,KAAK,EAAE,qBAAqB,KAAK,CAAC,UAAU,EAAE;YAC9C,WAAW,EAAE,SAAS;YACtB,oBAAoB;SACrB,CAAC;IACJ,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC;IAElC,MAAM,eAAe,GAAG,OAAO,CAAwB,GAAG,EAAE;QAC1D,OAAO;YACL,GAAG,WAAW,CAAC,KAAK,CAAC;YACrB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;SAC7C,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,oBAAC,cAAc,OAAK,WAAW,KAAM,eAAe,GAAI,CAAC;AAClE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoinflowPurchaseProps } from './common';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare function MobileWalletButton({ props, route, overlayDisplayOverride, children, alignItems
|
|
3
|
+
export declare function MobileWalletButton({ props, route, overlayDisplayOverride, children, alignItems }: {
|
|
4
4
|
props: CoinflowPurchaseProps & MobileWalletButtonProps;
|
|
5
5
|
route: string;
|
|
6
6
|
overlayDisplayOverride?: string;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { getHandlers, getWalletPubkey, } from './common';
|
|
3
2
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
4
3
|
import { CoinflowIFrame, useRandomHandleHeightChangeId, } from './CoinflowIFrame';
|
|
5
4
|
import { useOverlay } from './useOverlay';
|
|
6
|
-
export function MobileWalletButton(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
useEffect(function () {
|
|
5
|
+
export function MobileWalletButton({ props, route, overlayDisplayOverride, children, alignItems, }) {
|
|
6
|
+
const iframeRef = useRef(null);
|
|
7
|
+
const { opacity, display } = useOverlay(iframeRef);
|
|
8
|
+
const { onSuccess, onError } = props;
|
|
9
|
+
useEffect(() => {
|
|
12
10
|
if (!onSuccess)
|
|
13
11
|
return;
|
|
14
|
-
if (!
|
|
12
|
+
if (!iframeRef?.current)
|
|
15
13
|
return;
|
|
16
14
|
iframeRef.current
|
|
17
|
-
.listenForMessage(
|
|
15
|
+
.listenForMessage((data) => {
|
|
18
16
|
try {
|
|
19
|
-
|
|
17
|
+
const res = JSON.parse(data);
|
|
20
18
|
if ('method' in res && res.data.startsWith('ERROR')) {
|
|
21
|
-
onError
|
|
19
|
+
onError?.(res.info);
|
|
22
20
|
return false;
|
|
23
21
|
}
|
|
24
22
|
return 'method' in res && res.method === 'getToken';
|
|
@@ -27,15 +25,25 @@ export function MobileWalletButton(_a) {
|
|
|
27
25
|
return false;
|
|
28
26
|
}
|
|
29
27
|
})
|
|
30
|
-
.then(
|
|
28
|
+
.then(data => onSuccess?.(data));
|
|
31
29
|
}, [onError, onSuccess]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
30
|
+
const handleHeightChangeId = useRandomHandleHeightChangeId();
|
|
31
|
+
const iframeProps = useMemo(() => {
|
|
32
|
+
const walletPubkey = getWalletPubkey(props);
|
|
33
|
+
return {
|
|
34
|
+
...props,
|
|
35
|
+
walletPubkey,
|
|
36
|
+
transaction: undefined,
|
|
37
|
+
routePrefix: 'form',
|
|
38
|
+
route: `/${route}/${props.merchantId}`,
|
|
39
|
+
handleHeightChangeId,
|
|
40
|
+
};
|
|
36
41
|
}, [handleHeightChangeId, props, route]);
|
|
37
|
-
|
|
38
|
-
return
|
|
42
|
+
const messageHandlers = useMemo(() => {
|
|
43
|
+
return {
|
|
44
|
+
...getHandlers(props),
|
|
45
|
+
handleHeightChange: props.handleHeightChange,
|
|
46
|
+
};
|
|
39
47
|
}, [props]);
|
|
40
48
|
return (React.createElement("div", { style: {
|
|
41
49
|
position: 'relative',
|
|
@@ -50,10 +58,10 @@ export function MobileWalletButton(_a) {
|
|
|
50
58
|
bottom: 0,
|
|
51
59
|
left: 0,
|
|
52
60
|
zIndex: 20,
|
|
53
|
-
display: overlayDisplayOverride
|
|
54
|
-
opacity
|
|
61
|
+
display: overlayDisplayOverride ?? display,
|
|
62
|
+
opacity,
|
|
55
63
|
justifyContent: 'center',
|
|
56
|
-
alignItems
|
|
64
|
+
alignItems,
|
|
57
65
|
pointerEvents: 'none',
|
|
58
66
|
} }, children),
|
|
59
67
|
React.createElement("div", { style: {
|
|
@@ -61,6 +69,6 @@ export function MobileWalletButton(_a) {
|
|
|
61
69
|
zIndex: 10,
|
|
62
70
|
height: '100%',
|
|
63
71
|
} },
|
|
64
|
-
React.createElement(CoinflowIFrame,
|
|
72
|
+
React.createElement(CoinflowIFrame, { ref: iframeRef, ...iframeProps, ...messageHandlers }))));
|
|
65
73
|
}
|
|
66
74
|
//# sourceMappingURL=MobileWalletButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileWalletButton.js","sourceRoot":"","sources":["../../src/MobileWalletButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MobileWalletButton.js","sourceRoot":"","sources":["../../src/MobileWalletButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,eAAe,GAEhB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,EACL,cAAc,EAEd,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,KAAK,EACL,sBAAsB,EACtB,QAAQ,EACR,UAAU,GAOX;IACC,MAAM,SAAS,GAAG,MAAM,CAAiC,IAAI,CAAC,CAAC;IAC/D,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAEjD,MAAM,EAAC,SAAS,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS;YAAE,OAAO;QACvB,IAAI,CAAC,SAAS,EAAE,OAAO;YAAE,OAAO;QAChC,SAAS,CAAC,OAAO;aACd,gBAAgB,CAAC,CAAC,IAAY,EAAE,EAAE;YACjC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAE7B,IAAI,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;oBACpD,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACpB,OAAO,KA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