@coinflowlabs/react 1.2.0 → 2.0.0-sandbox-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/build/cjs/CoinflowIFrame.d.ts +4 -2
- package/build/cjs/CoinflowIFrame.js +8 -18
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.d.ts +30 -3
- package/build/cjs/CoinflowPurchase.js +36 -8
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowPurchaseHistory.js +7 -7
- package/build/cjs/CoinflowPurchaseHistory.js.map +1 -1
- package/build/cjs/CoinflowUtils.d.ts +7 -15
- package/build/cjs/CoinflowUtils.js +12 -7
- package/build/cjs/CoinflowUtils.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +7 -3
- package/build/cjs/CoinflowWithdraw.js +12 -11
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/CoinflowWithdrawHistory.js +10 -10
- package/build/cjs/CoinflowWithdrawHistory.js.map +1 -1
- package/build/cjs/CommonCoinflowProps.d.ts +5 -1
- package/build/cjs/CommonCoinflowProps.js +1 -1
- package/build/cjs/EthIFrameMessageHandlers.d.ts +3 -1
- package/build/cjs/EthIFrameMessageHandlers.js +16 -17
- package/build/cjs/EthIFrameMessageHandlers.js.map +1 -1
- package/build/cjs/NearIFrameMessageHandlers.js +1 -22
- package/build/cjs/NearIFrameMessageHandlers.js.map +1 -1
- package/build/cjs/SolanaIFrameMessageHandlers.d.ts +2 -2
- package/build/cjs/SolanaIFrameMessageHandlers.js +56 -73
- package/build/cjs/SolanaIFrameMessageHandlers.js.map +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/useIframeWallet.d.ts +1 -1
- package/build/cjs/useIframeWallet.js +24 -21
- package/build/cjs/useIframeWallet.js.map +1 -1
- package/build/esm/CoinflowIFrame.d.ts +4 -2
- package/build/esm/CoinflowIFrame.js +6 -16
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.d.ts +30 -3
- package/build/esm/CoinflowPurchase.js +31 -4
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowPurchaseHistory.js +3 -3
- package/build/esm/CoinflowUtils.d.ts +7 -15
- package/build/esm/CoinflowUtils.js +11 -6
- package/build/esm/CoinflowUtils.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +7 -3
- package/build/esm/CoinflowWithdraw.js +7 -6
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/CoinflowWithdrawHistory.js +4 -4
- package/build/esm/CommonCoinflowProps.d.ts +5 -1
- package/build/esm/EthIFrameMessageHandlers.d.ts +3 -1
- package/build/esm/EthIFrameMessageHandlers.js +15 -16
- package/build/esm/EthIFrameMessageHandlers.js.map +1 -1
- package/build/esm/NearIFrameMessageHandlers.js +0 -21
- package/build/esm/NearIFrameMessageHandlers.js.map +1 -1
- package/build/esm/SolanaIFrameMessageHandlers.d.ts +2 -2
- package/build/esm/SolanaIFrameMessageHandlers.js +54 -71
- package/build/esm/SolanaIFrameMessageHandlers.js.map +1 -1
- package/build/esm/useIframeWallet.d.ts +1 -1
- package/build/esm/useIframeWallet.js +23 -20
- package/build/esm/useIframeWallet.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +10 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Connection, Signer, Transaction } from
|
|
3
|
-
import { NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
2
|
+
import type { Connection, PublicKey, Signer, Transaction } from "@solana/web3.js";
|
|
3
|
+
import { EthWallet, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
4
4
|
import { OnSuccessMethod } from './useIframeWallet';
|
|
5
5
|
import { CommonCoinflowProps } from './CommonCoinflowProps';
|
|
6
6
|
export interface CoinflowCommonPurchaseProps extends CommonCoinflowProps {
|
|
@@ -16,6 +16,8 @@ export interface CoinflowSolanaPurchaseProps extends CoinflowCommonPurchaseProps
|
|
|
16
16
|
debugTx?: boolean;
|
|
17
17
|
connection: Connection;
|
|
18
18
|
blockchain: 'solana';
|
|
19
|
+
token?: PublicKey | string;
|
|
20
|
+
supportsVersionedTransactions?: boolean;
|
|
19
21
|
}
|
|
20
22
|
export type NearFtTransferCallAction = {
|
|
21
23
|
methodName: 'ft_transfer_call';
|
|
@@ -28,4 +30,29 @@ export interface CoinflowNearPurchaseProps extends CoinflowCommonPurchaseProps {
|
|
|
28
30
|
blockchain: 'near';
|
|
29
31
|
action?: NearFtTransferCallAction;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
type BigNumberish = object | bigint | string | number;
|
|
34
|
+
type Bytes = ArrayLike<number>;
|
|
35
|
+
type BytesLike = Bytes | string;
|
|
36
|
+
type EvmTransaction = {
|
|
37
|
+
to: string;
|
|
38
|
+
from?: string;
|
|
39
|
+
nonce?: BigNumberish;
|
|
40
|
+
gasLimit?: BigNumberish;
|
|
41
|
+
gasPrice?: BigNumberish;
|
|
42
|
+
data?: BytesLike;
|
|
43
|
+
value?: BigNumberish;
|
|
44
|
+
chainId?: number;
|
|
45
|
+
type?: number;
|
|
46
|
+
maxPriorityFeePerGas?: BigNumberish;
|
|
47
|
+
maxFeePerGas?: BigNumberish;
|
|
48
|
+
customData?: Record<string, any>;
|
|
49
|
+
ccipReadEnabled?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export interface CoinflowPolygonPurchaseProps extends CoinflowCommonPurchaseProps {
|
|
52
|
+
transaction?: EvmTransaction;
|
|
53
|
+
wallet: EthWallet;
|
|
54
|
+
blockchain: 'polygon';
|
|
55
|
+
}
|
|
56
|
+
export declare function CoinflowPurchase(props: CoinflowSolanaPurchaseProps | CoinflowNearPurchaseProps | CoinflowPolygonPurchaseProps): JSX.Element;
|
|
57
|
+
export declare function PolygonCoinflowPurchase({ merchantId, amount, env, onSuccess, wallet, transaction, webhookInfo, email, loaderBackground, }: CoinflowPolygonPurchaseProps): JSX.Element | null;
|
|
58
|
+
export {};
|
|
@@ -5,19 +5,21 @@ import { useSolanaIFrameMessageHandlers } from './SolanaIFrameMessageHandlers';
|
|
|
5
5
|
import { CoinflowUtils, } from './CoinflowUtils';
|
|
6
6
|
import { useIframeWallet } from './useIframeWallet';
|
|
7
7
|
import { useNearIFrameMessageHandlers } from './NearIFrameMessageHandlers';
|
|
8
|
+
import { useEthIFrameMessageHandlers } from './EthIFrameMessageHandlers';
|
|
8
9
|
export function CoinflowPurchase(props) {
|
|
9
10
|
return CoinflowUtils.byBlockchain(props.blockchain, {
|
|
10
11
|
solana: (React.createElement(SolanaCoinflowPurchase, __assign({}, props))),
|
|
11
|
-
near: React.createElement(NearCoinflowPurchase, __assign({}, props))
|
|
12
|
+
near: React.createElement(NearCoinflowPurchase, __assign({}, props)),
|
|
13
|
+
polygon: (React.createElement(PolygonCoinflowPurchase, __assign({}, props))),
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
function SolanaCoinflowPurchase(_a) {
|
|
15
|
-
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, webhookInfo = _a.webhookInfo, email = _a.email, loaderBackground = _a.loaderBackground;
|
|
17
|
+
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, webhookInfo = _a.webhookInfo, email = _a.email, loaderBackground = _a.loaderBackground, token = _a.token, supportsVersionedTransactionsParam = _a.supportsVersionedTransactions;
|
|
16
18
|
var handlers = useSolanaIFrameMessageHandlers({
|
|
17
19
|
wallet: wallet,
|
|
18
20
|
connection: connection,
|
|
19
21
|
partialSigners: partialSigners,
|
|
20
|
-
debugTx: debugTx
|
|
22
|
+
debugTx: debugTx,
|
|
21
23
|
});
|
|
22
24
|
var IFrameRef = useIframeWallet(handlers, onSuccess).IFrameRef;
|
|
23
25
|
var transactionStr = useMemo(function () {
|
|
@@ -25,10 +27,20 @@ function SolanaCoinflowPurchase(_a) {
|
|
|
25
27
|
? CoinflowUtils.serializeSolanaTransaction(transaction)
|
|
26
28
|
: undefined;
|
|
27
29
|
}, [transaction]);
|
|
30
|
+
var supportsVersionedTransactions = useMemo(function () {
|
|
31
|
+
if (supportsVersionedTransactionsParam !== undefined)
|
|
32
|
+
return supportsVersionedTransactionsParam;
|
|
33
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.wallet))
|
|
34
|
+
return false;
|
|
35
|
+
var supportedTransactionVersions = wallet.wallet.adapter.supportedTransactionVersions;
|
|
36
|
+
if (!supportedTransactionVersions)
|
|
37
|
+
return false;
|
|
38
|
+
return supportedTransactionVersions.has(0);
|
|
39
|
+
}, [supportsVersionedTransactionsParam, wallet.wallet]);
|
|
28
40
|
if (!wallet.publicKey)
|
|
29
41
|
return null;
|
|
30
42
|
var walletPubkey = wallet.publicKey.toString();
|
|
31
|
-
return (React.createElement(CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, transaction: transactionStr, amount: amount, blockchain: 'solana', webhookInfo: webhookInfo, email: email, loaderBackground: loaderBackground }));
|
|
43
|
+
return (React.createElement(CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, transaction: transactionStr, amount: amount, blockchain: 'solana', webhookInfo: webhookInfo, email: email, loaderBackground: loaderBackground, token: token, supportsVersionedTransactions: supportsVersionedTransactions }));
|
|
32
44
|
}
|
|
33
45
|
function NearCoinflowPurchase(_a) {
|
|
34
46
|
var merchantId = _a.merchantId, amount = _a.amount, env = _a.env, onSuccess = _a.onSuccess, wallet = _a.wallet, action = _a.action, webhookInfo = _a.webhookInfo, email = _a.email, loaderBackground = _a.loaderBackground;
|
|
@@ -41,4 +53,19 @@ function NearCoinflowPurchase(_a) {
|
|
|
41
53
|
}, [action]);
|
|
42
54
|
return (React.createElement(CoinflowIFrame, { walletPubkey: wallet.accountId, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, amount: amount, blockchain: 'near', transaction: transaction, webhookInfo: webhookInfo, email: email, loaderBackground: loaderBackground }));
|
|
43
55
|
}
|
|
56
|
+
export function PolygonCoinflowPurchase(_a) {
|
|
57
|
+
var merchantId = _a.merchantId, amount = _a.amount, env = _a.env, onSuccess = _a.onSuccess, wallet = _a.wallet, transaction = _a.transaction, webhookInfo = _a.webhookInfo, email = _a.email, loaderBackground = _a.loaderBackground;
|
|
58
|
+
var handlers = useEthIFrameMessageHandlers({ wallet: wallet });
|
|
59
|
+
var IFrameRef = useIframeWallet(handlers, onSuccess).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
|
+
return (React.createElement(CoinflowIFrame, { transaction: transactionStr, walletPubkey: wallet.address, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, amount: amount, blockchain: 'polygon',
|
|
68
|
+
// transaction={transaction} TODO
|
|
69
|
+
webhookInfo: webhookInfo, email: email, loaderBackground: loaderBackground }));
|
|
70
|
+
}
|
|
44
71
|
//# 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;AAErC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,O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Q,EAAE,SAAS,CAAC,UAAxC,CAAyC;IAEzD,IAAM,cAAc,GAAG,OAAO,CAAC;QAC7B,IAAI,CAAC,WAAW;YAAE,OAAO,SAAS,CAAC;QACnC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAEjC,OAAO,CACL,oBAAC,cAAc,IACb,WAAW,EAAE,cAAc,EAC3B,YAAY,EAAE,MAAM,CAAC,OAAO,EAC5B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,SAAS;QACrB,iCAAiC;QACjC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -8,14 +8,14 @@ import { CoinflowUtils } from './CoinflowUtils';
|
|
|
8
8
|
export function CoinflowPurchaseHistory(props) {
|
|
9
9
|
return CoinflowUtils.byBlockchain(props.blockchain, {
|
|
10
10
|
solana: (React.createElement(SolanaPurchaseHistory, __assign({}, props))),
|
|
11
|
-
near: React.createElement(NearPurchaseHistory, __assign({}, props))
|
|
11
|
+
near: React.createElement(NearPurchaseHistory, __assign({}, props)),
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
function SolanaPurchaseHistory(_a) {
|
|
15
15
|
var wallet = _a.wallet, merchantId = _a.merchantId, connection = _a.connection, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
16
16
|
var handlers = useSolanaIFrameMessageHandlers({
|
|
17
17
|
wallet: wallet,
|
|
18
|
-
connection: connection
|
|
18
|
+
connection: connection,
|
|
19
19
|
});
|
|
20
20
|
var IFrameRef = useIframeWallet(handlers).IFrameRef;
|
|
21
21
|
if (!wallet.publicKey)
|
|
@@ -26,7 +26,7 @@ function SolanaPurchaseHistory(_a) {
|
|
|
26
26
|
function NearPurchaseHistory(_a) {
|
|
27
27
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
28
28
|
var handlers = useNearIFrameMessageHandlers({
|
|
29
|
-
wallet: wallet
|
|
29
|
+
wallet: wallet,
|
|
30
30
|
});
|
|
31
31
|
var IFrameRef = useIframeWallet(handlers).IFrameRef;
|
|
32
32
|
if (!wallet)
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Transaction } from '@solana/web3.js';
|
|
2
2
|
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
3
|
-
export type CoinflowBlockchain = 'solana' | 'near' | 'eth';
|
|
3
|
+
export type CoinflowBlockchain = 'solana' | 'near' | 'eth' | 'polygon';
|
|
4
4
|
export type CoinflowEnvs = 'prod' | 'staging' | 'sandbox' | 'local';
|
|
5
|
-
|
|
5
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
6
|
+
export type SolanaWalletContextState = PartialBy<Pick<WalletContextState, 'wallet' | 'signTransaction' | 'connected' | 'publicKey' | 'sendTransaction'>, 'wallet'>;
|
|
6
7
|
export type NearWallet = {
|
|
7
8
|
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
9
|
signAndSendTransaction: (params: {
|
|
19
10
|
signerId?: string;
|
|
20
11
|
receiverId?: string;
|
|
@@ -38,7 +29,6 @@ type AccessList = Array<{
|
|
|
38
29
|
type AccessListish = AccessList | Array<[string, Array<string>]> | Record<string, Array<string>>;
|
|
39
30
|
export type EthWallet = {
|
|
40
31
|
address: string | null | undefined;
|
|
41
|
-
signMessage: (message: string) => Promise<string>;
|
|
42
32
|
sendTransaction: (transaction: {
|
|
43
33
|
to: string;
|
|
44
34
|
from?: string;
|
|
@@ -57,12 +47,13 @@ export type EthWallet = {
|
|
|
57
47
|
}) => Promise<{
|
|
58
48
|
hash: string;
|
|
59
49
|
}>;
|
|
50
|
+
signMessage: (message: string) => Promise<string>;
|
|
60
51
|
};
|
|
61
52
|
export declare class CoinflowUtils {
|
|
62
53
|
env: CoinflowEnvs;
|
|
63
54
|
url: string;
|
|
64
55
|
constructor(env?: CoinflowEnvs);
|
|
65
|
-
getFeePayer(merchantId: string): Promise<
|
|
56
|
+
getFeePayer(merchantId: string): Promise<string>;
|
|
66
57
|
getCreditBalance(publicKey: string, blockchain: 'solana' | 'near'): Promise<number>;
|
|
67
58
|
static getCoinflowBaseUrl(env?: CoinflowEnvs): string;
|
|
68
59
|
static getCoinflowUrl({ walletPubkey, route, env, amount, transaction, blockchain, supportsVersionedTransactions, webhookInfo, token, email, loaderBackground, }: {
|
|
@@ -84,6 +75,7 @@ export declare class CoinflowUtils {
|
|
|
84
75
|
solana: T;
|
|
85
76
|
near: T;
|
|
86
77
|
eth?: T;
|
|
78
|
+
polygon?: T;
|
|
87
79
|
}): T;
|
|
88
80
|
}
|
|
89
81
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { PublicKey } from '@solana/web3.js';
|
|
3
2
|
import base58 from 'bs58';
|
|
4
3
|
var CoinflowUtils = /** @class */ (function () {
|
|
5
4
|
function CoinflowUtils(env) {
|
|
@@ -22,7 +21,7 @@ var CoinflowUtils = /** @class */ (function () {
|
|
|
22
21
|
return [4 /*yield*/, response.json()];
|
|
23
22
|
case 2:
|
|
24
23
|
json = _a.sent();
|
|
25
|
-
return [2 /*return*/,
|
|
24
|
+
return [2 /*return*/, json.feePayerPublicKey];
|
|
26
25
|
}
|
|
27
26
|
});
|
|
28
27
|
});
|
|
@@ -80,16 +79,18 @@ var CoinflowUtils = /** @class */ (function () {
|
|
|
80
79
|
CoinflowUtils.serializeSolanaTransaction = function (transaction) {
|
|
81
80
|
if (!transaction)
|
|
82
81
|
return undefined;
|
|
83
|
-
|
|
82
|
+
var serializedTx = transaction.serialize({
|
|
84
83
|
requireAllSignatures: false,
|
|
85
|
-
verifySignatures: false
|
|
86
|
-
})
|
|
84
|
+
verifySignatures: false,
|
|
85
|
+
});
|
|
86
|
+
return base58.encode(serializedTx);
|
|
87
87
|
};
|
|
88
88
|
CoinflowUtils.solanaWalletSupportsVersionedTransactions = function (wallet) {
|
|
89
89
|
var _a, _b, _c;
|
|
90
90
|
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));
|
|
91
91
|
};
|
|
92
|
-
CoinflowUtils.byBlockchain = function (blockchain, args
|
|
92
|
+
CoinflowUtils.byBlockchain = function (blockchain, args // TODO polygon not optional
|
|
93
|
+
) {
|
|
93
94
|
switch (blockchain) {
|
|
94
95
|
case 'solana':
|
|
95
96
|
return args.solana;
|
|
@@ -99,6 +100,10 @@ var CoinflowUtils = /** @class */ (function () {
|
|
|
99
100
|
if (args.eth === undefined)
|
|
100
101
|
throw new Error('blockchain not supported for this operation!');
|
|
101
102
|
return args.eth;
|
|
103
|
+
case 'polygon':
|
|
104
|
+
if (args.polygon === undefined)
|
|
105
|
+
throw new Error('blockchain not supported for this operation!');
|
|
106
|
+
return args.polygon;
|
|
102
107
|
default:
|
|
103
108
|
throw new Error('blockchain not supported!');
|
|
104
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowUtils.js","sourceRoot":"","sources":["../../src/CoinflowUtils.ts"],"names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IA0IC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import type { Connection } from '@solana/web3.js';
|
|
3
3
|
import { EthWallet, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
4
4
|
import { OnSuccessMethod } from './useIframeWallet';
|
|
5
5
|
import { CommonCoinflowProps } from './CommonCoinflowProps';
|
|
@@ -19,7 +19,11 @@ export interface CoinflowNearWithdrawProps extends CoinflowCommonWithdrawProps {
|
|
|
19
19
|
blockchain: 'near';
|
|
20
20
|
}
|
|
21
21
|
export interface CoinflowEthWithdrawProps extends CoinflowCommonWithdrawProps {
|
|
22
|
-
wallet: EthWallet
|
|
22
|
+
wallet: Omit<EthWallet, 'signMessage'>;
|
|
23
23
|
blockchain: 'eth';
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export interface CoinflowPolygonWithdrawProps extends CoinflowCommonWithdrawProps {
|
|
26
|
+
wallet: Omit<EthWallet, 'signMessage'>;
|
|
27
|
+
blockchain: 'polygon';
|
|
28
|
+
}
|
|
29
|
+
export declare function CoinflowWithdraw(props: CoinflowSolanaWithdrawProps | CoinflowNearWithdrawProps | CoinflowEthWithdrawProps | CoinflowPolygonWithdrawProps): JSX.Element;
|
|
@@ -10,14 +10,15 @@ export function CoinflowWithdraw(props) {
|
|
|
10
10
|
return CoinflowUtils.byBlockchain(props.blockchain, {
|
|
11
11
|
solana: (React.createElement(CoinflowSolanaWithdraw, __assign({}, props))),
|
|
12
12
|
near: React.createElement(CoinflowNearWithdraw, __assign({}, props)),
|
|
13
|
-
eth: React.createElement(CoinflowEthWithdraw, __assign({}, props))
|
|
13
|
+
eth: React.createElement(CoinflowEthWithdraw, __assign({}, props)),
|
|
14
|
+
polygon: (React.createElement(CoinflowEthWithdraw, __assign({}, props))),
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
function CoinflowSolanaWithdraw(_a) {
|
|
17
18
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, connection = _a.connection, onSuccess = _a.onSuccess, email = _a.email, token = _a.token, amount = _a.amount, loaderBackground = _a.loaderBackground;
|
|
18
19
|
var handlers = useSolanaIFrameMessageHandlers({
|
|
19
20
|
wallet: wallet,
|
|
20
|
-
connection: connection
|
|
21
|
+
connection: connection,
|
|
21
22
|
});
|
|
22
23
|
var IFrameRef = useIframeWallet(handlers, onSuccess).IFrameRef;
|
|
23
24
|
if (!wallet.publicKey)
|
|
@@ -28,7 +29,7 @@ function CoinflowSolanaWithdraw(_a) {
|
|
|
28
29
|
function CoinflowNearWithdraw(_a) {
|
|
29
30
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, onSuccess = _a.onSuccess, email = _a.email, token = _a.token, amount = _a.amount, loaderBackground = _a.loaderBackground;
|
|
30
31
|
var handlers = useNearIFrameMessageHandlers({
|
|
31
|
-
wallet: wallet
|
|
32
|
+
wallet: wallet,
|
|
32
33
|
});
|
|
33
34
|
var IFrameRef = useIframeWallet(handlers, onSuccess).IFrameRef;
|
|
34
35
|
if (!wallet)
|
|
@@ -37,14 +38,14 @@ function CoinflowNearWithdraw(_a) {
|
|
|
37
38
|
return (React.createElement(CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(merchantId), env: env, blockchain: 'near', token: token, amount: amount, email: email, loaderBackground: loaderBackground }));
|
|
38
39
|
}
|
|
39
40
|
function CoinflowEthWithdraw(_a) {
|
|
40
|
-
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, onSuccess = _a.onSuccess, email = _a.email, token = _a.token, amount = _a.amount, loaderBackground = _a.loaderBackground;
|
|
41
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, onSuccess = _a.onSuccess, email = _a.email, token = _a.token, amount = _a.amount, loaderBackground = _a.loaderBackground, blockchain = _a.blockchain;
|
|
41
42
|
var handlers = useEthIFrameMessageHandlers({
|
|
42
|
-
wallet: wallet
|
|
43
|
+
wallet: wallet,
|
|
43
44
|
});
|
|
44
45
|
var IFrameRef = useIframeWallet(handlers, onSuccess).IFrameRef;
|
|
45
46
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address))
|
|
46
47
|
return null;
|
|
47
48
|
var walletPubkey = wallet.address;
|
|
48
|
-
return (React.createElement(CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(merchantId), env: env, blockchain:
|
|
49
|
+
return (React.createElement(CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/withdraw/".concat(merchantId), env: env, blockchain: blockchain, token: token, amount: amount, email: email, loaderBackground: loaderBackground }));
|
|
49
50
|
}
|
|
50
51
|
//# sourceMappingURL=CoinflowWithdraw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,aAAa,GAId,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAkB,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAC,4BAA4B,EAAC,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAC,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,aAAa,GAId,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAkB,eAAe,EAAC,MAA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AO,IAAI,CAAC;IAClC,IAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;IAEpC,OAAO,CACL,oBAAC,cAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -10,14 +10,14 @@ export function CoinflowWithdrawHistory(props) {
|
|
|
10
10
|
return CoinflowUtils.byBlockchain(props.blockchain, {
|
|
11
11
|
solana: (React.createElement(SolanaWithdrawHistory, __assign({}, props))),
|
|
12
12
|
near: React.createElement(NearWithdrawHistory, __assign({}, props)),
|
|
13
|
-
eth: React.createElement(EthWithdrawHistory, __assign({}, props))
|
|
13
|
+
eth: React.createElement(EthWithdrawHistory, __assign({}, props)),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
function SolanaWithdrawHistory(_a) {
|
|
17
17
|
var wallet = _a.wallet, merchantId = _a.merchantId, connection = _a.connection, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
18
18
|
var handlers = useSolanaIFrameMessageHandlers({
|
|
19
19
|
wallet: wallet,
|
|
20
|
-
connection: connection
|
|
20
|
+
connection: connection,
|
|
21
21
|
});
|
|
22
22
|
var IFrameRef = useIframeWallet(handlers).IFrameRef;
|
|
23
23
|
if (!wallet.publicKey)
|
|
@@ -28,7 +28,7 @@ function SolanaWithdrawHistory(_a) {
|
|
|
28
28
|
function NearWithdrawHistory(_a) {
|
|
29
29
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
30
30
|
var handlers = useNearIFrameMessageHandlers({
|
|
31
|
-
wallet: wallet
|
|
31
|
+
wallet: wallet,
|
|
32
32
|
});
|
|
33
33
|
var IFrameRef = useIframeWallet(handlers).IFrameRef;
|
|
34
34
|
if (!wallet)
|
|
@@ -39,7 +39,7 @@ function NearWithdrawHistory(_a) {
|
|
|
39
39
|
function EthWithdrawHistory(_a) {
|
|
40
40
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
41
41
|
var handlers = useEthIFrameMessageHandlers({
|
|
42
|
-
wallet: wallet
|
|
42
|
+
wallet: wallet,
|
|
43
43
|
});
|
|
44
44
|
var IFrameRef = useIframeWallet(handlers).IFrameRef;
|
|
45
45
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CoinflowBlockchain, CoinflowEnvs, EthWallet, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
2
|
-
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import type { Connection } from '@solana/web3.js';
|
|
3
3
|
export interface CommonCoinflowProps {
|
|
4
4
|
merchantId: string;
|
|
5
5
|
env?: CoinflowEnvs;
|
|
@@ -19,3 +19,7 @@ export interface CoinflowEthHistoryProps extends CommonCoinflowProps {
|
|
|
19
19
|
wallet: EthWallet;
|
|
20
20
|
blockchain: 'eth';
|
|
21
21
|
}
|
|
22
|
+
export interface CoinflowPolygonHistoryProps extends CommonCoinflowProps {
|
|
23
|
+
wallet: EthWallet;
|
|
24
|
+
blockchain: 'polygon';
|
|
25
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IFrameMessageHandlers } from './SolanaIFrameMessageHandlers';
|
|
2
2
|
import { EthWallet } from './CoinflowUtils';
|
|
3
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
3
4
|
export declare function useEthIFrameMessageHandlers({ wallet, }: {
|
|
4
|
-
wallet: EthWallet
|
|
5
|
+
wallet: PartialBy<EthWallet, 'signMessage'>;
|
|
5
6
|
}): IFrameMessageHandlers;
|
|
7
|
+
export {};
|
|
@@ -3,41 +3,40 @@ import { useCallback } from 'react';
|
|
|
3
3
|
export function useEthIFrameMessageHandlers(_a) {
|
|
4
4
|
var _this = this;
|
|
5
5
|
var wallet = _a.wallet;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var handleSendTransaction = useCallback(function (_a) {
|
|
7
|
+
var data = _a.data;
|
|
8
8
|
return __awaiter(_this, void 0, void 0, function () {
|
|
9
|
-
var
|
|
9
|
+
var transaction, hash;
|
|
10
10
|
return __generator(this, function (_b) {
|
|
11
11
|
switch (_b.label) {
|
|
12
|
-
case 0:
|
|
12
|
+
case 0:
|
|
13
|
+
transaction = JSON.parse(Buffer.from(data, 'base64').toString());
|
|
14
|
+
return [4 /*yield*/, wallet.sendTransaction(transaction)];
|
|
13
15
|
case 1:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
throw new Error('Wallet did not sign');
|
|
17
|
-
return [2 /*return*/, signedMessage];
|
|
16
|
+
hash = (_b.sent()).hash;
|
|
17
|
+
return [2 /*return*/, hash];
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
}, [wallet]);
|
|
22
|
-
var
|
|
22
|
+
var handleSignMessage = useCallback(function (_a) {
|
|
23
23
|
var data = _a.data;
|
|
24
24
|
return __awaiter(_this, void 0, void 0, function () {
|
|
25
|
-
var transaction, hash;
|
|
26
25
|
return __generator(this, function (_b) {
|
|
27
26
|
switch (_b.label) {
|
|
28
27
|
case 0:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
console.log('handleSignMessage');
|
|
29
|
+
if (!wallet.signMessage)
|
|
30
|
+
throw new Error('Wallet does not support message signing!');
|
|
31
|
+
return [4 /*yield*/, wallet.signMessage(data)];
|
|
32
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
});
|
|
37
36
|
}, [wallet]);
|
|
38
37
|
return {
|
|
39
38
|
handleSendTransaction: handleSendTransaction,
|
|
40
|
-
handleSignMessage: handleSignMessage
|
|
39
|
+
handleSignMessage: handleSignMessage,
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
//# sourceMappingURL=EthIFrameMessageHandlers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/EthIFrameMessageHandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"EthIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/EthIFrameMessageHandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAMlC,MAAM,UAAU,2BAA2B,CAAC,EAI3C;IAJD,iBA6BC;QA5BC,MAAM,YAAA;IAIN,IAAM,qBAAqB,GAAG,WAAW,CACvC,UAAO,EAAkB;YAAjB,IAAI,UAAA;;;;;;wBACJ,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;wBACxD,qBAAM,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,EAAA;;wBAAjD,IAAI,GAAI,CAAA,SAAyC,CAAA,KAA7C;wBACX,sBAAO,IAAI,EAAC;;;;KACb,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,IAAM,iBAAiB,GAAG,WAAW,CACnC,UAAO,EAAkB;YAAjB,IAAI,UAAA;;;;;wBACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;wBACjC,IAAI,CAAC,MAAM,CAAC,WAAW;4BACrB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;wBAEvD,qBAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAA;4BAArC,sBAAO,SAA8B,EAAC;;;;KACvC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,qBAAqB,uBAAA;QACrB,iBAAiB,mBAAA;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -3,26 +3,6 @@ import { useCallback } from 'react';
|
|
|
3
3
|
export function useNearIFrameMessageHandlers(_a) {
|
|
4
4
|
var _this = this;
|
|
5
5
|
var wallet = _a.wallet;
|
|
6
|
-
var handleSignMessage = useCallback(function (_a) {
|
|
7
|
-
var data = _a.data;
|
|
8
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
9
|
-
var message, owner;
|
|
10
|
-
return __generator(this, function (_b) {
|
|
11
|
-
switch (_b.label) {
|
|
12
|
-
case 0:
|
|
13
|
-
message = data;
|
|
14
|
-
return [4 /*yield*/, wallet.verifyOwner({
|
|
15
|
-
message: message
|
|
16
|
-
})];
|
|
17
|
-
case 1:
|
|
18
|
-
owner = _b.sent();
|
|
19
|
-
if (!owner)
|
|
20
|
-
throw new Error('Wallet did not sign');
|
|
21
|
-
return [2 /*return*/, JSON.stringify(owner)];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}, [wallet]);
|
|
26
6
|
var handleSendTransaction = useCallback(function (_a) {
|
|
27
7
|
var data = _a.data;
|
|
28
8
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -44,7 +24,6 @@ export function useNearIFrameMessageHandlers(_a) {
|
|
|
44
24
|
}, [wallet]);
|
|
45
25
|
return {
|
|
46
26
|
handleSendTransaction: handleSendTransaction,
|
|
47
|
-
handleSignMessage: handleSignMessage
|
|
48
27
|
};
|
|
49
28
|
}
|
|
50
29
|
//# sourceMappingURL=NearIFrameMessageHandlers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NearIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/NearIFrameMessageHandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAIlC,MAAM,UAAU,4BAA4B,CAAC,EAI5C;IAJD,
|
|
1
|
+
{"version":3,"file":"NearIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/NearIFrameMessageHandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAIlC,MAAM,UAAU,4BAA4B,CAAC,EAI5C;IAJD,iBAmBC;QAlBC,MAAM,YAAA;IAIN,IAAM,qBAAqB,GAAG,WAAW,CACvC,UAAO,EAAkB;YAAjB,IAAI,UAAA;;;;;;wBACJ,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;wBACzC,qBAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAA;;wBAA9D,gBAAgB,GAAG,SAA2C;wBACpE,IAAI,CAAC,gBAAgB;4BAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;wBAC/C,iBAAiB,GAAI,gBAAgB,YAApB,CAAqB;wBAC1D,sBAAO,iBAAiB,CAAC,IAAI,EAAC;;;;KAC/B,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,qBAAqB,uBAAA;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection, Signer } from '@solana/web3.js';
|
|
1
|
+
import type { Connection, Signer } from '@solana/web3.js';
|
|
2
2
|
import { SolanaWalletContextState } from './CoinflowUtils';
|
|
3
3
|
export type WalletCall = {
|
|
4
4
|
method: string;
|
|
@@ -11,8 +11,8 @@ export type SolanaIFrameWalletProps = {
|
|
|
11
11
|
debugTx?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export type IFrameMessageHandlers = {
|
|
14
|
+
handleSignMessage?: ({ data }: WalletCall) => Promise<string>;
|
|
14
15
|
handleSignTransaction?: ({ data }: WalletCall) => Promise<string>;
|
|
15
16
|
handleSendTransaction: ({ data }: WalletCall) => Promise<string>;
|
|
16
|
-
handleSignMessage: ({ data }: WalletCall) => Promise<string>;
|
|
17
17
|
};
|
|
18
18
|
export declare function useSolanaIFrameMessageHandlers({ wallet, connection, partialSigners, debugTx, }: SolanaIFrameWalletProps): IFrameMessageHandlers;
|