@coinflowlabs/react 1.1.2 → 1.3.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 +10 -0
- package/build/cjs/CoinflowIFrame.d.ts +8 -5
- package/build/cjs/CoinflowIFrame.js +9 -17
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.d.ts +32 -7
- package/build/cjs/CoinflowPurchase.js +37 -9
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowPurchaseHistory.d.ts +1 -1
- package/build/cjs/CoinflowPurchaseHistory.js +9 -9
- package/build/cjs/CoinflowPurchaseHistory.js.map +1 -1
- package/build/cjs/CoinflowUtils.d.ts +37 -13
- package/build/cjs/CoinflowUtils.js +19 -6
- package/build/cjs/CoinflowUtils.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +12 -6
- package/build/cjs/CoinflowWithdraw.js +23 -9
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/CoinflowWithdrawHistory.d.ts +2 -17
- package/build/cjs/CoinflowWithdrawHistory.js +21 -9
- package/build/cjs/CoinflowWithdrawHistory.js.map +1 -1
- package/build/cjs/CommonCoinflowProps.d.ts +25 -0
- package/build/cjs/CommonCoinflowProps.js +3 -0
- package/build/cjs/CommonCoinflowProps.js.map +1 -0
- package/build/cjs/EthIFrameMessageHandlers.d.ts +7 -0
- package/build/cjs/EthIFrameMessageHandlers.js +46 -0
- package/build/cjs/EthIFrameMessageHandlers.js.map +1 -0
- package/build/cjs/NearIFrameMessageHandlers.js +1 -22
- package/build/cjs/NearIFrameMessageHandlers.js.map +1 -1
- package/build/cjs/SolanaIFrameMessageHandlers.d.ts +1 -1
- package/build/cjs/SolanaIFrameMessageHandlers.js +22 -30
- 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 +8 -5
- package/build/esm/CoinflowIFrame.js +7 -15
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.d.ts +32 -7
- package/build/esm/CoinflowPurchase.js +33 -6
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowPurchaseHistory.d.ts +1 -1
- package/build/esm/CoinflowPurchaseHistory.js +7 -7
- package/build/esm/CoinflowPurchaseHistory.js.map +1 -1
- package/build/esm/CoinflowUtils.d.ts +37 -13
- package/build/esm/CoinflowUtils.js +18 -5
- package/build/esm/CoinflowUtils.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +12 -6
- package/build/esm/CoinflowWithdraw.js +21 -7
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/CoinflowWithdrawHistory.d.ts +2 -17
- package/build/esm/CoinflowWithdrawHistory.js +20 -8
- package/build/esm/CoinflowWithdrawHistory.js.map +1 -1
- package/build/esm/CommonCoinflowProps.d.ts +25 -0
- package/build/esm/CommonCoinflowProps.js +2 -0
- package/build/esm/CommonCoinflowProps.js.map +1 -0
- package/build/esm/EthIFrameMessageHandlers.d.ts +7 -0
- package/build/esm/EthIFrameMessageHandlers.js +42 -0
- package/build/esm/EthIFrameMessageHandlers.js.map +1 -0
- package/build/esm/NearIFrameMessageHandlers.js +0 -21
- package/build/esm/NearIFrameMessageHandlers.js.map +1 -1
- package/build/esm/SolanaIFrameMessageHandlers.d.ts +1 -1
- package/build/esm/SolanaIFrameMessageHandlers.js +18 -26
- 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/package.json +4 -4
|
@@ -1,18 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export interface CoinflowHistoryProps {
|
|
5
|
-
merchantId: string;
|
|
6
|
-
env?: CoinflowEnvs;
|
|
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
|
+
import { CoinflowNearHistoryProps, CoinflowSolanaHistoryProps, CoinflowEthHistoryProps } from './CommonCoinflowProps';
|
|
3
|
+
export declare function CoinflowWithdrawHistory(props: CoinflowSolanaHistoryProps | CoinflowNearHistoryProps | CoinflowEthHistoryProps): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoinflowWithdrawHistory = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var CoinflowUtils_1 = require("./CoinflowUtils");
|
|
@@ -8,34 +8,46 @@ var CoinflowIFrame_1 = require("./CoinflowIFrame");
|
|
|
8
8
|
var react_1 = tslib_1.__importDefault(require("react"));
|
|
9
9
|
var SolanaIFrameMessageHandlers_1 = require("./SolanaIFrameMessageHandlers");
|
|
10
10
|
var NearIFrameMessageHandlers_1 = require("./NearIFrameMessageHandlers");
|
|
11
|
+
var EthIFrameMessageHandlers_1 = require("./EthIFrameMessageHandlers");
|
|
11
12
|
function CoinflowWithdrawHistory(props) {
|
|
12
13
|
return CoinflowUtils_1.CoinflowUtils.byBlockchain(props.blockchain, {
|
|
13
|
-
solana: (react_1
|
|
14
|
-
near: react_1
|
|
14
|
+
solana: (react_1.default.createElement(SolanaWithdrawHistory, tslib_1.__assign({}, props))),
|
|
15
|
+
near: react_1.default.createElement(NearWithdrawHistory, tslib_1.__assign({}, props)),
|
|
16
|
+
eth: react_1.default.createElement(EthWithdrawHistory, tslib_1.__assign({}, props)),
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
exports.CoinflowWithdrawHistory = CoinflowWithdrawHistory;
|
|
18
20
|
function SolanaWithdrawHistory(_a) {
|
|
19
|
-
var wallet = _a.wallet, merchantId = _a.merchantId, connection = _a.connection, env = _a.env;
|
|
21
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, connection = _a.connection, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
20
22
|
var handlers = (0, SolanaIFrameMessageHandlers_1.useSolanaIFrameMessageHandlers)({
|
|
21
23
|
wallet: wallet,
|
|
22
|
-
connection: connection
|
|
24
|
+
connection: connection,
|
|
23
25
|
});
|
|
24
26
|
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
25
27
|
if (!wallet.publicKey)
|
|
26
28
|
return null;
|
|
27
29
|
var walletPubkey = wallet.publicKey.toString();
|
|
28
|
-
return (react_1
|
|
30
|
+
return (react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(merchantId), env: env, blockchain: 'solana', loaderBackground: loaderBackground }));
|
|
29
31
|
}
|
|
30
32
|
function NearWithdrawHistory(_a) {
|
|
31
|
-
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env;
|
|
33
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
32
34
|
var handlers = (0, NearIFrameMessageHandlers_1.useNearIFrameMessageHandlers)({
|
|
33
|
-
wallet: wallet
|
|
35
|
+
wallet: wallet,
|
|
34
36
|
});
|
|
35
37
|
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
36
38
|
if (!wallet)
|
|
37
39
|
return null;
|
|
38
40
|
var walletPubkey = wallet.accountId;
|
|
39
|
-
return (react_1
|
|
41
|
+
return (react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: walletPubkey, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(merchantId), env: env, blockchain: 'near', loaderBackground: loaderBackground }));
|
|
42
|
+
}
|
|
43
|
+
function EthWithdrawHistory(_a) {
|
|
44
|
+
var wallet = _a.wallet, merchantId = _a.merchantId, env = _a.env, loaderBackground = _a.loaderBackground;
|
|
45
|
+
var handlers = (0, EthIFrameMessageHandlers_1.useEthIFrameMessageHandlers)({
|
|
46
|
+
wallet: wallet,
|
|
47
|
+
});
|
|
48
|
+
var IFrameRef = (0, useIframeWallet_1.useIframeWallet)(handlers).IFrameRef;
|
|
49
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address))
|
|
50
|
+
return null;
|
|
51
|
+
return (react_1.default.createElement(CoinflowIFrame_1.CoinflowIFrame, { walletPubkey: wallet.address, IFrameRef: IFrameRef, route: "/history/withdraw/".concat(merchantId), env: env, blockchain: 'eth', loaderBackground: loaderBackground }));
|
|
40
52
|
}
|
|
41
53
|
//# sourceMappingURL=CoinflowWithdrawHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":";;;;AAAA,iDAA8C;AAC9C,qDAAkD;AAClD,mDAAgD;AAChD,wDAA0B;AAC1B,6EAA6E;AAC7E,yEAAyE;AAMzE,uEAAuE;AAEvE,SAAgB,uBAAuB,CACrC,KAG2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C;IACzB,IAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;IAEtC,OAAO,CACL,8BAAC,+BAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,4BAAqB,UAAU,CAAE,EACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,EAKF;QAJxB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,GAAG,SAAA,EACH,gBAAgB,sBAAA;IAEhB,IAAM,QAAQ,GAAG,IAAA,sDAA2B,EAAC;QAC3C,MAAM,QAAA;KACP,CAAC,CAAC;IACI,IAAA,SAAS,GAAI,IAAA,iCAAe,EAAC,QAAQ,CAAC,UAA7B,CAA8B;IAE9C,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAA;QAAE,OAAO,IAAI,CAAC;IAElC,OAAO,CACL,8BAAC,+BAAc,IACb,YAAY,EAAE,MAAM,CAAC,OAAO,EAC5B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,4BAAqB,UAAU,CAAE,EACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,KAAK,EACjB,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CoinflowBlockchain, CoinflowEnvs, EthWallet, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
export interface CommonCoinflowProps {
|
|
4
|
+
merchantId: string;
|
|
5
|
+
env?: CoinflowEnvs;
|
|
6
|
+
loaderBackground?: string;
|
|
7
|
+
blockchain: CoinflowBlockchain;
|
|
8
|
+
}
|
|
9
|
+
export interface CoinflowSolanaHistoryProps extends CommonCoinflowProps {
|
|
10
|
+
wallet: SolanaWalletContextState;
|
|
11
|
+
connection: Connection;
|
|
12
|
+
blockchain: 'solana';
|
|
13
|
+
}
|
|
14
|
+
export interface CoinflowNearHistoryProps extends CommonCoinflowProps {
|
|
15
|
+
wallet: NearWallet;
|
|
16
|
+
blockchain: 'near';
|
|
17
|
+
}
|
|
18
|
+
export interface CoinflowEthHistoryProps extends CommonCoinflowProps {
|
|
19
|
+
wallet: EthWallet;
|
|
20
|
+
blockchain: 'eth';
|
|
21
|
+
}
|
|
22
|
+
export interface CoinflowPolygonHistoryProps extends CommonCoinflowProps {
|
|
23
|
+
wallet: EthWallet;
|
|
24
|
+
blockchain: 'polygon';
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommonCoinflowProps.js","sourceRoot":"","sources":["../../src/CommonCoinflowProps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IFrameMessageHandlers } from './SolanaIFrameMessageHandlers';
|
|
2
|
+
import { EthWallet } from './CoinflowUtils';
|
|
3
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
4
|
+
export declare function useEthIFrameMessageHandlers({ wallet, }: {
|
|
5
|
+
wallet: PartialBy<EthWallet, 'signMessage'>;
|
|
6
|
+
}): IFrameMessageHandlers;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useEthIFrameMessageHandlers = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
function useEthIFrameMessageHandlers(_a) {
|
|
7
|
+
var _this = this;
|
|
8
|
+
var wallet = _a.wallet;
|
|
9
|
+
var handleSendTransaction = (0, react_1.useCallback)(function (_a) {
|
|
10
|
+
var data = _a.data;
|
|
11
|
+
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
12
|
+
var transaction, hash;
|
|
13
|
+
return tslib_1.__generator(this, function (_b) {
|
|
14
|
+
switch (_b.label) {
|
|
15
|
+
case 0:
|
|
16
|
+
transaction = JSON.parse(Buffer.from(data, 'base64').toString());
|
|
17
|
+
return [4 /*yield*/, wallet.sendTransaction(transaction)];
|
|
18
|
+
case 1:
|
|
19
|
+
hash = (_b.sent()).hash;
|
|
20
|
+
return [2 /*return*/, hash];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}, [wallet]);
|
|
25
|
+
var handleSignMessage = (0, react_1.useCallback)(function (_a) {
|
|
26
|
+
var data = _a.data;
|
|
27
|
+
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
28
|
+
return tslib_1.__generator(this, function (_b) {
|
|
29
|
+
switch (_b.label) {
|
|
30
|
+
case 0:
|
|
31
|
+
console.log('handleSignMessage');
|
|
32
|
+
if (!wallet.signMessage)
|
|
33
|
+
throw new Error('Wallet does not support message signing!');
|
|
34
|
+
return [4 /*yield*/, wallet.signMessage(data)];
|
|
35
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}, [wallet]);
|
|
40
|
+
return {
|
|
41
|
+
handleSendTransaction: handleSendTransaction,
|
|
42
|
+
handleSignMessage: handleSignMessage,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.useEthIFrameMessageHandlers = useEthIFrameMessageHandlers;
|
|
46
|
+
//# sourceMappingURL=EthIFrameMessageHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/EthIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAMlC,SAAgB,2BAA2B,CAAC,EAI3C;IAJD,iBA6BC;QA5BC,MAAM,YAAA;IAIN,IAAM,qBAAqB,GAAG,IAAA,mBAAW,EACvC,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,IAAA,mBAAW,EACnC,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;AA7BD,kEA6BC"}
|
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useNearIFrameMessageHandlers = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = require("react");
|
|
6
6
|
function useNearIFrameMessageHandlers(_a) {
|
|
7
7
|
var _this = this;
|
|
8
8
|
var wallet = _a.wallet;
|
|
9
|
-
var handleSignMessage = (0, react_1.useCallback)(function (_a) {
|
|
10
|
-
var data = _a.data;
|
|
11
|
-
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
12
|
-
var message, owner;
|
|
13
|
-
return tslib_1.__generator(this, function (_b) {
|
|
14
|
-
switch (_b.label) {
|
|
15
|
-
case 0:
|
|
16
|
-
message = data;
|
|
17
|
-
return [4 /*yield*/, wallet.verifyOwner({
|
|
18
|
-
message: message
|
|
19
|
-
})];
|
|
20
|
-
case 1:
|
|
21
|
-
owner = _b.sent();
|
|
22
|
-
if (!owner)
|
|
23
|
-
throw new Error('Wallet did not sign');
|
|
24
|
-
return [2 /*return*/, JSON.stringify(owner)];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}, [wallet]);
|
|
29
9
|
var handleSendTransaction = (0, react_1.useCallback)(function (_a) {
|
|
30
10
|
var data = _a.data;
|
|
31
11
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -47,7 +27,6 @@ function useNearIFrameMessageHandlers(_a) {
|
|
|
47
27
|
}, [wallet]);
|
|
48
28
|
return {
|
|
49
29
|
handleSendTransaction: handleSendTransaction,
|
|
50
|
-
handleSignMessage: handleSignMessage
|
|
51
30
|
};
|
|
52
31
|
}
|
|
53
32
|
exports.useNearIFrameMessageHandlers = useNearIFrameMessageHandlers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NearIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/NearIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAIlC,SAAgB,4BAA4B,CAAC,EAI5C;IAJD,
|
|
1
|
+
{"version":3,"file":"NearIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/NearIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAIlC,SAAgB,4BAA4B,CAAC,EAI5C;IAJD,iBAmBC;QAlBC,MAAM,YAAA;IAIN,IAAM,qBAAqB,GAAG,IAAA,mBAAW,EACvC,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;AAnBD,oEAmBC"}
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSolanaIFrameMessageHandlers = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = require("react");
|
|
@@ -8,39 +8,32 @@ var web3_js_1 = require("@solana/web3.js");
|
|
|
8
8
|
function useSolanaIFrameMessageHandlers(_a) {
|
|
9
9
|
var _this = this;
|
|
10
10
|
var wallet = _a.wallet, connection = _a.connection, partialSigners = _a.partialSigners, _b = _a.debugTx, debugTx = _b === void 0 ? false : _b;
|
|
11
|
-
var handleSignMessage = (0, react_1.useCallback)(function (_a) {
|
|
12
|
-
var data = _a.data;
|
|
13
|
-
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
14
|
-
var signature;
|
|
15
|
-
return tslib_1.__generator(this, function (_b) {
|
|
16
|
-
switch (_b.label) {
|
|
17
|
-
case 0:
|
|
18
|
-
if (!wallet.signMessage)
|
|
19
|
-
throw new Error('Wallet does not support message signing'); // TODO see if this is correct
|
|
20
|
-
return [4 /*yield*/, wallet.signMessage(bs58_1["default"].decode(data))];
|
|
21
|
-
case 1:
|
|
22
|
-
signature = _b.sent();
|
|
23
|
-
return [2 /*return*/, bs58_1["default"].encode(signature)];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}, [wallet]);
|
|
28
11
|
var sendTransactionDebug = (0, react_1.useCallback)(function (tx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
29
|
-
var signedTx, serializedTx, signature;
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
var signedTx, serializedTx, simulation, _i, _a, log, signature;
|
|
13
|
+
var _b;
|
|
14
|
+
return tslib_1.__generator(this, function (_c) {
|
|
15
|
+
switch (_c.label) {
|
|
32
16
|
case 0:
|
|
33
17
|
if (!wallet.signTransaction)
|
|
34
18
|
throw new Error('Wallet does not support sign transaction');
|
|
35
19
|
return [4 /*yield*/, wallet.signTransaction(tx)];
|
|
36
20
|
case 1:
|
|
37
|
-
signedTx =
|
|
21
|
+
signedTx = _c.sent();
|
|
38
22
|
serializedTx = signedTx.serialize();
|
|
23
|
+
return [4 /*yield*/, connection.simulateTransaction(signedTx)];
|
|
24
|
+
case 2:
|
|
25
|
+
simulation = (_c.sent()).value;
|
|
26
|
+
console.log('simulation logs:');
|
|
27
|
+
for (_i = 0, _a = (_b = simulation.logs) !== null && _b !== void 0 ? _b : []; _i < _a.length; _i++) {
|
|
28
|
+
log = _a[_i];
|
|
29
|
+
console.log(log);
|
|
30
|
+
}
|
|
39
31
|
return [4 /*yield*/, connection.sendRawTransaction(serializedTx, {
|
|
40
|
-
skipPreflight: true
|
|
32
|
+
skipPreflight: true,
|
|
41
33
|
})];
|
|
42
|
-
case
|
|
43
|
-
signature =
|
|
34
|
+
case 3:
|
|
35
|
+
signature = _c.sent();
|
|
36
|
+
console.log('signature', signature);
|
|
44
37
|
return [2 /*return*/, signature];
|
|
45
38
|
}
|
|
46
39
|
});
|
|
@@ -49,7 +42,7 @@ function useSolanaIFrameMessageHandlers(_a) {
|
|
|
49
42
|
var data = _a.data;
|
|
50
43
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
51
44
|
function getTransaction() {
|
|
52
|
-
var parsedUInt8Array = bs58_1
|
|
45
|
+
var parsedUInt8Array = bs58_1.default.decode(data);
|
|
53
46
|
var vtx = web3_js_1.VersionedTransaction.deserialize(parsedUInt8Array);
|
|
54
47
|
if (vtx.version === 'legacy')
|
|
55
48
|
return web3_js_1.Transaction.from(parsedUInt8Array);
|
|
@@ -102,7 +95,7 @@ function useSolanaIFrameMessageHandlers(_a) {
|
|
|
102
95
|
if (!wallet.signTransaction) {
|
|
103
96
|
throw new Error('signTransaction is not supported by this wallet');
|
|
104
97
|
}
|
|
105
|
-
tx = web3_js_1.Transaction.from(bs58_1
|
|
98
|
+
tx = web3_js_1.Transaction.from(bs58_1.default.decode(data));
|
|
106
99
|
partiallySign = function (signer) {
|
|
107
100
|
var requiredSignatures = tx.signatures.map(function (sig) {
|
|
108
101
|
return sig.publicKey.toString();
|
|
@@ -117,9 +110,9 @@ function useSolanaIFrameMessageHandlers(_a) {
|
|
|
117
110
|
return [4 /*yield*/, wallet.signTransaction(tx)];
|
|
118
111
|
case 1:
|
|
119
112
|
signedTransaction = _b.sent();
|
|
120
|
-
return [2 /*return*/, bs58_1
|
|
113
|
+
return [2 /*return*/, bs58_1.default.encode(signedTransaction.serialize({
|
|
121
114
|
requireAllSignatures: false,
|
|
122
|
-
verifySignatures: false
|
|
115
|
+
verifySignatures: false,
|
|
123
116
|
}))];
|
|
124
117
|
}
|
|
125
118
|
});
|
|
@@ -128,7 +121,6 @@ function useSolanaIFrameMessageHandlers(_a) {
|
|
|
128
121
|
return {
|
|
129
122
|
handleSignTransaction: handleSignTransaction,
|
|
130
123
|
handleSendTransaction: handleSendTransaction,
|
|
131
|
-
handleSignMessage: handleSignMessage
|
|
132
124
|
};
|
|
133
125
|
}
|
|
134
126
|
exports.useSolanaIFrameMessageHandlers = useSolanaIFrameMessageHandlers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/SolanaIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAClC,sDAA0B;AAC1B,2CAKyB;AAkBzB,SAAgB,8BAA8B,CAAC,EAKrB;IAL1B,
|
|
1
|
+
{"version":3,"file":"SolanaIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/SolanaIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAClC,sDAA0B;AAC1B,2CAKyB;AAkBzB,SAAgB,8BAA8B,CAAC,EAKrB;IAL1B,iBA8GC;QA7GC,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,cAAc,oBAAA,EACd,eAAe,EAAf,OAAO,mBAAG,KAAK,KAAA;IAEf,IAAM,oBAAoB,GAAG,IAAA,mBAAW,EACtC,UAAO,EAAsC;;;;;;oBAC3C,IAAI,CAAC,MAAM,CAAC,eAAe;wBACzB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;oBAE7C,qBAAM,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,EAAA;;oBAA3C,QAAQ,GAAG,SAAgC;oBAC3C,YAAY,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;oBACZ,qBAAM,UAAU,CAAC,mBAAmB,CAAC,QAAuB,CAAC,EAAA;;oBAA5E,UAAU,GAAK,CAAA,SAA6D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AG3C,aAAa,GAAG,UAAC,MAAc;4BACnC,IAAM,kBAAkB,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,UAAA,GAAG;gCAC9C,OAAA,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE;4BAAxB,CAAwB,CACzB,CAAC;4BACF,IAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAC5C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAC5B,CAAC;4BACF,IAAI,UAAU;gCAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;wBACzC,CAAC,CAAC;wBACF,IAAI,cAAc,EAAE;4BAClB,cAAc,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;yBACvC;wBAEyB,qBAAM,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,EAAA;;wBAApD,iBAAiB,GAAG,SAAgC;wBAC1D,sBAAO,cAAM,CAAC,MAAM,CAClB,iBAAiB,CAAC,SAAS,CAAC;gCAC1B,oBAAoB,EAAE,KAAK;gCAC3B,gBAAgB,EAAE,KAAK;6BACxB,CAAC,CACH,EAAC;;;;KACH,EACD,CAAC,cAAc,EAAE,MAAM,CAAC,CACzB,CAAC;IAEF,OAAO;QACL,qBAAqB,uBAAA;QACrB,qBAAqB,uBAAA;KACtB,CAAC;AACJ,CAAC;AA9GD,wEA8GC"}
|
package/build/cjs/index.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { IFrameMessageHandlers } from './SolanaIFrameMessageHandlers';
|
|
3
3
|
export type OnSuccessMethod = (params: string) => void | Promise<void>;
|
|
4
4
|
export declare function useIframeWallet({ handleSignTransaction, handleSendTransaction, handleSignMessage, }: IFrameMessageHandlers, onSuccess?: OnSuccessMethod): {
|
|
5
|
-
IFrameRef: import("react").
|
|
5
|
+
IFrameRef: import("react").MutableRefObject<HTMLIFrameElement | null>;
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useIframeWallet = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = require("react");
|
|
@@ -8,15 +8,15 @@ function useIframeWallet(_a, onSuccess) {
|
|
|
8
8
|
var handleSignTransaction = _a.handleSignTransaction, handleSendTransaction = _a.handleSendTransaction, handleSignMessage = _a.handleSignMessage;
|
|
9
9
|
var IFrameRef = (0, react_1.useRef)(null);
|
|
10
10
|
var sendIFrameMessage = (0, react_1.useCallback)(function (message) {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
12
12
|
if (!((_a = IFrameRef === null || IFrameRef === void 0 ? void 0 : IFrameRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow))
|
|
13
13
|
throw new Error('Iframe not defined');
|
|
14
|
-
IFrameRef.current.contentWindow.postMessage(message, '*');
|
|
14
|
+
(_b = IFrameRef.current) === null || _b === void 0 ? void 0 : _b.contentWindow.postMessage(message, '*');
|
|
15
15
|
}, [IFrameRef]);
|
|
16
16
|
var handleIframeMessages = (0, react_1.useCallback)(function (_a) {
|
|
17
17
|
var data = _a.data;
|
|
18
18
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
19
|
-
var parsedData, _b,
|
|
19
|
+
var parsedData, _b, signature, signedTransaction, signedMessage, e_1, message;
|
|
20
20
|
return tslib_1.__generator(this, function (_c) {
|
|
21
21
|
switch (_c.label) {
|
|
22
22
|
case 0:
|
|
@@ -26,40 +26,43 @@ function useIframeWallet(_a, onSuccess) {
|
|
|
26
26
|
return [2 /*return*/];
|
|
27
27
|
_b = parsedData.method;
|
|
28
28
|
switch (_b) {
|
|
29
|
-
case '
|
|
30
|
-
case '
|
|
31
|
-
case '
|
|
32
|
-
case '
|
|
29
|
+
case 'sendTransaction': return [3 /*break*/, 1];
|
|
30
|
+
case 'success': return [3 /*break*/, 3];
|
|
31
|
+
case 'signTransaction': return [3 /*break*/, 4];
|
|
32
|
+
case 'signMessage': return [3 /*break*/, 6];
|
|
33
33
|
}
|
|
34
34
|
return [3 /*break*/, 8];
|
|
35
|
-
case 1: return [4 /*yield*/,
|
|
35
|
+
case 1: return [4 /*yield*/, handleSendTransaction(parsedData)];
|
|
36
36
|
case 2:
|
|
37
|
-
message = _c.sent();
|
|
38
|
-
sendIFrameMessage(message);
|
|
39
|
-
return [3 /*break*/, 9];
|
|
40
|
-
case 3: return [4 /*yield*/, handleSendTransaction(parsedData)];
|
|
41
|
-
case 4:
|
|
42
37
|
signature = _c.sent();
|
|
43
38
|
sendIFrameMessage(signature);
|
|
44
39
|
return [3 /*break*/, 9];
|
|
45
|
-
case
|
|
40
|
+
case 3:
|
|
46
41
|
{
|
|
47
42
|
if (onSuccess)
|
|
48
43
|
onSuccess(data);
|
|
49
44
|
return [3 /*break*/, 9];
|
|
50
45
|
}
|
|
51
|
-
_c.label =
|
|
52
|
-
case
|
|
46
|
+
_c.label = 4;
|
|
47
|
+
case 4:
|
|
53
48
|
if (!handleSignTransaction)
|
|
54
49
|
throw new Error("This wallet does not support method ".concat(parsedData.method));
|
|
55
50
|
return [4 /*yield*/, handleSignTransaction(parsedData)];
|
|
56
|
-
case
|
|
51
|
+
case 5:
|
|
57
52
|
signedTransaction = _c.sent();
|
|
58
53
|
sendIFrameMessage(signedTransaction);
|
|
59
54
|
return [3 /*break*/, 9];
|
|
55
|
+
case 6:
|
|
56
|
+
if (!handleSignMessage)
|
|
57
|
+
throw new Error("This wallet does not support method ".concat(parsedData.method));
|
|
58
|
+
return [4 /*yield*/, handleSignMessage(parsedData)];
|
|
59
|
+
case 7:
|
|
60
|
+
signedMessage = _c.sent();
|
|
61
|
+
sendIFrameMessage(signedMessage);
|
|
62
|
+
return [3 /*break*/, 9];
|
|
60
63
|
case 8:
|
|
61
64
|
{
|
|
62
|
-
throw new Error("Unsupported Wallet Method ".concat(parsedData.method, ", must be
|
|
65
|
+
throw new Error("Unsupported Wallet Method ".concat(parsedData.method, ", must be sendTransaction"));
|
|
63
66
|
}
|
|
64
67
|
_c.label = 9;
|
|
65
68
|
case 9: return [3 /*break*/, 11];
|
|
@@ -79,11 +82,11 @@ function useIframeWallet(_a, onSuccess) {
|
|
|
79
82
|
});
|
|
80
83
|
});
|
|
81
84
|
}, [
|
|
82
|
-
handleSignMessage,
|
|
83
85
|
handleSendTransaction,
|
|
86
|
+
sendIFrameMessage,
|
|
84
87
|
onSuccess,
|
|
85
88
|
handleSignTransaction,
|
|
86
|
-
|
|
89
|
+
handleSignMessage,
|
|
87
90
|
]);
|
|
88
91
|
(0, react_1.useEffect)(function () {
|
|
89
92
|
if (!window)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../../src/useIframeWallet.ts"],"names":[],"mappings":";;;;AAAA,+BAAqD;AAKrD,SAAgB,eAAe,CAC7B,EAIwB,EACxB,SAA2B;IAN7B,
|
|
1
|
+
{"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../../src/useIframeWallet.ts"],"names":[],"mappings":";;;;AAAA,+BAAqD;AAKrD,SAAgB,eAAe,CAC7B,EAIwB,EACxB,SAA2B;IAN7B,iBAuFC;QArFG,qBAAqB,2BAAA,EACrB,qBAAqB,2BAAA,EACrB,iBAAiB,uBAAA;IAInB,IAAM,SAAS,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;IAEzD,IAAM,iBAAiB,GAAG,IAAA,mBAAW,EACnC,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;QAExC,MAAA,SAAS,CAAC,OAAO,0CAAE,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC7D,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF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AO,GAAG,GAAC,YAAY,KAAK,CAAC,CAAC,CAAC,GAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAC,CAAC,CAAC;4BACnE,iBAAiB,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;yBACvC;wBAAC,OAAO,CAAC,EAAE;4BACV,iBAAiB,CAAC,0BAA0B,CAAC,CAAC;yBAC/C;;;;;;KAEJ,EACD;QACE,qBAAqB;QACrB,iBAAiB;QACjB,SAAS;QACT,qBAAqB;QACrB,iBAAiB;KAClB,CACF,CAAC;IAEF,IAAA,iBAAS,EAAC;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;AAvFD,0CAuFC;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"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CoinflowBlockchain, CoinflowEnvs } from './CoinflowUtils';
|
|
3
|
-
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
interface CoinflowIFrameProps {
|
|
4
5
|
walletPubkey: string;
|
|
5
6
|
IFrameRef: React.RefObject<HTMLIFrameElement>;
|
|
6
|
-
env?: CoinflowEnvs;
|
|
7
7
|
route: string;
|
|
8
8
|
amount?: number;
|
|
9
9
|
transaction?: string;
|
|
10
10
|
blockchain: CoinflowBlockchain;
|
|
11
11
|
webhookInfo?: object;
|
|
12
|
-
token?: string;
|
|
12
|
+
token?: string | PublicKey;
|
|
13
13
|
email?: string;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
env?: CoinflowEnvs;
|
|
15
|
+
loaderBackground?: string;
|
|
16
|
+
supportsVersionedTransactions?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function CoinflowIFrame({ walletPubkey, IFrameRef, env, route, transaction, amount, blockchain, webhookInfo, token, email, loaderBackground, supportsVersionedTransactions }: CoinflowIFrameProps): JSX.Element;
|
|
16
19
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { CoinflowUtils } from './CoinflowUtils';
|
|
3
3
|
export function CoinflowIFrame(_a) {
|
|
4
|
-
var walletPubkey = _a.walletPubkey, IFrameRef = _a.IFrameRef, env = _a.env, route = _a.route, transaction = _a.transaction, amount = _a.amount, blockchain = _a.blockchain, webhookInfo = _a.webhookInfo, token = _a.token, email = _a.email;
|
|
4
|
+
var walletPubkey = _a.walletPubkey, IFrameRef = _a.IFrameRef, env = _a.env, route = _a.route, transaction = _a.transaction, amount = _a.amount, blockchain = _a.blockchain, webhookInfo = _a.webhookInfo, token = _a.token, email = _a.email, loaderBackground = _a.loaderBackground, supportsVersionedTransactions = _a.supportsVersionedTransactions;
|
|
5
5
|
var url = useMemo(function () {
|
|
6
6
|
return CoinflowUtils.getCoinflowUrl({
|
|
7
7
|
walletPubkey: walletPubkey,
|
|
@@ -11,20 +11,12 @@ export function CoinflowIFrame(_a) {
|
|
|
11
11
|
transaction: transaction,
|
|
12
12
|
blockchain: blockchain,
|
|
13
13
|
webhookInfo: webhookInfo,
|
|
14
|
-
token: token,
|
|
15
|
-
email: email
|
|
14
|
+
token: token === null || token === void 0 ? void 0 : token.toString(),
|
|
15
|
+
email: email,
|
|
16
|
+
loaderBackground: loaderBackground,
|
|
17
|
+
supportsVersionedTransactions: supportsVersionedTransactions
|
|
16
18
|
});
|
|
17
|
-
}, [
|
|
18
|
-
walletPubkey,
|
|
19
|
-
amount,
|
|
20
|
-
env,
|
|
21
|
-
route,
|
|
22
|
-
transaction,
|
|
23
|
-
blockchain,
|
|
24
|
-
webhookInfo,
|
|
25
|
-
token,
|
|
26
|
-
email,
|
|
27
|
-
]);
|
|
19
|
+
}, [walletPubkey, amount, env, route, transaction, blockchain, webhookInfo, token, email, loaderBackground, supportsVersionedTransactions]);
|
|
28
20
|
return useMemo(function () { return (React.createElement("iframe", { onLoad: function () {
|
|
29
21
|
if (IFrameRef.current)
|
|
30
22
|
IFrameRef.current.style.opacity = '1';
|
|
@@ -32,7 +24,7 @@ export function CoinflowIFrame(_a) {
|
|
|
32
24
|
width: '100%',
|
|
33
25
|
height: '100%',
|
|
34
26
|
opacity: 0,
|
|
35
|
-
transition: 'opacity 300ms linear'
|
|
27
|
+
transition: 'opacity 300ms linear',
|
|
36
28
|
}, title: "withdraw", frameBorder: "0", src: url })); }, [IFrameRef, url]);
|
|
37
29
|
}
|
|
38
30
|
//# 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;AACrC,OAAO,EAAmC,aAAa,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"CoinflowIFrame.js","sourceRoot":"","sources":["../../src/CoinflowIFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAmC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAkBhF,MAAM,UAAU,cAAc,CAAC,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