@coinflowlabs/react 1.2.0 → 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 +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 +5 -13
- package/build/cjs/CoinflowUtils.js +11 -5
- package/build/cjs/CoinflowUtils.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +6 -2
- 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 +4 -0
- 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 +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 +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 +5 -13
- package/build/esm/CoinflowUtils.js +10 -4
- package/build/esm/CoinflowUtils.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +6 -2
- 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 +4 -0
- 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 +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,46 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useEthIFrameMessageHandlers = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = require("react");
|
|
6
6
|
function useEthIFrameMessageHandlers(_a) {
|
|
7
7
|
var _this = this;
|
|
8
8
|
var wallet = _a.wallet;
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var handleSendTransaction = (0, react_1.useCallback)(function (_a) {
|
|
10
|
+
var data = _a.data;
|
|
11
11
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
12
|
-
var
|
|
12
|
+
var transaction, hash;
|
|
13
13
|
return tslib_1.__generator(this, function (_b) {
|
|
14
14
|
switch (_b.label) {
|
|
15
|
-
case 0:
|
|
15
|
+
case 0:
|
|
16
|
+
transaction = JSON.parse(Buffer.from(data, 'base64').toString());
|
|
17
|
+
return [4 /*yield*/, wallet.sendTransaction(transaction)];
|
|
16
18
|
case 1:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw new Error('Wallet did not sign');
|
|
20
|
-
return [2 /*return*/, signedMessage];
|
|
19
|
+
hash = (_b.sent()).hash;
|
|
20
|
+
return [2 /*return*/, hash];
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
}, [wallet]);
|
|
25
|
-
var
|
|
25
|
+
var handleSignMessage = (0, react_1.useCallback)(function (_a) {
|
|
26
26
|
var data = _a.data;
|
|
27
27
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
28
|
-
var transaction, hash;
|
|
29
28
|
return tslib_1.__generator(this, function (_b) {
|
|
30
29
|
switch (_b.label) {
|
|
31
30
|
case 0:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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()];
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
38
|
});
|
|
40
39
|
}, [wallet]);
|
|
41
40
|
return {
|
|
42
41
|
handleSendTransaction: handleSendTransaction,
|
|
43
|
-
handleSignMessage: handleSignMessage
|
|
42
|
+
handleSignMessage: handleSignMessage,
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
exports.useEthIFrameMessageHandlers = useEthIFrameMessageHandlers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/EthIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;
|
|
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');
|
|
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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|
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,iB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AAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CoinflowBlockchain, CoinflowEnvs } from './CoinflowUtils';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
4
|
interface CoinflowIFrameProps {
|
|
4
5
|
walletPubkey: string;
|
|
5
6
|
IFrameRef: React.RefObject<HTMLIFrameElement>;
|
|
@@ -8,10 +9,11 @@ interface CoinflowIFrameProps {
|
|
|
8
9
|
transaction?: string;
|
|
9
10
|
blockchain: CoinflowBlockchain;
|
|
10
11
|
webhookInfo?: object;
|
|
11
|
-
token?: string;
|
|
12
|
+
token?: string | PublicKey;
|
|
12
13
|
email?: string;
|
|
13
14
|
env?: CoinflowEnvs;
|
|
14
15
|
loaderBackground?: string;
|
|
16
|
+
supportsVersionedTransactions?: boolean;
|
|
15
17
|
}
|
|
16
|
-
export declare function CoinflowIFrame({ walletPubkey, IFrameRef, env, route, transaction, amount, blockchain, webhookInfo, token, email, loaderBackground, }: CoinflowIFrameProps): JSX.Element;
|
|
18
|
+
export declare function CoinflowIFrame({ walletPubkey, IFrameRef, env, route, transaction, amount, blockchain, webhookInfo, token, email, loaderBackground, supportsVersionedTransactions }: CoinflowIFrameProps): JSX.Element;
|
|
17
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, loaderBackground = _a.loaderBackground;
|
|
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,22 +11,12 @@ export function CoinflowIFrame(_a) {
|
|
|
11
11
|
transaction: transaction,
|
|
12
12
|
blockchain: blockchain,
|
|
13
13
|
webhookInfo: webhookInfo,
|
|
14
|
-
token: token,
|
|
14
|
+
token: token === null || token === void 0 ? void 0 : token.toString(),
|
|
15
15
|
email: email,
|
|
16
|
-
loaderBackground: loaderBackground
|
|
16
|
+
loaderBackground: loaderBackground,
|
|
17
|
+
supportsVersionedTransactions: supportsVersionedTransactions
|
|
17
18
|
});
|
|
18
|
-
}, [
|
|
19
|
-
loaderBackground,
|
|
20
|
-
walletPubkey,
|
|
21
|
-
amount,
|
|
22
|
-
env,
|
|
23
|
-
route,
|
|
24
|
-
transaction,
|
|
25
|
-
blockchain,
|
|
26
|
-
webhookInfo,
|
|
27
|
-
token,
|
|
28
|
-
email,
|
|
29
|
-
]);
|
|
19
|
+
}, [walletPubkey, amount, env, route, transaction, blockchain, webhookInfo, token, email, loaderBackground, supportsVersionedTransactions]);
|
|
30
20
|
return useMemo(function () { return (React.createElement("iframe", { onLoad: function () {
|
|
31
21
|
if (IFrameRef.current)
|
|
32
22
|
IFrameRef.current.style.opacity = '1';
|
|
@@ -34,7 +24,7 @@ export function CoinflowIFrame(_a) {
|
|
|
34
24
|
width: '100%',
|
|
35
25
|
height: '100%',
|
|
36
26
|
opacity: 0,
|
|
37
|
-
transition: 'opacity 300ms linear'
|
|
27
|
+
transition: 'opacity 300ms linear',
|
|
38
28
|
}, title: "withdraw", frameBorder: "0", src: url })); }, [IFrameRef, url]);
|
|
39
29
|
}
|
|
40
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,EAaT;QAZpB,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,GAAG,SAAA,EACH,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,KAAK,WAAA,EACL,KAAK,WAAA,EACL,gBAAgB,sBAAA,EAChB,6BAA6B,mCAAA;IAE7B,IAAM,GAAG,GAAG,OAAO,CAAC;QAClB,OAAO,aAAa,CAAC,cAAc,CAAC;YAClC,YAAY,cAAA;YACZ,MAAM,QAAA;YACN,GAAG,KAAA;YACH,KAAK,OAAA;YACL,WAAW,aAAA;YACX,UAAU,YAAA;YACV,WAAW,aAAA;YACX,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE;YACxB,KAAK,OAAA;YACL,gBAAgB,kBAAA;YAChB,6BAA6B,+BAAA;SAC9B,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,6BAA6B,CAAC,CAAC,CAAC;IAE5I,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,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Connection, Signer, Transaction } from
|
|
3
|
-
import { NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
2
|
+
import { 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,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,aAAa,
|
|
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,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,aAAa,GAId,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAkB,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,4BAA4B,EAAC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,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)
|