@coinflowlabs/react 0.3.0 → 1.0.0-PREVIEW-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/build/cjs/CoinflowIFrame.d.ts +5 -5
- package/build/cjs/CoinflowIFrame.js +5 -4
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.d.ts +21 -6
- package/build/cjs/CoinflowPurchase.js +35 -9
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowPurchaseHistory.d.ts +2 -2
- package/build/cjs/CoinflowPurchaseHistory.js +30 -5
- package/build/cjs/CoinflowPurchaseHistory.js.map +1 -1
- package/build/cjs/CoinflowUtils.d.ts +41 -6
- package/build/cjs/CoinflowUtils.js +41 -79
- package/build/cjs/CoinflowUtils.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +15 -7
- package/build/cjs/CoinflowWithdraw.js +30 -5
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/CoinflowWithdrawHistory.d.ts +14 -6
- package/build/cjs/CoinflowWithdrawHistory.js +30 -5
- package/build/cjs/CoinflowWithdrawHistory.js.map +1 -1
- package/build/cjs/NearIFrameMessageHandlers.d.ts +5 -0
- package/build/cjs/NearIFrameMessageHandlers.js +54 -0
- package/build/cjs/NearIFrameMessageHandlers.js.map +1 -0
- package/build/cjs/SolanaIFrameMessageHandlers.d.ts +18 -0
- package/build/cjs/{IFrameWalletConnector.js → SolanaIFrameMessageHandlers.js} +23 -108
- package/build/cjs/SolanaIFrameMessageHandlers.js.map +1 -0
- package/build/cjs/index.d.ts +0 -1
- package/build/cjs/index.js +0 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/useIframeWallet.d.ts +3 -11
- package/build/cjs/useIframeWallet.js +83 -11
- package/build/cjs/useIframeWallet.js.map +1 -1
- package/build/esm/CoinflowIFrame.d.ts +5 -5
- package/build/esm/CoinflowIFrame.js +6 -5
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.d.ts +21 -6
- package/build/esm/CoinflowPurchase.js +35 -8
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowPurchaseHistory.d.ts +2 -2
- package/build/esm/CoinflowPurchaseHistory.js +30 -4
- package/build/esm/CoinflowPurchaseHistory.js.map +1 -1
- package/build/esm/CoinflowUtils.d.ts +41 -6
- package/build/esm/CoinflowUtils.js +41 -79
- package/build/esm/CoinflowUtils.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +15 -7
- package/build/esm/CoinflowWithdraw.js +30 -4
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/CoinflowWithdrawHistory.d.ts +14 -6
- package/build/esm/CoinflowWithdrawHistory.js +30 -4
- package/build/esm/CoinflowWithdrawHistory.js.map +1 -1
- package/build/esm/NearIFrameMessageHandlers.d.ts +5 -0
- package/build/esm/NearIFrameMessageHandlers.js +50 -0
- package/build/esm/NearIFrameMessageHandlers.js.map +1 -0
- package/build/esm/SolanaIFrameMessageHandlers.d.ts +18 -0
- package/build/esm/{IFrameWalletConnector.js → SolanaIFrameMessageHandlers.js} +21 -106
- package/build/esm/SolanaIFrameMessageHandlers.js.map +1 -0
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.js +0 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/useIframeWallet.d.ts +3 -11
- package/build/esm/useIframeWallet.js +83 -11
- package/build/esm/useIframeWallet.js.map +1 -1
- package/package.json +2 -2
- package/build/cjs/IFrameWalletConnector.d.ts +0 -21
- package/build/cjs/IFrameWalletConnector.js.map +0 -1
- package/build/esm/IFrameWalletConnector.d.ts +0 -21
- package/build/esm/IFrameWalletConnector.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { CoinflowEnvs, SubsetWalletContextState } from './CoinflowUtils';
|
|
2
|
+
import { CoinflowBlockchain, CoinflowEnvs } from './CoinflowUtils';
|
|
4
3
|
type CoinflowIFrameProps = {
|
|
5
|
-
|
|
4
|
+
walletPubkey: string;
|
|
6
5
|
IFrameRef: React.RefObject<HTMLIFrameElement>;
|
|
7
6
|
env?: CoinflowEnvs;
|
|
8
7
|
route: string;
|
|
9
8
|
amount?: number;
|
|
10
|
-
transaction?:
|
|
9
|
+
transaction?: string;
|
|
10
|
+
blockchain: CoinflowBlockchain;
|
|
11
11
|
};
|
|
12
|
-
export declare function CoinflowIFrame({
|
|
12
|
+
export declare function CoinflowIFrame({ walletPubkey, IFrameRef, env, route, transaction, amount, blockchain, }: CoinflowIFrameProps): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -5,16 +5,17 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
7
7
|
function CoinflowIFrame(_a) {
|
|
8
|
-
var
|
|
8
|
+
var walletPubkey = _a.walletPubkey, IFrameRef = _a.IFrameRef, env = _a.env, route = _a.route, transaction = _a.transaction, amount = _a.amount, blockchain = _a.blockchain;
|
|
9
9
|
var url = (0, react_1.useMemo)(function () {
|
|
10
10
|
return CoinflowUtils_1.CoinflowUtils.getCoinflowUrl({
|
|
11
|
-
|
|
11
|
+
walletPubkey: walletPubkey,
|
|
12
12
|
amount: amount,
|
|
13
13
|
env: env,
|
|
14
14
|
route: route,
|
|
15
|
-
transaction: transaction
|
|
15
|
+
transaction: transaction,
|
|
16
|
+
blockchain: blockchain
|
|
16
17
|
});
|
|
17
|
-
}, [amount, env,
|
|
18
|
+
}, [walletPubkey, amount, env, route, transaction, blockchain]);
|
|
18
19
|
return (0, react_1.useMemo)(function () { return (react_1["default"].createElement("iframe", { onLoad: function () {
|
|
19
20
|
if (IFrameRef.current)
|
|
20
21
|
IFrameRef.current.style.opacity = '1';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":";;;;AAAA,qDAAqC;
|
|
1
|
+
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":";;;;AAAA,qDAAqC;AACrC,iDAAgF;AAYhF,SAAgB,cAAc,CAAC,EAQT;QAPpB,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,GAAG,SAAA,EACH,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,MAAM,YAAA,EACN,UAAU,gBAAA;IAEV,IAAM,GAAG,GAAG,IAAA,eAAO,EAAC;QAClB,OAAO,6BAAa,CAAC,cAAc,CAAC;YAClC,YAAY,cAAA;YACZ,MAAM,QAAA;YACN,GAAG,KAAA;YACH,KAAK,OAAA;YACL,WAAW,aAAA;YACX,UAAU,YAAA;SACX,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IAEhE,OAAO,IAAA,eAAO,EACZ,cAAM,OAAA,CACJ,6CACE,MAAM,EAAE;YACN,IAAI,SAAS,CAAC,OAAO;gBAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QAC/D,CAAC,EACD,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,EAhBK,CAgBL,EACD,CAAC,SAAS,EAAE,GAAG,CAAC,CACjB,CAAC;AACJ,CAAC;AAxCD,wCAwCC"}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Connection, Signer, Transaction } from '@solana/web3.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
wallet: SubsetWalletContextState;
|
|
3
|
+
import { CoinflowBlockchain, CoinflowEnvs, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
4
|
+
import { OnSuccessMethod } from './useIframeWallet';
|
|
5
|
+
export interface CoinflowCommonPurchaseProps {
|
|
7
6
|
merchantId: string;
|
|
8
|
-
connection: Connection;
|
|
9
7
|
amount?: number;
|
|
10
8
|
env?: CoinflowEnvs;
|
|
11
9
|
onSuccess?: OnSuccessMethod;
|
|
10
|
+
blockchain: CoinflowBlockchain;
|
|
11
|
+
}
|
|
12
|
+
export interface CoinflowSolanaPurchaseProps extends CoinflowCommonPurchaseProps {
|
|
13
|
+
wallet: SolanaWalletContextState;
|
|
12
14
|
transaction?: Transaction;
|
|
13
15
|
partialSigners?: Signer[];
|
|
14
16
|
debugTx?: boolean;
|
|
17
|
+
connection: Connection;
|
|
18
|
+
blockchain: 'solana';
|
|
19
|
+
}
|
|
20
|
+
export type NearFtTransferCallAction = {
|
|
21
|
+
methodName: 'ft_transfer_call';
|
|
22
|
+
args: object;
|
|
23
|
+
gas: string;
|
|
24
|
+
deposit: string;
|
|
15
25
|
};
|
|
16
|
-
export
|
|
26
|
+
export interface CoinflowNearPurchaseProps extends CoinflowCommonPurchaseProps {
|
|
27
|
+
wallet: NearWallet;
|
|
28
|
+
blockchain: 'near';
|
|
29
|
+
action?: NearFtTransferCallAction;
|
|
30
|
+
}
|
|
31
|
+
export declare function CoinflowPurchase(props: CoinflowSolanaPurchaseProps | CoinflowNearPurchaseProps): JSX.Element;
|
|
@@ -2,21 +2,47 @@
|
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.CoinflowPurchase = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var react_1 = tslib_1.
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
7
|
+
var SolanaIFrameMessageHandlers_1 = require("./SolanaIFrameMessageHandlers");
|
|
8
|
+
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
7
9
|
var useIframeWallet_1 = require("./useIframeWallet");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var NearIFrameMessageHandlers_1 = require("./NearIFrameMessageHandlers");
|
|
11
|
+
function CoinflowPurchase(props) {
|
|
12
|
+
return CoinflowUtils_1.CoinflowUtils.byBlockchain(props.blockchain, {
|
|
13
|
+
solana: (react_1["default"].createElement(SolanaCoinflowPurchase, tslib_1.__assign({}, props))),
|
|
14
|
+
near: react_1["default"].createElement(NearCoinflowPurchase, tslib_1.__assign({}, props))
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.CoinflowPurchase = CoinflowPurchase;
|
|
18
|
+
function SolanaCoinflowPurchase(_a) {
|
|
19
|
+
var merchantId = _a.merchantId, amount = _a.amount, env = _a.env, onSuccess = _a.onSuccess, wallet = _a.wallet, transaction = _a.transaction, partialSigners = _a.partialSigners, debugTx = _a.debugTx, connection = _a.connection;
|
|
20
|
+
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)({
|
|
11
21
|
wallet: wallet,
|
|
12
22
|
connection: connection,
|
|
13
|
-
onSuccess: onSuccess,
|
|
14
23
|
partialSigners: partialSigners,
|
|
15
24
|
debugTx: debugTx
|
|
16
|
-
})
|
|
17
|
-
|
|
25
|
+
});
|
|
26
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, onSuccess).IFrameRef;
|
|
27
|
+
var transactionStr = (0, react_1.useMemo)(function () {
|
|
28
|
+
return transaction
|
|
29
|
+
? CoinflowUtils_1.CoinflowUtils.serializeSolanaTransaction(transaction)
|
|
30
|
+
: undefined;
|
|
31
|
+
}, [transaction]);
|
|
32
|
+
if (!wallet.publicKey)
|
|
18
33
|
return null;
|
|
19
|
-
|
|
34
|
+
var walletPubkey = wallet.publicKey.toString();
|
|
35
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, transaction: transactionStr, amount: amount, blockchain: 'solana' }));
|
|
36
|
+
}
|
|
37
|
+
function NearCoinflowPurchase(_a) {
|
|
38
|
+
var merchantId = _a.merchantId, amount = _a.amount, env = _a.env, onSuccess = _a.onSuccess, wallet = _a.wallet, action = _a.action;
|
|
39
|
+
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)({ wallet: wallet });
|
|
40
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, onSuccess).IFrameRef;
|
|
41
|
+
var transaction = (0, react_1.useMemo)(function () {
|
|
42
|
+
return action
|
|
43
|
+
? Buffer.from(JSON.stringify(action)).toString('base64')
|
|
44
|
+
: undefined;
|
|
45
|
+
}, [action]);
|
|
46
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: wallet.accountId, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, amount: amount, blockchain: 'near', transaction: transaction }));
|
|
20
47
|
}
|
|
21
|
-
exports.CoinflowPurchase = CoinflowPurchase;
|
|
22
48
|
//# sourceMappingURL=CoinflowPurchase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":";;;;AAAA,qDAAqC;AAErC,mDAAgD;AAChD,6EAA6E;AAC7E,iDAMyB;AACzB,qDAAmE;AACnE,yEAAyE;AAiCzE,SAAgB,gBAAgB,CAC9B,KAA8D;IAE9D,OAAO,6BAAa,CAAC,YAAY,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AAA,EACH,SAAS,eAAA,EACT,MAAM,YAAA,EACN,MAAM,YAAA;IAEN,IAAM,QAAQ,GAAG,IAAA,wDAA4B,EAAC,EAAC,MAAM,QAAA,EAAC,CAAC,CAAC;IACjD,IAAA,SAAS,GAAI,IAAA,iCAAe,EAAC,QAAQ,EAAE,SAAS,CAAC,UAAxC,CAAyC;IAEzD,IAAM,WAAW,GAAG,IAAA,eAAO,EACzB;QACE,OAAA,MAAM;YACJ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACxD,CAAC,CAAC,SAAS;IAFb,CAEa,EACf,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,CACL,iCAAC,+BAAc,IACb,YAAY,EAAE,MAAM,CAAC,SAAS,EAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,GACxB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare function CoinflowPurchaseHistory(
|
|
2
|
+
import { CoinflowNearHistoryProps, CoinflowSolanaHistoryProps } from './CoinflowWithdrawHistory';
|
|
3
|
+
export declare function CoinflowPurchaseHistory(props: CoinflowSolanaHistoryProps | CoinflowNearHistoryProps): JSX.Element;
|
|
@@ -5,12 +5,37 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var useIframeWallet_1 = require("./useIframeWallet");
|
|
6
6
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
7
7
|
var react_1 = tslib_1.__importDefault(require("react"));
|
|
8
|
-
|
|
8
|
+
var SolanaIFrameMessageHandlers_1 = require("./SolanaIFrameMessageHandlers");
|
|
9
|
+
var NearIFrameMessageHandlers_1 = require("./NearIFrameMessageHandlers");
|
|
10
|
+
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
11
|
+
function CoinflowPurchaseHistory(props) {
|
|
12
|
+
return CoinflowUtils_1.CoinflowUtils.byBlockchain(props.blockchain, {
|
|
13
|
+
solana: (react_1["default"].createElement(SolanaPurchaseHistory, tslib_1.__assign({}, props))),
|
|
14
|
+
near: react_1["default"].createElement(NearPurchaseHistory, tslib_1.__assign({}, props))
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.CoinflowPurchaseHistory = CoinflowPurchaseHistory;
|
|
18
|
+
function SolanaPurchaseHistory(_a) {
|
|
9
19
|
var wallet = _a.wallet, merchantId = _a.merchantId, connection = _a.connection, env = _a.env;
|
|
10
|
-
var
|
|
11
|
-
|
|
20
|
+
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)({
|
|
21
|
+
wallet: wallet,
|
|
22
|
+
connection: connection
|
|
23
|
+
});
|
|
24
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
25
|
+
if (!wallet.publicKey)
|
|
12
26
|
return null;
|
|
13
|
-
|
|
27
|
+
var walletPubkey = wallet.publicKey.toString();
|
|
28
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/purchase/".concat(merchantId), env: env, blockchain: 'solana' }));
|
|
29
|
+
}
|
|
30
|
+
function NearPurchaseHistory(_a) {
|
|
31
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env;
|
|
32
|
+
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)({
|
|
33
|
+
wallet: wallet
|
|
34
|
+
});
|
|
35
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
36
|
+
if (!wallet)
|
|
37
|
+
return null;
|
|
38
|
+
var walletPubkey = wallet.accountId;
|
|
39
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/purchase/".concat(merchantId), env: env, blockchain: 'near' }));
|
|
14
40
|
}
|
|
15
|
-
exports.CoinflowPurchaseHistory = CoinflowPurchaseHistory;
|
|
16
41
|
//# sourceMappingURL=CoinflowPurchaseHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":";;;;AAAA,qDAAkD;AAClD,mDAAgD;AAChD,wDAA0B;
|
|
1
|
+
{"version":3,"file":"CoinflowPurchaseHistory.js","sourceRoot":"","sources":["../../src/CoinflowPurchaseHistory.tsx"],"names":[],"mappings":";;;;AAAA,qDAAkD;AAClD,mDAAgD;AAChD,wDAA0B;AAK1B,6EAA6E;AAC7E,yEAAyE;AACzE,iDAA8C;AAE9C,SAAgB,uBAAuB,CACrC,KAA4D;IAE5D,OAAO,6BAAa,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE;QAClD,MAAM,EAAE,CACN,iCAAC,qBAAqB,uBAAM,KAAoC,EAAI,CACrE;QACD,IAAI,EAAE,iCAAC,mBAAmB,uBAAM,KAAkC,EAAI;KACvE,CAAC,CAAC;AACL,CAAC;AATD,0DASC;AAED,SAAS,qBAAqB,CAAC,EAKF;QAJ3B,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,UAAU,gBAAA,EACV,GAAG,SAAA;IAEH,IAAM,QAAQ,GAAG,IAAA,4DAA8B,EAAC;QAC9C,MAAM,QAAA;QACN,UAAU,YAAA;KACX,CAAC,CAAC;IACI,IAAA,SAAS,GAAI,IAAA,iCAAe,EAAC,QAAQ,CAAC,UAA7B,CAA8B;IAE9C,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IACnC,IAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAEjD,OAAO,CACL,iCAAC,+BAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,4BAAqB,UAAU,CAAE,EACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,QAAQ,GACpB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,EAIF;QAHzB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,GAAG,SAAA;IAEH,IAAM,QAAQ,GAAG,IAAA,wDAA4B,EAAC;QAC5C,MAAM,QAAA;KACP,CAAC,CAAC;IACI,IAAA,SAAS,GAAI,IAAA,iCAAe,EAAC,QAAQ,CAAC,UAA7B,CAA8B;IAE9C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;IAEtC,OAAO,CACL,iCAAC,+BAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,4BAAqB,UAAU,CAAE,EACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,GAClB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,19 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
2
2
|
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
3
|
+
export type CoinflowBlockchain = 'solana' | 'near';
|
|
3
4
|
export type CoinflowEnvs = 'prod' | 'staging' | 'sandbox' | 'local';
|
|
4
|
-
export type
|
|
5
|
+
export type SolanaWalletContextState = Pick<WalletContextState, 'wallet' | 'signTransaction' | 'signMessage' | 'connected' | 'publicKey' | 'sendTransaction'>;
|
|
6
|
+
export type NearWallet = {
|
|
7
|
+
accountId: string;
|
|
8
|
+
verifyOwner: (params: {
|
|
9
|
+
message: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
accountId: string;
|
|
12
|
+
message: string;
|
|
13
|
+
blockId: string;
|
|
14
|
+
publicKey: string;
|
|
15
|
+
signature: string;
|
|
16
|
+
keyType: number;
|
|
17
|
+
}>;
|
|
18
|
+
signAndSendTransaction: (params: {
|
|
19
|
+
signerId?: string;
|
|
20
|
+
receiverId?: string;
|
|
21
|
+
actions: Array<{
|
|
22
|
+
type: string;
|
|
23
|
+
params: object;
|
|
24
|
+
}>;
|
|
25
|
+
}) => Promise<{
|
|
26
|
+
status: any;
|
|
27
|
+
transaction: any;
|
|
28
|
+
transaction_outcome: any;
|
|
29
|
+
receipts_outcome: any;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
5
32
|
export declare class CoinflowUtils {
|
|
6
33
|
env: CoinflowEnvs;
|
|
7
34
|
url: string;
|
|
8
35
|
constructor(env?: CoinflowEnvs);
|
|
9
36
|
getFeePayer(merchantId: string): Promise<PublicKey>;
|
|
37
|
+
getCreditBalance(publicKey: string, blockchain: 'solana' | 'near'): Promise<number>;
|
|
10
38
|
static getCoinflowBaseUrl(env?: CoinflowEnvs): string;
|
|
11
|
-
static getCoinflowUrl({
|
|
12
|
-
|
|
39
|
+
static getCoinflowUrl({ walletPubkey, route, env, amount, transaction, blockchain, supportsVersionedTransactions, }: {
|
|
40
|
+
walletPubkey: string;
|
|
13
41
|
route: string;
|
|
14
42
|
env?: CoinflowEnvs;
|
|
15
43
|
amount?: number;
|
|
16
|
-
transaction?:
|
|
44
|
+
transaction?: string;
|
|
45
|
+
supportsVersionedTransactions?: boolean;
|
|
46
|
+
blockchain: CoinflowBlockchain;
|
|
17
47
|
}): string;
|
|
18
|
-
|
|
48
|
+
static serializeSolanaTransaction(transaction: Transaction | undefined): string | undefined;
|
|
49
|
+
static solanaWalletSupportsVersionedTransactions(wallet: SolanaWalletContextState): boolean;
|
|
50
|
+
static byBlockchain<T>(blockchain: CoinflowBlockchain, args: {
|
|
51
|
+
solana: T;
|
|
52
|
+
near: T;
|
|
53
|
+
}): T;
|
|
19
54
|
}
|
|
@@ -4,8 +4,6 @@ exports.CoinflowUtils = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
var bs58_1 = tslib_1.__importDefault(require("bs58"));
|
|
7
|
-
var buffer_1 = require("buffer");
|
|
8
|
-
var bn_js_1 = tslib_1.__importDefault(require("bn.js"));
|
|
9
7
|
var CoinflowUtils = /** @class */ (function () {
|
|
10
8
|
function CoinflowUtils(env) {
|
|
11
9
|
this.env = env !== null && env !== void 0 ? env : 'prod';
|
|
@@ -32,6 +30,22 @@ var CoinflowUtils = /** @class */ (function () {
|
|
|
32
30
|
});
|
|
33
31
|
});
|
|
34
32
|
};
|
|
33
|
+
CoinflowUtils.prototype.getCreditBalance = function (publicKey, blockchain) {
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
35
|
+
var response, balance;
|
|
36
|
+
return tslib_1.__generator(this, function (_a) {
|
|
37
|
+
switch (_a.label) {
|
|
38
|
+
case 0: return [4 /*yield*/, fetch(this.url + "/mint/balance/".concat(publicKey, "/").concat(blockchain))];
|
|
39
|
+
case 1:
|
|
40
|
+
response = _a.sent();
|
|
41
|
+
return [4 /*yield*/, response.json()];
|
|
42
|
+
case 2:
|
|
43
|
+
balance = (_a.sent()).balance;
|
|
44
|
+
return [2 /*return*/, balance];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
};
|
|
35
49
|
CoinflowUtils.getCoinflowBaseUrl = function (env) {
|
|
36
50
|
if (!env || env === 'prod')
|
|
37
51
|
return 'https://coinflow.cash';
|
|
@@ -40,93 +54,41 @@ var CoinflowUtils = /** @class */ (function () {
|
|
|
40
54
|
return "https://".concat(env, ".coinflow.cash");
|
|
41
55
|
};
|
|
42
56
|
CoinflowUtils.getCoinflowUrl = function (_a) {
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
url.searchParams.append('pubkey', (_c = (_b = wallet.publicKey) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : '');
|
|
57
|
+
var walletPubkey = _a.walletPubkey, route = _a.route, env = _a.env, amount = _a.amount, transaction = _a.transaction, blockchain = _a.blockchain, supportsVersionedTransactions = _a.supportsVersionedTransactions;
|
|
58
|
+
var url = new URL("/".concat(blockchain) + route, CoinflowUtils.getCoinflowBaseUrl(env));
|
|
59
|
+
url.searchParams.append('pubkey', walletPubkey);
|
|
47
60
|
if (transaction) {
|
|
48
|
-
|
|
49
|
-
requireAllSignatures: false,
|
|
50
|
-
verifySignatures: false
|
|
51
|
-
}));
|
|
52
|
-
url.searchParams.append('transaction', serializedTx);
|
|
61
|
+
url.searchParams.append('transaction', transaction);
|
|
53
62
|
}
|
|
54
63
|
if (amount) {
|
|
55
64
|
url.searchParams.append('amount', amount.toString());
|
|
56
65
|
}
|
|
57
|
-
var supportsVersionedTransactions = !!((_f = (_e = (_d = wallet.wallet) === null || _d === void 0 ? void 0 : _d.adapter) === null || _e === void 0 ? void 0 : _e.supportedTransactionVersions) === null || _f === void 0 ? void 0 : _f.has(0));
|
|
58
66
|
if (supportsVersionedTransactions) {
|
|
59
67
|
url.searchParams.append('supportsVersionedTransactions', 'true');
|
|
60
68
|
}
|
|
61
69
|
return url.toString();
|
|
62
70
|
};
|
|
63
|
-
CoinflowUtils.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return tslib_1.__generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0: return [4 /*yield*/, getCreditAtaInfo(wallet)];
|
|
87
|
-
case 1:
|
|
88
|
-
ataInfo = _a.sent();
|
|
89
|
-
return [2 /*return*/, parseTokenAccountAmount(ataInfo)];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function getCreditAtaInfo(wallet) {
|
|
95
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
96
|
-
var ata;
|
|
97
|
-
return tslib_1.__generator(this, function (_a) {
|
|
98
|
-
try {
|
|
99
|
-
ata = getCreditAtaAddress(wallet);
|
|
100
|
-
return [2 /*return*/, connection.getAccountInfo(ata)];
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
return [2 /*return*/, null];
|
|
104
|
-
}
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function getCreditAtaAddress(wallet) {
|
|
110
|
-
var address = web3_js_1.PublicKey.findProgramAddressSync([
|
|
111
|
-
wallet.toBuffer(),
|
|
112
|
-
new web3_js_1.PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA').toBuffer(),
|
|
113
|
-
creditsMint().toBuffer(),
|
|
114
|
-
], new web3_js_1.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'))[0];
|
|
115
|
-
return address;
|
|
116
|
-
}
|
|
117
|
-
function creditsMint() {
|
|
118
|
-
return web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from('usdc-credits-mint-2')], new web3_js_1.PublicKey('FD1amxhTsDpwzoVX41dxp2ygAESURV2zdUACzxM1Dfw9'))[0];
|
|
119
|
-
}
|
|
120
|
-
return tslib_1.__generator(this, function (_a) {
|
|
121
|
-
switch (_a.label) {
|
|
122
|
-
case 0:
|
|
123
|
-
if (!publicKey)
|
|
124
|
-
return [2 /*return*/, 0];
|
|
125
|
-
return [4 /*yield*/, getCreditBalance(publicKey)];
|
|
126
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
71
|
+
CoinflowUtils.serializeSolanaTransaction = function (transaction) {
|
|
72
|
+
if (!transaction)
|
|
73
|
+
return undefined;
|
|
74
|
+
return bs58_1["default"].encode(transaction.serialize({
|
|
75
|
+
requireAllSignatures: false,
|
|
76
|
+
verifySignatures: false
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
CoinflowUtils.solanaWalletSupportsVersionedTransactions = function (wallet) {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
return !!((_c = (_b = (_a = wallet.wallet) === null || _a === void 0 ? void 0 : _a.adapter) === null || _b === void 0 ? void 0 : _b.supportedTransactionVersions) === null || _c === void 0 ? void 0 : _c.has(0));
|
|
82
|
+
};
|
|
83
|
+
CoinflowUtils.byBlockchain = function (blockchain, args) {
|
|
84
|
+
switch (blockchain) {
|
|
85
|
+
case 'solana':
|
|
86
|
+
return args.solana;
|
|
87
|
+
case 'near':
|
|
88
|
+
return args.near;
|
|
89
|
+
default:
|
|
90
|
+
throw new Error('blockchain not supported!');
|
|
91
|
+
}
|
|
130
92
|
};
|
|
131
93
|
return CoinflowUtils;
|
|
132
94
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowUtils.js","sourceRoot":"","sources":["../../src/CoinflowUtils.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoinflowUtils.js","sourceRoot":"","sources":["../../src/CoinflowUtils.ts"],"names":[],"mappings":";;;;AAAA,2CAAuD;AAEvD,sDAA0B;AAsC1B;IAIE,uBAAY,GAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,MAAM,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,KAAK,MAAM;YAAE,IAAI,CAAC,GAAG,GAAG,2BAA2B,CAAC;aAC3D,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO;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 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Connection } from '@solana/web3.js';
|
|
3
|
-
import { CoinflowEnvs,
|
|
4
|
-
import { OnSuccessMethod } from './
|
|
5
|
-
export
|
|
6
|
-
wallet: SubsetWalletContextState;
|
|
3
|
+
import { CoinflowBlockchain, CoinflowEnvs, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
4
|
+
import { OnSuccessMethod } from './useIframeWallet';
|
|
5
|
+
export interface CoinflowCommonWithdrawProps {
|
|
7
6
|
merchantId: string;
|
|
8
|
-
connection: Connection;
|
|
9
7
|
env?: CoinflowEnvs;
|
|
10
8
|
onSuccess?: OnSuccessMethod;
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
blockchain: CoinflowBlockchain;
|
|
10
|
+
}
|
|
11
|
+
export interface CoinflowSolanaWithdrawProps extends CoinflowCommonWithdrawProps {
|
|
12
|
+
wallet: SolanaWalletContextState;
|
|
13
|
+
connection: Connection;
|
|
14
|
+
blockchain: 'solana';
|
|
15
|
+
}
|
|
16
|
+
export interface CoinflowNearWithdrawProps extends CoinflowCommonWithdrawProps {
|
|
17
|
+
wallet: NearWallet;
|
|
18
|
+
blockchain: 'near';
|
|
19
|
+
}
|
|
20
|
+
export declare function CoinflowWithdraw(props: CoinflowSolanaWithdrawProps | CoinflowNearWithdrawProps): JSX.Element;
|
|
@@ -4,13 +4,38 @@ exports.CoinflowWithdraw = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
7
|
+
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
7
8
|
var useIframeWallet_1 = require("./useIframeWallet");
|
|
8
|
-
|
|
9
|
+
var SolanaIFrameMessageHandlers_1 = require("./SolanaIFrameMessageHandlers");
|
|
10
|
+
var NearIFrameMessageHandlers_1 = require("./NearIFrameMessageHandlers");
|
|
11
|
+
function CoinflowWithdraw(props) {
|
|
12
|
+
return CoinflowUtils_1.CoinflowUtils.byBlockchain(props.blockchain, {
|
|
13
|
+
solana: (react_1["default"].createElement(CoinflowSolanaWithdraw, tslib_1.__assign({}, props))),
|
|
14
|
+
near: react_1["default"].createElement(CoinflowNearWithdraw, tslib_1.__assign({}, props))
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.CoinflowWithdraw = CoinflowWithdraw;
|
|
18
|
+
function CoinflowSolanaWithdraw(_a) {
|
|
9
19
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, connection = _a.connection, onSuccess = _a.onSuccess;
|
|
10
|
-
var
|
|
11
|
-
|
|
20
|
+
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)({
|
|
21
|
+
wallet: wallet,
|
|
22
|
+
connection: connection
|
|
23
|
+
});
|
|
24
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, onSuccess).IFrameRef;
|
|
25
|
+
if (!wallet.publicKey)
|
|
12
26
|
return null;
|
|
13
|
-
|
|
27
|
+
var walletPubkey = wallet.publicKey.toString();
|
|
28
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(merchantId), env: env, blockchain: 'solana' }));
|
|
29
|
+
}
|
|
30
|
+
function CoinflowNearWithdraw(_a) {
|
|
31
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, onSuccess = _a.onSuccess;
|
|
32
|
+
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)({
|
|
33
|
+
wallet: wallet
|
|
34
|
+
});
|
|
35
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers, onSuccess).IFrameRef;
|
|
36
|
+
if (!wallet)
|
|
37
|
+
return null;
|
|
38
|
+
var walletPubkey = wallet.accountId;
|
|
39
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(merchantId), env: env, blockchain: 'near' }));
|
|
14
40
|
}
|
|
15
|
-
exports.CoinflowWithdraw = CoinflowWithdraw;
|
|
16
41
|
//# sourceMappingURL=CoinflowWithdraw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":";;;;AAAA,wDAA0B;AAE1B,mDAAgD;
|
|
1
|
+
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":";;;;AAAA,wDAA0B;AAE1B,mDAAgD;AAChD,iDAMyB;AACzB,qDAAmE;AACnE,6EAA6E;AAC7E,yEAAyE;AAqBzE,SAAgB,gBAAgB,CAC9B,KAA8D;IAE9D,OAAO,6BAAa,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE;QAClD,MAAM,EAAE,CACN,iCAAC,sBAAsB,uBAAM,KAAqC,EAAI,CACvE;QACD,IAAI,EAAE,iCAAC,oBAAoB,uBAAM,KAAmC,EAAI;KACzE,CAAC,CAAC;AACL,CAAC;AATD,4CASC;AAED,SAAS,sBAAsB,CAAC,EAMF;QAL5B,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,GAAG,SAAA,EACH,UAAU,gBAAA,EACV,SAAS,eAAA;IAET,IAAM,QAAQ,GAAG,IAAA,4DAA8B,EAAC;QAC9C,MAAM,QAAA;QACN,UAAU,YAAA;KACX,CAAC,CAAC;IACI,IAAA,SAAS,GAAI,IAAA,iCAAe,EAAC,QAAQ,EAAE,SAAS,CAAC,UAAxC,CAAyC;IAEzD,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IACnC,IAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAEjD,OAAO,CACL,iCAAC,+BAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,QAAQ,GACpB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,EAKF;QAJ1B,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,GAAG,SAAA,EACH,SAAS,eAAA;IAET,IAAM,QAAQ,GAAG,IAAA,wDAA4B,EAAC;QAC5C,MAAM,QAAA;KACP,CAAC,CAAC;IACI,IAAA,SAAS,GAAI,IAAA,iCAAe,EAAC,QAAQ,EAAE,SAAS,CAAC,UAAxC,CAAyC;IAEzD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;IAEtC,OAAO,CACL,iCAAC,+BAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,GAClB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CoinflowEnvs,
|
|
2
|
+
import { CoinflowBlockchain, CoinflowEnvs, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
3
3
|
import { Connection } from '@solana/web3.js';
|
|
4
|
-
export
|
|
5
|
-
wallet: SubsetWalletContextState;
|
|
4
|
+
export interface CoinflowHistoryProps {
|
|
6
5
|
merchantId: string;
|
|
7
|
-
connection: Connection;
|
|
8
6
|
env?: CoinflowEnvs;
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
blockchain: CoinflowBlockchain;
|
|
8
|
+
}
|
|
9
|
+
export interface CoinflowSolanaHistoryProps extends CoinflowHistoryProps {
|
|
10
|
+
wallet: SolanaWalletContextState;
|
|
11
|
+
connection: Connection;
|
|
12
|
+
blockchain: 'solana';
|
|
13
|
+
}
|
|
14
|
+
export interface CoinflowNearHistoryProps extends CoinflowHistoryProps {
|
|
15
|
+
wallet: NearWallet;
|
|
16
|
+
blockchain: 'near';
|
|
17
|
+
}
|
|
18
|
+
export declare function CoinflowWithdrawHistory(props: CoinflowSolanaHistoryProps | CoinflowNearHistoryProps): JSX.Element;
|
|
@@ -2,15 +2,40 @@
|
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.CoinflowWithdrawHistory = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
5
6
|
var useIframeWallet_1 = require("./useIframeWallet");
|
|
6
7
|
var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
7
8
|
var react_1 = tslib_1.__importDefault(require("react"));
|
|
8
|
-
|
|
9
|
+
var SolanaIFrameMessageHandlers_1 = require("./SolanaIFrameMessageHandlers");
|
|
10
|
+
var NearIFrameMessageHandlers_1 = require("./NearIFrameMessageHandlers");
|
|
11
|
+
function CoinflowWithdrawHistory(props) {
|
|
12
|
+
return CoinflowUtils_1.CoinflowUtils.byBlockchain(props.blockchain, {
|
|
13
|
+
solana: (react_1["default"].createElement(SolanaWithdrawHistory, tslib_1.__assign({}, props))),
|
|
14
|
+
near: react_1["default"].createElement(NearWithdrawHistory, tslib_1.__assign({}, props))
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.CoinflowWithdrawHistory = CoinflowWithdrawHistory;
|
|
18
|
+
function SolanaWithdrawHistory(_a) {
|
|
9
19
|
var wallet = _a.wallet, merchantId = _a.merchantId, connection = _a.connection, env = _a.env;
|
|
10
|
-
var
|
|
11
|
-
|
|
20
|
+
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)({
|
|
21
|
+
wallet: wallet,
|
|
22
|
+
connection: connection
|
|
23
|
+
});
|
|
24
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
25
|
+
if (!wallet.publicKey)
|
|
12
26
|
return null;
|
|
13
|
-
|
|
27
|
+
var walletPubkey = wallet.publicKey.toString();
|
|
28
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(merchantId), env: env, blockchain: 'solana' }));
|
|
29
|
+
}
|
|
30
|
+
function NearWithdrawHistory(_a) {
|
|
31
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env;
|
|
32
|
+
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)({
|
|
33
|
+
wallet: wallet
|
|
34
|
+
});
|
|
35
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
36
|
+
if (!wallet)
|
|
37
|
+
return null;
|
|
38
|
+
var walletPubkey = wallet.accountId;
|
|
39
|
+
return (react_1["default"].createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(merchantId), env: env, blockchain: 'near' }));
|
|
14
40
|
}
|
|
15
|
-
exports.CoinflowWithdrawHistory = CoinflowWithdrawHistory;
|
|
16
41
|
//# 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,iDAMyB;AAEzB,qDAAkD;AAClD,mDAAgD;AAChD,wDAA0B;AAC1B,6EAA6E;AAC7E,yEAAyE;AAmBzE,SAAgB,uBAAuB,CACrC,KAA4D;IAE5D,OAAO,6BAAa,CAA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