@portal-hq/web 2.0.0 → 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.
@@ -13,25 +13,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.GetTransactionsOrder = exports.BackupMethods = exports.MpcStatuses = exports.MpcErrorCodes = exports.MpcError = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
16
17
  const mpc_1 = __importDefault(require("./mpc"));
17
18
  const provider_1 = __importDefault(require("./provider"));
18
19
  class Portal {
19
20
  constructor({
20
21
  // Required
21
- gatewayConfig,
22
+ rpcConfig,
22
23
  // Optional
23
- apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {
24
+ apiKey, authToken, authUrl, autoApprove = false, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {
24
25
  optimized: false,
25
26
  }, }) {
26
27
  this.ready = false;
27
28
  this.errorCallbacks = [];
28
29
  this.readyCallbacks = [];
30
+ this.sendEth = ({ chainId, to, value, }) => __awaiter(this, void 0, void 0, function* () {
31
+ return this.provider.request({
32
+ chainId,
33
+ method: 'eth_sendTransaction',
34
+ params: [
35
+ {
36
+ from: this.address,
37
+ to,
38
+ value,
39
+ },
40
+ ],
41
+ });
42
+ });
29
43
  this.apiKey = apiKey;
30
44
  this.authToken = authToken;
31
45
  this.authUrl = authUrl;
32
46
  this.autoApprove = autoApprove;
33
- this.chainId = chainId;
34
- this.gatewayConfig = gatewayConfig;
47
+ this.rpcConfig = rpcConfig;
35
48
  this.host = host;
36
49
  this.mpcHost = mpcHost;
37
50
  this.mpcVersion = mpcVersion;
@@ -144,7 +157,7 @@ class Portal {
144
157
  return this.recoverWallet(cipherText, backupMethod, backupConfigs, progress);
145
158
  });
146
159
  }
147
- ejectPrivateKey(clientBackupCipherText, backupMethod, backupConfigs, orgBackupShare) {
160
+ eject(clientBackupCipherText, backupMethod, backupConfigs, orgBackupShare) {
148
161
  return __awaiter(this, void 0, void 0, function* () {
149
162
  if (clientBackupCipherText === '') {
150
163
  throw new Error('clientBackupCipherText cannot be empty string.');
@@ -152,7 +165,7 @@ class Portal {
152
165
  if (orgBackupShare === '') {
153
166
  throw new Error('orgBackupShare cannot be empty string.');
154
167
  }
155
- const privateKey = yield this.mpc.eject({
168
+ const { SECP256K1, ED25519 } = yield this.mpc.eject({
156
169
  cipherText: clientBackupCipherText,
157
170
  backupMethod,
158
171
  backupConfigs,
@@ -161,14 +174,73 @@ class Portal {
161
174
  mpcVersion: this.mpcVersion,
162
175
  featureFlags: this.featureFlags,
163
176
  });
164
- return privateKey;
177
+ return {
178
+ SECP256K1,
179
+ ED25519,
180
+ };
181
+ });
182
+ }
183
+ getEip155Address() {
184
+ var _a, _b, _c, _d;
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ const client = yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getClient());
187
+ const eip155Address = ((_d = (_c = (_b = client === null || client === void 0 ? void 0 : client.metadata) === null || _b === void 0 ? void 0 : _b.namespaces) === null || _c === void 0 ? void 0 : _c.eip155) === null || _d === void 0 ? void 0 : _d.address) || '';
188
+ return eip155Address;
189
+ });
190
+ }
191
+ getSolanaAddress() {
192
+ var _a, _b, _c, _d;
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ const client = yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getClient());
195
+ const solAddress = ((_d = (_c = (_b = client === null || client === void 0 ? void 0 : client.metadata) === null || _b === void 0 ? void 0 : _b.namespaces) === null || _c === void 0 ? void 0 : _c.solana) === null || _d === void 0 ? void 0 : _d.address) || '';
196
+ return solAddress;
197
+ });
198
+ }
199
+ doesWalletExist(chainId) {
200
+ var _a, _b, _c, _d, _e;
201
+ return __awaiter(this, void 0, void 0, function* () {
202
+ const client = yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getClient());
203
+ if (chainId) {
204
+ const namespace = ((_b = chainId === null || chainId === void 0 ? void 0 : chainId.split(':')) === null || _b === void 0 ? void 0 : _b[0]) || '';
205
+ const namespaceInfo = (_d = (_c = client === null || client === void 0 ? void 0 : client.metadata) === null || _c === void 0 ? void 0 : _c.namespaces) === null || _d === void 0 ? void 0 : _d[namespace];
206
+ return !!namespaceInfo;
207
+ }
208
+ return ((_e = client === null || client === void 0 ? void 0 : client.wallets) === null || _e === void 0 ? void 0 : _e.length) > 0;
209
+ });
210
+ }
211
+ isWalletOnDevice(chainId) {
212
+ var _a, _b, _c, _d, _e, _f;
213
+ return __awaiter(this, void 0, void 0, function* () {
214
+ const client = yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getClient());
215
+ const sharesOnDevice = yield ((_b = this.mpc) === null || _b === void 0 ? void 0 : _b.checkSharesOnDevice());
216
+ if (chainId) {
217
+ const namespace = ((_c = chainId === null || chainId === void 0 ? void 0 : chainId.split(':')) === null || _c === void 0 ? void 0 : _c[0]) || '';
218
+ const curve = ((_f = (_e = (_d = client === null || client === void 0 ? void 0 : client.metadata) === null || _d === void 0 ? void 0 : _d.namespaces) === null || _e === void 0 ? void 0 : _e[namespace]) === null || _f === void 0 ? void 0 : _f.curve) || '';
219
+ return sharesOnDevice[curve] || false;
220
+ }
221
+ return sharesOnDevice.ED25519 && sharesOnDevice.SECP256K1;
165
222
  });
166
223
  }
167
224
  /****************************
168
225
  * Provider Methods
169
226
  ****************************/
170
- ethEstimateGas(transaction, chainId) {
227
+ request(request) {
171
228
  return __awaiter(this, void 0, void 0, function* () {
229
+ return this.provider.request(request);
230
+ });
231
+ }
232
+ /**
233
+ * Estimates the amount of gas that will be required to execute an Ethereum transaction.
234
+ *
235
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_estimateGas' instead.
236
+ *
237
+ * @param {string} chainId - The chain ID of the Ethereum network.
238
+ * @param {EthereumTransaction} transaction - The transaction object containing the necessary transaction details.
239
+ * @returns {Promise<any>} A Promise that resolves to the gas estimate.
240
+ */
241
+ ethEstimateGas(chainId, transaction) {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ console.warn('"portal.ethEstimateGas" is deprecated. Use "portal.request" instead.');
172
244
  return this.provider.request({
173
245
  chainId,
174
246
  method: 'eth_estimateGas',
@@ -176,8 +248,17 @@ class Portal {
176
248
  });
177
249
  });
178
250
  }
251
+ /**
252
+ * Gets the current gas price for the Ethereum network.
253
+ *
254
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_gasPrice' instead.
255
+ *
256
+ * @param {string} chainId - The chain ID of the Ethereum network.
257
+ * @returns {Promise<string>} A Promise that resolves to the current gas price.
258
+ */
179
259
  ethGasPrice(chainId) {
180
260
  return __awaiter(this, void 0, void 0, function* () {
261
+ console.warn('"portal.ethGasPrice" is deprecated. Use "portal.request" instead.');
181
262
  return this.provider.request({
182
263
  chainId,
183
264
  method: 'eth_gasPrice',
@@ -185,8 +266,17 @@ class Portal {
185
266
  });
186
267
  });
187
268
  }
269
+ /**
270
+ * Gets the balance of the current Ethereum address.
271
+ *
272
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_getBalance' instead.
273
+ *
274
+ * @param {string} chainId - The chain ID of the Ethereum network.
275
+ * @returns {Promise<string>} A Promise that resolves to the current balance.
276
+ */
188
277
  ethGetBalance(chainId) {
189
278
  return __awaiter(this, void 0, void 0, function* () {
279
+ console.warn('"portal.ethGetBalance" is deprecated. Use "portal.request" instead.');
190
280
  return this.provider.request({
191
281
  chainId,
192
282
  method: 'eth_getBalance',
@@ -194,8 +284,18 @@ class Portal {
194
284
  });
195
285
  });
196
286
  }
197
- ethSendTransaction(transaction, chainId) {
287
+ /**
288
+ * Sends an Ethereum transaction.
289
+ *
290
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_getTransactionCount' instead.
291
+ *
292
+ * @param {string} chainId - The chain ID of the Ethereum network.
293
+ * @param {EthereumTransaction} transaction - The transaction object containing the necessary transaction details.
294
+ * @returns {Promise<string>} A Promise that resolves to the transaction hash.
295
+ */
296
+ ethSendTransaction(chainId, transaction) {
198
297
  return __awaiter(this, void 0, void 0, function* () {
298
+ console.warn('"portal.ethSendTransaction" is deprecated. Use "portal.request" instead.');
199
299
  return this.provider.request({
200
300
  chainId,
201
301
  method: 'eth_sendTransaction',
@@ -203,17 +303,18 @@ class Portal {
203
303
  });
204
304
  });
205
305
  }
206
- ethSign(message, chainId) {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- return this.provider.request({
209
- chainId,
210
- method: 'eth_sign',
211
- params: [this.address, this.stringToHex(message)],
212
- });
213
- });
214
- }
215
- ethSignTransaction(transaction, chainId) {
306
+ /**
307
+ * Signs an Ethereum transaction.
308
+ *
309
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_signTransaction' instead.
310
+ *
311
+ * @param {string} chainId - The chain ID of the Ethereum network.
312
+ * @param {EthereumTransaction} transaction - The transaction object containing the necessary transaction details.
313
+ * @returns {Promise<string>} A Promise that resolves to the signed transaction.
314
+ */
315
+ ethSignTransaction(chainId, transaction) {
216
316
  return __awaiter(this, void 0, void 0, function* () {
317
+ console.warn('"portal.ethSignTransaction" is deprecated. Use "portal.request" instead.');
217
318
  return this.provider.request({
218
319
  chainId,
219
320
  method: 'eth_signTransaction',
@@ -221,8 +322,18 @@ class Portal {
221
322
  });
222
323
  });
223
324
  }
224
- ethSignTypedData(data, chainId) {
325
+ /**
326
+ * Signs an Ethereum message using EIP-712.
327
+ *
328
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_signTypedData' instead.
329
+ *
330
+ * @param {string} chainId - The chain ID of the Ethereum network.
331
+ * @param {TypedData} data - The typed data object to sign.
332
+ * @returns {Promise<string>} A Promise that resolves to the signed message.
333
+ */
334
+ ethSignTypedData(chainId, data) {
225
335
  return __awaiter(this, void 0, void 0, function* () {
336
+ console.warn('"portal.ethSignTypedData" is deprecated. Use "portal.request" instead.');
226
337
  return this.provider.request({
227
338
  chainId,
228
339
  method: 'eth_signTypedData',
@@ -230,8 +341,18 @@ class Portal {
230
341
  });
231
342
  });
232
343
  }
233
- ethSignTypedDataV3(data, chainId) {
344
+ /**
345
+ * Signs an Ethereum message using EIP-712 (legacy).
346
+ *
347
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_signTypedData_v3' instead.
348
+ *
349
+ * @param {string} chainId - The chain ID of the Ethereum network.
350
+ * @param {TypedData} data - The typed data object to sign.
351
+ * @returns {Promise<string>} A Promise that resolves to the signed message.
352
+ */
353
+ ethSignTypedDataV3(chainId, data) {
234
354
  return __awaiter(this, void 0, void 0, function* () {
355
+ console.warn('"portal.ethSignTypedDataV3" is deprecated. Use "portal.request" instead.');
235
356
  return this.provider.request({
236
357
  chainId,
237
358
  method: 'eth_signTypedData_v3',
@@ -239,8 +360,18 @@ class Portal {
239
360
  });
240
361
  });
241
362
  }
242
- ethSignTypedDataV4(data, chainId) {
363
+ /**
364
+ * Signs an Ethereum message using EIP-712 (v4).
365
+ *
366
+ * @deprecated This method is deprecated. Use `portal.request` with method 'eth_signTypedData_v4' instead.
367
+ *
368
+ * @param {string} chainId - The chain ID of the Ethereum network.
369
+ * @param {TypedData} data - The typed data object to sign.
370
+ * @returns {Promise<string>} A Promise that resolves to the signed message.
371
+ */
372
+ ethSignTypedDataV4(chainId, data) {
243
373
  return __awaiter(this, void 0, void 0, function* () {
374
+ console.warn('"portal.ethSignTypedDataV4" is deprecated. Use "portal.request" instead.');
244
375
  return this.provider.request({
245
376
  chainId,
246
377
  method: 'eth_signTypedData_v4',
@@ -248,8 +379,9 @@ class Portal {
248
379
  });
249
380
  });
250
381
  }
251
- personalSign(message, chainId) {
382
+ personalSign(chainId, message) {
252
383
  return __awaiter(this, void 0, void 0, function* () {
384
+ console.warn('"portal.personalSign" is deprecated. Use "portal.request" instead.');
253
385
  return (yield this.provider.request({
254
386
  chainId,
255
387
  method: 'personal_sign',
@@ -257,13 +389,89 @@ class Portal {
257
389
  }));
258
390
  });
259
391
  }
392
+ sendSol({ chainId, to, lamports, }) {
393
+ var _a;
394
+ return __awaiter(this, void 0, void 0, function* () {
395
+ // Ensure the chainId is solana.
396
+ if (!chainId.startsWith('solana:')) {
397
+ throw new Error('[Portal] Invalid chainId. Please provide a chainId that starts with "solana:"');
398
+ }
399
+ // Ensure the to address is a valid Solana address.
400
+ if (!to || typeof to !== 'string' || to.length !== 44) {
401
+ throw new Error('[Portal] Invalid "to" Solana address provided, must be 44 characters');
402
+ }
403
+ // Validate the lamports.
404
+ if (typeof lamports !== 'number' || lamports <= 0) {
405
+ throw new Error('[Portal] Invalid lamports amount, must be a positive number greater than 0');
406
+ }
407
+ // Get the most recent blockhash.
408
+ const blockhashResponse = yield this.provider.request({
409
+ chainId: chainId,
410
+ method: 'getLatestBlockhash',
411
+ params: [],
412
+ });
413
+ const blockhash = ((_a = blockhashResponse === null || blockhashResponse === void 0 ? void 0 : blockhashResponse.value) === null || _a === void 0 ? void 0 : _a.blockhash) || '';
414
+ // If we didn't get a blockhash, throw an error.
415
+ if (!blockhash) {
416
+ throw new Error('[Portal] Failed to get most recent blockhash');
417
+ }
418
+ // Get the Solana address from the client, validate the addresses.
419
+ const solanaAddress = yield this.getSolanaAddress();
420
+ if (!solanaAddress) {
421
+ throw new Error('[Portal] Failed to get Solana address');
422
+ }
423
+ // Get the Solana gateway URL.
424
+ const gatewayUrl = this.getRpcUrl(chainId);
425
+ if (!gatewayUrl) {
426
+ throw new Error('[Portal] No RPC endpoint configured for chainId');
427
+ }
428
+ // Create a new connection to the Solana network.
429
+ new web3_js_1.Connection(gatewayUrl, 'confirmed');
430
+ // The sender's public key.
431
+ const fromPublicKey = new web3_js_1.PublicKey(solanaAddress);
432
+ // The recipient's public key.
433
+ const toPublicKey = new web3_js_1.PublicKey(to);
434
+ // Create a new transaction.
435
+ const transaction = new web3_js_1.Transaction().add(web3_js_1.SystemProgram.transfer({
436
+ fromPubkey: fromPublicKey,
437
+ toPubkey: toPublicKey,
438
+ lamports,
439
+ }));
440
+ transaction.recentBlockhash = blockhash;
441
+ transaction.feePayer = fromPublicKey;
442
+ const compiledMessage = transaction.compileMessage();
443
+ // Build the transaction and its message.
444
+ const message = {
445
+ accountKeys: compiledMessage.accountKeys.map((key) => key.toBase58()),
446
+ header: compiledMessage.header,
447
+ instructions: compiledMessage.instructions,
448
+ recentBlockhash: blockhash,
449
+ };
450
+ const formattedTransaction = {
451
+ signatures: null,
452
+ message,
453
+ };
454
+ // Attempt to sign and send the transaction
455
+ const transactionResult = yield this.provider.request({
456
+ chainId: chainId,
457
+ method: 'sol_signAndSendTransaction',
458
+ params: [formattedTransaction],
459
+ });
460
+ // If we didn't get a transactionResult, throw an error.
461
+ if (!transactionResult) {
462
+ throw new Error('[Portal] Failed to send Solana transaction');
463
+ }
464
+ // Return the transactionResult.
465
+ return transactionResult;
466
+ });
467
+ }
260
468
  /*******************************
261
469
  * API Methods
262
470
  *******************************/
263
- getBalances() {
471
+ getBalances(chainId) {
264
472
  var _a;
265
473
  return __awaiter(this, void 0, void 0, function* () {
266
- return yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getBalances());
474
+ return yield ((_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getBalances(chainId));
267
475
  });
268
476
  }
269
477
  getClient() {
@@ -272,34 +480,22 @@ class Portal {
272
480
  return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getClient();
273
481
  });
274
482
  }
275
- getNFTs() {
276
- var _a;
277
- return __awaiter(this, void 0, void 0, function* () {
278
- return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getNFTs();
279
- });
280
- }
281
- getBackupShareMetadata() {
282
- var _a;
283
- return __awaiter(this, void 0, void 0, function* () {
284
- return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getBackupShareMetadata();
285
- });
286
- }
287
- getSigningShareMetadata() {
483
+ getNFTs(chainId) {
288
484
  var _a;
289
485
  return __awaiter(this, void 0, void 0, function* () {
290
- return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getSigningShareMetadata();
486
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getNFTs(chainId);
291
487
  });
292
488
  }
293
- getTransactions(limit, offset, order, chainId) {
489
+ getTransactions(chainId, limit, offset, order) {
294
490
  var _a;
295
491
  return __awaiter(this, void 0, void 0, function* () {
296
- return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getTransactions(limit, offset, order, chainId);
492
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.getTransactions(chainId, limit, offset, order);
297
493
  });
298
494
  }
299
- simulateTransaction(transaction) {
495
+ simulateTransaction(chainId, transaction) {
300
496
  var _a;
301
497
  return __awaiter(this, void 0, void 0, function* () {
302
- return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.simulateTransaction(transaction);
498
+ return (_a = this.mpc) === null || _a === void 0 ? void 0 : _a.simulateTransaction(transaction, chainId);
303
499
  });
304
500
  }
305
501
  /*******************************
@@ -329,24 +525,24 @@ class Portal {
329
525
  /****************************
330
526
  * RPC Methods
331
527
  ****************************/
332
- getRpcUrl() {
333
- if (typeof this.gatewayConfig === 'string') {
334
- // If the gatewayConfig is just a static URL, return that
335
- return this.gatewayConfig;
528
+ getRpcUrl(chainId) {
529
+ // Ensure a chainId is provided.
530
+ if (!chainId) {
531
+ throw new Error('[Portal] No chainId provided. Please provide a chainId to get the RPC endpoint');
336
532
  }
337
- else if (typeof this.gatewayConfig === 'object' &&
338
- // eslint-disable-next-line no-prototype-builtins
339
- !this.gatewayConfig.hasOwnProperty(this.chainId)) {
340
- // If there's no explicit mapping for the current chainId, error out
341
- throw new Error(`[PortalProvider] No RPC endpoint configured for chainId: ${this.chainId}`);
533
+ // Ensure the chainId is configured in the rpcConfig.
534
+ // eslint-disable-next-line no-prototype-builtins
535
+ if (!this.rpcConfig.hasOwnProperty(chainId)) {
536
+ throw new Error(`[Portal] No RPC endpoint configured for chainId: ${chainId}`);
342
537
  }
343
- // Get the entry for the current chainId from the gatewayConfig
344
- const config = this.gatewayConfig[this.chainId];
345
- if (typeof config === 'string') {
346
- return config;
538
+ // Derive the RPC endpoint from the rpcConfig.
539
+ const gatewayUrl = this.rpcConfig[chainId];
540
+ // If the RPC endpoint is a string, return it as-is.
541
+ if (typeof gatewayUrl === 'string') {
542
+ return gatewayUrl;
347
543
  }
348
- // If we got this far, there's no way to support the chain with the current config
349
- throw new Error(`[PortalProvider] Could not find a valid gatewayConfig entry for chainId: ${this.chainId}`);
544
+ // Otherwise, something is wrong with the configuration.
545
+ throw new Error(`[Portal] Could not find a valid rpcConfig entry for chainId: ${chainId}`);
350
546
  }
351
547
  /**************************
352
548
  * RPC Encoding Methods
@@ -62,7 +62,7 @@ class MpcError extends Error {
62
62
  // Init the actual error
63
63
  super(error.message(context));
64
64
  // Custom error context
65
- this.code = error.code;
65
+ this.code = (error === null || error === void 0 ? void 0 : error.code) || 999;
66
66
  if (context) {
67
67
  this.context = context;
68
68
  }
@@ -140,7 +140,7 @@ exports.PortalErrorCodeTypes = {
140
140
  class PortalMpcError extends Error {
141
141
  constructor(error) {
142
142
  super(error.message);
143
- this.code = error.code;
143
+ this.code = (error === null || error === void 0 ? void 0 : error.code) || 999;
144
144
  }
145
145
  }
146
146
  exports.PortalMpcError = PortalMpcError;
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MpcErrorCodes = exports.MpcError = void 0;
13
13
  const errors_1 = require("./errors");
14
14
  const index_1 = require("../index");
15
- const WEB_SDK_VERSION = '2.0.0';
15
+ const WEB_SDK_VERSION = '3.0.0';
16
16
  class Mpc {
17
17
  constructor({ portal }) {
18
18
  this.configureIframe = () => {
@@ -21,11 +21,9 @@ class Mpc {
21
21
  authToken: this.portal.authToken,
22
22
  authUrl: this.portal.authUrl,
23
23
  autoApprove: this.portal.autoApprove,
24
- chainId: this.portal.chainId,
25
24
  gdrive: this.portal.gDriveConfig,
26
25
  passkey: this.portal.passkeyConfig,
27
26
  host: this.portal.host,
28
- rpcUrl: this.portal.getRpcUrl(),
29
27
  mpcHost: this.portal.mpcHost,
30
28
  mpcVersion: this.portal.mpcVersion,
31
29
  featureFlags: this.portal.featureFlags,
@@ -261,7 +259,7 @@ class Mpc {
261
259
  return __awaiter(this, void 0, void 0, function* () {
262
260
  return new Promise((resolve, reject) => {
263
261
  const handleEject = (message) => {
264
- const { type, data } = message.data;
262
+ const { type, data: result } = message.data;
265
263
  const { origin } = message;
266
264
  // ignore any broadcast postMessages
267
265
  if (origin !== this.getOrigin()) {
@@ -270,12 +268,12 @@ class Mpc {
270
268
  if (type === 'portal:wasm:ejectError') {
271
269
  // Remove the event listeners
272
270
  window.removeEventListener('message', handleEject);
273
- reject(new errors_1.PortalMpcError(data));
271
+ reject(new errors_1.PortalMpcError(result));
274
272
  }
275
273
  else if (type === 'portal:wasm:ejectResult') {
276
274
  // Remove the event listeners
277
275
  window.removeEventListener('message', handleEject);
278
- resolve(data);
276
+ resolve(result);
279
277
  }
280
278
  };
281
279
  window.addEventListener('message', handleEject);
@@ -290,10 +288,6 @@ class Mpc {
290
288
  // Noop
291
289
  }) {
292
290
  return __awaiter(this, void 0, void 0, function* () {
293
- const message = {
294
- type: 'portal:wasm:sign',
295
- data,
296
- };
297
291
  return new Promise((resolve, reject) => {
298
292
  // Create a function to be bound when sign is triggered
299
293
  const handleSign = (event) => {
@@ -333,7 +327,43 @@ class Mpc {
333
327
  window.addEventListener('message', handleSign);
334
328
  window.addEventListener('message', handleProgress);
335
329
  // Send the request to the iframe
336
- this.postMessage(message);
330
+ this.postMessage({
331
+ type: 'portal:wasm:sign',
332
+ data,
333
+ });
334
+ });
335
+ });
336
+ }
337
+ checkSharesOnDevice() {
338
+ return __awaiter(this, void 0, void 0, function* () {
339
+ return new Promise((resolve, reject) => {
340
+ const handleCheckSharesOnDevice = (event) => {
341
+ const { type, data } = event.data;
342
+ const { origin } = event;
343
+ // ignore any broadcast postMessages
344
+ if (origin !== this.getOrigin()) {
345
+ return;
346
+ }
347
+ if (type === 'portal:checkSharesOnDeviceError') {
348
+ // Remove the event listener
349
+ window.removeEventListener('message', handleCheckSharesOnDevice);
350
+ // Reject the promise with the error
351
+ return reject(new errors_1.PortalMpcError(data));
352
+ }
353
+ else if (type === 'portal:checkSharesOnDeviceResult') {
354
+ // Remove the event listener
355
+ window.removeEventListener('message', handleCheckSharesOnDevice);
356
+ // Resolve the promise with the result
357
+ resolve(data);
358
+ }
359
+ };
360
+ // Bind the function to the message event
361
+ window.addEventListener('message', handleCheckSharesOnDevice);
362
+ // Send the request to the iframe
363
+ this.postMessage({
364
+ type: 'portal:checkSharesOnDevice',
365
+ data: {},
366
+ });
337
367
  });
338
368
  });
339
369
  }
@@ -512,7 +542,7 @@ class Mpc {
512
542
  });
513
543
  });
514
544
  }
515
- getTransactions(limit, offset, order, chainId) {
545
+ getTransactions(chainId, limit, offset, order) {
516
546
  return __awaiter(this, void 0, void 0, function* () {
517
547
  return new Promise((resolve, reject) => {
518
548
  const handleGetTransactions = (event) => {
@@ -541,10 +571,10 @@ class Mpc {
541
571
  this.postMessage({
542
572
  type: 'portal:getTransactions',
543
573
  data: {
574
+ chainId,
544
575
  limit,
545
576
  offset,
546
577
  order,
547
- chainId,
548
578
  },
549
579
  });
550
580
  });
@@ -655,72 +685,6 @@ class Mpc {
655
685
  });
656
686
  });
657
687
  }
658
- getBackupShareMetadata() {
659
- return __awaiter(this, void 0, void 0, function* () {
660
- return new Promise((resolve, reject) => {
661
- const handleGetBackupShareMetadata = (event) => {
662
- const { type, data } = event.data;
663
- const { origin } = event;
664
- // ignore any broadcast postMessages
665
- if (origin !== this.getOrigin()) {
666
- return;
667
- }
668
- if (type === 'portal:getBackupShareMetadataError') {
669
- // Remove the event listener
670
- window.removeEventListener('message', handleGetBackupShareMetadata);
671
- // Reject the promise with the error
672
- return reject(new errors_1.PortalMpcError(data));
673
- }
674
- else if (type === 'portal:getBackupShareMetadataResult') {
675
- // Remove the event listener
676
- window.removeEventListener('message', handleGetBackupShareMetadata);
677
- // Resolve the promise with the result
678
- resolve(data);
679
- }
680
- };
681
- // Bind the function to the message event
682
- window.addEventListener('message', handleGetBackupShareMetadata);
683
- // Send the request to the iframe
684
- this.postMessage({
685
- type: 'portal:getBackupShareMetadata',
686
- data: {},
687
- });
688
- });
689
- });
690
- }
691
- getSigningShareMetadata() {
692
- return __awaiter(this, void 0, void 0, function* () {
693
- return new Promise((resolve, reject) => {
694
- const handleGetSigningShareMetadata = (event) => {
695
- const { type, data } = event.data;
696
- const { origin } = event;
697
- // ignore any broadcast postMessages
698
- if (origin !== this.getOrigin()) {
699
- return;
700
- }
701
- if (type === 'portal:getSigningShareMetadataError') {
702
- // Remove the event listener
703
- window.removeEventListener('message', handleGetSigningShareMetadata);
704
- // Reject the promise with the error
705
- return reject(new errors_1.PortalMpcError(data));
706
- }
707
- else if (type === 'portal:getSigningShareMetadataResult') {
708
- // Remove the event listener
709
- window.removeEventListener('message', handleGetSigningShareMetadata);
710
- // Resolve the promise with the result
711
- resolve(data);
712
- }
713
- };
714
- // Bind the function to the message event
715
- window.addEventListener('message', handleGetSigningShareMetadata);
716
- // Send the request to the iframe
717
- this.postMessage({
718
- type: 'portal:getSigningShareMetadata',
719
- data: {},
720
- });
721
- });
722
- });
723
- }
724
688
  /***************************
725
689
  * Private Methods
726
690
  ***************************/