@coinflowlabs/react 0.2.8 → 0.2.10
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 +4 -0
- package/build/cjs/CoinflowIFrame.d.ts +3 -3
- package/build/cjs/CoinflowIFrame.js +18 -27
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.d.ts +4 -6
- package/build/cjs/CoinflowPurchase.js +3 -3
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowUtils.d.ts +11 -1
- package/build/cjs/CoinflowUtils.js +37 -7
- package/build/cjs/CoinflowUtils.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +4 -6
- package/build/cjs/CoinflowWithdraw.js +3 -3
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/IFrameWalletConnector.d.ts +7 -5
- package/build/cjs/IFrameWalletConnector.js +78 -34
- package/build/cjs/IFrameWalletConnector.js.map +1 -1
- package/build/cjs/index.d.ts +3 -0
- package/build/cjs/index.js +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/useIframeWallet.d.ts +14 -0
- package/build/cjs/useIframeWallet.js +31 -0
- package/build/cjs/useIframeWallet.js.map +1 -0
- package/build/esm/CoinflowIFrame.d.ts +3 -3
- package/build/esm/CoinflowIFrame.js +18 -27
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.d.ts +4 -6
- package/build/esm/CoinflowPurchase.js +2 -2
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowUtils.d.ts +11 -1
- package/build/esm/CoinflowUtils.js +37 -7
- package/build/esm/CoinflowUtils.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +4 -6
- package/build/esm/CoinflowWithdraw.js +2 -2
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/IFrameWalletConnector.d.ts +7 -5
- package/build/esm/IFrameWalletConnector.js +78 -34
- package/build/esm/IFrameWalletConnector.js.map +1 -1
- package/build/esm/index.d.ts +3 -0
- package/build/esm/index.js +3 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/useIframeWallet.d.ts +14 -0
- package/build/esm/useIframeWallet.js +27 -0
- package/build/esm/useIframeWallet.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import
|
|
3
|
-
function getCoinflowUrl(env) {
|
|
4
|
-
console.log('getCoinflowUrl', { env: env });
|
|
5
|
-
if (!env || env === 'prod')
|
|
6
|
-
return 'https://coinflow.cash';
|
|
7
|
-
if (env === 'local')
|
|
8
|
-
return 'http://localhost:3000';
|
|
9
|
-
return "https://".concat(env, ".coinflow.cash");
|
|
10
|
-
}
|
|
2
|
+
import { CoinflowUtils, } from './CoinflowUtils';
|
|
11
3
|
export function CoinflowIFrame(_a) {
|
|
12
|
-
var
|
|
4
|
+
var wallet = _a.wallet, IFrameRef = _a.IFrameRef, env = _a.env, route = _a.route, transaction = _a.transaction, amount = _a.amount;
|
|
13
5
|
var url = useMemo(function () {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return url;
|
|
27
|
-
}, [amount, env, publicKey, route, transaction]);
|
|
28
|
-
return useMemo(function () { return (React.createElement("iframe", { ref: IFrameRef, style: {
|
|
6
|
+
return CoinflowUtils.getCoinflowUrl({
|
|
7
|
+
wallet: wallet,
|
|
8
|
+
amount: amount,
|
|
9
|
+
env: env,
|
|
10
|
+
route: route,
|
|
11
|
+
transaction: transaction
|
|
12
|
+
});
|
|
13
|
+
}, [amount, env, wallet, route, transaction]);
|
|
14
|
+
return useMemo(function () { return (React.createElement("iframe", { onLoad: function () {
|
|
15
|
+
if (IFrameRef.current)
|
|
16
|
+
IFrameRef.current.style.opacity = '1';
|
|
17
|
+
}, ref: IFrameRef, style: {
|
|
29
18
|
width: '100%',
|
|
30
|
-
height: '100%'
|
|
31
|
-
|
|
19
|
+
height: '100%',
|
|
20
|
+
opacity: 0,
|
|
21
|
+
transition: 'opacity 300ms linear'
|
|
22
|
+
}, title: "withdraw", frameBorder: "0", src: url })); }, [IFrameRef, url]);
|
|
32
23
|
}
|
|
33
24
|
//# sourceMappingURL=CoinflowIFrame.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,
|
|
1
|
+
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,EAEL,aAAa,GAEd,MAAM,iBAAiB,CAAC;AAWzB,MAAM,UAAU,cAAc,CAAC,EAOT;QANpB,MAAM,YAAA,EACN,SAAS,eAAA,EACT,GAAG,SAAA,EACH,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,MAAM,YAAA;IAEN,IAAM,GAAG,GAAG,OAAO,CAAC;QAClB,OAAO,aAAa,CAAC,cAAc,CAAC;YAClC,MAAM,QAAA;YACN,MAAM,QAAA;YACN,GAAG,KAAA;YACH,KAAK,OAAA;YACL,WAAW,aAAA;SACZ,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAE9C,OAAO,OAAO,CACZ,cAAM,OAAA,CACJ,gCACE,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"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
3
2
|
import { Connection, Signer, Transaction } from '@solana/web3.js';
|
|
4
3
|
import { OnSuccessMethod } from './IFrameWalletConnector';
|
|
5
|
-
import { CoinflowEnvs } from './CoinflowUtils';
|
|
6
|
-
type
|
|
7
|
-
wallet:
|
|
4
|
+
import { CoinflowEnvs, SubsetWalletContextState } from './CoinflowUtils';
|
|
5
|
+
export type CoinflowPurchaseProps = {
|
|
6
|
+
wallet: SubsetWalletContextState;
|
|
8
7
|
merchantId: string;
|
|
9
8
|
connection: Connection;
|
|
10
9
|
amount?: number;
|
|
@@ -14,5 +13,4 @@ type Props = {
|
|
|
14
13
|
partialSigners?: Signer[];
|
|
15
14
|
debugTx?: boolean;
|
|
16
15
|
};
|
|
17
|
-
export declare function CoinflowPurchase({ wallet, merchantId, env, connection, onSuccess, transaction, amount, partialSigners, debugTx, }:
|
|
18
|
-
export {};
|
|
16
|
+
export declare function CoinflowPurchase({ wallet, merchantId, env, connection, onSuccess, transaction, amount, partialSigners, debugTx, }: CoinflowPurchaseProps): JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
3
|
-
import { useIframeWallet } from './
|
|
3
|
+
import { useIframeWallet } from './useIframeWallet';
|
|
4
4
|
export function CoinflowPurchase(_a) {
|
|
5
5
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, connection = _a.connection, onSuccess = _a.onSuccess, transaction = _a.transaction, amount = _a.amount, partialSigners = _a.partialSigners, _b = _a.debugTx, debugTx = _b === void 0 ? false : _b;
|
|
6
6
|
var IFrameRef = useIframeWallet({
|
|
@@ -12,6 +12,6 @@ export function CoinflowPurchase(_a) {
|
|
|
12
12
|
}).IFrameRef;
|
|
13
13
|
if (!wallet.publicKey || !wallet.connected)
|
|
14
14
|
return null;
|
|
15
|
-
return (React.createElement(CoinflowIFrame, {
|
|
15
|
+
return (React.createElement(CoinflowIFrame, { wallet: wallet, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, transaction: transaction, amount: amount }));
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=CoinflowPurchase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAclD,MAAM,UAAU,gBAAgB,CAAC,EAUT;QATtB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,GAAG,SAAA,EACH,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,MAAM,YAAA,EACN,cAAc,oBAAA,EACd,eAAe,EAAf,OAAO,mBAAG,KAAK,KAAA;IAER,IAAA,SAAS,GAAI,eAAe,CAAC;QAClC,MAAM,QAAA;QACN,UAAU,YAAA;QACV,SAAS,WAAA;QACT,cAAc,gBAAA;QACd,OAAO,SAAA;KACR,CAAC,UANc,CAMb;IAEH,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAExD,OAAO,CACL,oBAAC,cAAc,IACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { Connection, PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { Connection, PublicKey, Transaction } from '@solana/web3.js';
|
|
2
|
+
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
2
3
|
export type CoinflowEnvs = 'prod' | 'staging' | 'sandbox' | 'local';
|
|
4
|
+
export type SubsetWalletContextState = Pick<WalletContextState, 'wallet' | 'signTransaction' | 'signMessage' | 'connected' | 'publicKey' | 'sendTransaction'>;
|
|
3
5
|
export declare class CoinflowUtils {
|
|
4
6
|
env: CoinflowEnvs;
|
|
5
7
|
url: string;
|
|
6
8
|
constructor(env?: CoinflowEnvs);
|
|
7
9
|
getFeePayer(): Promise<PublicKey>;
|
|
10
|
+
static getCoinflowBaseUrl(env?: CoinflowEnvs): string;
|
|
11
|
+
static getCoinflowUrl({ wallet, route, env, amount, transaction, }: {
|
|
12
|
+
wallet: SubsetWalletContextState;
|
|
13
|
+
route: string;
|
|
14
|
+
env?: CoinflowEnvs;
|
|
15
|
+
amount?: number;
|
|
16
|
+
transaction?: Transaction;
|
|
17
|
+
}): string;
|
|
8
18
|
getCoinflowCreditsBalance(publicKey: PublicKey, connection: Connection): Promise<number>;
|
|
9
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter, __generator } from "tslib";
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import axios from 'axios';
|
|
4
3
|
import { getAccount, getAssociatedTokenAddress, } from '@solana/spl-token';
|
|
4
|
+
import base58 from 'bs58';
|
|
5
5
|
var CoinflowUtils = /** @class */ (function () {
|
|
6
6
|
function CoinflowUtils(env) {
|
|
7
7
|
this.env = env !== null && env !== void 0 ? env : 'prod';
|
|
@@ -14,17 +14,47 @@ var CoinflowUtils = /** @class */ (function () {
|
|
|
14
14
|
}
|
|
15
15
|
CoinflowUtils.prototype.getFeePayer = function () {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function () {
|
|
17
|
-
var
|
|
18
|
-
return __generator(this, function (
|
|
19
|
-
switch (
|
|
20
|
-
case 0: return [4 /*yield*/,
|
|
17
|
+
var response, _a;
|
|
18
|
+
return __generator(this, function (_b) {
|
|
19
|
+
switch (_b.label) {
|
|
20
|
+
case 0: return [4 /*yield*/, fetch(this.url + '/v1/redeem/fee-payer')];
|
|
21
21
|
case 1:
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
response = _b.sent();
|
|
23
|
+
_a = PublicKey.bind;
|
|
24
|
+
return [4 /*yield*/, response.json()];
|
|
25
|
+
case 2: return [2 /*return*/, new (_a.apply(PublicKey, [void 0, _b.sent()]))()];
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
});
|
|
27
29
|
};
|
|
30
|
+
CoinflowUtils.getCoinflowBaseUrl = function (env) {
|
|
31
|
+
if (!env || env === 'prod')
|
|
32
|
+
return 'https://coinflow.cash';
|
|
33
|
+
if (env === 'local')
|
|
34
|
+
return 'http://localhost:3000';
|
|
35
|
+
return "https://".concat(env, ".coinflow.cash");
|
|
36
|
+
};
|
|
37
|
+
CoinflowUtils.getCoinflowUrl = function (_a) {
|
|
38
|
+
var _b, _c, _d, _e;
|
|
39
|
+
var wallet = _a.wallet, route = _a.route, env = _a.env, amount = _a.amount, transaction = _a.transaction;
|
|
40
|
+
var url = new URL(route, CoinflowUtils.getCoinflowBaseUrl(env));
|
|
41
|
+
url.searchParams.append('pubkey', (_c = (_b = wallet.publicKey) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : '');
|
|
42
|
+
if (transaction) {
|
|
43
|
+
var serializedTx = base58.encode(transaction.serialize({
|
|
44
|
+
requireAllSignatures: false,
|
|
45
|
+
verifySignatures: false
|
|
46
|
+
}));
|
|
47
|
+
url.searchParams.append('transaction', serializedTx);
|
|
48
|
+
}
|
|
49
|
+
if (amount) {
|
|
50
|
+
url.searchParams.append('amount', amount.toString());
|
|
51
|
+
}
|
|
52
|
+
var supportsVersionedTransactions = !!((_e = (_d = wallet.wallet) === null || _d === void 0 ? void 0 : _d.adapter.supportedTransactionVersions) === null || _e === void 0 ? void 0 : _e.has(0));
|
|
53
|
+
if (supportsVersionedTransactions) {
|
|
54
|
+
url.searchParams.append('supportsVersionedTransactions', 'true');
|
|
55
|
+
}
|
|
56
|
+
return url.toString();
|
|
57
|
+
};
|
|
28
58
|
CoinflowUtils.prototype.getCoinflowCreditsBalance = function (publicKey, connection) {
|
|
29
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
30
60
|
function getCreditBalance(wallet) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowUtils.js","sourceRoot":"","sources":["../../src/CoinflowUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,
|
|
1
|
+
{"version":3,"file":"CoinflowUtils.js","sourceRoot":"","sources":["../../src/CoinflowUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,EAAc,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAEL,UAAU,EACV,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,MAAM,MAAM,MAAM,CAAC;AAa1B;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,GAA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oCAEtB,qBAAM,SAAS,CAAC,kBAAkB,CAChC,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,EACpC,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAC9D,EAAA;oCAJH,sBAAO,CACL,SAGC,CACF,CAAC,CAAC,CAAC,EAAC;;;;aACN;;;;wBA9BD,IAAI,CAAC,SAAS;4BAAE,sBAAO,CAAC,EAAC;wBAgClB,qBAAM,gBAAgB,CAAC,SAAS,CAAC,EAAA;4BAAxC,sBAAO,SAAiC,EAAC;;;;KAC1C;IACH,oBAAC;AAAD,CAAC,AAnGD,IAmGC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { WalletContextState } from '@solana/wallet-adapter-react';
|
|
3
2
|
import { Connection } from '@solana/web3.js';
|
|
3
|
+
import { CoinflowEnvs, SubsetWalletContextState } from './CoinflowUtils';
|
|
4
4
|
import { OnSuccessMethod } from './IFrameWalletConnector';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
wallet: WalletContextState;
|
|
5
|
+
export type CoinflowWithdrawProps = {
|
|
6
|
+
wallet: SubsetWalletContextState;
|
|
8
7
|
merchantId: string;
|
|
9
8
|
connection: Connection;
|
|
10
9
|
env?: CoinflowEnvs;
|
|
11
10
|
onSuccess?: OnSuccessMethod;
|
|
12
11
|
};
|
|
13
|
-
export declare function CoinflowWithdraw({ wallet, merchantId, env, connection, onSuccess, }:
|
|
14
|
-
export {};
|
|
12
|
+
export declare function CoinflowWithdraw({ wallet, merchantId, env, connection, onSuccess, }: CoinflowWithdrawProps): JSX.Element | null;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
3
|
-
import { useIframeWallet } from './
|
|
3
|
+
import { useIframeWallet } from './useIframeWallet';
|
|
4
4
|
export function CoinflowWithdraw(_a) {
|
|
5
5
|
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, connection = _a.connection, onSuccess = _a.onSuccess;
|
|
6
6
|
var IFrameRef = useIframeWallet({ wallet: wallet, connection: connection, onSuccess: onSuccess }).IFrameRef;
|
|
7
7
|
if (!wallet.publicKey || !wallet.connected)
|
|
8
8
|
return null;
|
|
9
|
-
return (React.createElement(CoinflowIFrame, {
|
|
9
|
+
return (React.createElement(CoinflowIFrame, { wallet: wallet, IFrameRef: IFrameRef, route: "/withdraw/".concat(merchantId), env: env }));
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=CoinflowWithdraw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../../src/CoinflowWithdraw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAUlD,MAAM,UAAU,gBAAgB,CAAC,EAMT;QALtB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,GAAG,SAAA,EACH,UAAU,gBAAA,EACV,SAAS,eAAA;IAEF,IAAA,SAAS,GAAI,eAAe,CAAC,EAAC,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,SAAS,WAAA,EAAC,CAAC,UAApD,CAAqD;IAErE,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAExD,OAAO,CACL,oBAAC,cAAc,IACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Connection, Signer } from '@solana/web3.js';
|
|
3
|
-
import {
|
|
2
|
+
import { SubsetWalletContextState } from './CoinflowUtils';
|
|
4
3
|
export type WalletCall = {
|
|
5
4
|
method: string;
|
|
6
5
|
data: string;
|
|
7
6
|
};
|
|
8
7
|
export type OnSuccessMethod = (params: string) => void | Promise<void>;
|
|
9
8
|
type Props = {
|
|
10
|
-
wallet:
|
|
9
|
+
wallet: SubsetWalletContextState;
|
|
11
10
|
connection: Connection;
|
|
12
11
|
onSuccess?: OnSuccessMethod;
|
|
13
12
|
partialSigners?: Signer[];
|
|
14
13
|
debugTx?: boolean;
|
|
14
|
+
sendIFrameMessage: (message: string) => void;
|
|
15
15
|
};
|
|
16
|
-
export declare function
|
|
17
|
-
|
|
16
|
+
export declare function useHandleIFrameMessages({ wallet, connection, onSuccess, partialSigners, debugTx, sendIFrameMessage, }: Props): {
|
|
17
|
+
handleIframeMessages: ({ data }: {
|
|
18
|
+
data: string;
|
|
19
|
+
}) => Promise<void>;
|
|
18
20
|
};
|
|
19
21
|
export {};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { useCallback
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
3
|
import base58 from 'bs58';
|
|
4
|
-
import { Transaction } from '@solana/web3.js';
|
|
5
|
-
export function
|
|
4
|
+
import { Transaction, VersionedTransaction, } from '@solana/web3.js';
|
|
5
|
+
export function useHandleIFrameMessages(_a) {
|
|
6
6
|
var _this = this;
|
|
7
|
-
var wallet = _a.wallet, connection = _a.connection, onSuccess = _a.onSuccess, partialSigners = _a.partialSigners, _b = _a.debugTx, debugTx = _b === void 0 ? false : _b;
|
|
8
|
-
var IFrameRef = useRef(null);
|
|
9
|
-
var sendIFrameMessage = useCallback(function (message) {
|
|
10
|
-
var _a;
|
|
11
|
-
if (!((_a = IFrameRef === null || IFrameRef === void 0 ? void 0 : IFrameRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow))
|
|
12
|
-
throw new Error('Iframe not defined');
|
|
13
|
-
IFrameRef.current.contentWindow.postMessage(message, '*');
|
|
14
|
-
}, [IFrameRef]);
|
|
7
|
+
var wallet = _a.wallet, connection = _a.connection, onSuccess = _a.onSuccess, partialSigners = _a.partialSigners, _b = _a.debugTx, debugTx = _b === void 0 ? false : _b, sendIFrameMessage = _a.sendIFrameMessage;
|
|
15
8
|
var handleSignMessage = useCallback(function (_a) {
|
|
16
9
|
var data = _a.data;
|
|
17
10
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -54,18 +47,35 @@ export function useIframeWallet(_a) {
|
|
|
54
47
|
var handleSendTransaction = useCallback(function (_a) {
|
|
55
48
|
var data = _a.data;
|
|
56
49
|
return __awaiter(_this, void 0, void 0, function () {
|
|
50
|
+
function getTransaction() {
|
|
51
|
+
var parsedUInt8Array = base58.decode(data);
|
|
52
|
+
var vtx = VersionedTransaction.deserialize(parsedUInt8Array);
|
|
53
|
+
if (vtx.version === 'legacy')
|
|
54
|
+
return Transaction.from(parsedUInt8Array);
|
|
55
|
+
return vtx;
|
|
56
|
+
}
|
|
57
57
|
var tx, partiallySign, signature;
|
|
58
58
|
return __generator(this, function (_b) {
|
|
59
59
|
switch (_b.label) {
|
|
60
60
|
case 0:
|
|
61
|
-
tx =
|
|
61
|
+
tx = getTransaction();
|
|
62
62
|
partiallySign = function (signer) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
if (tx instanceof Transaction) {
|
|
64
|
+
var requiredSignatures = tx.signatures.map(function (sig) {
|
|
65
|
+
return sig.publicKey.toString();
|
|
66
|
+
});
|
|
67
|
+
var shouldSign_1 = requiredSignatures.includes(signer.publicKey.toString());
|
|
68
|
+
if (shouldSign_1)
|
|
69
|
+
tx.partialSign(signer);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
var signerPubkeys = tx.message.staticAccountKeys
|
|
73
|
+
.slice(0, tx.message.header.numRequiredSignatures)
|
|
74
|
+
.map(function (pk) { return pk.toString(); });
|
|
75
|
+
var shouldSign = signerPubkeys.includes(signer.publicKey.toString());
|
|
67
76
|
if (shouldSign)
|
|
68
|
-
tx.
|
|
77
|
+
tx.sign([signer]);
|
|
78
|
+
return;
|
|
69
79
|
};
|
|
70
80
|
if (partialSigners) {
|
|
71
81
|
partialSigners.forEach(partiallySign);
|
|
@@ -91,6 +101,40 @@ export function useIframeWallet(_a) {
|
|
|
91
101
|
sendTransactionDebug,
|
|
92
102
|
wallet,
|
|
93
103
|
]);
|
|
104
|
+
var handleSignTransaction = useCallback(function (_a) {
|
|
105
|
+
var data = _a.data;
|
|
106
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
+
var tx, partiallySign, signedTransaction;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (!wallet.signTransaction) {
|
|
112
|
+
throw new Error('signTransaction is not supported by this wallet');
|
|
113
|
+
}
|
|
114
|
+
tx = Transaction.from(base58.decode(data));
|
|
115
|
+
partiallySign = function (signer) {
|
|
116
|
+
var requiredSignatures = tx.signatures.map(function (sig) {
|
|
117
|
+
return sig.publicKey.toString();
|
|
118
|
+
});
|
|
119
|
+
var shouldSign = requiredSignatures.includes(signer.publicKey.toString());
|
|
120
|
+
if (shouldSign)
|
|
121
|
+
tx.partialSign(signer);
|
|
122
|
+
};
|
|
123
|
+
if (partialSigners) {
|
|
124
|
+
partialSigners.forEach(partiallySign);
|
|
125
|
+
}
|
|
126
|
+
return [4 /*yield*/, wallet.signTransaction(tx)];
|
|
127
|
+
case 1:
|
|
128
|
+
signedTransaction = _b.sent();
|
|
129
|
+
sendIFrameMessage(base58.encode(signedTransaction.serialize({
|
|
130
|
+
requireAllSignatures: false,
|
|
131
|
+
verifySignatures: false
|
|
132
|
+
})));
|
|
133
|
+
return [2 /*return*/];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}, [partialSigners, sendIFrameMessage, wallet]);
|
|
94
138
|
var handleIframeMessages = useCallback(function (_a) {
|
|
95
139
|
var data = _a.data;
|
|
96
140
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -98,7 +142,7 @@ export function useIframeWallet(_a) {
|
|
|
98
142
|
return __generator(this, function (_c) {
|
|
99
143
|
switch (_c.label) {
|
|
100
144
|
case 0:
|
|
101
|
-
_c.trys.push([0,
|
|
145
|
+
_c.trys.push([0, 10, , 11]);
|
|
102
146
|
if (!wallet)
|
|
103
147
|
return [2 /*return*/];
|
|
104
148
|
parsedData = parseJSON(data);
|
|
@@ -109,35 +153,40 @@ export function useIframeWallet(_a) {
|
|
|
109
153
|
case 'signMessage': return [3 /*break*/, 1];
|
|
110
154
|
case 'sendTransaction': return [3 /*break*/, 3];
|
|
111
155
|
case 'success': return [3 /*break*/, 5];
|
|
156
|
+
case 'signTransaction': return [3 /*break*/, 6];
|
|
112
157
|
}
|
|
113
|
-
return [3 /*break*/,
|
|
158
|
+
return [3 /*break*/, 8];
|
|
114
159
|
case 1: return [4 /*yield*/, handleSignMessage(parsedData)];
|
|
115
160
|
case 2:
|
|
116
161
|
_c.sent();
|
|
117
|
-
return [3 /*break*/,
|
|
162
|
+
return [3 /*break*/, 9];
|
|
118
163
|
case 3: return [4 /*yield*/, handleSendTransaction(parsedData)];
|
|
119
164
|
case 4:
|
|
120
165
|
_c.sent();
|
|
121
|
-
return [3 /*break*/,
|
|
166
|
+
return [3 /*break*/, 9];
|
|
122
167
|
case 5:
|
|
123
168
|
{
|
|
124
169
|
if (onSuccess)
|
|
125
170
|
onSuccess(data);
|
|
126
|
-
return [3 /*break*/,
|
|
171
|
+
return [3 /*break*/, 9];
|
|
127
172
|
}
|
|
128
173
|
_c.label = 6;
|
|
129
|
-
case 6:
|
|
174
|
+
case 6: return [4 /*yield*/, handleSignTransaction(parsedData)];
|
|
175
|
+
case 7:
|
|
176
|
+
_c.sent();
|
|
177
|
+
return [3 /*break*/, 9];
|
|
178
|
+
case 8:
|
|
130
179
|
{
|
|
131
180
|
throw new Error("Unsupported Wallet Method ".concat(parsedData.method, ", must be signMessage or signTransaction"));
|
|
132
181
|
}
|
|
133
|
-
_c.label =
|
|
134
|
-
case
|
|
135
|
-
case
|
|
182
|
+
_c.label = 9;
|
|
183
|
+
case 9: return [3 /*break*/, 11];
|
|
184
|
+
case 10:
|
|
136
185
|
e_1 = _c.sent();
|
|
137
186
|
console.error('handleIframeMessages', e_1);
|
|
138
187
|
sendIFrameMessage('ERROR');
|
|
139
|
-
return [3 /*break*/,
|
|
140
|
-
case
|
|
188
|
+
return [3 /*break*/, 11];
|
|
189
|
+
case 11: return [2 /*return*/];
|
|
141
190
|
}
|
|
142
191
|
});
|
|
143
192
|
});
|
|
@@ -148,12 +197,7 @@ export function useIframeWallet(_a) {
|
|
|
148
197
|
sendIFrameMessage,
|
|
149
198
|
wallet,
|
|
150
199
|
]);
|
|
151
|
-
|
|
152
|
-
if (!window)
|
|
153
|
-
throw new Error('Window not defined');
|
|
154
|
-
window.onmessage = handleIframeMessages;
|
|
155
|
-
}, [handleIframeMessages]);
|
|
156
|
-
return { IFrameRef: IFrameRef };
|
|
200
|
+
return { handleIframeMessages: handleIframeMessages };
|
|
157
201
|
}
|
|
158
202
|
function parseJSON(data) {
|
|
159
203
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFrameWalletConnector.js","sourceRoot":"","sources":["../../src/IFrameWalletConnector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"IFrameWalletConnector.js","sourceRoot":"","sources":["../../src/IFrameWalletConnector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAClC,OAAO,MAAM,MAAM,MAAM,CAAC;AAC1B,OAAO,EAGL,WAAW,EACX,oBAAoB,GACrB,M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EAAC,CAAC;AAChC,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI;QACF,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAC3B,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC"}
|
package/build/esm/index.d.ts
CHANGED
package/build/esm/index.js
CHANGED
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Connection, Signer } from '@solana/web3.js';
|
|
3
|
+
import { OnSuccessMethod } from './IFrameWalletConnector';
|
|
4
|
+
import { SubsetWalletContextState } from './CoinflowUtils';
|
|
5
|
+
export type IFrameWalletProps = {
|
|
6
|
+
wallet: SubsetWalletContextState;
|
|
7
|
+
connection: Connection;
|
|
8
|
+
onSuccess?: OnSuccessMethod;
|
|
9
|
+
partialSigners?: Signer[];
|
|
10
|
+
debugTx?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function useIframeWallet({ wallet, connection, onSuccess, partialSigners, debugTx, }: IFrameWalletProps): {
|
|
13
|
+
IFrameRef: import("react").RefObject<HTMLIFrameElement>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useHandleIFrameMessages, } from './IFrameWalletConnector';
|
|
3
|
+
export function useIframeWallet(_a) {
|
|
4
|
+
var wallet = _a.wallet, connection = _a.connection, onSuccess = _a.onSuccess, partialSigners = _a.partialSigners, _b = _a.debugTx, debugTx = _b === void 0 ? false : _b;
|
|
5
|
+
var IFrameRef = useRef(null);
|
|
6
|
+
var sendIFrameMessage = useCallback(function (message) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (!((_a = IFrameRef === null || IFrameRef === void 0 ? void 0 : IFrameRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow))
|
|
9
|
+
throw new Error('Iframe not defined');
|
|
10
|
+
IFrameRef.current.contentWindow.postMessage(message, '*');
|
|
11
|
+
}, [IFrameRef]);
|
|
12
|
+
var handleIframeMessages = useHandleIFrameMessages({
|
|
13
|
+
wallet: wallet,
|
|
14
|
+
connection: connection,
|
|
15
|
+
onSuccess: onSuccess,
|
|
16
|
+
partialSigners: partialSigners,
|
|
17
|
+
debugTx: debugTx,
|
|
18
|
+
sendIFrameMessage: sendIFrameMessage
|
|
19
|
+
}).handleIframeMessages;
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
if (!window)
|
|
22
|
+
throw new Error('Window not defined');
|
|
23
|
+
window.onmessage = handleIframeMessages;
|
|
24
|
+
}, [handleIframeMessages]);
|
|
25
|
+
return { IFrameRef: IFrameRef };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=useIframeWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../../src/useIframeWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,EAEL,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAWjC,MAAM,UAAU,eAAe,CAAC,EAMZ;QALlB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,cAAc,oBAAA,EACd,eAAe,EAAf,OAAO,mBAAG,KAAK,KAAA;IAEf,IAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAElD,IAAM,iBAAiB,GAAG,WAAW,CACnC,UAAC,OAAe;;QACd,IAAI,CAAC,CAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,0CAAE,aAAa,CAAA;YACpC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEK,IAAA,oBAAoB,GAAI,uBAAuB,CAAC;QACrD,MAAM,QAAA;QACN,UAAU,YAAA;QACV,SAAS,WAAA;QACT,cAAc,gBAAA;QACd,OAAO,SAAA;QACP,iBAAiB,mBAAA;KAClB,CAAC,qBAPyB,CAOxB;IAEH,SAAS,CAAC;QACR,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACnD,MAAM,CAAC,SAAS,GAAG,oBAAoB,CAAC;IAC1C,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAE3B,OAAO,EAAC,SAAS,WAAA,EAAC,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinflowlabs/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "React Component for Coinflow Withdraw",
|
|
5
5
|
"main": "./build/cjs/index.js",
|
|
6
6
|
"module": "./build/esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"bs58": "^5.0.0",
|
|
27
|
-
"@solana/web3.js": "^1.
|
|
27
|
+
"@solana/web3.js": "^1.70.0",
|
|
28
28
|
"@solana/spl-token": "^0.3.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"eslint-config-react-app": "^7.0.1",
|
|
33
33
|
"react": "^18.2.0",
|
|
34
34
|
"react-dom": "^18.2.0",
|
|
35
|
-
"typescript": "^4.9.
|
|
35
|
+
"typescript": "^4.9.4"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=16"
|