@coinflowlabs/react 4.1.0 → 4.1.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.
- package/README.md +1 -0
- package/build/cjs/CoinflowApplePayButton.d.ts +3 -5
- package/build/cjs/CoinflowApplePayButton.js +42 -38
- package/build/cjs/CoinflowApplePayButton.js.map +1 -1
- package/build/cjs/CoinflowCardForm.d.ts +2 -2
- package/build/cjs/CoinflowCardForm.js +35 -38
- package/build/cjs/CoinflowCardForm.js.map +1 -1
- package/build/cjs/CoinflowGooglePayButton.d.ts +1 -1
- package/build/cjs/CoinflowIFrame.d.ts +7 -2
- package/build/cjs/CoinflowIFrame.js +65 -6
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.d.ts +2 -3
- package/build/cjs/CoinflowPurchase.js +11 -67
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowPurchaseHistory.d.ts +2 -2
- package/build/cjs/CoinflowPurchaseHistory.js +10 -42
- package/build/cjs/CoinflowPurchaseHistory.js.map +1 -1
- package/build/cjs/CoinflowPurchaseProtection.d.ts +1 -1
- package/build/cjs/CoinflowPurchaseProtection.js +2 -2
- package/build/cjs/CoinflowPurchaseProtection.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +3 -3
- package/build/cjs/CoinflowWithdraw.js +11 -45
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/CoinflowWithdrawHistory.d.ts +2 -2
- package/build/cjs/CoinflowWithdrawHistory.js +10 -43
- package/build/cjs/CoinflowWithdrawHistory.js.map +1 -1
- package/build/cjs/common/CoinflowLibMessageHandlers.d.ts +21 -0
- package/build/cjs/common/CoinflowLibMessageHandlers.js +186 -0
- package/build/cjs/common/CoinflowLibMessageHandlers.js.map +1 -0
- package/build/cjs/{CoinflowTypes.d.ts → common/CoinflowTypes.d.ts} +36 -41
- package/build/cjs/{CoinflowTypes.js → common/CoinflowTypes.js} +3 -2
- package/build/cjs/common/CoinflowTypes.js.map +1 -0
- package/build/cjs/common/CoinflowUtils.d.ts +21 -0
- package/build/cjs/{CoinflowUtils.js → common/CoinflowUtils.js} +37 -22
- package/build/cjs/common/CoinflowUtils.js.map +1 -0
- package/build/cjs/common/SolanaPeerDeps.d.ts +5 -0
- package/build/cjs/common/SolanaPeerDeps.js +22 -0
- package/build/cjs/common/SolanaPeerDeps.js.map +1 -0
- package/build/cjs/common/index.d.ts +3 -0
- package/build/cjs/common/index.js +7 -0
- package/build/cjs/common/index.js.map +1 -0
- package/build/cjs/index.d.ts +1 -3
- package/build/cjs/index.js +1 -3
- package/build/cjs/index.js.map +1 -1
- package/build/esm/CoinflowApplePayButton.d.ts +3 -5
- package/build/esm/CoinflowApplePayButton.js +42 -36
- package/build/esm/CoinflowApplePayButton.js.map +1 -1
- package/build/esm/CoinflowCardForm.d.ts +2 -2
- package/build/esm/CoinflowCardForm.js +37 -40
- package/build/esm/CoinflowCardForm.js.map +1 -1
- package/build/esm/CoinflowGooglePayButton.d.ts +1 -1
- package/build/esm/CoinflowIFrame.d.ts +7 -2
- package/build/esm/CoinflowIFrame.js +66 -5
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.d.ts +2 -3
- package/build/esm/CoinflowPurchase.js +10 -65
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowPurchaseHistory.d.ts +2 -2
- package/build/esm/CoinflowPurchaseHistory.js +10 -42
- package/build/esm/CoinflowPurchaseHistory.js.map +1 -1
- package/build/esm/CoinflowPurchaseProtection.d.ts +1 -1
- package/build/esm/CoinflowPurchaseProtection.js +1 -1
- package/build/esm/CoinflowPurchaseProtection.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +3 -3
- package/build/esm/CoinflowWithdraw.js +11 -45
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/CoinflowWithdrawHistory.d.ts +2 -2
- package/build/esm/CoinflowWithdrawHistory.js +10 -43
- package/build/esm/CoinflowWithdrawHistory.js.map +1 -1
- package/build/esm/common/CoinflowLibMessageHandlers.d.ts +21 -0
- package/build/esm/common/CoinflowLibMessageHandlers.js +180 -0
- package/build/esm/common/CoinflowLibMessageHandlers.js.map +1 -0
- package/build/esm/{CoinflowTypes.d.ts → common/CoinflowTypes.d.ts} +36 -41
- package/build/esm/{CoinflowTypes.js → common/CoinflowTypes.js} +2 -3
- package/build/esm/common/CoinflowTypes.js.map +1 -0
- package/build/esm/common/CoinflowUtils.d.ts +21 -0
- package/build/esm/{CoinflowUtils.js → common/CoinflowUtils.js} +37 -22
- package/build/esm/common/CoinflowUtils.js.map +1 -0
- package/build/esm/common/SolanaPeerDeps.d.ts +5 -0
- package/build/esm/common/SolanaPeerDeps.js +17 -0
- package/build/esm/common/SolanaPeerDeps.js.map +1 -0
- package/build/esm/common/index.d.ts +3 -0
- package/build/esm/common/index.js +4 -0
- package/build/esm/common/index.js.map +1 -0
- package/build/esm/index.d.ts +1 -3
- package/build/esm/index.js +1 -3
- package/build/esm/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -10
- package/build/cjs/CoinflowTypes.js.map +0 -1
- package/build/cjs/CoinflowUtils.d.ts +0 -22
- package/build/cjs/CoinflowUtils.js.map +0 -1
- package/build/cjs/useHandleHeightChange.d.ts +0 -2
- package/build/cjs/useHandleHeightChange.js +0 -24
- package/build/cjs/useHandleHeightChange.js.map +0 -1
- package/build/cjs/wallet/EthIFrameMessageHandlers.d.ts +0 -5
- package/build/cjs/wallet/EthIFrameMessageHandlers.js +0 -42
- package/build/cjs/wallet/EthIFrameMessageHandlers.js.map +0 -1
- package/build/cjs/wallet/NearIFrameMessageHandlers.d.ts +0 -5
- package/build/cjs/wallet/NearIFrameMessageHandlers.js +0 -31
- package/build/cjs/wallet/NearIFrameMessageHandlers.js.map +0 -1
- package/build/cjs/wallet/SocketService.d.ts +0 -5
- package/build/cjs/wallet/SocketService.js +0 -43
- package/build/cjs/wallet/SocketService.js.map +0 -1
- package/build/cjs/wallet/SolanaIFrameMessageHandlers.d.ts +0 -19
- package/build/cjs/wallet/SolanaIFrameMessageHandlers.js +0 -132
- package/build/cjs/wallet/SolanaIFrameMessageHandlers.js.map +0 -1
- package/build/cjs/wallet/useIframeWallet.d.ts +0 -15
- package/build/cjs/wallet/useIframeWallet.js +0 -137
- package/build/cjs/wallet/useIframeWallet.js.map +0 -1
- package/build/esm/CoinflowTypes.js.map +0 -1
- package/build/esm/CoinflowUtils.d.ts +0 -22
- package/build/esm/CoinflowUtils.js.map +0 -1
- package/build/esm/useHandleHeightChange.d.ts +0 -2
- package/build/esm/useHandleHeightChange.js +0 -19
- package/build/esm/useHandleHeightChange.js.map +0 -1
- package/build/esm/wallet/EthIFrameMessageHandlers.d.ts +0 -5
- package/build/esm/wallet/EthIFrameMessageHandlers.js +0 -38
- package/build/esm/wallet/EthIFrameMessageHandlers.js.map +0 -1
- package/build/esm/wallet/NearIFrameMessageHandlers.d.ts +0 -5
- package/build/esm/wallet/NearIFrameMessageHandlers.js +0 -27
- package/build/esm/wallet/NearIFrameMessageHandlers.js.map +0 -1
- package/build/esm/wallet/SocketService.d.ts +0 -5
- package/build/esm/wallet/SocketService.js +0 -35
- package/build/esm/wallet/SocketService.js.map +0 -1
- package/build/esm/wallet/SolanaIFrameMessageHandlers.d.ts +0 -19
- package/build/esm/wallet/SolanaIFrameMessageHandlers.js +0 -128
- package/build/esm/wallet/SolanaIFrameMessageHandlers.js.map +0 -1
- package/build/esm/wallet/useIframeWallet.d.ts +0 -15
- package/build/esm/wallet/useIframeWallet.js +0 -131
- package/build/esm/wallet/useIframeWallet.js.map +0 -1
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ Props:
|
|
|
59
59
|
* `supportsVersionedTransactions` (optional): Instruct the system that you support versioned transactions
|
|
60
60
|
* `rent` (optional, Solana only): Specify the blockchain rent amount to add to the total
|
|
61
61
|
* `nativeSolToConvert` (optional, Solana only): Specify the amount of native SOL to convert wSOL for the purchase
|
|
62
|
+
* `jwtToken` (optional): A JWT token which encodes verified checkout parameters to prevent spoofing of arguments.
|
|
62
63
|
|
|
63
64
|
## Utils
|
|
64
65
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { CoinflowPurchaseProps } from './
|
|
2
|
-
import React from
|
|
1
|
+
import { CoinflowPurchaseProps } from './common';
|
|
2
|
+
import React from "react";
|
|
3
3
|
export declare function CoinflowApplePayButton(props: CoinflowPurchaseProps & MobileWalletButtonProps): React.JSX.Element;
|
|
4
4
|
export declare function MobileWalletButton({ props, route }: {
|
|
5
5
|
props: CoinflowPurchaseProps;
|
|
6
6
|
route: string;
|
|
7
|
-
}): React.JSX.Element
|
|
7
|
+
}): React.JSX.Element;
|
|
8
8
|
export interface MobileWalletButtonProps {
|
|
9
9
|
color: "white" | "black";
|
|
10
10
|
}
|
|
11
|
-
export declare function useStringWalletPubkey(props: CoinflowPurchaseProps): string | null | undefined;
|
|
12
|
-
export declare function useGetTokenHandler(props: CoinflowPurchaseProps): void;
|
|
@@ -1,55 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MobileWalletButton = exports.CoinflowApplePayButton = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var common_1 = require("./common");
|
|
5
6
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
6
7
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
-
var useHandleHeightChange_1 = require("./useHandleHeightChange");
|
|
8
|
-
var useIframeWallet_1 = require("./wallet/useIframeWallet");
|
|
9
|
-
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
10
8
|
function CoinflowApplePayButton(props) {
|
|
11
9
|
return react_1.default.createElement(MobileWalletButton, { props: props, route: 'apple-pay' });
|
|
12
10
|
}
|
|
13
11
|
exports.CoinflowApplePayButton = CoinflowApplePayButton;
|
|
14
12
|
function MobileWalletButton(_a) {
|
|
15
13
|
var props = _a.props, route = _a.route;
|
|
16
|
-
var
|
|
17
|
-
(0, useHandleHeightChange_1.useHandleHeightChange)(props.handleHeightChange);
|
|
18
|
-
useGetTokenHandler(props);
|
|
19
|
-
var walletPubkey = useStringWalletPubkey(props);
|
|
20
|
-
if (!walletPubkey)
|
|
21
|
-
return null;
|
|
22
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, transaction: undefined, routePrefix: 'form', route: "/".concat(route, "/").concat(props.merchantId) });
|
|
23
|
-
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps));
|
|
24
|
-
}
|
|
25
|
-
exports.MobileWalletButton = MobileWalletButton;
|
|
26
|
-
function useStringWalletPubkey(props) {
|
|
27
|
-
return (0, react_1.useMemo)(function () {
|
|
28
|
-
var getWalletPubkey = CoinflowUtils_1.CoinflowUtils.byBlockchain(props.blockchain, {
|
|
29
|
-
solana: function () { var _a, _b; return (_b = (_a = props === null || props === void 0 ? void 0 : props.wallet) === null || _a === void 0 ? void 0 : _a.publicKey) === null || _b === void 0 ? void 0 : _b.toString(); },
|
|
30
|
-
near: function () { return props.wallet.accountId; },
|
|
31
|
-
eth: function () { return props.wallet.address; },
|
|
32
|
-
polygon: function () { return props.wallet.address; },
|
|
33
|
-
base: function () { return props.wallet.address; },
|
|
34
|
-
});
|
|
35
|
-
return getWalletPubkey();
|
|
36
|
-
}, [props]);
|
|
37
|
-
}
|
|
38
|
-
exports.useStringWalletPubkey = useStringWalletPubkey;
|
|
39
|
-
function useGetTokenHandler(props) {
|
|
14
|
+
var iframeRef = (0, react_1.useRef)(null);
|
|
40
15
|
var onSuccess = props.onSuccess;
|
|
41
16
|
(0, react_1.useEffect)(function () {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
17
|
+
if (!onSuccess)
|
|
18
|
+
return;
|
|
19
|
+
if (!(iframeRef === null || iframeRef === void 0 ? void 0 : iframeRef.current))
|
|
20
|
+
return;
|
|
21
|
+
iframeRef.current.listenForMessage(function (data) {
|
|
22
|
+
try {
|
|
23
|
+
var res = JSON.parse(data);
|
|
24
|
+
return 'method' in res && res.method === 'getToken';
|
|
46
25
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
window.addEventListener('message', handler);
|
|
26
|
+
catch (e) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}).then(function (data) { return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data); });
|
|
52
30
|
}, [onSuccess]);
|
|
31
|
+
var iframeProps = (0, react_1.useMemo)(function () {
|
|
32
|
+
var walletPubkey = (0, common_1.getWalletPubkey)(props);
|
|
33
|
+
return tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: walletPubkey, transaction: undefined, routePrefix: 'form', route: "/".concat(route, "/").concat(props.merchantId) });
|
|
34
|
+
}, [props, route]);
|
|
35
|
+
var messageHandlers = (0, react_1.useMemo)(function () {
|
|
36
|
+
return tslib_1.__assign(tslib_1.__assign({}, (0, common_1.getHandlers)(props)), { handleHeightChange: props.handleHeightChange });
|
|
37
|
+
}, [props]);
|
|
38
|
+
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({ ref: iframeRef }, iframeProps, messageHandlers));
|
|
53
39
|
}
|
|
54
|
-
exports.
|
|
40
|
+
exports.MobileWalletButton = MobileWalletButton;
|
|
41
|
+
// TODO
|
|
42
|
+
// export function useGetTokenHandler(props: CoinflowPurchaseProps) {
|
|
43
|
+
// const {onSuccess} = props;
|
|
44
|
+
//
|
|
45
|
+
// useEffect(() => {
|
|
46
|
+
// const handler = getMessageHandler('getToken', (data: string) => {
|
|
47
|
+
// if (data.startsWith('ERROR')) {
|
|
48
|
+
// console.error('Mobile Wallet Payment Error', data.replace('ERROR', ''));
|
|
49
|
+
// return;
|
|
50
|
+
// }
|
|
51
|
+
//
|
|
52
|
+
// onSuccess?.(data);
|
|
53
|
+
// });
|
|
54
|
+
//
|
|
55
|
+
// if (!window) throw new Error('Window not defined');
|
|
56
|
+
// window.addEventListener('message', handler);
|
|
57
|
+
// }, [onSuccess]);
|
|
58
|
+
// }
|
|
55
59
|
//# sourceMappingURL=CoinflowApplePayButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowApplePayButton.js","sourceRoot":"","sources":["../../src/CoinflowApplePayButton.tsx"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"CoinflowApplePayButton.js","sourceRoot":"","sources":["../../src/CoinflowApplePayButton.tsx"],"names":[],"mappings":";;;;AAAA,mCAMkB;AAClB,mDAAkF;AAClF,qDAA0D;AAE1D,SAAgB,sBAAsB,CAAC,KAAsD;IAC3F,OAAO,8BAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,GAAI,CAAC;AAClE,CAAC;AAFD,wDAEC;AAED,SAAgB,kBAAkB,CAAC,EAA6D;QAA5D,KAAK,WAAA,EAAE,KAAK,WAAA;IAC9C,IAAM,SAAS,GAAG,IAAA,cAAM,EAAiC,IAAI,CAAC,CAAC;IACxD,IAAA,SAAS,GAAI,KAAK,UAAT,CAAU;IAE1B,IAAA,iBAAS,EAAC;QACR,IAAI,CAAC,SAAS;YAAE,OAAO;QACvB,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAA;YAAE,OAAO;QAChC,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,UAAC,IAAY;YAC9C,IAAI,CAAC;gBACH,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,UAAU,CAAA;YACrD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,IAAI,CAAC,EAAjB,CAAiB,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,IAAM,WAAW,GAAG,IAAA,eAAO,EAAsB;QAC/C,IAAM,YAAY,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC;QAC5C,6CACK,KAAK,KACR,YAAY,cAAA,EACZ,WAAW,EAAE,SAAS,EACtB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,WAAI,KAAK,cAAI,KAAK,CAAC,UAAU,CAAE,IACvC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IACnB,IAAM,eAAe,GAAG,IAAA,eAAO,EAAwB;QACrD,6CACK,IAAA,oBAAW,EAAC,KAAK,CAAC,KACrB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAC5C;IACJ,CAAC,EAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEb,OAAO,8BAAC,+BAAc,qBAAC,GAAG,EAAE,SAAS,IAAM,WAAW,EAAO,eAAe,EAAI,CAAC;AACnF,CAAC;AAnCD,gDAmCC;AAMD,OAAO;AACP,qEAAqE;AACrE,+BAA+B;AAC/B,EAAE;AACF,sBAAsB;AACtB,wEAAwE;AACxE,wCAAwC;AACxC,mFAAmF;AACnF,kBAAkB;AAClB,UAAU;AACV,EAAE;AACF,2BAA2B;AAC3B,UAAU;AACV,EAAE;AACF,0DAA0D;AAC1D,mDAAmD;AACnD,qBAAqB;AACrB,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { CSSProperties } from
|
|
2
|
-
import { CoinflowBlockchain, CoinflowEnvs } from './
|
|
1
|
+
import React, { CSSProperties } from "react";
|
|
2
|
+
import { CoinflowBlockchain, CoinflowEnvs } from './common';
|
|
3
3
|
export type CoinflowCardTokenResponse = {
|
|
4
4
|
last4: string;
|
|
5
5
|
type: 'VISA' | 'MSTR' | 'AMEX' | 'DISC';
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CoinflowCardForm = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
var useIframeWallet_1 = require("./wallet/useIframeWallet");
|
|
7
6
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
8
|
-
var useHandleHeightChange_1 = require("./useHandleHeightChange");
|
|
9
7
|
/**
|
|
10
8
|
* Allows merchants to collect card information from their customers in a PCI-compliant way and receive a token for use with the `/api/checkout/token` endpoint.
|
|
11
9
|
*
|
|
@@ -26,56 +24,55 @@ var useHandleHeightChange_1 = require("./useHandleHeightChange");
|
|
|
26
24
|
*
|
|
27
25
|
* ```
|
|
28
26
|
*/
|
|
29
|
-
exports.CoinflowCardForm = (0, react_1.forwardRef)(function (
|
|
30
|
-
var
|
|
31
|
-
var IFrameRef = (0, react_1.useRef)(null);
|
|
32
|
-
(0, useHandleHeightChange_1.useHandleHeightChange)(handleHeightChange);
|
|
27
|
+
exports.CoinflowCardForm = (0, react_1.forwardRef)(function (props, ref) {
|
|
28
|
+
var iframeRef = (0, react_1.useRef)();
|
|
33
29
|
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
34
30
|
getToken: function () {
|
|
35
31
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
36
|
-
var
|
|
37
|
-
return tslib_1.__generator(this, function (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
var methodName, isValid, response;
|
|
33
|
+
return tslib_1.__generator(this, function (_a) {
|
|
34
|
+
switch (_a.label) {
|
|
35
|
+
case 0:
|
|
36
|
+
methodName = 'getToken';
|
|
37
|
+
if (!iframeRef.current)
|
|
38
|
+
throw new Error('Unable to get token');
|
|
39
|
+
isValid = function (data) {
|
|
40
|
+
try {
|
|
41
|
+
var res = JSON.parse(data);
|
|
42
|
+
return 'method' in res && res.method === methodName;
|
|
46
43
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
catch (e) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return [4 /*yield*/, iframeRef.current.sendAndReceiveMessage(methodName, isValid)];
|
|
49
|
+
case 1:
|
|
50
|
+
response = _a.sent();
|
|
51
|
+
return [2 /*return*/, JSON.parse(response).data];
|
|
52
|
+
}
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
}); });
|
|
57
57
|
var merchantCss = (0, react_1.useMemo)(function () {
|
|
58
|
-
if (!customCss)
|
|
58
|
+
if (!props.customCss)
|
|
59
59
|
return undefined;
|
|
60
|
-
var cssStr = Object.entries(customCss).reduce(function (acc, _a) {
|
|
60
|
+
var cssStr = Object.entries(props.customCss).reduce(function (acc, _a) {
|
|
61
61
|
var key = _a[0], value = _a[1];
|
|
62
62
|
return acc + "".concat(key, " {").concat(CSSPropertiesToComponent(value), "}\n");
|
|
63
63
|
}, '');
|
|
64
64
|
return Buffer.from(cssStr).toString('base64');
|
|
65
|
-
}, [customCss]);
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
handleHeightChange: handleHeightChange,
|
|
77
|
-
};
|
|
78
|
-
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iFrameProps));
|
|
65
|
+
}, [props.customCss]);
|
|
66
|
+
var iframeProps = (0, react_1.useMemo)(function () {
|
|
67
|
+
return tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: props.walletPubkey, route: "/checkout-form/".concat(props.merchantId), routePrefix: 'form', merchantCss: merchantCss, transaction: undefined });
|
|
68
|
+
}, [merchantCss, props]);
|
|
69
|
+
var messageHandlers = (0, react_1.useMemo)(function () {
|
|
70
|
+
return {
|
|
71
|
+
handleSendTransaction: function () { throw new Error('Not Supported'); },
|
|
72
|
+
handleHeightChange: props.handleHeightChange
|
|
73
|
+
};
|
|
74
|
+
}, [props]);
|
|
75
|
+
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({ ref: iframeRef }, iframeProps, messageHandlers));
|
|
79
76
|
});
|
|
80
77
|
function CSSPropertiesToComponent(dict) {
|
|
81
78
|
var str = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowCardForm.js","sourceRoot":"","sources":["../../src/CoinflowCardForm.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoinflowCardForm.js","sourceRoot":"","sources":["../../src/CoinflowCardForm.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+F;AAC/F,mDAAkF;AAmBlF;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,gBAAgB,GAAG,IAAA,kBAAU,EAAC,UAAC,KAA4B,EAAE,GAAG;IAC3E,IAAM,SAAS,GAAG,IAAA,cAAM,GAAkC,CAAC;IAC3D,IAAA,2BAAmB,EAAC,GAAG,EAAE,cAAM,OAAA,CAAC;QACxB,QAAQ;;;;;;4BACN,UAAU,GAAG,UAAU,CAAC;4BAC9B,IAAI,CAAC,SAAS,CAAC,OAAO;gCAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;4BACzD,OAAO,GAAG,UAAC,IAAY;gCAC3B,IAAI,CAAC;oCACH,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oCAC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,eAAO,EAAwB;QACrD,OAAO;YACL,qBAAqB,EAAE,cAAO,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA,CAAA,CAAC;YAC/D,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;SAC7C,CAAC;IACJ,CAAC,EAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEb,OAAO,8BAAC,+BAAc,qBAAC,GAAG,EAAE,SAAS,IAAM,WAAW,EAAO,eAAe,EAAI,CAAC;AACnF,CAAC,CAAC,CAAC;AAEH,SAAS,wBAAwB,CAAC,IAAmB;IACnD,IAAI,GAAG,GAAG,EAAE,CAAC;4BACF,GAAG,EAAE,KAAK;QACnB,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAA,EAAE;YACtB,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC5B,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;YAChC,CAAC;iBAAK,CAAC;gBACL,GAAG,IAAI,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;QACH,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC;;IATjC,KAA0B,UAAoB,EAApB,KAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAApB,cAAoB,EAApB,IAAoB;QAApC,IAAA,WAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;gBAAV,GAAG,EAAE,KAAK;KAUpB;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoinflowPurchaseProps } from './
|
|
1
|
+
import { CoinflowPurchaseProps } from './common';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { MobileWalletButtonProps } from './CoinflowApplePayButton';
|
|
4
4
|
export declare function CoinflowGooglePayButton(props: CoinflowPurchaseProps & MobileWalletButtonProps): React.JSX.Element;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CoinflowIFrameProps } from './
|
|
3
|
-
export
|
|
2
|
+
import { CoinflowIFrameProps, IFrameMessageHandlers } from './common';
|
|
3
|
+
export type SendAndReceiveMessage = (message: string, isResponseValid: (response: string) => boolean) => Promise<string>;
|
|
4
|
+
export type CoinflowIFrameExposedFunctions = {
|
|
5
|
+
sendAndReceiveMessage: SendAndReceiveMessage;
|
|
6
|
+
listenForMessage: (isResponseValid: (response: string) => boolean) => Promise<string>;
|
|
7
|
+
};
|
|
8
|
+
export declare const CoinflowIFrame: React.ForwardRefExoticComponent<CoinflowIFrameProps & IFrameMessageHandlers & React.RefAttributes<unknown>>;
|
|
@@ -3,12 +3,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CoinflowIFrame = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
var
|
|
7
|
-
function
|
|
6
|
+
var common_1 = require("./common");
|
|
7
|
+
exports.CoinflowIFrame = (0, react_1.forwardRef)(function (props, ref) {
|
|
8
|
+
var IFrameRef = (0, react_1.useRef)(null);
|
|
8
9
|
var url = (0, react_1.useMemo)(function () {
|
|
9
|
-
return
|
|
10
|
+
return common_1.CoinflowUtils.getCoinflowUrl(props);
|
|
10
11
|
}, [props]);
|
|
11
|
-
var
|
|
12
|
+
var sendMessage = (0, react_1.useCallback)(function (message) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!((_a = IFrameRef === null || IFrameRef === void 0 ? void 0 : IFrameRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow))
|
|
15
|
+
throw new Error('Iframe not defined');
|
|
16
|
+
IFrameRef.current.contentWindow.postMessage(message, '*');
|
|
17
|
+
}, []);
|
|
18
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
19
|
+
listenForMessage: function (isResponseValid) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
21
|
+
var handler;
|
|
22
|
+
return tslib_1.__generator(this, function (_a) {
|
|
23
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
24
|
+
handler = function (_a) {
|
|
25
|
+
var data = _a.data, origin = _a.origin;
|
|
26
|
+
if (!origin.includes(common_1.CoinflowUtils.getCoinflowBaseUrl(props.env)))
|
|
27
|
+
return;
|
|
28
|
+
if (data.startsWith('ERROR')) {
|
|
29
|
+
reject(new Error(data.replace('ERROR', '')));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!isResponseValid(data))
|
|
33
|
+
return;
|
|
34
|
+
resolve(data);
|
|
35
|
+
};
|
|
36
|
+
if (!window)
|
|
37
|
+
throw new Error('Window not defined');
|
|
38
|
+
window.addEventListener('message', handler);
|
|
39
|
+
}).finally(function () {
|
|
40
|
+
window.removeEventListener('message', handler);
|
|
41
|
+
})];
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
sendAndReceiveMessage: function (message, isResponseValid) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
47
|
+
return tslib_1.__generator(this, function (_a) {
|
|
48
|
+
sendMessage(message);
|
|
49
|
+
return [2 /*return*/, this.listenForMessage(isResponseValid)];
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
}); });
|
|
54
|
+
var handleIframeMessages = (0, react_1.useCallback)(function (_a) {
|
|
55
|
+
var data = _a.data, origin = _a.origin;
|
|
56
|
+
if (!origin.includes(common_1.CoinflowUtils.getCoinflowBaseUrl(props.env)))
|
|
57
|
+
return;
|
|
58
|
+
var promise = (0, common_1.handleIFrameMessage)(data, props);
|
|
59
|
+
if (!promise)
|
|
60
|
+
return;
|
|
61
|
+
promise.then(sendMessage).catch(function (e) { return sendMessage('ERROR ' + e.message); });
|
|
62
|
+
}, [props, sendMessage]);
|
|
63
|
+
(0, react_1.useEffect)(function () {
|
|
64
|
+
if (!window)
|
|
65
|
+
throw new Error('Window not defined');
|
|
66
|
+
window.addEventListener('message', handleIframeMessages);
|
|
67
|
+
return function () {
|
|
68
|
+
window.removeEventListener('message', handleIframeMessages);
|
|
69
|
+
};
|
|
70
|
+
}, [handleIframeMessages]);
|
|
71
|
+
var handleHeightChange = props.handleHeightChange;
|
|
12
72
|
return (0, react_1.useMemo)(function () { return (react_1.default.createElement("iframe", { scrolling: handleHeightChange ? 'no' : 'yes', onLoad: function () {
|
|
13
73
|
if (IFrameRef.current)
|
|
14
74
|
IFrameRef.current.style.opacity = '1';
|
|
@@ -18,6 +78,5 @@ function CoinflowIFrame(props) {
|
|
|
18
78
|
opacity: 0,
|
|
19
79
|
transition: 'opacity 300ms linear',
|
|
20
80
|
}, title: "withdraw", frameBorder: "0", src: url })); }, [IFrameRef, handleHeightChange, url]);
|
|
21
|
-
}
|
|
22
|
-
exports.CoinflowIFrame = CoinflowIFrame;
|
|
81
|
+
});
|
|
23
82
|
//# sourceMappingURL=CoinflowIFrame.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":";;;;AAAA,qDAOe;AACf,mCAKkB;AAaL,QAAA,cAAc,GAAG,IAAA,kBAAU,EACtC,UAAC,KAAkD,EAAE,GAAG;IACtD,IAAM,SAAS,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;IAEzD,IAAM,GAAG,GAAG,IAAA,eAAO,EAAC;QAClB,OAAO,sBAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAM,WAAW,GAAG,I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O;gBAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QAC/D,CAAC,EACD,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE;YACL,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,CAAC;YACV,UAAU,EAAE,sBAAsB;SACnC,EACD,KAAK,EAAC,UAAU,EAChB,WAAW,EAAC,GAAG,EACf,GAAG,EAAE,GAAG,GACR,CACH,EAlBK,CAkBL,EACD,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,CAAC,CACrC,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare function CoinflowPurchase(
|
|
4
|
-
export declare function EvmCoinflowPurchase(props: CoinflowEvmPurchaseProps): React.JSX.Element | null;
|
|
2
|
+
import { CoinflowPurchaseProps } from './common';
|
|
3
|
+
export declare function CoinflowPurchase(purchaseProps: CoinflowPurchaseProps): React.JSX.Element;
|
|
@@ -1,75 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CoinflowPurchase = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
var common_1 = require("./common");
|
|
6
7
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
polygon: (react_1.default.createElement(EvmCoinflowPurchase, tslib_1.__assign({}, props))),
|
|
17
|
-
eth: (react_1.default.createElement(EvmCoinflowPurchase, tslib_1.__assign({}, props))),
|
|
18
|
-
base: (react_1.default.createElement(EvmCoinflowPurchase, tslib_1.__assign({}, props)))
|
|
19
|
-
});
|
|
8
|
+
function CoinflowPurchase(purchaseProps) {
|
|
9
|
+
var iframeProps = (0, react_1.useMemo)(function () {
|
|
10
|
+
var walletPubkey = (0, common_1.getWalletPubkey)(purchaseProps);
|
|
11
|
+
return tslib_1.__assign(tslib_1.__assign({}, purchaseProps), { walletPubkey: walletPubkey, route: "/purchase/".concat(purchaseProps.merchantId), transaction: common_1.CoinflowUtils.getTransaction(purchaseProps) });
|
|
12
|
+
}, [purchaseProps]);
|
|
13
|
+
var messageHandlers = (0, react_1.useMemo)(function () {
|
|
14
|
+
return tslib_1.__assign(tslib_1.__assign({}, (0, common_1.getHandlers)(purchaseProps)), { handleHeightChange: purchaseProps.handleHeightChange });
|
|
15
|
+
}, [purchaseProps]);
|
|
16
|
+
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps, messageHandlers));
|
|
20
17
|
}
|
|
21
18
|
exports.CoinflowPurchase = CoinflowPurchase;
|
|
22
|
-
function SolanaCoinflowPurchase(props) {
|
|
23
|
-
var _a;
|
|
24
|
-
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)(props);
|
|
25
|
-
var wallet = props.wallet, transaction = props.transaction, supportsVersionedTransactionsParam = props.supportsVersionedTransactions;
|
|
26
|
-
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, props, (_a = wallet.publicKey) === null || _a === void 0 ? void 0 : _a.toString()).IFrameRef;
|
|
27
|
-
var transactionStr = (0, react_1.useMemo)(function () {
|
|
28
|
-
return transaction
|
|
29
|
-
? CoinflowUtils_1.CoinflowUtils.serializeSolanaTransaction(transaction)
|
|
30
|
-
: undefined;
|
|
31
|
-
}, [transaction]);
|
|
32
|
-
var supportsVersionedTransactions = (0, react_1.useMemo)(function () {
|
|
33
|
-
if (supportsVersionedTransactionsParam !== undefined)
|
|
34
|
-
return supportsVersionedTransactionsParam;
|
|
35
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.wallet))
|
|
36
|
-
return false;
|
|
37
|
-
var supportedTransactionVersions = wallet.wallet.adapter.supportedTransactionVersions;
|
|
38
|
-
if (!supportedTransactionVersions)
|
|
39
|
-
return false;
|
|
40
|
-
return supportedTransactionVersions.has(0);
|
|
41
|
-
}, [supportsVersionedTransactionsParam, wallet.wallet]);
|
|
42
|
-
if (!wallet.publicKey)
|
|
43
|
-
return null;
|
|
44
|
-
var walletPubkey = wallet.publicKey.toString();
|
|
45
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, transaction: transactionStr, supportsVersionedTransactions: supportsVersionedTransactions, route: "/purchase/".concat(props.merchantId) });
|
|
46
|
-
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps));
|
|
47
|
-
}
|
|
48
|
-
function NearCoinflowPurchase(props) {
|
|
49
|
-
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)(props);
|
|
50
|
-
var wallet = props.wallet, action = props.action;
|
|
51
|
-
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, props, wallet.accountId).IFrameRef;
|
|
52
|
-
var transaction = (0, react_1.useMemo)(function () {
|
|
53
|
-
return action
|
|
54
|
-
? Buffer.from(JSON.stringify(action)).toString('base64')
|
|
55
|
-
: undefined;
|
|
56
|
-
}, [action]);
|
|
57
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: wallet.accountId, IFrameRef: IFrameRef, transaction: transaction, route: "/purchase/".concat(props.merchantId), nearDeposit: props.nearDeposit });
|
|
58
|
-
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps));
|
|
59
|
-
}
|
|
60
|
-
function EvmCoinflowPurchase(props) {
|
|
61
|
-
var handlers = (0, EthIFrameMessageHandlers_1.useEthIFrameMessageHandlers)(props);
|
|
62
|
-
var transaction = props.transaction, wallet = props.wallet;
|
|
63
|
-
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, props, wallet.address).IFrameRef;
|
|
64
|
-
var transactionStr = (0, react_1.useMemo)(function () {
|
|
65
|
-
if (!transaction)
|
|
66
|
-
return undefined;
|
|
67
|
-
return Buffer.from(JSON.stringify(transaction)).toString('base64');
|
|
68
|
-
}, [transaction]);
|
|
69
|
-
if (!wallet.address)
|
|
70
|
-
return null;
|
|
71
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: wallet.address, IFrameRef: IFrameRef, transaction: transactionStr, route: "/purchase/".concat(props.merchantId) });
|
|
72
|
-
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps));
|
|
73
|
-
}
|
|
74
|
-
exports.EvmCoinflowPurchase = EvmCoinflowPurchase;
|
|
75
19
|
//# sourceMappingURL=CoinflowPurchase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":";;;;AAAA,qDAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":";;;;AAAA,qDAAqC;AACrC,mCAOkB;AAClB,mDAAgD;AAEhD,SAAgB,gBAAgB,CAAC,aAAoC;IACnE,IAAM,WAAW,GAAG,IAAA,eAAO,EAAsB;QAC/C,IAAM,YAAY,GAAG,IAAA,wBAAe,EAAC,aAAa,CAAC,CAAC;QACpD,6CACK,aAAa,KAChB,YAAY,cAAA,EACZ,KAAK,EAAE,oBAAa,aAAa,CAAC,UAAU,CAAE,EAC9C,WAAW,EAAE,sBAAa,CAAC,cAAc,CAAC,aAAa,CAAC,IACxD;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,IAAM,eAAe,GAAG,IAAA,eAAO,EAAwB;QACrD,6CACK,IAAA,oBAAW,EAAC,aAAa,CAAC,KAC7B,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,IACpD;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,8BAAC,+BAAc,uBAAK,WAAW,EAAM,eAAe,EAAI,CAAC;AAClE,CAAC;AAnBD,4CAmBC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { CoinflowHistoryProps } from "./
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CoinflowHistoryProps } from "./common";
|
|
3
3
|
export declare function CoinflowPurchaseHistory(props: CoinflowHistoryProps): React.JSX.Element;
|
|
@@ -2,50 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoinflowPurchaseHistory = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var useIframeWallet_1 = require("./wallet/useIframeWallet");
|
|
6
5
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
7
|
-
var react_1 = tslib_1.
|
|
8
|
-
var
|
|
9
|
-
var NearIFrameMessageHandlers_1 = require("./wallet/NearIFrameMessageHandlers");
|
|
10
|
-
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
11
|
-
var EthIFrameMessageHandlers_1 = require("./wallet/EthIFrameMessageHandlers");
|
|
6
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
+
var common_1 = require("./common");
|
|
12
8
|
function CoinflowPurchaseHistory(props) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
9
|
+
var iframeProps = (0, react_1.useMemo)(function () {
|
|
10
|
+
var walletPubkey = (0, common_1.getWalletPubkey)(props);
|
|
11
|
+
return tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: walletPubkey, route: "/history/purchase/".concat(props.merchantId), transaction: undefined });
|
|
12
|
+
}, [props]);
|
|
13
|
+
var messageHandlers = (0, react_1.useMemo)(function () {
|
|
14
|
+
return tslib_1.__assign(tslib_1.__assign({}, (0, common_1.getHandlers)(props)), { handleHeightChange: props.handleHeightChange });
|
|
15
|
+
}, [props]);
|
|
16
|
+
return react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps, messageHandlers));
|
|
20
17
|
}
|
|
21
18
|
exports.CoinflowPurchaseHistory = CoinflowPurchaseHistory;
|
|
22
|
-
function SolanaPurchaseHistory(props) {
|
|
23
|
-
var _a;
|
|
24
|
-
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)(props);
|
|
25
|
-
var wallet = props.wallet;
|
|
26
|
-
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, props, (_a = wallet.publicKey) === null || _a === void 0 ? void 0 : _a.toString()).IFrameRef;
|
|
27
|
-
if (!wallet.publicKey)
|
|
28
|
-
return null;
|
|
29
|
-
var walletPubkey = wallet.publicKey.toString();
|
|
30
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/purchase/".concat(props.merchantId) });
|
|
31
|
-
return (react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps)));
|
|
32
|
-
}
|
|
33
|
-
function NearPurchaseHistory(props) {
|
|
34
|
-
var _a, _b;
|
|
35
|
-
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)(props);
|
|
36
|
-
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, props, (_a = props.wallet) === null || _a === void 0 ? void 0 : _a.accountId).IFrameRef;
|
|
37
|
-
if (!((_b = props.wallet) === null || _b === void 0 ? void 0 : _b.accountId))
|
|
38
|
-
return null;
|
|
39
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: props.wallet.accountId, IFrameRef: IFrameRef, route: "/history/purchase/".concat(props.merchantId) });
|
|
40
|
-
return (react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps)));
|
|
41
|
-
}
|
|
42
|
-
function EvmPurchaseHistory(props) {
|
|
43
|
-
var _a, _b, _c;
|
|
44
|
-
var handlers = (0, EthIFrameMessageHandlers_1.useEthIFrameMessageHandlers)(props);
|
|
45
|
-
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, props, (_a = props.wallet) === null || _a === void 0 ? void 0 : _a.address).IFrameRef;
|
|
46
|
-
if (!((_b = props.wallet) === null || _b === void 0 ? void 0 : _b.address))
|
|
47
|
-
return null;
|
|
48
|
-
var iframeProps = tslib_1.__assign(tslib_1.__assign({}, props), { walletPubkey: (_c = props.wallet) === null || _c === void 0 ? void 0 : _c.address, IFrameRef: IFrameRef, route: "/history/purchase/".concat(props.merchantId) });
|
|
49
|
-
return (react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, tslib_1.__assign({}, iframeProps)));
|
|
50
|
-
}
|
|
51
19
|
//# sourceMappingURL=CoinflowPurchaseHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":";;;;AAAA,mDAAgD;AAChD,qDAAuC;AACvC,mCAMkB;AAElB,SAAgB,uBAAuB,CACrC,KAA2B;IAE3B,IAAM,WAAW,GAAG,IAAA,eAAO,EAAsB;QAC/C,IAAM,YAAY,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC;QAC5C,6CACK,KAAK,KACR,YAAY,cAAA,EACZ,KAAK,EAAE,4BAAqB,KAAK,CAAC,UAAU,CAAE,EAC9C,WAAW,EAAE,SAAS,IACtB;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAM,eAAe,GAAG,IAAA,eAAO,EAAwB;QACrD,6CACK,IAAA,oBAAW,EAAC,KAAK,CAAC,KACrB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAC5C;IACJ,CAAC,EAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEb,OAAO,8BAAC,+BAAc,uBAAK,WAAW,EAAO,eAAe,EAAI,CAAC;AACnE,CAAC;AArBD,0DAqBC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoinflowPurchaseProtection = void 0;
|
|
4
4
|
var react_1 = require("react");
|
|
5
|
-
var
|
|
5
|
+
var common_1 = require("./common");
|
|
6
6
|
function CoinflowPurchaseProtection(_a) {
|
|
7
7
|
var coinflowEnv = _a.coinflowEnv, merchantId = _a.merchantId;
|
|
8
8
|
var sdkUrl = (0, react_1.useMemo)(function () {
|
|
@@ -15,7 +15,7 @@ function CoinflowPurchaseProtection(_a) {
|
|
|
15
15
|
}, [coinflowEnv]);
|
|
16
16
|
var _b = (0, react_1.useState)(undefined), partnerId = _b[0], setPartnerId = _b[1];
|
|
17
17
|
(0, react_1.useEffect)(function () {
|
|
18
|
-
new
|
|
18
|
+
new common_1.CoinflowUtils(coinflowEnv)
|
|
19
19
|
.getNSurePartnerId(merchantId)
|
|
20
20
|
.then(function (partnerId) { return setPartnerId(partnerId); });
|
|
21
21
|
}, [coinflowEnv, merchantId]);
|