@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
|
@@ -1,70 +1,15 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
|
+
import { CoinflowUtils, getHandlers, getWalletPubkey, } from './common';
|
|
3
4
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
polygon: (React.createElement(EvmCoinflowPurchase, __assign({}, props))),
|
|
14
|
-
eth: (React.createElement(EvmCoinflowPurchase, __assign({}, props))),
|
|
15
|
-
base: (React.createElement(EvmCoinflowPurchase, __assign({}, props)))
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function SolanaCoinflowPurchase(props) {
|
|
19
|
-
var _a;
|
|
20
|
-
var handlers = useSolanaIFrameMessageHandlers(props);
|
|
21
|
-
var wallet = props.wallet, transaction = props.transaction, supportsVersionedTransactionsParam = props.supportsVersionedTransactions;
|
|
22
|
-
var IFrameRef = useIframeWallet(handlers, props, (_a = wallet.publicKey) === null || _a === void 0 ? void 0 : _a.toString()).IFrameRef;
|
|
23
|
-
var transactionStr = useMemo(function () {
|
|
24
|
-
return transaction
|
|
25
|
-
? CoinflowUtils.serializeSolanaTransaction(transaction)
|
|
26
|
-
: undefined;
|
|
27
|
-
}, [transaction]);
|
|
28
|
-
var supportsVersionedTransactions = useMemo(function () {
|
|
29
|
-
if (supportsVersionedTransactionsParam !== undefined)
|
|
30
|
-
return supportsVersionedTransactionsParam;
|
|
31
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.wallet))
|
|
32
|
-
return false;
|
|
33
|
-
var supportedTransactionVersions = wallet.wallet.adapter.supportedTransactionVersions;
|
|
34
|
-
if (!supportedTransactionVersions)
|
|
35
|
-
return false;
|
|
36
|
-
return supportedTransactionVersions.has(0);
|
|
37
|
-
}, [supportsVersionedTransactionsParam, wallet.wallet]);
|
|
38
|
-
if (!wallet.publicKey)
|
|
39
|
-
return null;
|
|
40
|
-
var walletPubkey = wallet.publicKey.toString();
|
|
41
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, transaction: transactionStr, supportsVersionedTransactions: supportsVersionedTransactions, route: "/purchase/".concat(props.merchantId) });
|
|
42
|
-
return React.createElement(CoinflowIFrame, __assign({}, iframeProps));
|
|
43
|
-
}
|
|
44
|
-
function NearCoinflowPurchase(props) {
|
|
45
|
-
var handlers = useNearIFrameMessageHandlers(props);
|
|
46
|
-
var wallet = props.wallet, action = props.action;
|
|
47
|
-
var IFrameRef = useIframeWallet(handlers, props, wallet.accountId).IFrameRef;
|
|
48
|
-
var transaction = useMemo(function () {
|
|
49
|
-
return action
|
|
50
|
-
? Buffer.from(JSON.stringify(action)).toString('base64')
|
|
51
|
-
: undefined;
|
|
52
|
-
}, [action]);
|
|
53
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: wallet.accountId, IFrameRef: IFrameRef, transaction: transaction, route: "/purchase/".concat(props.merchantId), nearDeposit: props.nearDeposit });
|
|
54
|
-
return React.createElement(CoinflowIFrame, __assign({}, iframeProps));
|
|
55
|
-
}
|
|
56
|
-
export function EvmCoinflowPurchase(props) {
|
|
57
|
-
var handlers = useEthIFrameMessageHandlers(props);
|
|
58
|
-
var transaction = props.transaction, wallet = props.wallet;
|
|
59
|
-
var IFrameRef = useIframeWallet(handlers, props, wallet.address).IFrameRef;
|
|
60
|
-
var transactionStr = useMemo(function () {
|
|
61
|
-
if (!transaction)
|
|
62
|
-
return undefined;
|
|
63
|
-
return Buffer.from(JSON.stringify(transaction)).toString('base64');
|
|
64
|
-
}, [transaction]);
|
|
65
|
-
if (!wallet.address)
|
|
66
|
-
return null;
|
|
67
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: wallet.address, IFrameRef: IFrameRef, transaction: transactionStr, route: "/purchase/".concat(props.merchantId) });
|
|
68
|
-
return React.createElement(CoinflowIFrame, __assign({}, iframeProps));
|
|
5
|
+
export function CoinflowPurchase(purchaseProps) {
|
|
6
|
+
var iframeProps = useMemo(function () {
|
|
7
|
+
var walletPubkey = getWalletPubkey(purchaseProps);
|
|
8
|
+
return __assign(__assign({}, purchaseProps), { walletPubkey: walletPubkey, route: "/purchase/".concat(purchaseProps.merchantId), transaction: CoinflowUtils.getTransaction(purchaseProps) });
|
|
9
|
+
}, [purchaseProps]);
|
|
10
|
+
var messageHandlers = useMemo(function () {
|
|
11
|
+
return __assign(__assign({}, getHandlers(purchaseProps)), { handleHeightChange: purchaseProps.handleHeightChange });
|
|
12
|
+
}, [purchaseProps]);
|
|
13
|
+
return React.createElement(CoinflowIFrame, __assign({}, iframeProps, messageHandlers));
|
|
69
14
|
}
|
|
70
15
|
//# sourceMappingURL=CoinflowPurchase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAGL,aAAa,EACb,WAAW,EACX,eAAe,GAEhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,MAAM,UAAU,gBAAgB,CAAC,aAAoC;IACnE,IAAM,WAAW,GAAG,OAAO,CAAsB;QAC/C,IAAM,YAAY,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;QACpD,6BACK,aAAa,KAChB,YAAY,cAAA,EACZ,KAAK,EAAE,oBAAa,aAAa,CAAC,UAAU,CAAE,EAC9C,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,IACxD;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,IAAM,eAAe,GAAG,OAAO,CAAwB;QACrD,6BACK,WAAW,CAAC,aAAa,CAAC,KAC7B,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,IACpD;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,oBAAC,cAAc,eAAK,WAAW,EAAM,eAAe,EAAI,CAAC;AAClE,CAAC"}
|
|
@@ -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;
|
|
@@ -1,47 +1,15 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
|
-
import { useIframeWallet } from './wallet/useIframeWallet';
|
|
3
2
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
4
|
-
import React from
|
|
5
|
-
import {
|
|
6
|
-
import { useNearIFrameMessageHandlers } from './wallet/NearIFrameMessageHandlers';
|
|
7
|
-
import { CoinflowUtils } from './CoinflowUtils';
|
|
8
|
-
import { useEthIFrameMessageHandlers } from './wallet/EthIFrameMessageHandlers';
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { getHandlers, getWalletPubkey } from "./common";
|
|
9
5
|
export function CoinflowPurchaseHistory(props) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function SolanaPurchaseHistory(props) {
|
|
19
|
-
var _a;
|
|
20
|
-
var handlers = useSolanaIFrameMessageHandlers(props);
|
|
21
|
-
var wallet = props.wallet;
|
|
22
|
-
var IFrameRef = useIframeWallet(handlers, props, (_a = wallet.publicKey) === null || _a === void 0 ? void 0 : _a.toString()).IFrameRef;
|
|
23
|
-
if (!wallet.publicKey)
|
|
24
|
-
return null;
|
|
25
|
-
var walletPubkey = wallet.publicKey.toString();
|
|
26
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/purchase/".concat(props.merchantId) });
|
|
27
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
28
|
-
}
|
|
29
|
-
function NearPurchaseHistory(props) {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
var handlers = useNearIFrameMessageHandlers(props);
|
|
32
|
-
var IFrameRef = useIframeWallet(handlers, props, (_a = props.wallet) === null || _a === void 0 ? void 0 : _a.accountId).IFrameRef;
|
|
33
|
-
if (!((_b = props.wallet) === null || _b === void 0 ? void 0 : _b.accountId))
|
|
34
|
-
return null;
|
|
35
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: props.wallet.accountId, IFrameRef: IFrameRef, route: "/history/purchase/".concat(props.merchantId) });
|
|
36
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
37
|
-
}
|
|
38
|
-
function EvmPurchaseHistory(props) {
|
|
39
|
-
var _a, _b, _c;
|
|
40
|
-
var handlers = useEthIFrameMessageHandlers(props);
|
|
41
|
-
var IFrameRef = useIframeWallet(handlers, props, (_a = props.wallet) === null || _a === void 0 ? void 0 : _a.address).IFrameRef;
|
|
42
|
-
if (!((_b = props.wallet) === null || _b === void 0 ? void 0 : _b.address))
|
|
43
|
-
return null;
|
|
44
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: (_c = props.wallet) === null || _c === void 0 ? void 0 : _c.address, IFrameRef: IFrameRef, route: "/history/purchase/".concat(props.merchantId) });
|
|
45
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
6
|
+
var iframeProps = useMemo(function () {
|
|
7
|
+
var walletPubkey = getWalletPubkey(props);
|
|
8
|
+
return __assign(__assign({}, props), { walletPubkey: walletPubkey, route: "/history/purchase/".concat(props.merchantId), transaction: undefined });
|
|
9
|
+
}, [props]);
|
|
10
|
+
var messageHandlers = useMemo(function () {
|
|
11
|
+
return __assign(__assign({}, getHandlers(props)), { handleHeightChange: props.handleHeightChange });
|
|
12
|
+
}, [props]);
|
|
13
|
+
return React.createElement(CoinflowIFrame, __assign({}, iframeProps, messageHandlers));
|
|
46
14
|
}
|
|
47
15
|
//# sourceMappingURL=CoinflowPurchaseHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAGL,WAAW,EAEX,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,MAAM,UAAU,uBAAuB,CACrC,KAA2B;IAE3B,IAAM,WAAW,GAAG,OAAO,CAAsB;QAC/C,IAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5C,6BACK,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,OAAO,CAAwB;QACrD,6BACK,WAAW,CAAC,KAAK,CAAC,KACrB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAC5C;IACJ,CAAC,EAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEb,OAAO,oBAAC,cAAc,eAAK,WAAW,EAAO,eAAe,EAAI,CAAC;AACnE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { CoinflowUtils } from './
|
|
2
|
+
import { CoinflowUtils } from './common';
|
|
3
3
|
export function CoinflowPurchaseProtection(_a) {
|
|
4
4
|
var coinflowEnv = _a.coinflowEnv, merchantId = _a.merchantId;
|
|
5
5
|
var sdkUrl = useMemo(function () {
|
|
@@ -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;
|
|
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;AAErD,MAAM,UAAU,0BAA0B,CAAC,EAM1C;QALC,WAAW,iBAAA,EACX,UAAU,gBAAA;IAKV,IAAM,MAAM,GAAG,OAAO,CACpB;QACE,OAAA,WAAW,KAAK,MAAM;YACpB,CAAC,CAAC,iCAAiC;YACnC,CAAC,CAAC,yCAAyC;IAF7C,CAE6C,EAC/C,CAAC,WAAW,CAAC,CACd,CAAC;IACF,IAAM,aAAa,GAAG,OAAO,CAC3B;QACE,OAAA,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,0BAA0B;IAAxE,CAAwE,EAC1E,CAAC,WAAW,CAAC,CACd,CAAC;IAEI,IAAA,KAA4B,QAAQ,CAAqB,SAAS,CAAC,EAAlE,SAAS,QAAA,EAAE,YAAY,QAA2C,CAAC;IAE1E,SAAS,CAAC;QACR,IAAI,aAAa,CAAC,WAAW,CAAC;aAC3B,iBAAiB,CAAC,UAAU,CAAC;aAC7B,IAAI,CAAC,UAAA,SAAS,IAAI,OAAA,YAAY,CAAC,SAAS,CAAC,EAAvB,CAAuB,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IAE9B,IAAM,gBAAgB,GAAG,OAAO,CAAC;QAC/B,OAAO,sHAEe,aAAa,6CACT,SAAS,0CAExB,CAAC;IACd,CAAC,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;IAE/B,SAAS,CAAC;QACR,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,IAAM,mBAAmB,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC7D,mBAAmB,CAAC,SAAS,GAAG,gBAAgB,CAAC;QACjD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QAE/C,IAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACtD,YAAY,CAAC,GAAG,GAAG,MAAM,CAAC;QAC1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO;YACL,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAE1C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { CoinflowWithdrawProps } from "./
|
|
3
|
-
export declare function CoinflowWithdraw(
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CoinflowWithdrawProps } from "./common";
|
|
3
|
+
export declare function CoinflowWithdraw(withdrawProps: CoinflowWithdrawProps): React.JSX.Element;
|
|
@@ -1,49 +1,15 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
|
-
import React from
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
3
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
polygon: (React.createElement(CoinflowEthWithdraw, __assign({}, props))),
|
|
15
|
-
base: (React.createElement(CoinflowEthWithdraw, __assign({}, props))),
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function CoinflowSolanaWithdraw(props) {
|
|
19
|
-
var _a;
|
|
20
|
-
var handlers = useSolanaIFrameMessageHandlers(props);
|
|
21
|
-
var wallet = props.wallet;
|
|
22
|
-
var IFrameRef = useIframeWallet(handlers, props, (_a = wallet.publicKey) === null || _a === void 0 ? void 0 : _a.toString()).IFrameRef;
|
|
23
|
-
if (!wallet.publicKey)
|
|
24
|
-
return null;
|
|
25
|
-
var walletPubkey = wallet.publicKey.toString();
|
|
26
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(props.merchantId), supportsVersionedTransactions: props.supportsVersionedTransactions !== false });
|
|
27
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
28
|
-
}
|
|
29
|
-
function CoinflowNearWithdraw(props) {
|
|
30
|
-
var handlers = useNearIFrameMessageHandlers(props);
|
|
31
|
-
var wallet = props.wallet;
|
|
32
|
-
var IFrameRef = useIframeWallet(handlers, props, wallet.accountId).IFrameRef;
|
|
33
|
-
if (!wallet)
|
|
34
|
-
return null;
|
|
35
|
-
var walletPubkey = wallet.accountId;
|
|
36
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(props.merchantId) });
|
|
37
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
38
|
-
}
|
|
39
|
-
function CoinflowEthWithdraw(props) {
|
|
40
|
-
var handlers = useEthIFrameMessageHandlers(props);
|
|
41
|
-
var wallet = props.wallet;
|
|
42
|
-
var IFrameRef = useIframeWallet(handlers, props, wallet.address).IFrameRef;
|
|
43
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address))
|
|
44
|
-
return null;
|
|
45
|
-
var walletPubkey = wallet.address;
|
|
46
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(props.merchantId) });
|
|
47
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
4
|
+
import { getHandlers, getWalletPubkey } from "./common";
|
|
5
|
+
export function CoinflowWithdraw(withdrawProps) {
|
|
6
|
+
var iframeProps = useMemo(function () {
|
|
7
|
+
var walletPubkey = getWalletPubkey(withdrawProps);
|
|
8
|
+
return __assign(__assign({}, withdrawProps), { walletPubkey: walletPubkey, route: "/withdraw/".concat(withdrawProps.merchantId), transaction: undefined });
|
|
9
|
+
}, [withdrawProps]);
|
|
10
|
+
var messageHandlers = useMemo(function () {
|
|
11
|
+
return __assign(__assign({}, getHandlers(withdrawProps)), { handleHeightChange: withdrawProps.handleHeightChange });
|
|
12
|
+
}, [withdrawProps]);
|
|
13
|
+
return React.createElement(CoinflowIFrame, __assign({}, iframeProps, messageHandlers));
|
|
48
14
|
}
|
|
49
15
|
//# sourceMappingURL=CoinflowWithdraw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAGL,WAAW,EAEX,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,MAAM,UAAU,gBAAgB,CAC9B,aAAoC;IAEpC,IAAM,WAAW,GAAG,OAAO,CAAsB;QAC/C,IAAM,YAAY,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;QACpD,6BACK,aAAa,KAChB,YAAY,cAAA,EACZ,KAAK,EAAE,oBAAa,aAAa,CAAC,UAAU,CAAE,EAC9C,WAAW,EAAE,SAAS,IACtB;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,IAAM,eAAe,GAAG,OAAO,CAAwB;QACrD,6BACK,WAAW,CAAC,aAAa,CAAC,KAC7B,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,IACpD;IACJ,CAAC,EAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAErB,OAAO,oBAAC,cAAc,eAAK,WAAW,EAAO,eAAe,EAAI,CAAC;AACnE,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { CoinflowNearHistoryProps, CoinflowSolanaHistoryProps, CoinflowEthHistoryProps, CoinflowPolygonHistoryProps, CoinflowBaseHistoryProps } from "./
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CoinflowNearHistoryProps, CoinflowSolanaHistoryProps, CoinflowEthHistoryProps, CoinflowPolygonHistoryProps, CoinflowBaseHistoryProps } from "./common";
|
|
3
3
|
export declare function CoinflowWithdrawHistory(props: CoinflowSolanaHistoryProps | CoinflowNearHistoryProps | CoinflowEthHistoryProps | CoinflowPolygonHistoryProps | CoinflowBaseHistoryProps): React.JSX.Element;
|
|
@@ -1,48 +1,15 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
|
-
import { CoinflowUtils } from './CoinflowUtils';
|
|
3
|
-
import { useIframeWallet } from './wallet/useIframeWallet';
|
|
4
2
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
5
|
-
import React from
|
|
6
|
-
import {
|
|
7
|
-
import { useNearIFrameMessageHandlers } from './wallet/NearIFrameMessageHandlers';
|
|
8
|
-
import { useEthIFrameMessageHandlers } from './wallet/EthIFrameMessageHandlers';
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { getWalletPubkey, getHandlers } from "./common";
|
|
9
5
|
export function CoinflowWithdrawHistory(props) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function SolanaWithdrawHistory(props) {
|
|
19
|
-
var _a;
|
|
20
|
-
var handlers = useSolanaIFrameMessageHandlers(props);
|
|
21
|
-
var wallet = props.wallet;
|
|
22
|
-
var IFrameRef = useIframeWallet(handlers, props, (_a = wallet.publicKey) === null || _a === void 0 ? void 0 : _a.toString()).IFrameRef;
|
|
23
|
-
if (!wallet.publicKey)
|
|
24
|
-
return null;
|
|
25
|
-
var walletPubkey = wallet.publicKey.toString();
|
|
26
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(props.merchantId) });
|
|
27
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
28
|
-
}
|
|
29
|
-
function NearWithdrawHistory(props) {
|
|
30
|
-
var handlers = useNearIFrameMessageHandlers(props);
|
|
31
|
-
var wallet = props.wallet;
|
|
32
|
-
var IFrameRef = useIframeWallet(handlers, props, wallet.accountId).IFrameRef;
|
|
33
|
-
if (!wallet)
|
|
34
|
-
return null;
|
|
35
|
-
var walletPubkey = wallet.accountId;
|
|
36
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(props.merchantId) });
|
|
37
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
38
|
-
}
|
|
39
|
-
function EthWithdrawHistory(props) {
|
|
40
|
-
var handlers = useEthIFrameMessageHandlers(props);
|
|
41
|
-
var wallet = props.wallet;
|
|
42
|
-
var IFrameRef = useIframeWallet(handlers, props, wallet.address).IFrameRef;
|
|
43
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address))
|
|
44
|
-
return null;
|
|
45
|
-
var iframeProps = __assign(__assign({}, props), { walletPubkey: wallet.address, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(props.merchantId) });
|
|
46
|
-
return (React.createElement(CoinflowIFrame, __assign({}, iframeProps)));
|
|
6
|
+
var iframeProps = useMemo(function () {
|
|
7
|
+
var walletPubkey = getWalletPubkey(props);
|
|
8
|
+
return __assign(__assign({}, props), { walletPubkey: walletPubkey, route: "/history/withdraw/".concat(props.merchantId), transaction: undefined });
|
|
9
|
+
}, [props]);
|
|
10
|
+
var messageHandlers = useMemo(function () {
|
|
11
|
+
return __assign(__assign({}, getHandlers(props)), { handleHeightChange: props.handleHeightChange });
|
|
12
|
+
}, [props]);
|
|
13
|
+
return React.createElement(CoinflowIFrame, __assign({}, iframeProps, messageHandlers));
|
|
47
14
|
}
|
|
48
15
|
//# sourceMappingURL=CoinflowWithdrawHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAOL,eAAe,EAEf,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,MAAM,UAAU,uBAAuB,CACrC,KAK4B;IAE5B,IAAM,WAAW,GAAG,OAAO,CAAsB;QAC/C,IAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5C,6BACK,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,OAAO,CAAwB;QACrD,6BACK,WAAW,CAAC,KAAK,CAAC,KACrB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAC5C;IACJ,CAAC,EAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEb,OAAO,oBAAC,cAAc,eAAK,WAAW,EAAO,eAAe,EAAI,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CoinflowPurchaseProps } from './CoinflowTypes';
|
|
2
|
+
export type WalletCall = {
|
|
3
|
+
method: IFrameMessageMethods;
|
|
4
|
+
data: string;
|
|
5
|
+
};
|
|
6
|
+
export interface IFrameMessageHandlers {
|
|
7
|
+
handleSendTransaction: (transaction: string) => Promise<string>;
|
|
8
|
+
handleSignMessage?: (message: string) => Promise<string>;
|
|
9
|
+
handleSignTransaction?: (transaction: string) => Promise<string>;
|
|
10
|
+
handleHeightChange?: (height: string) => void;
|
|
11
|
+
}
|
|
12
|
+
declare enum IFrameMessageMethods {
|
|
13
|
+
SignMessage = "signMessage",
|
|
14
|
+
SignTransaction = "signTransaction",
|
|
15
|
+
SendTransaction = "sendTransaction",
|
|
16
|
+
HeightChange = "heightChange"
|
|
17
|
+
}
|
|
18
|
+
export declare function getWalletPubkey({ wallet, }: Pick<CoinflowPurchaseProps, 'wallet'>): string | null | undefined;
|
|
19
|
+
export declare function handleIFrameMessage(rawMessage: string, handlers: IFrameMessageHandlers): Promise<string> | void;
|
|
20
|
+
export declare function getHandlers({ wallet, blockchain, }: Pick<CoinflowPurchaseProps, 'wallet' | 'blockchain'>): Omit<IFrameMessageHandlers, 'handleHeightChange'>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { CoinflowUtils } from './CoinflowUtils';
|
|
3
|
+
import { web3, base58 } from './SolanaPeerDeps';
|
|
4
|
+
var IFrameMessageMethods;
|
|
5
|
+
(function (IFrameMessageMethods) {
|
|
6
|
+
IFrameMessageMethods["SignMessage"] = "signMessage";
|
|
7
|
+
IFrameMessageMethods["SignTransaction"] = "signTransaction";
|
|
8
|
+
IFrameMessageMethods["SendTransaction"] = "sendTransaction";
|
|
9
|
+
IFrameMessageMethods["HeightChange"] = "heightChange";
|
|
10
|
+
})(IFrameMessageMethods || (IFrameMessageMethods = {}));
|
|
11
|
+
export function getWalletPubkey(_a) {
|
|
12
|
+
var wallet = _a.wallet;
|
|
13
|
+
if ('publicKey' in wallet) {
|
|
14
|
+
return wallet.publicKey.toString();
|
|
15
|
+
}
|
|
16
|
+
if ('address' in wallet) {
|
|
17
|
+
return wallet.address;
|
|
18
|
+
}
|
|
19
|
+
if ('accountId' in wallet) {
|
|
20
|
+
return wallet.accountId;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export function handleIFrameMessage(rawMessage, handlers) {
|
|
25
|
+
var walletCall;
|
|
26
|
+
try {
|
|
27
|
+
walletCall = JSON.parse(rawMessage);
|
|
28
|
+
if (!('method' in walletCall) || !('data' in walletCall))
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
console.error('handleIFrameMessage JSON parse', e);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
var data = walletCall.data, method = walletCall.method;
|
|
36
|
+
switch (method) {
|
|
37
|
+
case IFrameMessageMethods.SignMessage:
|
|
38
|
+
if (!handlers.handleSignMessage)
|
|
39
|
+
return;
|
|
40
|
+
return handlers.handleSignMessage(data);
|
|
41
|
+
case IFrameMessageMethods.SignTransaction:
|
|
42
|
+
if (!handlers.handleSignTransaction)
|
|
43
|
+
return;
|
|
44
|
+
return handlers.handleSignTransaction(data);
|
|
45
|
+
case IFrameMessageMethods.SendTransaction:
|
|
46
|
+
return handlers.handleSendTransaction(data);
|
|
47
|
+
case IFrameMessageMethods.HeightChange:
|
|
48
|
+
if (!handlers.handleHeightChange)
|
|
49
|
+
return;
|
|
50
|
+
return handlers.handleHeightChange(data);
|
|
51
|
+
}
|
|
52
|
+
console.warn("Didn't expect to get here, handleIFrameMessage method:".concat(method, " is not one of ").concat(Object.values(IFrameMessageMethods)));
|
|
53
|
+
}
|
|
54
|
+
export function getHandlers(_a) {
|
|
55
|
+
var wallet = _a.wallet, blockchain = _a.blockchain;
|
|
56
|
+
return CoinflowUtils.byBlockchain(blockchain, {
|
|
57
|
+
solana: function () { return getSolanaWalletHandlers({ wallet: wallet }); },
|
|
58
|
+
near: function () { return getNearWalletHandlers({ wallet: wallet }); },
|
|
59
|
+
eth: function () { return getEvmWalletHandlers({ wallet: wallet }); },
|
|
60
|
+
polygon: function () { return getEvmWalletHandlers({ wallet: wallet }); },
|
|
61
|
+
base: function () { return getEvmWalletHandlers({ wallet: wallet }); },
|
|
62
|
+
})();
|
|
63
|
+
}
|
|
64
|
+
function getSolanaWalletHandlers(_a) {
|
|
65
|
+
var _this = this;
|
|
66
|
+
var wallet = _a.wallet;
|
|
67
|
+
return {
|
|
68
|
+
handleSendTransaction: function (transaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
69
|
+
var tx;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
tx = getSolanaTransaction(transaction);
|
|
74
|
+
return [4 /*yield*/, wallet.sendTransaction(tx)];
|
|
75
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); },
|
|
79
|
+
handleSignMessage: function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
+
var signMessage, signedMessage;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
signMessage = wallet.signMessage;
|
|
85
|
+
if (!signMessage) {
|
|
86
|
+
throw new Error('signMessage is not supported by this wallet');
|
|
87
|
+
}
|
|
88
|
+
return [4 /*yield*/, signMessage(new TextEncoder().encode(message))];
|
|
89
|
+
case 1:
|
|
90
|
+
signedMessage = _a.sent();
|
|
91
|
+
if (!base58)
|
|
92
|
+
throw new Error('bs58 dependency is required');
|
|
93
|
+
return [2 /*return*/, base58.encode(signedMessage)];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}); },
|
|
97
|
+
handleSignTransaction: function (transaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
98
|
+
var signTransaction, tx, signedTransaction;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
signTransaction = wallet.signTransaction;
|
|
103
|
+
if (!signTransaction) {
|
|
104
|
+
throw new Error('signTransaction is not supported by this wallet');
|
|
105
|
+
}
|
|
106
|
+
tx = getSolanaTransaction(transaction);
|
|
107
|
+
return [4 /*yield*/, signTransaction(tx)];
|
|
108
|
+
case 1:
|
|
109
|
+
signedTransaction = _a.sent();
|
|
110
|
+
if (!base58)
|
|
111
|
+
throw new Error('bs58 dependency is required');
|
|
112
|
+
return [2 /*return*/, base58.encode(signedTransaction.serialize({
|
|
113
|
+
requireAllSignatures: false,
|
|
114
|
+
verifySignatures: false,
|
|
115
|
+
}))];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}); },
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function getSolanaTransaction(data) {
|
|
122
|
+
if (!web3)
|
|
123
|
+
throw new Error('@solana/web3.js is not defined. Please install @solana/web3.js into your project');
|
|
124
|
+
if (!base58)
|
|
125
|
+
throw new Error('bs58 is not defined. Please install bs58 into your project');
|
|
126
|
+
var parsedUInt8Array = base58.decode(data);
|
|
127
|
+
var vtx = web3.VersionedTransaction.deserialize(parsedUInt8Array);
|
|
128
|
+
if (vtx.version === 'legacy')
|
|
129
|
+
return web3.Transaction.from(parsedUInt8Array);
|
|
130
|
+
return vtx;
|
|
131
|
+
}
|
|
132
|
+
function getNearWalletHandlers(_a) {
|
|
133
|
+
var _this = this;
|
|
134
|
+
var wallet = _a.wallet;
|
|
135
|
+
var nearWallet = wallet;
|
|
136
|
+
return {
|
|
137
|
+
handleSendTransaction: function (transaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
138
|
+
var action, executionOutcome, transactionResult;
|
|
139
|
+
return __generator(this, function (_a) {
|
|
140
|
+
switch (_a.label) {
|
|
141
|
+
case 0:
|
|
142
|
+
action = JSON.parse(Buffer.from(transaction, 'base64').toString());
|
|
143
|
+
return [4 /*yield*/, nearWallet.signAndSendTransaction(action)];
|
|
144
|
+
case 1:
|
|
145
|
+
executionOutcome = _a.sent();
|
|
146
|
+
if (!executionOutcome)
|
|
147
|
+
throw new Error('Transaction did not send');
|
|
148
|
+
transactionResult = executionOutcome.transaction;
|
|
149
|
+
return [2 /*return*/, transactionResult.hash];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}); },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function getEvmWalletHandlers(_a) {
|
|
156
|
+
var _this = this;
|
|
157
|
+
var wallet = _a.wallet;
|
|
158
|
+
var evmWallet = wallet;
|
|
159
|
+
return {
|
|
160
|
+
handleSendTransaction: function (transaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
161
|
+
var tx, hash;
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
switch (_a.label) {
|
|
164
|
+
case 0:
|
|
165
|
+
tx = JSON.parse(Buffer.from(transaction, 'base64').toString());
|
|
166
|
+
return [4 /*yield*/, evmWallet.sendTransaction(tx)];
|
|
167
|
+
case 1:
|
|
168
|
+
hash = (_a.sent()).hash;
|
|
169
|
+
return [2 /*return*/, hash];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}); },
|
|
173
|
+
handleSignMessage: function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
return [2 /*return*/, evmWallet.signMessage(message)];
|
|
176
|
+
});
|
|
177
|
+
}); },
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=CoinflowLibMessageHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoinflowLibMessageHandlers.js","sourceRoot":"","sources":["../../../src/common/CoinflowLibMessageHandlers.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAW9C,IAAK,oBAKJ;AALD,WAAK,oBAAoB;IACvB,mDAA2B,CAAA;IAC3B,2DAAmC,CAAA;IACnC,2DAAmC,CAAA;IACnC,qDAA6B,CAAA;AAC/B,CAAC,EALI,oBAAoB,KAApB,oBAAoB,QAKxB;AAED,MAAM,UAAU,eAAe,CAAC,EAEQ;QADtC,MAAM,YAAA;IAEN,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,SAAU,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,UAAkB,EAClB,QAA+B;IAE/B,IAAI,UAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,CAAC,CAAC,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,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