@coinflowlabs/react 0.3.0 → 1.0.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 +4 -0
- package/build/cjs/CoinflowIFrame.d.ts +5 -5
- package/build/cjs/CoinflowIFrame.js +5 -4
- package/build/cjs/CoinflowIFrame.js.map +1 -1
- package/build/cjs/CoinflowPurchase.d.ts +21 -6
- package/build/cjs/CoinflowPurchase.js +35 -9
- package/build/cjs/CoinflowPurchase.js.map +1 -1
- package/build/cjs/CoinflowPurchaseHistory.d.ts +2 -2
- package/build/cjs/CoinflowPurchaseHistory.js +30 -5
- package/build/cjs/CoinflowPurchaseHistory.js.map +1 -1
- package/build/cjs/CoinflowUtils.d.ts +41 -6
- package/build/cjs/CoinflowUtils.js +41 -79
- package/build/cjs/CoinflowUtils.js.map +1 -1
- package/build/cjs/CoinflowWithdraw.d.ts +15 -7
- package/build/cjs/CoinflowWithdraw.js +30 -5
- package/build/cjs/CoinflowWithdraw.js.map +1 -1
- package/build/cjs/CoinflowWithdrawHistory.d.ts +14 -6
- package/build/cjs/CoinflowWithdrawHistory.js +30 -5
- package/build/cjs/CoinflowWithdrawHistory.js.map +1 -1
- package/build/cjs/NearIFrameMessageHandlers.d.ts +5 -0
- package/build/cjs/NearIFrameMessageHandlers.js +54 -0
- package/build/cjs/NearIFrameMessageHandlers.js.map +1 -0
- package/build/cjs/SolanaIFrameMessageHandlers.d.ts +18 -0
- package/build/cjs/{IFrameWalletConnector.js → SolanaIFrameMessageHandlers.js} +23 -108
- package/build/cjs/SolanaIFrameMessageHandlers.js.map +1 -0
- package/build/cjs/index.d.ts +0 -1
- package/build/cjs/index.js +0 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/useIframeWallet.d.ts +3 -11
- package/build/cjs/useIframeWallet.js +83 -11
- package/build/cjs/useIframeWallet.js.map +1 -1
- package/build/esm/CoinflowIFrame.d.ts +5 -5
- package/build/esm/CoinflowIFrame.js +6 -5
- package/build/esm/CoinflowIFrame.js.map +1 -1
- package/build/esm/CoinflowPurchase.d.ts +21 -6
- package/build/esm/CoinflowPurchase.js +35 -8
- package/build/esm/CoinflowPurchase.js.map +1 -1
- package/build/esm/CoinflowPurchaseHistory.d.ts +2 -2
- package/build/esm/CoinflowPurchaseHistory.js +30 -4
- package/build/esm/CoinflowPurchaseHistory.js.map +1 -1
- package/build/esm/CoinflowUtils.d.ts +41 -6
- package/build/esm/CoinflowUtils.js +41 -79
- package/build/esm/CoinflowUtils.js.map +1 -1
- package/build/esm/CoinflowWithdraw.d.ts +15 -7
- package/build/esm/CoinflowWithdraw.js +30 -4
- package/build/esm/CoinflowWithdraw.js.map +1 -1
- package/build/esm/CoinflowWithdrawHistory.d.ts +14 -6
- package/build/esm/CoinflowWithdrawHistory.js +30 -4
- package/build/esm/CoinflowWithdrawHistory.js.map +1 -1
- package/build/esm/NearIFrameMessageHandlers.d.ts +5 -0
- package/build/esm/NearIFrameMessageHandlers.js +50 -0
- package/build/esm/NearIFrameMessageHandlers.js.map +1 -0
- package/build/esm/SolanaIFrameMessageHandlers.d.ts +18 -0
- package/build/esm/{IFrameWalletConnector.js → SolanaIFrameMessageHandlers.js} +21 -106
- package/build/esm/SolanaIFrameMessageHandlers.js.map +1 -0
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.js +0 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/useIframeWallet.d.ts +3 -11
- package/build/esm/useIframeWallet.js +83 -11
- package/build/esm/useIframeWallet.js.map +1 -1
- package/package.json +2 -2
- package/build/cjs/IFrameWalletConnector.d.ts +0 -21
- package/build/cjs/IFrameWalletConnector.js.map +0 -1
- package/build/esm/IFrameWalletConnector.d.ts +0 -21
- package/build/esm/IFrameWalletConnector.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowWithdrawHistory.js","sourceRoot":"","sources":["../../src/CoinflowWithdrawHistory.tsx"],"names":[],"mappings":";;;;
|
|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AI,IAAA,iCAAe,EAAC,QAAQ,CAAC,UAA7B,CAA8B;IAE9C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;IAEtC,OAAO,CACL,iCAAC,+BAAc,IACb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,4BAAqB,UAAU,CAAE,EACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,GAClB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.useNearIFrameMessageHandlers = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
function useNearIFrameMessageHandlers(_a) {
|
|
7
|
+
var _this = this;
|
|
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
|
+
var handleSendTransaction = (0, react_1.useCallback)(function (_a) {
|
|
30
|
+
var data = _a.data;
|
|
31
|
+
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
32
|
+
var action, executionOutcome, transactionResult;
|
|
33
|
+
return tslib_1.__generator(this, function (_b) {
|
|
34
|
+
switch (_b.label) {
|
|
35
|
+
case 0:
|
|
36
|
+
action = JSON.parse(Buffer.from(data, 'base64').toString());
|
|
37
|
+
return [4 /*yield*/, wallet.signAndSendTransaction(action)];
|
|
38
|
+
case 1:
|
|
39
|
+
executionOutcome = _b.sent();
|
|
40
|
+
if (!executionOutcome)
|
|
41
|
+
throw new Error('Transaction did not send');
|
|
42
|
+
transactionResult = executionOutcome.transaction;
|
|
43
|
+
return [2 /*return*/, transactionResult.hash];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}, [wallet]);
|
|
48
|
+
return {
|
|
49
|
+
handleSendTransaction: handleSendTransaction,
|
|
50
|
+
handleSignMessage: handleSignMessage
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.useNearIFrameMessageHandlers = useNearIFrameMessageHandlers;
|
|
54
|
+
//# sourceMappingURL=NearIFrameMessageHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NearIFrameMessageHandlers.js","sourceRoot":"","sources":["../../src/NearIFrameMessageHandlers.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAIlC,SAAgB,4BAA4B,CAAC,EAI5C;IAJD,iBAgCC;QA/BC,MAAM,YAAA;IAIN,IAAM,iBAAiB,GAAG,IAAA,mBAAW,EACnC,UAAO,EAAkB;YAAjB,IAAI,UAAA;;;;;;wBACJ,OAAO,GAAG,IAAI,CAAC;wBACP,qBAAM,MAAM,CAAC,WAAW,CAAC;gCACrC,OAAO,SAAA;6BACR,CAAC,EAAA;;wBAFI,KAAK,GAAG,SAEZ;wBACF,IAAI,CAAC,KAAK;4BAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;wBACnD,sBAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAC;;;;KAC9B,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,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;QACrB,iBAAiB,mBAAA;KAClB,CAAC;AACJ,CAAC;AAhCD,oEAgCC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Connection, Signer } from '@solana/web3.js';
|
|
2
|
+
import { SolanaWalletContextState } from './CoinflowUtils';
|
|
3
|
+
export type WalletCall = {
|
|
4
|
+
method: string;
|
|
5
|
+
data: string;
|
|
6
|
+
};
|
|
7
|
+
export type SolanaIFrameWalletProps = {
|
|
8
|
+
wallet: SolanaWalletContextState;
|
|
9
|
+
connection: Connection;
|
|
10
|
+
partialSigners?: Signer[];
|
|
11
|
+
debugTx?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type IFrameMessageHandlers = {
|
|
14
|
+
handleSignTransaction?: ({ data }: WalletCall) => Promise<string>;
|
|
15
|
+
handleSendTransaction: ({ data }: WalletCall) => Promise<string>;
|
|
16
|
+
handleSignMessage: ({ data }: WalletCall) => Promise<string>;
|
|
17
|
+
};
|
|
18
|
+
export declare function useSolanaIFrameMessageHandlers({ wallet, connection, partialSigners, debugTx, }: SolanaIFrameWalletProps): IFrameMessageHandlers;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.
|
|
3
|
+
exports.useSolanaIFrameMessageHandlers = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = require("react");
|
|
6
6
|
var bs58_1 = tslib_1.__importDefault(require("bs58"));
|
|
7
7
|
var web3_js_1 = require("@solana/web3.js");
|
|
8
|
-
function
|
|
8
|
+
function useSolanaIFrameMessageHandlers(_a) {
|
|
9
9
|
var _this = this;
|
|
10
|
-
var wallet = _a.wallet, connection = _a.connection,
|
|
10
|
+
var wallet = _a.wallet, connection = _a.connection, partialSigners = _a.partialSigners, _b = _a.debugTx, debugTx = _b === void 0 ? false : _b;
|
|
11
11
|
var handleSignMessage = (0, react_1.useCallback)(function (_a) {
|
|
12
12
|
var data = _a.data;
|
|
13
13
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -16,16 +16,15 @@ function useHandleIFrameMessages(_a) {
|
|
|
16
16
|
switch (_b.label) {
|
|
17
17
|
case 0:
|
|
18
18
|
if (!wallet.signMessage)
|
|
19
|
-
|
|
19
|
+
throw new Error('Wallet does not support message signing'); // TODO see if this is correct
|
|
20
20
|
return [4 /*yield*/, wallet.signMessage(bs58_1["default"].decode(data))];
|
|
21
21
|
case 1:
|
|
22
22
|
signature = _b.sent();
|
|
23
|
-
|
|
24
|
-
return [2 /*return*/];
|
|
23
|
+
return [2 /*return*/, bs58_1["default"].encode(signature)];
|
|
25
24
|
}
|
|
26
25
|
});
|
|
27
26
|
});
|
|
28
|
-
}, [
|
|
27
|
+
}, [wallet]);
|
|
29
28
|
var sendTransactionDebug = (0, react_1.useCallback)(function (tx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
30
29
|
var signedTx, serializedTx, signature;
|
|
31
30
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -42,11 +41,10 @@ function useHandleIFrameMessages(_a) {
|
|
|
42
41
|
})];
|
|
43
42
|
case 2:
|
|
44
43
|
signature = _a.sent();
|
|
45
|
-
|
|
46
|
-
return [2 /*return*/];
|
|
44
|
+
return [2 /*return*/, signature];
|
|
47
45
|
}
|
|
48
46
|
});
|
|
49
|
-
}); }, [connection,
|
|
47
|
+
}); }, [connection, wallet]);
|
|
50
48
|
var handleSendTransaction = (0, react_1.useCallback)(function (_a) {
|
|
51
49
|
var data = _a.data;
|
|
52
50
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -85,25 +83,15 @@ function useHandleIFrameMessages(_a) {
|
|
|
85
83
|
}
|
|
86
84
|
if (!debugTx) return [3 /*break*/, 2];
|
|
87
85
|
return [4 /*yield*/, sendTransactionDebug(tx)];
|
|
88
|
-
case 1:
|
|
89
|
-
_b.sent();
|
|
90
|
-
return [2 /*return*/];
|
|
86
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
91
87
|
case 2: return [4 /*yield*/, wallet.sendTransaction(tx, connection)];
|
|
92
88
|
case 3:
|
|
93
89
|
signature = _b.sent();
|
|
94
|
-
|
|
95
|
-
return [2 /*return*/];
|
|
90
|
+
return [2 /*return*/, signature];
|
|
96
91
|
}
|
|
97
92
|
});
|
|
98
93
|
});
|
|
99
|
-
}, [
|
|
100
|
-
connection,
|
|
101
|
-
debugTx,
|
|
102
|
-
partialSigners,
|
|
103
|
-
sendIFrameMessage,
|
|
104
|
-
sendTransactionDebug,
|
|
105
|
-
wallet,
|
|
106
|
-
]);
|
|
94
|
+
}, [connection, debugTx, partialSigners, sendTransactionDebug, wallet]);
|
|
107
95
|
var handleSignTransaction = (0, react_1.useCallback)(function (_a) {
|
|
108
96
|
var data = _a.data;
|
|
109
97
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -129,92 +117,19 @@ function useHandleIFrameMessages(_a) {
|
|
|
129
117
|
return [4 /*yield*/, wallet.signTransaction(tx)];
|
|
130
118
|
case 1:
|
|
131
119
|
signedTransaction = _b.sent();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return [2 /*return*/];
|
|
120
|
+
return [2 /*return*/, bs58_1["default"].encode(signedTransaction.serialize({
|
|
121
|
+
requireAllSignatures: false,
|
|
122
|
+
verifySignatures: false
|
|
123
|
+
}))];
|
|
137
124
|
}
|
|
138
125
|
});
|
|
139
126
|
});
|
|
140
|
-
}, [partialSigners,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
switch (_c.label) {
|
|
147
|
-
case 0:
|
|
148
|
-
_c.trys.push([0, 10, , 11]);
|
|
149
|
-
if (!wallet)
|
|
150
|
-
return [2 /*return*/];
|
|
151
|
-
parsedData = parseJSON(data);
|
|
152
|
-
if (!parsedData)
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
_b = parsedData.method;
|
|
155
|
-
switch (_b) {
|
|
156
|
-
case 'signMessage': return [3 /*break*/, 1];
|
|
157
|
-
case 'sendTransaction': return [3 /*break*/, 3];
|
|
158
|
-
case 'success': return [3 /*break*/, 5];
|
|
159
|
-
case 'signTransaction': return [3 /*break*/, 6];
|
|
160
|
-
}
|
|
161
|
-
return [3 /*break*/, 8];
|
|
162
|
-
case 1: return [4 /*yield*/, handleSignMessage(parsedData)];
|
|
163
|
-
case 2:
|
|
164
|
-
_c.sent();
|
|
165
|
-
return [3 /*break*/, 9];
|
|
166
|
-
case 3: return [4 /*yield*/, handleSendTransaction(parsedData)];
|
|
167
|
-
case 4:
|
|
168
|
-
_c.sent();
|
|
169
|
-
return [3 /*break*/, 9];
|
|
170
|
-
case 5:
|
|
171
|
-
{
|
|
172
|
-
if (onSuccess)
|
|
173
|
-
onSuccess(data);
|
|
174
|
-
return [3 /*break*/, 9];
|
|
175
|
-
}
|
|
176
|
-
_c.label = 6;
|
|
177
|
-
case 6: return [4 /*yield*/, handleSignTransaction(parsedData)];
|
|
178
|
-
case 7:
|
|
179
|
-
_c.sent();
|
|
180
|
-
return [3 /*break*/, 9];
|
|
181
|
-
case 8:
|
|
182
|
-
{
|
|
183
|
-
throw new Error("Unsupported Wallet Method ".concat(parsedData.method, ", must be signMessage or signTransaction"));
|
|
184
|
-
}
|
|
185
|
-
_c.label = 9;
|
|
186
|
-
case 9: return [3 /*break*/, 11];
|
|
187
|
-
case 10:
|
|
188
|
-
e_1 = _c.sent();
|
|
189
|
-
console.error('handleIframeMessages', e_1);
|
|
190
|
-
sendIFrameMessage('ERROR');
|
|
191
|
-
return [3 /*break*/, 11];
|
|
192
|
-
case 11: return [2 /*return*/];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
}, [
|
|
197
|
-
wallet,
|
|
198
|
-
handleSignMessage,
|
|
199
|
-
handleSendTransaction,
|
|
200
|
-
onSuccess,
|
|
201
|
-
handleSignTransaction,
|
|
202
|
-
sendIFrameMessage,
|
|
203
|
-
]);
|
|
204
|
-
return { handleIframeMessages: handleIframeMessages };
|
|
205
|
-
}
|
|
206
|
-
exports.useHandleIFrameMessages = useHandleIFrameMessages;
|
|
207
|
-
function parseJSON(data) {
|
|
208
|
-
try {
|
|
209
|
-
var res = JSON.parse(data);
|
|
210
|
-
if (!res.method)
|
|
211
|
-
return null;
|
|
212
|
-
if (!res.data)
|
|
213
|
-
return null;
|
|
214
|
-
return res;
|
|
215
|
-
}
|
|
216
|
-
catch (e) {
|
|
217
|
-
return null;
|
|
218
|
-
}
|
|
127
|
+
}, [partialSigners, wallet]);
|
|
128
|
+
return {
|
|
129
|
+
handleSignTransaction: handleSignTransaction,
|
|
130
|
+
handleSendTransaction: handleSendTransaction,
|
|
131
|
+
handleSignMessage: handleSignMessage
|
|
132
|
+
};
|
|
219
133
|
}
|
|
220
|
-
|
|
134
|
+
exports.useSolanaIFrameMessageHandlers = useSolanaIFrameMessageHandlers;
|
|
135
|
+
//# sourceMappingURL=SolanaIFrameMessageHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AAiB,GAAG,SAAgC;wBAC1D,sBAAO,iBAAM,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;QACrB,iBAAiB,mBAAA;KAClB,CAAC;AACJ,CAAC;AApHD,wEAoHC"}
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './CoinflowWithdraw';
|
|
2
2
|
export * from './CoinflowPurchase';
|
|
3
3
|
export * from './CoinflowUtils';
|
|
4
|
-
export * from './IFrameWalletConnector';
|
|
5
4
|
export * from './useIframeWallet';
|
|
6
5
|
export * from './CoinflowIFrame';
|
|
7
6
|
export * from './CoinflowPurchaseHistory';
|
package/build/cjs/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./CoinflowWithdraw"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./CoinflowPurchase"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./CoinflowUtils"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./IFrameWalletConnector"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./useIframeWallet"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./CoinflowIFrame"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./CoinflowPurchaseHistory"), exports);
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,6DAAmC;AACnC,0DAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,6DAAmC;AACnC,0DAAgC;AAChC,4DAAkC;AAClC,2DAAiC;AACjC,oEAA0C;AAC1C,oEAA0C"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
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): {
|
|
2
|
+
import { IFrameMessageHandlers } from './SolanaIFrameMessageHandlers';
|
|
3
|
+
export type OnSuccessMethod = (params: string) => void | Promise<void>;
|
|
4
|
+
export declare function useIframeWallet({ handleSignTransaction, handleSendTransaction, handleSignMessage, }: IFrameMessageHandlers, onSuccess?: OnSuccessMethod): {
|
|
13
5
|
IFrameRef: import("react").RefObject<HTMLIFrameElement>;
|
|
14
6
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.useIframeWallet = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
4
5
|
var react_1 = require("react");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
6
|
+
function useIframeWallet(_a, onSuccess) {
|
|
7
|
+
var _this = this;
|
|
8
|
+
var handleSignTransaction = _a.handleSignTransaction, handleSendTransaction = _a.handleSendTransaction, handleSignMessage = _a.handleSignMessage;
|
|
8
9
|
var IFrameRef = (0, react_1.useRef)(null);
|
|
9
10
|
var sendIFrameMessage = (0, react_1.useCallback)(function (message) {
|
|
10
11
|
var _a;
|
|
@@ -12,14 +13,72 @@ function useIframeWallet(_a) {
|
|
|
12
13
|
throw new Error('Iframe not defined');
|
|
13
14
|
IFrameRef.current.contentWindow.postMessage(message, '*');
|
|
14
15
|
}, [IFrameRef]);
|
|
15
|
-
var handleIframeMessages = (0,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
var handleIframeMessages = (0, react_1.useCallback)(function (_a) {
|
|
17
|
+
var data = _a.data;
|
|
18
|
+
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
19
|
+
var parsedData, _b, message, signature, signedTransaction, e_1;
|
|
20
|
+
return tslib_1.__generator(this, function (_c) {
|
|
21
|
+
switch (_c.label) {
|
|
22
|
+
case 0:
|
|
23
|
+
_c.trys.push([0, 10, , 11]);
|
|
24
|
+
parsedData = parseJSON(data);
|
|
25
|
+
if (!parsedData)
|
|
26
|
+
return [2 /*return*/];
|
|
27
|
+
_b = parsedData.method;
|
|
28
|
+
switch (_b) {
|
|
29
|
+
case 'signMessage': return [3 /*break*/, 1];
|
|
30
|
+
case 'sendTransaction': return [3 /*break*/, 3];
|
|
31
|
+
case 'success': return [3 /*break*/, 5];
|
|
32
|
+
case 'signTransaction': return [3 /*break*/, 6];
|
|
33
|
+
}
|
|
34
|
+
return [3 /*break*/, 8];
|
|
35
|
+
case 1: return [4 /*yield*/, handleSignMessage(parsedData)];
|
|
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
|
+
signature = _c.sent();
|
|
43
|
+
sendIFrameMessage(signature);
|
|
44
|
+
return [3 /*break*/, 9];
|
|
45
|
+
case 5:
|
|
46
|
+
{
|
|
47
|
+
if (onSuccess)
|
|
48
|
+
onSuccess(data);
|
|
49
|
+
return [3 /*break*/, 9];
|
|
50
|
+
}
|
|
51
|
+
_c.label = 6;
|
|
52
|
+
case 6:
|
|
53
|
+
if (!handleSignTransaction)
|
|
54
|
+
throw new Error("This wallet does not support method ".concat(parsedData.method));
|
|
55
|
+
return [4 /*yield*/, handleSignTransaction(parsedData)];
|
|
56
|
+
case 7:
|
|
57
|
+
signedTransaction = _c.sent();
|
|
58
|
+
sendIFrameMessage(signedTransaction);
|
|
59
|
+
return [3 /*break*/, 9];
|
|
60
|
+
case 8:
|
|
61
|
+
{
|
|
62
|
+
throw new Error("Unsupported Wallet Method ".concat(parsedData.method, ", must be signMessage or sendTransaction"));
|
|
63
|
+
}
|
|
64
|
+
_c.label = 9;
|
|
65
|
+
case 9: return [3 /*break*/, 11];
|
|
66
|
+
case 10:
|
|
67
|
+
e_1 = _c.sent();
|
|
68
|
+
console.error('handleIframeMessages', e_1);
|
|
69
|
+
sendIFrameMessage('ERROR');
|
|
70
|
+
return [3 /*break*/, 11];
|
|
71
|
+
case 11: return [2 /*return*/];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}, [
|
|
76
|
+
handleSignMessage,
|
|
77
|
+
handleSendTransaction,
|
|
78
|
+
onSuccess,
|
|
79
|
+
handleSignTransaction,
|
|
80
|
+
sendIFrameMessage,
|
|
81
|
+
]);
|
|
23
82
|
(0, react_1.useEffect)(function () {
|
|
24
83
|
if (!window)
|
|
25
84
|
throw new Error('Window not defined');
|
|
@@ -28,4 +87,17 @@ function useIframeWallet(_a) {
|
|
|
28
87
|
return { IFrameRef: IFrameRef };
|
|
29
88
|
}
|
|
30
89
|
exports.useIframeWallet = useIframeWallet;
|
|
90
|
+
function parseJSON(data) {
|
|
91
|
+
try {
|
|
92
|
+
var res = JSON.parse(data);
|
|
93
|
+
if (!res.method)
|
|
94
|
+
return null;
|
|
95
|
+
if (!res.data)
|
|
96
|
+
return null;
|
|
97
|
+
return res;
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
31
103
|
//# sourceMappingURL=useIframeWallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../../src/useIframeWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../../src/useIframeWallet.ts"],"names":[],"mappings":";;;;AAAA,+BAAqD;AAKrD,SAAgB,eAAe,CAC7B,EAIwB,EACxB,SAA2B;IAN7B,iBA4EC;QA1EG,qBAAqB,2BAAA,EACrB,qBAAqB,2BAAA,EACrB,iBAAiB,uBAAA;IAInB,IAAM,SAAS,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAElD,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;QACxC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,IAAM,oBAAoB,GAAG,IAAA,mBAAW,EACtC,UAAO,EAAsB;YAArB,IAAI,UAAA;;;;;;;wBAEJ,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;wBACjC,IAAI,CAAC,UAAU;4BAAE,sBAAO;wBAEhB,KAAA,UAAU,CAAC,MAAM,CAAA;;iCAClB,aAAa,CAAC,CAAd,wBAAa;iCAKb,iBAAiB,CAAC,CAAlB,wBAAiB;iCAKjB,SAAS,CAAC,CAAV,wBAAS;iCAIT,iBAAiB,CAAC,CAAlB,wBAAiB;;;4BAbJ,qBAAM,iBAAiB,CAAC,UAAU,CAAC,EAAA;;wBAA7C,OAAO,GAAG,SAAmC;wBACnD,iBAAiB,CAAC,OAAO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AAI,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,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { CoinflowEnvs, SubsetWalletContextState } from './CoinflowUtils';
|
|
2
|
+
import { CoinflowBlockchain, CoinflowEnvs } from './CoinflowUtils';
|
|
4
3
|
type CoinflowIFrameProps = {
|
|
5
|
-
|
|
4
|
+
walletPubkey: string;
|
|
6
5
|
IFrameRef: React.RefObject<HTMLIFrameElement>;
|
|
7
6
|
env?: CoinflowEnvs;
|
|
8
7
|
route: string;
|
|
9
8
|
amount?: number;
|
|
10
|
-
transaction?:
|
|
9
|
+
transaction?: string;
|
|
10
|
+
blockchain: CoinflowBlockchain;
|
|
11
11
|
};
|
|
12
|
-
export declare function CoinflowIFrame({
|
|
12
|
+
export declare function CoinflowIFrame({ walletPubkey, IFrameRef, env, route, transaction, amount, blockchain, }: CoinflowIFrameProps): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import { CoinflowUtils
|
|
2
|
+
import { CoinflowUtils } from './CoinflowUtils';
|
|
3
3
|
export function CoinflowIFrame(_a) {
|
|
4
|
-
var
|
|
4
|
+
var walletPubkey = _a.walletPubkey, IFrameRef = _a.IFrameRef, env = _a.env, route = _a.route, transaction = _a.transaction, amount = _a.amount, blockchain = _a.blockchain;
|
|
5
5
|
var url = useMemo(function () {
|
|
6
6
|
return CoinflowUtils.getCoinflowUrl({
|
|
7
|
-
|
|
7
|
+
walletPubkey: walletPubkey,
|
|
8
8
|
amount: amount,
|
|
9
9
|
env: env,
|
|
10
10
|
route: route,
|
|
11
|
-
transaction: transaction
|
|
11
|
+
transaction: transaction,
|
|
12
|
+
blockchain: blockchain
|
|
12
13
|
});
|
|
13
|
-
}, [amount, env,
|
|
14
|
+
}, [walletPubkey, amount, env, route, transaction, blockchain]);
|
|
14
15
|
return useMemo(function () { return (React.createElement("iframe", { onLoad: function () {
|
|
15
16
|
if (IFrameRef.current)
|
|
16
17
|
IFrameRef.current.style.opacity = '1';
|
|
@@ -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;
|
|
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;AAYhF,MAAM,UAAU,cAAc,CAAC,EAQT;QAPpB,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,GAAG,SAAA,EACH,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,MAAM,YAAA,EACN,UAAU,gBAAA;IAEV,IAAM,GAAG,GAAG,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;SACX,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IAEhE,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,16 +1,31 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Connection, Signer, Transaction } from '@solana/web3.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
wallet: SubsetWalletContextState;
|
|
3
|
+
import { CoinflowBlockchain, CoinflowEnvs, NearWallet, SolanaWalletContextState } from './CoinflowUtils';
|
|
4
|
+
import { OnSuccessMethod } from './useIframeWallet';
|
|
5
|
+
export interface CoinflowCommonPurchaseProps {
|
|
7
6
|
merchantId: string;
|
|
8
|
-
connection: Connection;
|
|
9
7
|
amount?: number;
|
|
10
8
|
env?: CoinflowEnvs;
|
|
11
9
|
onSuccess?: OnSuccessMethod;
|
|
10
|
+
blockchain: CoinflowBlockchain;
|
|
11
|
+
}
|
|
12
|
+
export interface CoinflowSolanaPurchaseProps extends CoinflowCommonPurchaseProps {
|
|
13
|
+
wallet: SolanaWalletContextState;
|
|
12
14
|
transaction?: Transaction;
|
|
13
15
|
partialSigners?: Signer[];
|
|
14
16
|
debugTx?: boolean;
|
|
17
|
+
connection: Connection;
|
|
18
|
+
blockchain: 'solana';
|
|
19
|
+
}
|
|
20
|
+
export type NearFtTransferCallAction = {
|
|
21
|
+
methodName: 'ft_transfer_call';
|
|
22
|
+
args: object;
|
|
23
|
+
gas: string;
|
|
24
|
+
deposit: string;
|
|
15
25
|
};
|
|
16
|
-
export
|
|
26
|
+
export interface CoinflowNearPurchaseProps extends CoinflowCommonPurchaseProps {
|
|
27
|
+
wallet: NearWallet;
|
|
28
|
+
blockchain: 'near';
|
|
29
|
+
action?: NearFtTransferCallAction;
|
|
30
|
+
}
|
|
31
|
+
export declare function CoinflowPurchase(props: CoinflowSolanaPurchaseProps | CoinflowNearPurchaseProps): JSX.Element;
|
|
@@ -1,17 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
2
3
|
import { CoinflowIFrame } from './CoinflowIFrame';
|
|
4
|
+
import { useSolanaIFrameMessageHandlers } from './SolanaIFrameMessageHandlers';
|
|
5
|
+
import { CoinflowUtils, } from './CoinflowUtils';
|
|
3
6
|
import { useIframeWallet } from './useIframeWallet';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
import { useNearIFrameMessageHandlers } from './NearIFrameMessageHandlers';
|
|
8
|
+
export function CoinflowPurchase(props) {
|
|
9
|
+
return CoinflowUtils.byBlockchain(props.blockchain, {
|
|
10
|
+
solana: (React.createElement(SolanaCoinflowPurchase, __assign({}, props))),
|
|
11
|
+
near: React.createElement(NearCoinflowPurchase, __assign({}, props))
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
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;
|
|
16
|
+
var handlers = useSolanaIFrameMessageHandlers({
|
|
7
17
|
wallet: wallet,
|
|
8
18
|
connection: connection,
|
|
9
|
-
onSuccess: onSuccess,
|
|
10
19
|
partialSigners: partialSigners,
|
|
11
20
|
debugTx: debugTx
|
|
12
|
-
})
|
|
13
|
-
|
|
21
|
+
});
|
|
22
|
+
var IFrameRef = useIframeWallet(handlers, onSuccess).IFrameRef;
|
|
23
|
+
var transactionStr = useMemo(function () {
|
|
24
|
+
return transaction
|
|
25
|
+
? CoinflowUtils.serializeSolanaTransaction(transaction)
|
|
26
|
+
: undefined;
|
|
27
|
+
}, [transaction]);
|
|
28
|
+
if (!wallet.publicKey)
|
|
14
29
|
return null;
|
|
15
|
-
|
|
30
|
+
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' }));
|
|
32
|
+
}
|
|
33
|
+
function NearCoinflowPurchase(_a) {
|
|
34
|
+
var merchantId = _a.merchantId, amount = _a.amount, env = _a.env, onSuccess = _a.onSuccess, wallet = _a.wallet, action = _a.action;
|
|
35
|
+
var handlers = useNearIFrameMessageHandlers({ wallet: wallet });
|
|
36
|
+
var IFrameRef = useIframeWallet(handlers, onSuccess).IFrameRef;
|
|
37
|
+
var transaction = useMemo(function () {
|
|
38
|
+
return action
|
|
39
|
+
? Buffer.from(JSON.stringify(action)).toString('base64')
|
|
40
|
+
: undefined;
|
|
41
|
+
}, [action]);
|
|
42
|
+
return (React.createElement(CoinflowIFrame, { walletPubkey: wallet.accountId, IFrameRef: IFrameRef, route: "/purchase/".concat(merchantId), env: env, amount: amount, blockchain: 'near', transaction: transaction }));
|
|
16
43
|
}
|
|
17
44
|
//# sourceMappingURL=CoinflowPurchase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../../src/CoinflowPurchase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
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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G,EACR,WAAW,EAAE,cAAc,EAC3B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,QAAQ,GACpB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,EAOF;QAN1B,UAAU,gBAAA,EACV,MAAM,YAAA,EACN,GAAG,SAAA,EACH,SAAS,eAAA,EACT,MAAM,YAAA,EACN,MAAM,YAAA;IAEN,IAAM,QAAQ,GAAG,4BAA4B,CAAC,EAAC,MAAM,QAAA,EAAC,CAAC,CAAC;IACjD,IAAA,SAAS,GAAI,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,UAAxC,CAAyC;IAEzD,IAAM,WAAW,GAAG,OAAO,CACzB;QACE,OAAA,MAAM;YACJ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACxD,CAAC,CAAC,SAAS;IAFb,CAEa,EACf,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,CACL,oBAAC,cAAc,IACb,YAAY,EAAE,MAAM,CAAC,SAAS,EAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,oBAAa,UAAU,CAAE,EAChC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,GACxB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare function CoinflowPurchaseHistory(
|
|
2
|
+
import { CoinflowNearHistoryProps, CoinflowSolanaHistoryProps } from './CoinflowWithdrawHistory';
|
|
3
|
+
export declare function CoinflowPurchaseHistory(props: CoinflowSolanaHistoryProps | CoinflowNearHistoryProps): JSX.Element;
|