@toruslabs/ethereum-controllers 8.15.0 → 8.17.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.
Files changed (56) hide show
  1. package/dist/ethereumControllers.umd.min.js +1 -1
  2. package/dist/lib.cjs/Eip5792/walletGetCallsStatus.js +75 -0
  3. package/dist/lib.cjs/Eip5792/walletGetCapabilities.js +64 -0
  4. package/dist/lib.cjs/Eip5792/walletSendCalls.js +163 -0
  5. package/dist/lib.cjs/Eip7702/eip7702Utils.js +82 -0
  6. package/dist/lib.cjs/Eip7702/walletGetUpgradeStatus.js +35 -0
  7. package/dist/lib.cjs/Eip7702/walletUpgradeAccount.js +58 -0
  8. package/dist/lib.cjs/Keyring/KeyringController.js +50 -14
  9. package/dist/lib.cjs/Network/createEthereumMiddleware.js +114 -1
  10. package/dist/lib.cjs/Transaction/TransactionController.js +117 -6
  11. package/dist/lib.cjs/Transaction/TransactionGasUtil.js +13 -0
  12. package/dist/lib.cjs/Transaction/TransactionStateManager.js +9 -0
  13. package/dist/lib.cjs/Transaction/TransactionUtils.js +103 -10
  14. package/dist/lib.cjs/index.js +36 -0
  15. package/dist/lib.cjs/types/Eip5792/index.d.ts +3 -0
  16. package/dist/lib.cjs/types/Eip5792/walletGetCallsStatus.d.ts +19 -0
  17. package/dist/lib.cjs/types/Eip5792/walletGetCapabilities.d.ts +17 -0
  18. package/dist/lib.cjs/types/Eip5792/walletSendCalls.d.ts +45 -0
  19. package/dist/lib.cjs/types/Eip7702/eip7702Utils.d.ts +27 -0
  20. package/dist/lib.cjs/types/Eip7702/walletGetUpgradeStatus.d.ts +11 -0
  21. package/dist/lib.cjs/types/Eip7702/walletUpgradeAccount.d.ts +13 -0
  22. package/dist/lib.cjs/types/Keyring/KeyringController.d.ts +2 -0
  23. package/dist/lib.cjs/types/Network/createEthereumMiddleware.d.ts +53 -1
  24. package/dist/lib.cjs/types/Transaction/TransactionController.d.ts +9 -1
  25. package/dist/lib.cjs/types/Transaction/TransactionStateManager.d.ts +1 -0
  26. package/dist/lib.cjs/types/Transaction/TransactionUtils.d.ts +38 -1
  27. package/dist/lib.cjs/types/index.d.ts +4 -0
  28. package/dist/lib.cjs/types/utils/abis.d.ts +15 -0
  29. package/dist/lib.cjs/types/utils/constants.d.ts +2 -0
  30. package/dist/lib.cjs/types/utils/eip5792Types.d.ts +155 -0
  31. package/dist/lib.cjs/types/utils/eip7702Types.d.ts +60 -0
  32. package/dist/lib.cjs/types/utils/interfaces.d.ts +22 -2
  33. package/dist/lib.cjs/utils/abis.js +30 -0
  34. package/dist/lib.cjs/utils/constants.js +4 -1
  35. package/dist/lib.cjs/utils/eip5792Types.js +41 -0
  36. package/dist/lib.cjs/utils/eip7702Types.js +14 -0
  37. package/dist/lib.cjs/utils/interfaces.js +8 -0
  38. package/dist/lib.esm/Eip5792/walletGetCallsStatus.js +76 -0
  39. package/dist/lib.esm/Eip5792/walletGetCapabilities.js +63 -0
  40. package/dist/lib.esm/Eip5792/walletSendCalls.js +168 -0
  41. package/dist/lib.esm/Eip7702/eip7702Utils.js +81 -0
  42. package/dist/lib.esm/Eip7702/walletGetUpgradeStatus.js +33 -0
  43. package/dist/lib.esm/Eip7702/walletUpgradeAccount.js +56 -0
  44. package/dist/lib.esm/Keyring/KeyringController.js +53 -15
  45. package/dist/lib.esm/Network/createEthereumMiddleware.js +117 -2
  46. package/dist/lib.esm/Transaction/TransactionController.js +124 -10
  47. package/dist/lib.esm/Transaction/TransactionGasUtil.js +13 -0
  48. package/dist/lib.esm/Transaction/TransactionStateManager.js +9 -0
  49. package/dist/lib.esm/Transaction/TransactionUtils.js +103 -11
  50. package/dist/lib.esm/index.js +11 -4
  51. package/dist/lib.esm/utils/abis.js +30 -1
  52. package/dist/lib.esm/utils/constants.js +4 -2
  53. package/dist/lib.esm/utils/eip5792Types.js +105 -0
  54. package/dist/lib.esm/utils/eip7702Types.js +15 -0
  55. package/dist/lib.esm/utils/interfaces.js +28 -0
  56. package/package.json +8 -5
@@ -1,3 +1,4 @@
1
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
2
  import { addHexPrefix, isHexString, isValidAddress } from '@ethereumjs/util';
2
3
  import { randomId, TransactionStatus, TRANSACTION_TYPES } from '@toruslabs/base-controllers';
3
4
  import { rpcErrors } from '@web3auth/auth';
@@ -28,7 +29,8 @@ const normalizers = {
28
29
  preVerificationGas: addHexPrefix,
29
30
  verificationGasLimit: addHexPrefix,
30
31
  paymasterVerificationGasLimit: addHexPrefix,
31
- paymasterPostOpGasLimit: addHexPrefix
32
+ paymasterPostOpGasLimit: addHexPrefix,
33
+ authorizationList: authorizationList => authorizationList
32
34
  };
33
35
 
34
36
  /**
@@ -108,13 +110,13 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
108
110
  switch (field) {
109
111
  case "maxFeePerGas":
110
112
  case "maxPriorityFeePerGas":
111
- if (txParams.type && txParams.type !== TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
113
+ if (txParams.type && txParams.type !== TRANSACTION_ENVELOPE_TYPES.FEE_MARKET && txParams.type !== TRANSACTION_ENVELOPE_TYPES.SET_CODE) {
112
114
  throw rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + `including maxFeePerGas and maxPriorityFeePerGas requires type: "${TRANSACTION_ENVELOPE_TYPES.FEE_MARKET}"`);
113
115
  }
114
116
  break;
115
117
  case "gasPrice":
116
118
  default:
117
- if (txParams.type && txParams.type === TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
119
+ if (txParams.type && (txParams.type === TRANSACTION_ENVELOPE_TYPES.FEE_MARKET || txParams.type === TRANSACTION_ENVELOPE_TYPES.SET_CODE)) {
118
120
  throw rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + "included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas");
119
121
  }
120
122
  }
@@ -203,6 +205,22 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
203
205
  throw rpcErrors.invalidParams(`Invalid transaction params: ${key} is not a Number or hex string. got: (${value})`);
204
206
  }
205
207
  break;
208
+ case "authorizationList":
209
+ if (!Array.isArray(value)) {
210
+ throw rpcErrors.invalidParams(`Invalid transaction params: ${key} is not an array. got: (${value})`);
211
+ }
212
+ value.forEach(authorization => {
213
+ if (typeof authorization !== "object" || authorization === null) {
214
+ throw rpcErrors.invalidParams(`Invalid transaction params: ${key} is not an object. got: (${authorization})`);
215
+ }
216
+ if (typeof authorization.address !== "string" || !isValidAddress(authorization.address)) {
217
+ throw rpcErrors.invalidParams(`Invalid transaction params: authorization.address is not a valid address. got: (${authorization.address})`);
218
+ }
219
+ if (typeof authorization.chainId !== "string" || !isHexString(addHexPrefix(authorization.chainId))) {
220
+ throw rpcErrors.invalidParams(`Invalid transaction params: authorization.chainId is not a valid hex string. got: (${authorization.chainId})`);
221
+ }
222
+ });
223
+ break;
206
224
  default:
207
225
  ensureFieldIsString(txParams, key);
208
226
  }
@@ -282,7 +300,11 @@ const readAddressAsContract = async (provider, address) => {
282
300
  isContractAddress
283
301
  };
284
302
  };
285
- async function determineTransactionType(txParams, provider) {
303
+ async function determineTransactionType(txParams, provider, overrideTxMeta) {
304
+ const {
305
+ transactionCategory: overrideTransactionCategory,
306
+ type: overrideType
307
+ } = overrideTxMeta || {};
286
308
  const {
287
309
  data,
288
310
  to
@@ -291,17 +313,23 @@ async function determineTransactionType(txParams, provider) {
291
313
  let methodParams = [];
292
314
  let type = "";
293
315
  try {
294
- ({
295
- name,
296
- methodParams,
297
- type
298
- } = data && parseStandardTokenTransactionData(data) || {});
316
+ if (overrideType) {
317
+ type = overrideType;
318
+ } else {
319
+ ({
320
+ name,
321
+ methodParams,
322
+ type
323
+ } = data && parseStandardTokenTransactionData(data) || {});
324
+ }
299
325
  } catch (error) {
300
326
  log.debug("Failed to parse transaction data", error);
301
327
  }
302
328
  let result;
303
329
  let contractCode = "";
304
- if (data && !to) {
330
+ if (overrideTransactionCategory) {
331
+ result = overrideTransactionCategory;
332
+ } else if (data && !to) {
305
333
  result = TRANSACTION_TYPES.DEPLOY_CONTRACT;
306
334
  } else {
307
335
  const {
@@ -328,4 +356,68 @@ async function determineTransactionType(txParams, provider) {
328
356
  };
329
357
  }
330
358
 
331
- export { determineTransactionType, ensureFieldIsString, ensureMutuallyExclusiveFieldsNotProvided, getFinalStates, isEIP1559Transaction, isLegacyTransaction, normalizeAndValidateTxParams, normalizeTxParameters, parseStandardTokenTransactionData, readAddressAsContract, transactionMatchesNetwork, validateFrom, validateRecipient, validateTxParameters };
359
+ /**
360
+ * Create the nested transaction metadata for a batch transaction.
361
+ *
362
+ * Reference: {@link https://github.com/MetaMask/core/blob/main/packages/transaction-controller/src/utils/batch.ts#L253}
363
+ *
364
+ * @param from - The sender address.
365
+ * @param batchTxParam - The batch transaction parameter.
366
+ * @param provider - The provider.
367
+ * @returns The nested transaction metadata.
368
+ */
369
+ async function createNestedTransactionMeta(from, batchTxParam, provider) {
370
+ const {
371
+ params,
372
+ type
373
+ } = batchTxParam;
374
+ if (type) {
375
+ return _objectSpread(_objectSpread({}, params), {}, {
376
+ type
377
+ });
378
+ }
379
+ const txParams = _objectSpread({
380
+ from
381
+ }, batchTxParam.params);
382
+ const {
383
+ category: determinedType
384
+ } = await determineTransactionType(txParams, provider);
385
+ return _objectSpread(_objectSpread({}, txParams), {}, {
386
+ type: determinedType
387
+ });
388
+ }
389
+ function isEip7702SetCodeTx(txMeta) {
390
+ return txMeta.transaction.type === TRANSACTION_ENVELOPE_TYPES.SET_CODE && txMeta.transaction.to === txMeta.transaction.from && Boolean(txMeta.transaction.authorizationList && txMeta.transaction.authorizationList.length > 0);
391
+ }
392
+
393
+ /**
394
+ * Check if a transaction is a EIP-7702 upgrade with data to self transaction.
395
+ * Example: batch transactions with EIP5792 `wallet_sendCalls` method with EIP-7702 upgrade.
396
+ *
397
+ * @example
398
+ * ```json
399
+ * {
400
+ * "from": "0x1234567890123456789012345678901234567890",
401
+ * "to": "0x1234567890123456789012345678901234567890",
402
+ * "data": "0xdeadbeef", // ERC7821 execute batch function data
403
+ * "type": "0x04",
404
+ * "authorizationList": [
405
+ * {
406
+ * "address": "0x1234567890123456789012345678901234567890",
407
+ * "chainId": "0x1",
408
+ * "nonce": "0x1"
409
+ * }
410
+ * ]
411
+ * }
412
+ * ```
413
+ * @param txMeta - The transaction metadata
414
+ * @returns true if it's a EIP-7702 upgrade with data to self transaction
415
+ */
416
+ function isEip7702UpgradeWithDataToSelfTransaction(txMeta) {
417
+ const {
418
+ data
419
+ } = txMeta.transaction;
420
+ return isEip7702SetCodeTx(txMeta) && data && data !== "0x" && data !== "0x0";
421
+ }
422
+
423
+ export { createNestedTransactionMeta, determineTransactionType, ensureFieldIsString, ensureMutuallyExclusiveFieldsNotProvided, getFinalStates, isEIP1559Transaction, isEip7702SetCodeTx, isEip7702UpgradeWithDataToSelfTransaction, isLegacyTransaction, normalizeAndValidateTxParams, normalizeTxParameters, parseStandardTokenTransactionData, readAddressAsContract, transactionMatchesNetwork, validateFrom, validateRecipient, validateTxParameters };
@@ -2,6 +2,7 @@ export { AccountTrackerController } from './Account/AccountTrackerController.js'
2
2
  export { AccountAbstractionController, eoaInterceptorMiddleware, eoaProviderAsMiddleware } from './AccountAbstraction/AccountAbstractionController.js';
3
3
  export { PollingBlockTracker } from './Block/PollingBlockTracker.js';
4
4
  export { CurrencyController } from './Currency/CurrencyController.js';
5
+ export { MetaMask_EIP7702_Stateless_Delegator, generateEIP7702BatchTransaction, getDelegationAddress, getIsEip7702UpgradeSupported } from './Eip7702/eip7702Utils.js';
5
6
  export { GasFeeController } from './Gas/GasFeeController.js';
6
7
  export { KeyringController } from './Keyring/KeyringController.js';
7
8
  export { AddChainController } from './Message/AddChainController.js';
@@ -10,7 +11,7 @@ export { PersonalMessageController } from './Message/PersonalMessageController.j
10
11
  export { SwitchChainController } from './Message/SwitchChainController.js';
11
12
  export { TypedMessageController } from './Message/TypedMessageController.js';
12
13
  export { normalizeMessageData, validateAddChainData, validateAddress, validateSignMessageData, validateSwitchChainData, validateTypedSignMessageDataV4 } from './Message/utils.js';
13
- export { createAAMiddleware, createEthereumMiddleware, createGetAccountsMiddleware, createPendingNonceMiddleware, createPendingTxMiddleware, createProcessAddEthereumChain, createProcessEstimateUserOperationGasMiddleware, createProcessEthSignMessage, createProcessPersonalMessage, createProcessSignTransactionMiddleware, createProcessSwitchEthereumChain, createProcessTransactionMiddleware, createProcessTypedMessageV4, createProcessWalletSwitchChain, createRequestAccountsMiddleware, formatTxMetaForRpcResult } from './Network/createEthereumMiddleware.js';
14
+ export { createAAMiddleware, createEip5792Middleware, createEip7702Middleware, createEthereumMiddleware, createGetAccountsMiddleware, createPendingNonceMiddleware, createPendingTxMiddleware, createProcessAddEthereumChain, createProcessEstimateUserOperationGasMiddleware, createProcessEthSignMessage, createProcessPersonalMessage, createProcessSignTransactionMiddleware, createProcessSwitchEthereumChain, createProcessTransactionMiddleware, createProcessTypedMessageV4, createProcessWalletSwitchChain, createRequestAccountsMiddleware, formatTxMetaForRpcResult } from './Network/createEthereumMiddleware.js';
14
15
  export { createChainIdMiddleware, createJsonRpcClient, createProviderConfigMiddleware } from './Network/createJsonRpcClient.js';
15
16
  export { NetworkController } from './Network/NetworkController.js';
16
17
  export { NftHandler } from './Nfts/NftHandler.js';
@@ -25,14 +26,20 @@ export { TransactionController } from './Transaction/TransactionController.js';
25
26
  export { TransactionGasUtil } from './Transaction/TransactionGasUtil.js';
26
27
  export { generateHistoryEntry, replayHistory, snapshotFromTxMeta } from './Transaction/TransactionStateHistoryHelper.js';
27
28
  export { TransactionStateManager } from './Transaction/TransactionStateManager.js';
28
- export { determineTransactionType, ensureFieldIsString, ensureMutuallyExclusiveFieldsNotProvided, getFinalStates, isEIP1559Transaction, isLegacyTransaction, normalizeAndValidateTxParams, normalizeTxParameters, parseStandardTokenTransactionData, readAddressAsContract, transactionMatchesNetwork, validateFrom, validateRecipient, validateTxParameters } from './Transaction/TransactionUtils.js';
29
- export { erc1155Abi, erc20Abi, erc721Abi, singleBalanceCheckerAbi } from './utils/abis.js';
30
- export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ETH, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID } from './utils/constants.js';
29
+ export { createNestedTransactionMeta, determineTransactionType, ensureFieldIsString, ensureMutuallyExclusiveFieldsNotProvided, getFinalStates, isEIP1559Transaction, isEip7702SetCodeTx, isEip7702UpgradeWithDataToSelfTransaction, isLegacyTransaction, normalizeAndValidateTxParams, normalizeTxParameters, parseStandardTokenTransactionData, readAddressAsContract, transactionMatchesNetwork, validateFrom, validateRecipient, validateTxParameters } from './Transaction/TransactionUtils.js';
30
+ export { erc1155Abi, erc20Abi, erc721Abi, erc7821Abi, singleBalanceCheckerAbi } from './utils/abis.js';
31
+ export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC7821, CONTRACT_TYPE_ETH, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID } from './utils/constants.js';
31
32
  export { addCurrencies, conversionGTE, conversionGreaterThan, conversionLTE, conversionLessThan, conversionMax, conversionUtil, decGWEIToHexWEI, getBigNumber, hexWEIToDecGWEI, multiplyCurrencies, subtractCurrencies, toNegative } from './utils/conversionUtils.js';
33
+ export { EIP5792ErrorCode, EIP_5792_METHODS, Eip5792AtomicStatus, GetCallsStatusCode, SUPPORTED_EIP_5792_VERSIONS } from './utils/eip5792Types.js';
34
+ export { DUMMY_AUTHORIZATION_SIGNATURE, EIP_7702_METHODS, EIP_7702_PREFIX, EIP_7702_REVOKE_ADDRESS } from './utils/eip7702Types.js';
32
35
  export { BNToHex, GAS_LIMITS, addEtherscanTransactions, bnLessThan, formatDate, formatPastTx, formatTime, getChainType, getEthTxStatus, getEtherScanHashLink, getIpfsEndpoint, hexToBn, isAddressByChainId, sanitizeNftMetdataUrl, toChecksumAddressByChainId } from './utils/helpers.js';
36
+ export { TRANSACTION_CATEGORY_EIP7702 } from './utils/interfaces.js';
33
37
  export { BiconomySmartAccount } from './AccountAbstraction/smartAccounts/BiconomySmartAccount.js';
34
38
  export { KernelSmartAccount } from './AccountAbstraction/smartAccounts/KernelSmartAccount.js';
35
39
  export { MetamaskSmartAccount } from './AccountAbstraction/smartAccounts/MetamaskSmartAccount.js';
36
40
  export { NexusSmartAccount } from './AccountAbstraction/smartAccounts/NexusSmartAccount.js';
37
41
  export { SafeSmartAccount } from './AccountAbstraction/smartAccounts/SafeSmartAccount.js';
38
42
  export { TrustSmartAccount } from './AccountAbstraction/smartAccounts/TrustSmartAccount.js';
43
+ export { mapTransactionStatusToEip5792Status, walletGetCallsStatus } from './Eip5792/walletGetCallsStatus.js';
44
+ export { walletGetCapabilities } from './Eip5792/walletGetCapabilities.js';
45
+ export { generateBatchId, processMultipleTransactions, processSingleTransaction, validateSendCallsParams, walletSendCalls } from './Eip5792/walletSendCalls.js';
@@ -501,5 +501,34 @@ const singleBalanceCheckerAbi = [{
501
501
  stateMutability: "view",
502
502
  type: "function"
503
503
  }];
504
+ const erc7821Abi = [{
505
+ type: "function",
506
+ name: "execute",
507
+ inputs: [{
508
+ name: "mode",
509
+ type: "bytes32",
510
+ internalType: "ModeCode"
511
+ }, {
512
+ name: "executionData",
513
+ type: "bytes",
514
+ internalType: "bytes"
515
+ }],
516
+ outputs: [],
517
+ stateMutability: "payable"
518
+ }, {
519
+ type: "function",
520
+ name: "supportsExecutionMode",
521
+ inputs: [{
522
+ name: "mode",
523
+ type: "bytes32",
524
+ internalType: "ModeCode"
525
+ }],
526
+ outputs: [{
527
+ name: "",
528
+ type: "bool",
529
+ internalType: "bool"
530
+ }],
531
+ stateMutability: "view"
532
+ }];
504
533
 
505
- export { erc1155Abi, erc20Abi, erc721Abi, singleBalanceCheckerAbi };
534
+ export { erc1155Abi, erc20Abi, erc721Abi, erc7821Abi, singleBalanceCheckerAbi };
@@ -5,6 +5,7 @@ const CONTRACT_TYPE_ETH = "eth";
5
5
  const CONTRACT_TYPE_ERC20 = "erc20";
6
6
  const CONTRACT_TYPE_ERC721 = "erc721";
7
7
  const CONTRACT_TYPE_ERC1155 = "erc1155";
8
+ const CONTRACT_TYPE_ERC7821 = "erc7821";
8
9
  const ERC1155_INTERFACE_ID = "0xd9b67a26";
9
10
  const ERC721_INTERFACE_ID = "0x80ac58cd";
10
11
  const ERC721_METADATA_INTERFACE_ID = "0x5b5e139f";
@@ -277,7 +278,8 @@ const PAYMASTER_METHOD_TYPES = [METHOD_TYPES.ETH_GET_PAYMASTER_DATA, METHOD_TYPE
277
278
  const TRANSACTION_ENVELOPE_TYPES = {
278
279
  LEGACY: "0x0",
279
280
  ACCESS_LIST: "0x1",
280
- FEE_MARKET: "0x2"
281
+ FEE_MARKET: "0x2",
282
+ SET_CODE: "0x4" // Type 4 transaction
281
283
  };
282
284
  const GAS_ESTIMATE_TYPES = {
283
285
  // Fee Market describes the way gas is set after the london hardfork, and was
@@ -365,4 +367,4 @@ const SMART_ACCOUNT = {
365
367
  METAMASK: "metamask"
366
368
  };
367
369
 
368
- export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ETH, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID };
370
+ export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC7821, CONTRACT_TYPE_ETH, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID };
@@ -0,0 +1,105 @@
1
+ // ============================================================================
2
+ // EIP-5792 Method Names
3
+ // ============================================================================
4
+
5
+ const EIP_5792_METHODS = {
6
+ WALLET_GET_CAPABILITIES: "wallet_getCapabilities",
7
+ WALLET_SEND_CALLS: "wallet_sendCalls",
8
+ WALLET_GET_CALLS_STATUS: "wallet_getCallsStatus",
9
+ WALLET_SHOW_CALLS_STATUS: "wallet_showCallsStatus"
10
+ };
11
+ const SUPPORTED_EIP_5792_VERSIONS = ["1.0", "2.0"];
12
+
13
+ // ============================================================================
14
+ // EIP-5792 Types
15
+ // ============================================================================
16
+
17
+ /**
18
+ * A single call in a batch (EIP-5792)
19
+ */
20
+
21
+ /**
22
+ * Parameters for wallet_sendCalls (EIP-5792)
23
+ */
24
+
25
+ /**
26
+ * Parameters for wallet_getCallsStatus (EIP-5792)
27
+ */
28
+ // batch ID
29
+
30
+ /**
31
+ * Parameters for wallet_showCallsStatus (EIP-5792)
32
+ */
33
+ // batch ID
34
+
35
+ /**
36
+ * Parameters for wallet_getCapabilities (EIP-5792)
37
+ */
38
+
39
+ // [wallet address, supported chains (optional)]
40
+
41
+ const EIP5792ErrorCode = {
42
+ UnsupportedNonOptionalCapability: 5700,
43
+ UnsupportedChainId: 5710,
44
+ UnknownBundleId: 5730,
45
+ RejectedUpgrade: 5750
46
+ };
47
+ const GetCallsStatusCode = {
48
+ PENDING: 100,
49
+ CONFIRMED: 200,
50
+ FAILED_OFFCHAIN: 400,
51
+ REVERTED: 500,
52
+ REVERTED_PARTIAL: 600
53
+ };
54
+
55
+ /**
56
+ * Response for wallet_getCallsStatus (EIP-5792)
57
+ */
58
+
59
+ /**
60
+ * EIP-5792 atomic status (EIP-5792)
61
+ *
62
+ * Reference: https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities
63
+ */
64
+ const Eip5792AtomicStatus = {
65
+ SUPPORTED: "supported",
66
+ READY: "ready",
67
+ UNSUPPORTED: "unsupported"
68
+ };
69
+
70
+ /**
71
+ * Capabilities for a chain (EIP-5792)
72
+ */
73
+
74
+ /**
75
+ * Response for wallet_getCapabilities (EIP-5792)
76
+ */
77
+
78
+ /**
79
+ * Internal representation of a batch of calls
80
+ */
81
+
82
+ /**
83
+ * Function type for getting supported chains
84
+ */
85
+
86
+ /**
87
+ * Function type for getting cached delegations
88
+ */
89
+
90
+ // ============================================================================
91
+ // Batch Transaction Types
92
+ // ============================================================================
93
+
94
+ /**
95
+ * The parameters of a transaction within an atomic batch.
96
+ */
97
+
98
+ /** Metadata for a nested transaction within a standard transaction. */
99
+
100
+ /**
101
+ * Request to submit a batch of transactions.
102
+ * Currently only atomic batches are supported via EIP-7702.
103
+ */
104
+
105
+ export { EIP5792ErrorCode, EIP_5792_METHODS, Eip5792AtomicStatus, GetCallsStatusCode, SUPPORTED_EIP_5792_VERSIONS };
@@ -0,0 +1,15 @@
1
+ const EIP_7702_METHODS = {
2
+ WALLET_UPGRADE_ACCOUNT: "wallet_upgradeAccount",
3
+ WALLET_GET_ACCOUNT_UPGRADE_STATUS: "wallet_getAccountUpgradeStatus"
4
+ };
5
+ const EIP_7702_PREFIX = "0xef0100";
6
+ const EIP_7702_REVOKE_ADDRESS = "0x0000000000000000000000000000000000000000";
7
+ const DUMMY_AUTHORIZATION_SIGNATURE = "0x1111111111111111111111111111111111111111111111111111111111111111";
8
+
9
+ /**
10
+ * An authorization to be included in a `setCode` transaction.
11
+ * Specifies code to be added to the authorization signer's EOA account.
12
+ * Introduced in EIP-7702.
13
+ */
14
+
15
+ export { DUMMY_AUTHORIZATION_SIGNATURE, EIP_7702_METHODS, EIP_7702_PREFIX, EIP_7702_REVOKE_ADDRESS };
@@ -0,0 +1,28 @@
1
+ import '@toruslabs/base-controllers';
2
+
3
+ // Re-export types for backwards compatibility
4
+
5
+ /**
6
+ * Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
7
+ */
8
+
9
+ const TRANSACTION_CATEGORY_EIP7702 = {
10
+ BATCH: "batch",
11
+ REVOKE_DELEGATION: "revokeDelegation"
12
+ };
13
+
14
+ // TODO:// mark fields which will be optional.
15
+
16
+ // use type of function so we don't need to pass in generic to parameter type
17
+
18
+ // use type of function so we don't need to pass in generic to parameter type
19
+
20
+ // use type of function so we don't need to pass in generic to parameter type
21
+
22
+ // use type of function so we don't need to pass in generic to parameter type
23
+
24
+ /**
25
+ * Type Def for function to query the deployment bytecode of an address. (eth_getCode)
26
+ */
27
+
28
+ export { TRANSACTION_CATEGORY_EIP7702 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "8.15.0",
3
+ "version": "8.17.0",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "sideEffects": false,
@@ -20,10 +20,11 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@ethereumjs/common": "^10.1.0",
23
+ "@ethereumjs/rlp": "^10.1.0",
23
24
  "@ethereumjs/tx": "^10.1.0",
24
25
  "@ethereumjs/util": "^10.1.0",
25
26
  "@metamask/smart-accounts-kit": "~0.3.0",
26
- "@toruslabs/base-controllers": "^8.15.0",
27
+ "@toruslabs/base-controllers": "^8.17.0",
27
28
  "@toruslabs/http-helpers": "^8.1.1",
28
29
  "@web3auth/auth": "^10.8.0",
29
30
  "async-mutex": "^0.5.0",
@@ -36,11 +37,12 @@
36
37
  "fast-safe-stringify": "^2.1.1",
37
38
  "jsonschema": "^1.5.0",
38
39
  "loglevel": "^1.9.2",
39
- "permissionless": "^0.3.2"
40
+ "permissionless": "^0.3.4",
41
+ "uuid": "^8.3.2"
40
42
  },
41
43
  "peerDependencies": {
42
44
  "@babel/runtime": "7.x",
43
- "viem": ">=2.23"
45
+ "viem": ">=2.45.0"
44
46
  },
45
47
  "files": [
46
48
  "dist"
@@ -66,9 +68,10 @@
66
68
  "publishConfig": {
67
69
  "access": "public"
68
70
  },
69
- "gitHead": "34e5c37fb5f516e1d5900bbe46c6c879ceb90bd3",
71
+ "gitHead": "8755704edcb1b9a066eb6a045975d72d48e7f2dd",
70
72
  "devDependencies": {
71
73
  "@typechain/ethers-v6": "^0.5.1",
74
+ "@types/uuid": "^10.0.0",
72
75
  "typechain": "^8.3.2"
73
76
  }
74
77
  }