@toruslabs/ethereum-controllers 9.1.0 → 9.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.
@@ -2,6 +2,7 @@
2
2
 
3
3
  var auth = require('@web3auth/auth');
4
4
  var eip7702Utils = require('../Eip7702/eip7702Utils.js');
5
+ var constants = require('../utils/constants.js');
5
6
  var eip5792Types = require('../utils/eip5792Types.js');
6
7
 
7
8
  /**
@@ -33,6 +34,14 @@ async function walletGetCapabilities(request, getEthCode, context) {
33
34
  const cachedDelegations = ((_context$getCachedDel = context.getCachedDelegations) === null || _context$getCachedDel === void 0 ? void 0 : _context$getCachedDel.call(context)) || {};
34
35
  const capabilities = {};
35
36
  for (const chainId of supportedChains) {
37
+ if (context.getSmartAccountEipStandard() !== constants.SMART_ACCOUNT_EIP_STANDARD.EIP_7702) {
38
+ capabilities[chainId] = {
39
+ atomic: {
40
+ status: eip5792Types.Eip5792AtomicStatus.UNSUPPORTED
41
+ }
42
+ };
43
+ continue;
44
+ }
36
45
  const cacheKey = `${walletAddress.toLowerCase()}-${chainId.toLowerCase()}`;
37
46
  let delegationAddress = cachedDelegations[cacheKey];
38
47
  let atomicStatus = eip5792Types.Eip5792AtomicStatus.SUPPORTED;
@@ -4,6 +4,7 @@ var auth = require('@web3auth/auth');
4
4
  var uuid = require('uuid');
5
5
  var viem = require('viem');
6
6
  var eip7702Utils = require('../Eip7702/eip7702Utils.js');
7
+ var constants = require('../utils/constants.js');
7
8
  var eip5792Types = require('../utils/eip5792Types.js');
8
9
 
9
10
  /**
@@ -42,8 +43,9 @@ function validateCall(call, index) {
42
43
  /**
43
44
  * Validates the parameters for wallet_sendCalls (EIP-5792).
44
45
  * @param sendCallsParams - The parameters to validate.
46
+ * @param context - The context
45
47
  */
46
- function validateSendCallsParams(sendCallsParams) {
48
+ function validateSendCallsParams(sendCallsParams, context) {
47
49
  // Basic structure validation
48
50
  if (!sendCallsParams) {
49
51
  throw auth.rpcErrors.invalidParams("Missing send calls parameters");
@@ -67,6 +69,10 @@ function validateSendCallsParams(sendCallsParams) {
67
69
  if (!Array.isArray(sendCallsParams.calls) || sendCallsParams.calls.length === 0) {
68
70
  throw auth.rpcErrors.invalidParams("Invalid calls: must be a non-empty array");
69
71
  }
72
+ // Validate smart account standard for batch calls
73
+ if (sendCallsParams.calls.length > 1 && context.getSmartAccountEipStandard() !== constants.SMART_ACCOUNT_EIP_STANDARD.EIP_7702) {
74
+ throw auth.rpcErrors.methodNotSupported("wallet_sendCalls is only supported for batch calls when smart account standard is EIP-7702");
75
+ }
70
76
  // Validate each call
71
77
  sendCallsParams.calls.forEach((call, index) => {
72
78
  validateCall(call, index);
@@ -128,7 +134,7 @@ async function walletSendCalls(request, getEthCode, context) {
128
134
  return;
129
135
  }
130
136
  const sendCallsParams = Array.isArray(params) ? params[0] : params;
131
- validateSendCallsParams(sendCallsParams);
137
+ validateSendCallsParams(sendCallsParams, context);
132
138
  const {
133
139
  chainId,
134
140
  from,
@@ -482,15 +482,19 @@ function createEip5792Middleware({
482
482
  const {
483
483
  getSupportedChains,
484
484
  getCachedDelegations,
485
- updateDelegationCache
485
+ updateDelegationCache,
486
+ getSmartAccountEipStandard
486
487
  } = eip5792Config;
487
488
  const getCapabilitiesContext = {
488
489
  getSupportedChains,
489
490
  getCachedDelegations,
490
- updateDelegationCache
491
+ updateDelegationCache,
492
+ getSmartAccountEipStandard
491
493
  };
492
494
  const sendCallsContext = {
493
- processTransactionBatch
495
+ processTransaction,
496
+ processTransactionBatch,
497
+ getSmartAccountEipStandard
494
498
  };
495
499
  return auth.createScaffoldMiddlewareV2({
496
500
  [eip5792Types.EIP_5792_METHODS.WALLET_GET_CAPABILITIES]: async ({
@@ -28,6 +28,7 @@ function createProviderConfigMiddleware(providerConfig) {
28
28
  next
29
29
  }) => {
30
30
  if (request.method === "eth_provider_config") {
31
+ // can't do the direct cast because `interface ProviderConfig` doesn't satisfy the `Json` type
31
32
  return providerConfig;
32
33
  }
33
34
  return next();
@@ -3,7 +3,6 @@
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var baseControllers = require('@toruslabs/base-controllers');
5
5
  var metadataHelpers = require('@toruslabs/metadata-helpers');
6
- var asyncMutex = require('async-mutex');
7
6
  var log = require('loglevel');
8
7
  var constants = require('../utils/constants.js');
9
8
  var helpers = require('../utils/helpers.js');
@@ -22,17 +21,12 @@ class PreferencesController extends baseControllers.BasePreferencesController {
22
21
  config,
23
22
  state,
24
23
  defaultPreferences: {
25
- formattedPastTransactions: [],
26
- fetchedPastTx: [],
27
- paymentTx: [],
28
24
  etherscanTransactions: []
29
25
  },
30
26
  signAuthMessage,
31
27
  validateSignMessage
32
28
  });
33
29
  _defineProperty(this, "chainNamespace", baseControllers.CHAIN_NAMESPACES.EIP155);
34
- _defineProperty(this, "_handle", void 0);
35
- _defineProperty(this, "_mutex", new asyncMutex.Mutex());
36
30
  _defineProperty(this, "getProviderConfig", void 0);
37
31
  _defineProperty(this, "setProviderConfig", void 0);
38
32
  _defineProperty(this, "provider", void 0);
@@ -40,24 +34,6 @@ class PreferencesController extends baseControllers.BasePreferencesController {
40
34
  this.getProviderConfig = getProviderConfig;
41
35
  this.setProviderConfig = setProviderConfig;
42
36
  }
43
- async poll(interval) {
44
- var _this$getAddressState;
45
- const releaseLock = await this._mutex.acquire();
46
- if (interval) this.configure({
47
- pollInterval: interval
48
- });
49
- if (this._handle) window.clearTimeout(this._handle);
50
- // call here
51
- const storeSelectedAddress = this.state.selectedAddress;
52
- if (!storeSelectedAddress) return;
53
- if (!((_this$getAddressState = this.getAddressState(storeSelectedAddress)) !== null && _this$getAddressState !== void 0 && _this$getAddressState.jwtToken)) return;
54
- // This should never throw
55
- await this.sync(storeSelectedAddress);
56
- releaseLock();
57
- this._handle = window.setTimeout(() => {
58
- this.poll(this.config.pollInterval);
59
- }, this.config.pollInterval);
60
- }
61
37
  async initPreferences(params) {
62
38
  const {
63
39
  address,
@@ -65,7 +41,6 @@ class PreferencesController extends baseControllers.BasePreferencesController {
65
41
  calledFromEmbed,
66
42
  userInfo,
67
43
  rehydrate,
68
- locale = "en",
69
44
  type,
70
45
  signatures,
71
46
  web3AuthClientId,
@@ -99,26 +74,6 @@ class PreferencesController extends baseControllers.BasePreferencesController {
99
74
  authConnectionId,
100
75
  userId
101
76
  } = userInfo || {};
102
- const userExists = await this.sync(address);
103
- if (!userExists) {
104
- const accountState = this.getAddressState(address);
105
- await this.createUser({
106
- selectedCurrency: accountState.selectedCurrency,
107
- theme: accountState.theme,
108
- groupedAuthConnectionId,
109
- authConnectionId,
110
- userId,
111
- locale,
112
- address,
113
- type,
114
- web3AuthNetwork,
115
- metadata: {
116
- aa_provider: aaProvider,
117
- chain_id: chainId,
118
- eoa_address: eoaAddress
119
- }
120
- });
121
- }
122
77
  if (eoaAddress) this.updateState({
123
78
  eoaAddress
124
79
  }, address);
@@ -140,102 +95,16 @@ class PreferencesController extends baseControllers.BasePreferencesController {
140
95
  getSelectedAddress() {
141
96
  return this.state.selectedAddress;
142
97
  }
143
- async sync(address) {
144
- try {
145
- const user = await this.getUser(address);
146
- if (user) {
147
- const {
148
- default_currency: defaultCurrency,
149
- contacts,
150
- theme,
151
- locale,
152
- public_address: userPublicAddress,
153
- default_public_address: defaultPublicAddress,
154
- customNetworks,
155
- customTokens,
156
- customNfts,
157
- account_type: accountType
158
- } = user || {};
159
- // update latest data in state.
160
- this.updateState({
161
- contacts,
162
- theme,
163
- selectedCurrency: defaultCurrency,
164
- locale,
165
- defaultPublicAddress: defaultPublicAddress || userPublicAddress,
166
- customTokens,
167
- customNfts,
168
- customNetworks,
169
- accountType: accountType
170
- }, address);
171
- return true;
172
- }
173
- return false;
174
- } catch (error) {
175
- if (baseControllers.isUnauthorizedError(error)) {
176
- throw error;
177
- }
178
- log.error(error);
179
- return false;
180
- } finally {
181
- this.getWalletOrders(address).then(walletTx => {
182
- // eslint-disable-next-line promise/always-return
183
- if (walletTx && walletTx.length > 0) {
184
- this.updateState({
185
- fetchedPastTx: [...walletTx]
186
- }, address);
187
- this.calculatePastTx(walletTx, address);
188
- }
189
- }).catch(error => log.error(error));
190
- }
191
- }
192
- async patchNewTx(tx, address) {
193
- var _this$getAddressState2;
194
- const formattedTx = helpers.formatPastTx({
195
- transaction: tx,
196
- blockExplorerUrl: this.getBlockExplorerUrl()
197
- });
198
- const storePastTx = ((_this$getAddressState2 = this.getAddressState(address)) === null || _this$getAddressState2 === void 0 ? void 0 : _this$getAddressState2.formattedPastTransactions) || [];
199
- const duplicateIndex = storePastTx.findIndex(x => x.transaction_hash === tx.transaction_hash && x.chainId === tx.chain_id);
200
- if (tx.status === baseControllers.TransactionStatus.submitted || tx.status === baseControllers.TransactionStatus.confirmed) {
201
- if (duplicateIndex === -1) {
202
- var _tx$to;
203
- // No duplicate found
204
- const finalTx = this.cancelTxCalculate([...storePastTx, formattedTx]);
205
- tx.is_cancel = formattedTx.is_cancel;
206
- tx.to = (_tx$to = tx.to) === null || _tx$to === void 0 ? void 0 : _tx$to.toLowerCase();
207
- tx.from = tx.from.toLowerCase();
208
- this.updateState({
209
- formattedPastTransactions: finalTx
210
- }, address);
211
- this.postPastTx(tx, address);
212
- } else {
213
- // avoid overriding is_cancel
214
- formattedTx.is_cancel = storePastTx[duplicateIndex].is_cancel;
215
- storePastTx[duplicateIndex] = formattedTx;
216
- this.updateState({
217
- formattedPastTransactions: this.cancelTxCalculate([...storePastTx])
218
- }, address);
219
- }
220
- }
221
- }
222
- recalculatePastTx(address) {
223
- // This triggers store update which calculates past Tx status for that network
224
- const selectedAddress = address || this.state.selectedAddress;
225
- const state = this.getAddressState(selectedAddress);
226
- if (!(state !== null && state !== void 0 && state.fetchedPastTx)) return;
227
- this.calculatePastTx(state.fetchedPastTx, selectedAddress);
228
- }
229
98
  async refetchEtherscanTx(address) {
230
- var _this$getAddressState3;
99
+ var _this$getAddressState;
231
100
  const selectedAddress = address || this.state.selectedAddress;
232
101
  if (!selectedAddress) return [];
233
- const lowerCaseSelectedAddress = selectedAddress === null || selectedAddress === void 0 ? void 0 : selectedAddress.toLowerCase();
234
- if ((_this$getAddressState3 = this.getAddressState(selectedAddress)) !== null && _this$getAddressState3 !== void 0 && _this$getAddressState3.jwtToken) {
102
+ if ((_this$getAddressState = this.getAddressState(selectedAddress)) !== null && _this$getAddressState !== void 0 && _this$getAddressState.jwtToken) {
235
103
  const {
236
104
  chainId
237
105
  } = this.getProviderConfig();
238
106
  if (constants.MM_TOKEN_API_SUPPORTED_CHAINS.includes(chainId)) {
107
+ const lowerCaseSelectedAddress = selectedAddress.toLowerCase();
239
108
  const etherscanTxn = await this.fetchEtherscanTx({
240
109
  selectedAddress,
241
110
  chainId: this.getProviderConfig().chainId
@@ -293,15 +162,16 @@ class PreferencesController extends baseControllers.BasePreferencesController {
293
162
  return result.data;
294
163
  }
295
164
  getCustomTokens(address) {
296
- var _this$getAddressState4, _this$getAddressState5;
297
- return (_this$getAddressState4 = (_this$getAddressState5 = this.getAddressState(address)) === null || _this$getAddressState5 === void 0 ? void 0 : _this$getAddressState5.customTokens) !== null && _this$getAddressState4 !== void 0 ? _this$getAddressState4 : [];
165
+ var _this$getAddressState2, _this$getAddressState3;
166
+ return (_this$getAddressState2 = (_this$getAddressState3 = this.getAddressState(address)) === null || _this$getAddressState3 === void 0 ? void 0 : _this$getAddressState3.customTokens) !== null && _this$getAddressState2 !== void 0 ? _this$getAddressState2 : [];
298
167
  }
299
168
  getCustomNfts(address) {
300
- var _this$getAddressState6, _this$getAddressState7;
301
- return (_this$getAddressState6 = (_this$getAddressState7 = this.getAddressState(address)) === null || _this$getAddressState7 === void 0 ? void 0 : _this$getAddressState7.customNfts) !== null && _this$getAddressState6 !== void 0 ? _this$getAddressState6 : [];
169
+ var _this$getAddressState4, _this$getAddressState5;
170
+ return (_this$getAddressState4 = (_this$getAddressState5 = this.getAddressState(address)) === null || _this$getAddressState5 === void 0 ? void 0 : _this$getAddressState5.customNfts) !== null && _this$getAddressState4 !== void 0 ? _this$getAddressState4 : [];
302
171
  }
303
- isChainIdSupported(address, chainId) {
304
- const approveChainOptions = this.getChainOptions(address);
172
+ // NOTE: keep address params for now, might need to handle aa addresses later
173
+ isChainIdSupported(_address, chainId) {
174
+ const approveChainOptions = this.getChainOptions();
305
175
  const providerConfig = approveChainOptions.find(x => metadataHelpers.remove0x(x.chainId) === chainId);
306
176
  return !!providerConfig;
307
177
  }
@@ -309,19 +179,7 @@ class PreferencesController extends baseControllers.BasePreferencesController {
309
179
  const approveChainOptions = this.getChainOptions();
310
180
  const providerConfig = approveChainOptions.find(x => x.chainId === network.chainId);
311
181
  if (providerConfig) return;
312
- const newNetwork = {
313
- displayName: network.chainName,
314
- rpcTarget: network.rpcUrls[0],
315
- ticker: network.nativeCurrency.symbol,
316
- chainId: network.chainId,
317
- blockExplorerUrl: network.blockExplorerUrls[0],
318
- tickerName: network.nativeCurrency.name,
319
- logo: network.nativeCurrency.symbol
320
- };
321
- const isSuccess = await this.addCustomNetwork({
322
- network: newNetwork
323
- });
324
- if (!isSuccess) throw new Error("unable to add custom network");
182
+ throw new Error(`chainId ${network.chainId} is not supported`);
325
183
  }
326
184
  switchChain(data) {
327
185
  const chainOptions = this.getChainOptions();
@@ -332,102 +190,8 @@ class PreferencesController extends baseControllers.BasePreferencesController {
332
190
  throw new Error(`chainId ${data.chainId} is not supported`);
333
191
  }
334
192
  }
335
- // Custom Network methods
336
- async addCustomNetwork({
337
- network
338
- }) {
339
- try {
340
- const {
341
- selectedAddress
342
- } = this.state;
343
- const payload = {
344
- network_name: network.displayName,
345
- rpc_url: network.rpcTarget,
346
- chain_id: network.chainId,
347
- symbol: network.ticker,
348
- block_explorer_url: network.blockExplorerUrl || undefined,
349
- is_testnet: network.isTestnet || false,
350
- logo: network.logo,
351
- symbol_name: network.tickerName
352
- };
353
- const res = await this.wsApiClient.authPost("customnetwork", payload, this.authCredentials(selectedAddress), {
354
- useAPIKey: true
355
- });
356
- await this.sync(selectedAddress);
357
- return res.data.id;
358
- } catch {
359
- log.error("error adding custom network");
360
- return null;
361
- }
362
- }
363
- async deleteCustomNetwork(id) {
364
- try {
365
- const {
366
- selectedAddress
367
- } = this.state;
368
- await this.wsApiClient.authRemove(`customnetwork/${id}`, {}, this.authCredentials(selectedAddress), {
369
- useAPIKey: true
370
- });
371
- await this.sync(selectedAddress);
372
- return true;
373
- } catch {
374
- log.error("error deleting custom network");
375
- return false;
376
- }
377
- }
378
- async editCustomNetwork({
379
- network,
380
- id
381
- }) {
382
- try {
383
- const {
384
- selectedAddress
385
- } = this.state;
386
- const payload = {
387
- network_name: network.displayName,
388
- rpc_url: network.rpcTarget,
389
- chain_id: network.chainId,
390
- symbol: network.ticker || undefined,
391
- block_explorer_url: network.blockExplorerUrl || undefined,
392
- is_testnet: network.isTestnet || false
393
- };
394
- await this.wsApiClient.authPatch(`customnetwork/${id}`, payload, this.authCredentials(selectedAddress), {
395
- useAPIKey: true
396
- });
397
- await this.sync(selectedAddress);
398
- return true;
399
- } catch {
400
- log.error("error editing custom network");
401
- return false;
402
- }
403
- }
404
- getChainOptions(address = this.state.selectedAddress) {
405
- var _identities$address$c, _identities$address;
406
- const {
407
- identities
408
- } = this.state;
409
- const customNetworks = (_identities$address$c = (_identities$address = identities[address]) === null || _identities$address === void 0 ? void 0 : _identities$address.customNetworks) !== null && _identities$address$c !== void 0 ? _identities$address$c : [];
410
- const custom = Object.values(customNetworks).reduce((chains, network) => {
411
- const networkItem = {
412
- blockExplorerUrl: network.block_explorer_url,
413
- chainId: network.chain_id,
414
- displayName: network.network_name,
415
- logo: "eth.svg",
416
- rpcTarget: network.rpc_url,
417
- ticker: network.symbol,
418
- tickerName: network.symbol.toUpperCase(),
419
- isCustom: true,
420
- id: network.id
421
- };
422
- if (Object.keys(constants.SUPPORTED_NETWORKS).includes(networkItem.chainId)) return chains;
423
- chains.push(networkItem);
424
- return chains;
425
- }, []);
426
- const supported = Object.values(constants.SUPPORTED_NETWORKS).reduce((chains, network) => {
427
- chains.push(network);
428
- return chains;
429
- }, []);
430
- return [...supported, ...custom];
193
+ getChainOptions() {
194
+ return Object.values(constants.SUPPORTED_NETWORKS);
431
195
  }
432
196
  getBlockExplorerUrl() {
433
197
  const supportedNetworks = this.getChainOptions();
@@ -435,77 +199,6 @@ class PreferencesController extends baseControllers.BasePreferencesController {
435
199
  if (!network) return "";
436
200
  return `${network.blockExplorerUrl}`;
437
201
  }
438
- async calculatePastTx(txs, address) {
439
- const pastTx = [];
440
- const pendingTx = [];
441
- const lowerCaseSelectedAddress = address.toLowerCase();
442
- const supportedNetworks = this.getChainOptions(address);
443
- const supportedNetwork = supportedNetworks.find(x => x.chainId === this.getProviderConfig().chainId);
444
- for (const x of txs) {
445
- var _x$to;
446
- if ((supportedNetwork === null || supportedNetwork === void 0 ? void 0 : supportedNetwork.chainId) === x.chain_id && x.to && x.from && (lowerCaseSelectedAddress === x.from.toLowerCase() || lowerCaseSelectedAddress === ((_x$to = x.to) === null || _x$to === void 0 ? void 0 : _x$to.toLowerCase()))) {
447
- if (x.status !== "confirmed") {
448
- pendingTx.push(x);
449
- } else {
450
- const finalObject = helpers.formatPastTx({
451
- transaction: x,
452
- lowerCaseSelectedAddress,
453
- blockExplorerUrl: this.getBlockExplorerUrl()
454
- });
455
- pastTx.push(finalObject);
456
- }
457
- }
458
- }
459
- const pendingTxPromises = pendingTx.map(x => helpers.getEthTxStatus(x.transaction_hash, this.provider).catch(error => log.error(error)));
460
- const resolvedTxStatuses = await Promise.all(pendingTxPromises);
461
- for (const [index, element] of pendingTx.entries()) {
462
- const finalObject = helpers.formatPastTx({
463
- transaction: element,
464
- lowerCaseSelectedAddress,
465
- blockExplorerUrl: this.getBlockExplorerUrl()
466
- });
467
- finalObject.status = resolvedTxStatuses[index] || baseControllers.TransactionStatus.submitted;
468
- pastTx.push(finalObject);
469
- if (lowerCaseSelectedAddress === element.from.toLowerCase() && finalObject.status && finalObject.status !== element.status) this.patchPastTx({
470
- id: element.id,
471
- status: finalObject.status
472
- }, address);
473
- }
474
- const finalTx = this.cancelTxCalculate(pastTx);
475
- this.updateState({
476
- formattedPastTransactions: [...finalTx]
477
- }, address);
478
- }
479
- cancelTxCalculate(pastTx) {
480
- const nonceMap = {};
481
- for (const x of pastTx) {
482
- if (!nonceMap[x.nonce]) nonceMap[x.nonce] = [x];else {
483
- nonceMap[x.nonce].push(x);
484
- }
485
- }
486
- for (const [, value] of Object.entries(nonceMap)) {
487
- // has duplicate
488
- if (value.length > 1) {
489
- // get latest and mark it as is_cancel
490
- const latestTxs = value.sort((a, b) => {
491
- const aDate = new Date(a.date).getTime();
492
- const bDate = new Date(b.date).getTime();
493
- return bDate - aDate;
494
- });
495
- const latestCancelTx = latestTxs[0];
496
- latestCancelTx.is_cancel = true;
497
- latestTxs.slice(1).forEach(x => {
498
- x.hasCancel = true;
499
- x.status = latestCancelTx.status === "confirmed" ? baseControllers.TransactionStatus.cancelled : baseControllers.TransactionStatus.cancelling;
500
- x.cancelDateInitiated = `${helpers.formatTime(new Date(latestCancelTx.date).getTime())} - ${helpers.formatDate(latestCancelTx.date)}`;
501
- x.etherscanLink = latestCancelTx.etherscanLink;
502
- x.cancelGas = latestCancelTx.gas;
503
- x.cancelGasPrice = latestCancelTx.gasPrice;
504
- });
505
- }
506
- }
507
- return pastTx;
508
- }
509
202
  }
510
203
 
511
204
  exports.PreferencesController = PreferencesController;
@@ -9,8 +9,8 @@ var bignumber_js = require('bignumber.js');
9
9
  var log = require('loglevel');
10
10
  var viem = require('viem');
11
11
  var eip7702Utils = require('../Eip7702/eip7702Utils.js');
12
- var walletSendCalls = require('../Eip5792/walletSendCalls.js');
13
12
  var constants = require('../utils/constants.js');
13
+ var walletSendCalls = require('../Eip5792/walletSendCalls.js');
14
14
  var conversionUtils = require('../utils/conversionUtils.js');
15
15
  var helpers = require('../utils/helpers.js');
16
16
  var interfaces = require('../utils/interfaces.js');
@@ -171,6 +171,7 @@ exports.CONTRACT_TYPE_ERC20 = constants.CONTRACT_TYPE_ERC20;
171
171
  exports.CONTRACT_TYPE_ERC721 = constants.CONTRACT_TYPE_ERC721;
172
172
  exports.CONTRACT_TYPE_ERC7821 = constants.CONTRACT_TYPE_ERC7821;
173
173
  exports.CONTRACT_TYPE_ETH = constants.CONTRACT_TYPE_ETH;
174
+ exports.EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES = constants.EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES;
174
175
  exports.ERC1155_INTERFACE_ID = constants.ERC1155_INTERFACE_ID;
175
176
  exports.ERC721_ENUMERABLE_INTERFACE_ID = constants.ERC721_ENUMERABLE_INTERFACE_ID;
176
177
  exports.ERC721_INTERFACE_ID = constants.ERC721_INTERFACE_ID;
@@ -191,6 +192,7 @@ exports.POLYGON_AMOY_CHAIN_ID = constants.POLYGON_AMOY_CHAIN_ID;
191
192
  exports.POLYGON_CHAIN_ID = constants.POLYGON_CHAIN_ID;
192
193
  exports.SEPOLIA_CHAIN_ID = constants.SEPOLIA_CHAIN_ID;
193
194
  exports.SMART_ACCOUNT = constants.SMART_ACCOUNT;
195
+ exports.SMART_ACCOUNT_EIP_STANDARD = constants.SMART_ACCOUNT_EIP_STANDARD;
194
196
  exports.SUPPORTED_NETWORKS = constants.SUPPORTED_NETWORKS;
195
197
  exports.TEST_CHAINS = constants.TEST_CHAINS;
196
198
  exports.TRANSACTION_ENVELOPE_TYPES = constants.TRANSACTION_ENVELOPE_TYPES;
@@ -1,10 +1,11 @@
1
1
  import { JRPCRequest } from "@web3auth/auth";
2
2
  import { Eip5792GetCapabilitiesParams, Eip5792GetCapabilitiesResponse, GetCachedDelegationsFn, GetSupportedChainsFn } from "../utils/eip5792Types";
3
- import { GetEthCodeFn } from "../utils/interfaces";
3
+ import { type GetEthCodeFn, type SmartAccountEipStandardType } from "../utils/interfaces";
4
4
  export interface WalletGetCapabilitiesContext {
5
5
  getSupportedChains: GetSupportedChainsFn;
6
6
  getCachedDelegations?: GetCachedDelegationsFn;
7
7
  updateDelegationCache?: (walletAddress: `0x${string}`, chainId: `0x${string}`, delegation: `0x${string}` | null) => void;
8
+ getSmartAccountEipStandard: () => SmartAccountEipStandardType | undefined;
8
9
  }
9
10
  /**
10
11
  * Handler for wallet_getCapabilities (EIP-5792).
@@ -1,10 +1,11 @@
1
1
  import { JRPCRequest } from "@web3auth/auth";
2
2
  import { IProviderHandlers } from "../Network/interfaces";
3
3
  import { BatchTransactionParams, Eip5792SendCallsParams } from "../utils/eip5792Types";
4
- import { GetEthCodeFn } from "../utils/interfaces";
4
+ import { GetEthCodeFn, SmartAccountEipStandardType } from "../utils/interfaces";
5
5
  export interface WalletSendCallsContext {
6
6
  processTransaction: IProviderHandlers["processTransaction"];
7
7
  processTransactionBatch: IProviderHandlers["processTransactionBatch"];
8
+ getSmartAccountEipStandard: () => SmartAccountEipStandardType | undefined;
8
9
  }
9
10
  /**
10
11
  * Generates a unique batch ID for EIP-5792 calls.
@@ -14,8 +15,9 @@ export declare function generateBatchId(): `0x${string}`;
14
15
  /**
15
16
  * Validates the parameters for wallet_sendCalls (EIP-5792).
16
17
  * @param sendCallsParams - The parameters to validate.
18
+ * @param context - The context
17
19
  */
18
- export declare function validateSendCallsParams(sendCallsParams: Eip5792SendCallsParams): void;
20
+ export declare function validateSendCallsParams(sendCallsParams: Eip5792SendCallsParams, context: WalletSendCallsContext): void;
19
21
  export declare function processMultipleTransactions({ from, transactions, request, chainId, getEthCode, processTransactionBatch, }: {
20
22
  from: `0x${string}`;
21
23
  transactions: {
@@ -2,7 +2,7 @@ import { InPageWalletProviderState, SwitchChainMessageParams } from "@toruslabs/
2
2
  import { JRPCRequest } from "@web3auth/auth";
3
3
  import { TransactionStateManager } from "../Transaction/TransactionStateManager";
4
4
  import { Eip5792SendCallsParams, TransactionBatchRequest } from "../utils/eip5792Types";
5
- import { AddChainMessageParams, EthereumTransactionMeta, GetEthCodeFn, MessageParams, TransactionParams, TypedMessageParams, UserOperationGas, UserRequestApprovalParams } from "../utils/interfaces";
5
+ import { AddChainMessageParams, EthereumTransactionMeta, GetEthCodeFn, MessageParams, SmartAccountEipStandardType, TransactionParams, TypedMessageParams, UserOperationGas, UserRequestApprovalParams } from "../utils/interfaces";
6
6
  export interface IProviderHandlers {
7
7
  version: string;
8
8
  aaConfig?: {
@@ -45,6 +45,10 @@ export interface IProviderHandlers {
45
45
  * Get the list of supported chain IDs for EIP-5792/EIP-7702.
46
46
  */
47
47
  getSupportedChains: () => `0x${string}`[];
48
+ /**
49
+ * Smart account EIP standard (4337 or 7702).
50
+ */
51
+ getSmartAccountEipStandard: () => SmartAccountEipStandardType | undefined;
48
52
  /**
49
53
  * Get cached delegation addresses.
50
54
  * Key format: `${walletAddress}-${chainId}`
@@ -1,10 +1,6 @@
1
1
  import { AddressPreferences } from "@toruslabs/base-controllers";
2
- import { CustomNetworks, FetchCommonTransaction, FetchedTransaction, FormattedTransactionActivity } from "../utils/interfaces";
2
+ import { FormattedTransactionActivity } from "../utils/interfaces";
3
3
  export interface ExtendedAddressPreferences extends AddressPreferences {
4
4
  eoaAddress?: string;
5
- fetchedPastTx?: FetchedTransaction[];
6
- formattedPastTransactions?: FormattedTransactionActivity[];
7
- paymentTx: FetchCommonTransaction[];
8
- customNetworks: CustomNetworks[];
9
5
  etherscanTransactions?: FormattedTransactionActivity[];
10
6
  }
@@ -3,7 +3,7 @@ import { SafeEventEmitterProvider } from "@web3auth/auth";
3
3
  import { KeyringController } from "../Keyring/KeyringController";
4
4
  import { NetworkController } from "../Network/NetworkController";
5
5
  import { EthereumNftInfo as CustomNftInfo } from "../Nfts/INftsController";
6
- import type { AddChainMessageParams, CustomNetworkPayload, CustomTokenInfo, EtherscanTransaction, TransactionPayload } from "../utils/interfaces";
6
+ import type { AddChainMessageParams, CustomTokenInfo, EtherscanTransaction } from "../utils/interfaces";
7
7
  import { ExtendedAddressPreferences } from "./IPreferencesController";
8
8
  export interface IPreferencesControllerOptions {
9
9
  config?: Partial<PreferencesConfig> & Pick<PreferencesConfig, "api" | "commonApiHost">;
@@ -16,22 +16,16 @@ export interface IPreferencesControllerOptions {
16
16
  }
17
17
  export declare class PreferencesController extends BasePreferencesController<ExtendedAddressPreferences, PreferencesConfig, PreferencesState<ExtendedAddressPreferences>> implements IPreferencesController<ExtendedAddressPreferences, PreferencesConfig, PreferencesState<ExtendedAddressPreferences>> {
18
18
  protected chainNamespace: "eip155";
19
- private _handle?;
20
- private _mutex;
21
19
  private getProviderConfig;
22
20
  private setProviderConfig;
23
21
  private provider;
24
22
  constructor({ config, state, provider, signAuthMessage, getProviderConfig, setProviderConfig, validateSignMessage, }: IPreferencesControllerOptions);
25
- poll(interval?: number): Promise<void>;
26
23
  initPreferences(params: InitPreferencesParams & {
27
24
  eoaAddress?: string;
28
25
  aaProvider?: string;
29
26
  mainAddress?: string;
30
27
  }): Promise<void>;
31
28
  getSelectedAddress(): string;
32
- sync(address: string): Promise<boolean>;
33
- patchNewTx(tx: TransactionPayload, address: string): Promise<void>;
34
- recalculatePastTx(address?: string): void;
35
29
  refetchEtherscanTx(address?: string): Promise<EtherscanTransaction[]>;
36
30
  fetchEtherscanTx<T>(parameters: {
37
31
  selectedAddress: string;
@@ -57,21 +51,11 @@ export declare class PreferencesController extends BasePreferencesController<Ext
57
51
  getSimpleHashNfts(address: string, chainId: string, skipCache?: boolean): Promise<CustomNftInfo[]>;
58
52
  getCustomTokens(address?: string): CustomToken[];
59
53
  getCustomNfts(address?: string): CustomNft[];
60
- isChainIdSupported(address: string, chainId: string): boolean;
54
+ isChainIdSupported(_address: string, chainId: string): boolean;
61
55
  addChain(network: AddChainMessageParams): Promise<void>;
62
56
  switchChain(data: {
63
57
  chainId: string;
64
58
  }): void;
65
- addCustomNetwork({ network }: {
66
- network: CustomNetworkPayload;
67
- }): Promise<number>;
68
- deleteCustomNetwork(id: number): Promise<boolean>;
69
- editCustomNetwork({ network, id }: {
70
- network: CustomNetworkPayload;
71
- id: number | null;
72
- }): Promise<boolean>;
73
59
  private getChainOptions;
74
60
  private getBlockExplorerUrl;
75
- private calculatePastTx;
76
- private cancelTxCalculate;
77
61
  }