@meshconnect/web-link-sdk 2.1.1 → 3.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/Link.js +330 -75
- package/package.json +31 -12
- package/utils/types.d.ts +29 -0
- package/utils/version.d.ts +1 -1
- package/utils/version.js +1 -1
- package/utils/wagmiCoreConnectorsUtils.d.ts +11 -0
- package/utils/wagmiCoreConnectorsUtils.js +396 -0
- package/utils/wallet-browser-event-types.d.ts +65 -0
- package/utils/wallet-browser-event-types.js +14 -0
- package/cjs/Link.js +0 -186
- package/cjs/index.js +0 -21
- package/cjs/utils/event-types.js +0 -31
- package/cjs/utils/popup.js +0 -39
- package/cjs/utils/sdk-specs.js +0 -8
- package/cjs/utils/style.js +0 -18
- package/cjs/utils/types.js +0 -2
- package/cjs/utils/version.js +0 -4
package/Link.js
CHANGED
|
@@ -47,7 +47,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import { addPopup, iframeId, removePopup } from './utils/popup';
|
|
49
49
|
import { isLinkEventTypeKey } from './utils/event-types';
|
|
50
|
+
import { isWalletBrowserEventTypeKey } from './utils/wallet-browser-event-types';
|
|
50
51
|
import { sdkSpecs } from './utils/sdk-specs';
|
|
52
|
+
import { connectToSpecificWallet, signedMessage, sendTransactionFromSDK, switchChainFromSDK, getWagmiCoreInjectedData, sendNonNativeTransactionFromSDK, disconnectAllAccounts } from './utils/wagmiCoreConnectorsUtils';
|
|
51
53
|
var currentOptions;
|
|
52
54
|
var possibleOrigins = new Set([
|
|
53
55
|
'https://web.meshconnect.com',
|
|
@@ -68,85 +70,337 @@ function sendMessageToIframe(message) {
|
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
73
|
+
function handleLinkEvent(event) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var _a, payload, payload, payload, payload, w, h, left, top_1, injectedConnectors;
|
|
76
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
77
|
+
return __generator(this, function (_o) {
|
|
78
|
+
switch (_o.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
_a = event.data.type;
|
|
81
|
+
switch (_a) {
|
|
82
|
+
case 'brokerageAccountAccessToken': return [3 /*break*/, 1];
|
|
83
|
+
case 'delayedAuthentication': return [3 /*break*/, 2];
|
|
84
|
+
case 'transferFinished': return [3 /*break*/, 3];
|
|
85
|
+
case 'close': return [3 /*break*/, 4];
|
|
86
|
+
case 'done': return [3 /*break*/, 4];
|
|
87
|
+
case 'oauthLinkOpen': return [3 /*break*/, 5];
|
|
88
|
+
case 'loaded': return [3 /*break*/, 6];
|
|
89
|
+
}
|
|
90
|
+
return [3 /*break*/, 8];
|
|
91
|
+
case 1:
|
|
92
|
+
{
|
|
93
|
+
payload = {
|
|
94
|
+
accessToken: event.data.payload
|
|
95
|
+
};
|
|
96
|
+
(_b = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _b === void 0 ? void 0 : _b.call(currentOptions, {
|
|
97
|
+
type: 'integrationConnected',
|
|
98
|
+
payload: payload
|
|
99
|
+
});
|
|
100
|
+
(_c = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _c === void 0 ? void 0 : _c.call(currentOptions, payload);
|
|
101
|
+
return [3 /*break*/, 9];
|
|
102
|
+
}
|
|
103
|
+
_o.label = 2;
|
|
104
|
+
case 2:
|
|
105
|
+
{
|
|
106
|
+
payload = {
|
|
107
|
+
delayedAuth: event.data.payload
|
|
108
|
+
};
|
|
109
|
+
(_d = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _d === void 0 ? void 0 : _d.call(currentOptions, {
|
|
110
|
+
type: 'integrationConnected',
|
|
111
|
+
payload: payload
|
|
112
|
+
});
|
|
113
|
+
(_e = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _e === void 0 ? void 0 : _e.call(currentOptions, payload);
|
|
114
|
+
return [3 /*break*/, 9];
|
|
115
|
+
}
|
|
116
|
+
_o.label = 3;
|
|
117
|
+
case 3:
|
|
118
|
+
{
|
|
119
|
+
payload = event.data.payload;
|
|
120
|
+
(_f = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _f === void 0 ? void 0 : _f.call(currentOptions, {
|
|
121
|
+
type: 'transferCompleted',
|
|
122
|
+
payload: payload
|
|
123
|
+
});
|
|
124
|
+
(_g = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onTransferFinished) === null || _g === void 0 ? void 0 : _g.call(currentOptions, payload);
|
|
125
|
+
return [3 /*break*/, 9];
|
|
126
|
+
}
|
|
127
|
+
_o.label = 4;
|
|
128
|
+
case 4:
|
|
129
|
+
{
|
|
130
|
+
payload = (_h = event.data) === null || _h === void 0 ? void 0 : _h.payload;
|
|
131
|
+
(_j = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onExit) === null || _j === void 0 ? void 0 : _j.call(currentOptions, payload === null || payload === void 0 ? void 0 : payload.errorMessage, payload);
|
|
132
|
+
removePopup();
|
|
133
|
+
return [3 /*break*/, 9];
|
|
134
|
+
}
|
|
135
|
+
_o.label = 5;
|
|
136
|
+
case 5:
|
|
137
|
+
{
|
|
138
|
+
if (event.data.link) {
|
|
139
|
+
w = 700;
|
|
140
|
+
h = 800;
|
|
141
|
+
left = screen.width / 2 - w / 2;
|
|
142
|
+
top_1 = screen.height / 2 - h / 2;
|
|
143
|
+
(_k = window
|
|
144
|
+
.open(event.data.link, '_blank', "popup,noopener,noreferrer,resizable,scrollbars,width=".concat(w, ",height=").concat(h, ",top=").concat(top_1, ",left=").concat(left))) === null || _k === void 0 ? void 0 : _k.focus();
|
|
145
|
+
}
|
|
146
|
+
return [3 /*break*/, 9];
|
|
147
|
+
}
|
|
148
|
+
_o.label = 6;
|
|
149
|
+
case 6:
|
|
150
|
+
sendMessageToIframe({
|
|
151
|
+
type: 'meshSDKSpecs',
|
|
152
|
+
payload: __assign({}, sdkSpecs)
|
|
153
|
+
});
|
|
154
|
+
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.accessTokens) {
|
|
155
|
+
sendMessageToIframe({
|
|
156
|
+
type: 'frontAccessTokens',
|
|
157
|
+
payload: currentOptions.accessTokens
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.transferDestinationTokens) {
|
|
161
|
+
sendMessageToIframe({
|
|
162
|
+
type: 'frontTransferDestinationTokens',
|
|
163
|
+
payload: currentOptions.transferDestinationTokens
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return [4 /*yield*/, getWagmiCoreInjectedData()];
|
|
167
|
+
case 7:
|
|
168
|
+
injectedConnectors = _o.sent();
|
|
169
|
+
if (injectedConnectors) {
|
|
170
|
+
sendMessageToIframe({
|
|
171
|
+
type: 'SDKinjectedWagmiConnectorsData',
|
|
172
|
+
payload: injectedConnectors
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
(_l = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _l === void 0 ? void 0 : _l.call(currentOptions, { type: 'pageLoaded' });
|
|
176
|
+
return [3 /*break*/, 9];
|
|
177
|
+
case 8:
|
|
178
|
+
{
|
|
179
|
+
if (isLinkEventTypeKey(event.data.type)) {
|
|
180
|
+
(_m = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _m === void 0 ? void 0 : _m.call(currentOptions, event.data);
|
|
181
|
+
}
|
|
182
|
+
return [3 /*break*/, 9];
|
|
183
|
+
}
|
|
184
|
+
_o.label = 9;
|
|
185
|
+
case 9: return [2 /*return*/];
|
|
120
186
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
type
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function handleWalletBrowserEvent(event) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
+
var _a, payload, result, error_1, payload, result, error_2, payload, result, error_3, payload, result, error_4, payload, result, error_5, payload, result, error_6, payload, result, error_7;
|
|
193
|
+
return __generator(this, function (_b) {
|
|
194
|
+
switch (_b.label) {
|
|
195
|
+
case 0:
|
|
196
|
+
_a = event.data.type;
|
|
197
|
+
switch (_a) {
|
|
198
|
+
case 'walletBrowserInjectedWalletSelected': return [3 /*break*/, 1];
|
|
199
|
+
case 'walletBrowserSignRequest': return [3 /*break*/, 6];
|
|
200
|
+
case 'walletBrowserChainSwitchRequest': return [3 /*break*/, 11];
|
|
201
|
+
case 'walletBrowserNativeTransferRequest': return [3 /*break*/, 16];
|
|
202
|
+
case 'walletBrowserNonNativeTransferRequest': return [3 /*break*/, 21];
|
|
203
|
+
case 'walletBrowserNativeSmartDeposit': return [3 /*break*/, 26];
|
|
204
|
+
case 'walletBrowserNonNativeSmartDeposit': return [3 /*break*/, 31];
|
|
205
|
+
case 'walletBrowserDisconnect': return [3 /*break*/, 36];
|
|
206
|
+
}
|
|
207
|
+
return [3 /*break*/, 37];
|
|
208
|
+
case 1:
|
|
209
|
+
payload = event.data.payload;
|
|
210
|
+
_b.label = 2;
|
|
211
|
+
case 2:
|
|
212
|
+
_b.trys.push([2, 4, , 5]);
|
|
213
|
+
return [4 /*yield*/, connectToSpecificWallet(payload.integrationName)];
|
|
214
|
+
case 3:
|
|
215
|
+
result = _b.sent();
|
|
216
|
+
if (result instanceof Error) {
|
|
217
|
+
throw result;
|
|
218
|
+
}
|
|
219
|
+
sendMessageToIframe({
|
|
220
|
+
type: 'SDKinjectedConnectionCompleted',
|
|
221
|
+
payload: {
|
|
222
|
+
accounts: result.accounts,
|
|
223
|
+
chainId: result.chainId
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return [3 /*break*/, 5];
|
|
227
|
+
case 4:
|
|
228
|
+
error_1 = _b.sent();
|
|
229
|
+
handleErrorAndSendMessage(error_1, 'SDKinjectedConnectionCompleted');
|
|
230
|
+
return [3 /*break*/, 5];
|
|
231
|
+
case 5: return [3 /*break*/, 37];
|
|
232
|
+
case 6:
|
|
233
|
+
payload = event.data.payload;
|
|
234
|
+
_b.label = 7;
|
|
235
|
+
case 7:
|
|
236
|
+
_b.trys.push([7, 9, , 10]);
|
|
237
|
+
return [4 /*yield*/, signedMessage(payload.address)];
|
|
238
|
+
case 8:
|
|
239
|
+
result = _b.sent();
|
|
240
|
+
if (result instanceof Error) {
|
|
241
|
+
throw result;
|
|
242
|
+
}
|
|
243
|
+
sendMessageToIframe({
|
|
244
|
+
type: 'SDKsignRequestCompleted',
|
|
245
|
+
payload: result
|
|
246
|
+
});
|
|
247
|
+
return [3 /*break*/, 10];
|
|
248
|
+
case 9:
|
|
249
|
+
error_2 = _b.sent();
|
|
250
|
+
handleErrorAndSendMessage(error_2, 'SDKsignRequestCompleted');
|
|
251
|
+
return [3 /*break*/, 10];
|
|
252
|
+
case 10: return [3 /*break*/, 37];
|
|
253
|
+
case 11:
|
|
254
|
+
payload = event.data.payload;
|
|
255
|
+
_b.label = 12;
|
|
256
|
+
case 12:
|
|
257
|
+
_b.trys.push([12, 14, , 15]);
|
|
258
|
+
return [4 /*yield*/, switchChainFromSDK(payload.chainId)];
|
|
259
|
+
case 13:
|
|
260
|
+
result = _b.sent();
|
|
261
|
+
if (result instanceof Error) {
|
|
262
|
+
throw result;
|
|
263
|
+
}
|
|
264
|
+
sendMessageToIframe({
|
|
265
|
+
type: 'SDKswitchChainCompleted',
|
|
266
|
+
payload: result
|
|
267
|
+
});
|
|
268
|
+
return [3 /*break*/, 15];
|
|
269
|
+
case 14:
|
|
270
|
+
error_3 = _b.sent();
|
|
271
|
+
handleErrorAndSendMessage(error_3, 'SDKswitchChainCompleted');
|
|
272
|
+
return [3 /*break*/, 15];
|
|
273
|
+
case 15: return [3 /*break*/, 37];
|
|
274
|
+
case 16:
|
|
275
|
+
payload = event.data.payload;
|
|
276
|
+
_b.label = 17;
|
|
277
|
+
case 17:
|
|
278
|
+
_b.trys.push([17, 19, , 20]);
|
|
279
|
+
return [4 /*yield*/, sendTransactionFromSDK(payload.toAddress, payload.amount, payload.decimalPlaces, payload.chainId, payload.account)];
|
|
280
|
+
case 18:
|
|
281
|
+
result = _b.sent();
|
|
282
|
+
if (result instanceof Error) {
|
|
283
|
+
throw result;
|
|
284
|
+
}
|
|
285
|
+
sendMessageToIframe({
|
|
286
|
+
type: 'SDKnativeTransferCompleted',
|
|
287
|
+
payload: result
|
|
288
|
+
});
|
|
289
|
+
return [3 /*break*/, 20];
|
|
290
|
+
case 19:
|
|
291
|
+
error_4 = _b.sent();
|
|
292
|
+
handleErrorAndSendMessage(error_4, 'SDKnativeTransferCompleted');
|
|
293
|
+
return [3 /*break*/, 20];
|
|
294
|
+
case 20: return [3 /*break*/, 37];
|
|
295
|
+
case 21:
|
|
296
|
+
payload = event.data.payload;
|
|
297
|
+
_b.label = 22;
|
|
298
|
+
case 22:
|
|
299
|
+
_b.trys.push([22, 24, , 25]);
|
|
300
|
+
return [4 /*yield*/, sendNonNativeTransactionFromSDK(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args)];
|
|
301
|
+
case 23:
|
|
302
|
+
result = _b.sent();
|
|
303
|
+
if (result instanceof Error) {
|
|
304
|
+
throw result;
|
|
305
|
+
}
|
|
306
|
+
sendMessageToIframe({
|
|
307
|
+
type: 'SDKnonNativeTransferCompleted',
|
|
308
|
+
payload: result
|
|
309
|
+
});
|
|
310
|
+
return [3 /*break*/, 25];
|
|
311
|
+
case 24:
|
|
312
|
+
error_5 = _b.sent();
|
|
313
|
+
handleErrorAndSendMessage(error_5, 'SDKnonNativeTransferCompleted');
|
|
314
|
+
return [3 /*break*/, 25];
|
|
315
|
+
case 25: return [3 /*break*/, 37];
|
|
316
|
+
case 26:
|
|
317
|
+
payload = event.data.payload;
|
|
318
|
+
_b.label = 27;
|
|
319
|
+
case 27:
|
|
320
|
+
_b.trys.push([27, 29, , 30]);
|
|
321
|
+
return [4 /*yield*/, sendNonNativeTransactionFromSDK(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args, payload.value)];
|
|
322
|
+
case 28:
|
|
323
|
+
result = _b.sent();
|
|
324
|
+
if (result instanceof Error) {
|
|
325
|
+
throw result;
|
|
326
|
+
}
|
|
327
|
+
sendMessageToIframe({
|
|
328
|
+
type: 'SDKnativeSmartDepositCompleted',
|
|
329
|
+
payload: {
|
|
330
|
+
txHash: result
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
return [3 /*break*/, 30];
|
|
334
|
+
case 29:
|
|
335
|
+
error_6 = _b.sent();
|
|
336
|
+
handleErrorAndSendMessage(error_6, 'SDKnativeSmartDepositCompleted');
|
|
337
|
+
return [3 /*break*/, 30];
|
|
338
|
+
case 30: return [3 /*break*/, 37];
|
|
339
|
+
case 31:
|
|
340
|
+
payload = event.data.payload;
|
|
341
|
+
_b.label = 32;
|
|
342
|
+
case 32:
|
|
343
|
+
_b.trys.push([32, 34, , 35]);
|
|
344
|
+
return [4 /*yield*/, sendNonNativeTransactionFromSDK(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args)];
|
|
345
|
+
case 33:
|
|
346
|
+
result = _b.sent();
|
|
347
|
+
if (result) {
|
|
348
|
+
sendMessageToIframe({
|
|
349
|
+
type: 'SDKnonNativeSmartDepositCompleted',
|
|
350
|
+
payload: {
|
|
351
|
+
txHash: result
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
throw new Error('Transfer failed');
|
|
357
|
+
}
|
|
358
|
+
return [3 /*break*/, 35];
|
|
359
|
+
case 34:
|
|
360
|
+
error_7 = _b.sent();
|
|
361
|
+
handleErrorAndSendMessage(error_7, 'SDKnonNativeSmartDepositCompleted');
|
|
362
|
+
return [3 /*break*/, 35];
|
|
363
|
+
case 35: return [3 /*break*/, 37];
|
|
364
|
+
case 36:
|
|
365
|
+
{
|
|
366
|
+
disconnectAllAccounts();
|
|
367
|
+
sendMessageToIframe({
|
|
368
|
+
type: 'SDKdisconnectSuccess'
|
|
369
|
+
});
|
|
370
|
+
return [3 /*break*/, 37];
|
|
371
|
+
}
|
|
372
|
+
_b.label = 37;
|
|
373
|
+
case 37: return [2 /*return*/];
|
|
139
374
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function eventsListener(event) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
380
|
+
return __generator(this, function (_a) {
|
|
381
|
+
switch (_a.label) {
|
|
382
|
+
case 0:
|
|
383
|
+
if (!isWalletBrowserEventTypeKey(event.data.type)) return [3 /*break*/, 2];
|
|
384
|
+
return [4 /*yield*/, handleWalletBrowserEvent(event)];
|
|
385
|
+
case 1:
|
|
386
|
+
_a.sent();
|
|
387
|
+
return [3 /*break*/, 4];
|
|
388
|
+
case 2: return [4 /*yield*/, handleLinkEvent(event)];
|
|
389
|
+
case 3:
|
|
390
|
+
_a.sent();
|
|
391
|
+
_a.label = 4;
|
|
392
|
+
case 4: return [2 /*return*/];
|
|
146
393
|
}
|
|
147
|
-
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function handleErrorAndSendMessage(error, messageType) {
|
|
398
|
+
sendMessageToIframe({
|
|
399
|
+
type: messageType,
|
|
400
|
+
payload: {
|
|
401
|
+
error: error
|
|
148
402
|
}
|
|
149
|
-
}
|
|
403
|
+
});
|
|
150
404
|
}
|
|
151
405
|
export var createLink = function (options) {
|
|
152
406
|
var openLink = function (linkToken) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -174,6 +428,7 @@ export var createLink = function (options) {
|
|
|
174
428
|
removePopup();
|
|
175
429
|
window.removeEventListener('message', eventsListener);
|
|
176
430
|
(_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
431
|
+
disconnectAllAccounts();
|
|
177
432
|
};
|
|
178
433
|
return {
|
|
179
434
|
openLink: openLink,
|
package/package.json
CHANGED
|
@@ -1,43 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshconnect/web-link-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A client-side JS library for integrating with Mesh Connect",
|
|
5
|
+
"exports": "./index.js",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"repository": "https://github.com/FrontFin/mesh-web-sdk.git",
|
|
7
8
|
"homepage": "https://github.com/FrontFin/mesh-web-sdk",
|
|
8
9
|
"devDependencies": {
|
|
9
|
-
"@
|
|
10
|
-
"@typescript-eslint/parser": "^4.21.0",
|
|
10
|
+
"@types/jest": "^29.5.12",
|
|
11
11
|
"eslint": "^7.23.0",
|
|
12
12
|
"eslint-config-prettier": "^8.1.0",
|
|
13
13
|
"eslint-plugin-import": "^2.22.1",
|
|
14
14
|
"eslint-plugin-prettier": "^3.4.0",
|
|
15
|
+
"babel-jest": "^29.5.0",
|
|
16
|
+
"@babel/preset-env": "^7.20.0",
|
|
17
|
+
"@babel/preset-typescript": "^7.20.0",
|
|
18
|
+
"jest": "^29.7.0",
|
|
19
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
15
20
|
"prettier": "^2.2.1",
|
|
16
|
-
"typescript": "^4.6.4",
|
|
17
21
|
"ts-jest": "^29.1.2",
|
|
18
|
-
"
|
|
19
|
-
"@types/jest": "^29.5.12",
|
|
20
|
-
"jest-environment-jsdom": "^29.7.0"
|
|
22
|
+
"util": "^0.12.4"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {
|
|
23
|
-
"@meshconnect/node-api": "^2.0.
|
|
25
|
+
"@meshconnect/node-api": "^2.0.7",
|
|
26
|
+
"@wagmi/core": "^2.11.2",
|
|
27
|
+
"viem": "^2.x",
|
|
28
|
+
"@wagmi/connectors": "^5.0.14"
|
|
24
29
|
},
|
|
25
30
|
"jest": {
|
|
26
31
|
"preset": "ts-jest",
|
|
27
32
|
"testEnvironment": "jsdom",
|
|
33
|
+
"setupFiles": [
|
|
34
|
+
"./jest.setup.ts"
|
|
35
|
+
],
|
|
28
36
|
"testPathIgnorePatterns": [
|
|
29
37
|
"/node_modules/",
|
|
30
38
|
"/dist/"
|
|
31
39
|
],
|
|
32
40
|
"coverageDirectory": "./coverage",
|
|
33
41
|
"transform": {
|
|
34
|
-
"
|
|
42
|
+
"^.+\\.[tj]sx?$": [
|
|
43
|
+
"babel-jest",
|
|
44
|
+
{
|
|
45
|
+
"presets": [
|
|
46
|
+
"@babel/preset-env",
|
|
47
|
+
"@babel/preset-typescript"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
35
51
|
},
|
|
52
|
+
"transformIgnorePatterns": [
|
|
53
|
+
"/node_modules/(?!(@wagmi/core|@wagmi/connectors)).+\\.js$"
|
|
54
|
+
],
|
|
36
55
|
"testEnvironmentOptions": {
|
|
37
56
|
"url": "http://localhost/"
|
|
38
57
|
}
|
|
39
58
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"types": "index.d.ts"
|
|
59
|
+
"module": "./index.js",
|
|
60
|
+
"main": "./index.js",
|
|
61
|
+
"types": "./index.d.ts"
|
|
43
62
|
}
|
package/utils/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BrokerType } from '@meshconnect/node-api';
|
|
2
2
|
import { SessionSymmary, LinkEventType } from './event-types';
|
|
3
|
+
import { Hash, Chain } from 'viem';
|
|
3
4
|
export type EventType = 'brokerageAccountAccessToken' | 'delayedAuthentication' | 'loaded' | 'oauthLinkOpen' | 'transferFinished';
|
|
4
5
|
export interface Link {
|
|
5
6
|
/**
|
|
@@ -62,6 +63,34 @@ export interface IntegrationAccessToken {
|
|
|
62
63
|
brokerType: BrokerType;
|
|
63
64
|
brokerName: string;
|
|
64
65
|
}
|
|
66
|
+
export interface WagmiInjectedConnectorData {
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
type: string;
|
|
70
|
+
icon?: string;
|
|
71
|
+
uid: string;
|
|
72
|
+
}
|
|
73
|
+
export interface WalletConnectSignedTxHash {
|
|
74
|
+
txSigned: Hash;
|
|
75
|
+
}
|
|
76
|
+
export interface IncomingConfig {
|
|
77
|
+
chains: Chain[];
|
|
78
|
+
transports: Record<number, string | string[]>;
|
|
79
|
+
}
|
|
80
|
+
export interface AbiItem {
|
|
81
|
+
name: string;
|
|
82
|
+
type: string;
|
|
83
|
+
inputs: {
|
|
84
|
+
name: string;
|
|
85
|
+
type: string;
|
|
86
|
+
}[];
|
|
87
|
+
outputs?: {
|
|
88
|
+
name: string;
|
|
89
|
+
type: string;
|
|
90
|
+
}[];
|
|
91
|
+
stateMutability?: string;
|
|
92
|
+
}
|
|
93
|
+
export type Abi = AbiItem[];
|
|
65
94
|
export interface LinkOptions {
|
|
66
95
|
/**
|
|
67
96
|
* Client ID that can be obtained at https://dashboard.meshconnect.com/company/keys
|
package/utils/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sdkVersion = "
|
|
1
|
+
export declare const sdkVersion = "3.0.0";
|
package/utils/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var sdkVersion = '
|
|
1
|
+
export var sdkVersion = '3.0.0';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type GetBalanceReturnType, type ConnectReturnType } from '@wagmi/core';
|
|
2
|
+
import { WagmiInjectedConnectorData, Abi } from './types';
|
|
3
|
+
import { Hash, Chain } from 'viem';
|
|
4
|
+
export declare const getWagmiCoreInjectedData: () => Promise<WagmiInjectedConnectorData[] | Error>;
|
|
5
|
+
export declare const connectToSpecificWallet: (walletName: string) => Promise<ConnectReturnType | Error>;
|
|
6
|
+
export declare const signedMessage: (address: `0x${string}`) => Promise<Hash | Error>;
|
|
7
|
+
export declare const walletBalance: (account: string, chainId: number) => Promise<GetBalanceReturnType | Error>;
|
|
8
|
+
export declare const switchChainFromSDK: (chainId: number) => Promise<Chain | Error>;
|
|
9
|
+
export declare const sendTransactionFromSDK: (toAddress: string, amount: number, decimalPlaces: number, chainId: number, account: string) => Promise<Hash | Error>;
|
|
10
|
+
export declare const sendNonNativeTransactionFromSDK: (address: string, abi: Abi, functionName: string, args: any[], value?: bigint) => Promise<Hash | Error>;
|
|
11
|
+
export declare const disconnectAllAccounts: () => Promise<void | Error>;
|