@metamask-previews/transaction-controller 45.0.0-preview-1adbaffc → 45.1.0-preview-1a21f764

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 (86) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/TransactionController.cjs +84 -67
  3. package/dist/TransactionController.cjs.map +1 -1
  4. package/dist/TransactionController.d.cts +22 -17
  5. package/dist/TransactionController.d.cts.map +1 -1
  6. package/dist/TransactionController.d.mts +22 -17
  7. package/dist/TransactionController.d.mts.map +1 -1
  8. package/dist/TransactionController.mjs +83 -66
  9. package/dist/TransactionController.mjs.map +1 -1
  10. package/dist/abi/SimpleDelegateContract.cjs +50 -0
  11. package/dist/abi/SimpleDelegateContract.cjs.map +1 -0
  12. package/dist/abi/SimpleDelegateContract.d.cts +37 -0
  13. package/dist/abi/SimpleDelegateContract.d.cts.map +1 -0
  14. package/dist/abi/SimpleDelegateContract.d.mts +37 -0
  15. package/dist/abi/SimpleDelegateContract.d.mts.map +1 -0
  16. package/dist/abi/SimpleDelegateContract.mjs +47 -0
  17. package/dist/abi/SimpleDelegateContract.mjs.map +1 -0
  18. package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +4 -13
  19. package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -1
  20. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -1
  21. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -1
  22. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +4 -13
  23. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
  24. package/dist/index.cjs +3 -2
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +3 -2
  27. package/dist/index.d.cts.map +1 -1
  28. package/dist/index.d.mts +3 -2
  29. package/dist/index.d.mts.map +1 -1
  30. package/dist/index.mjs +2 -1
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/types.cjs +6 -37
  33. package/dist/types.cjs.map +1 -1
  34. package/dist/types.d.cts +93 -1
  35. package/dist/types.d.cts.map +1 -1
  36. package/dist/types.d.mts +93 -1
  37. package/dist/types.d.mts.map +1 -1
  38. package/dist/types.mjs +6 -37
  39. package/dist/types.mjs.map +1 -1
  40. package/dist/utils/batch.cjs +83 -0
  41. package/dist/utils/batch.cjs.map +1 -0
  42. package/dist/utils/batch.d.cts +32 -0
  43. package/dist/utils/batch.d.cts.map +1 -0
  44. package/dist/utils/batch.d.mts +32 -0
  45. package/dist/utils/batch.d.mts.map +1 -0
  46. package/dist/utils/batch.mjs +78 -0
  47. package/dist/utils/batch.mjs.map +1 -0
  48. package/dist/utils/eip7702.cjs +157 -0
  49. package/dist/utils/eip7702.cjs.map +1 -0
  50. package/dist/utils/eip7702.d.cts +63 -0
  51. package/dist/utils/eip7702.d.cts.map +1 -0
  52. package/dist/utils/eip7702.d.mts +63 -0
  53. package/dist/utils/eip7702.d.mts.map +1 -0
  54. package/dist/utils/eip7702.mjs +150 -0
  55. package/dist/utils/eip7702.mjs.map +1 -0
  56. package/dist/utils/feature-flags.cjs +53 -0
  57. package/dist/utils/feature-flags.cjs.map +1 -0
  58. package/dist/utils/feature-flags.d.cts +34 -0
  59. package/dist/utils/feature-flags.d.cts.map +1 -0
  60. package/dist/utils/feature-flags.d.mts +34 -0
  61. package/dist/utils/feature-flags.d.mts.map +1 -0
  62. package/dist/utils/feature-flags.mjs +47 -0
  63. package/dist/utils/feature-flags.mjs.map +1 -0
  64. package/dist/utils/prepare.cjs +49 -0
  65. package/dist/utils/prepare.cjs.map +1 -0
  66. package/dist/utils/prepare.d.cts +21 -0
  67. package/dist/utils/prepare.d.cts.map +1 -0
  68. package/dist/utils/prepare.d.mts +21 -0
  69. package/dist/utils/prepare.d.mts.map +1 -0
  70. package/dist/utils/prepare.mjs +44 -0
  71. package/dist/utils/prepare.mjs.map +1 -0
  72. package/dist/utils/utils.cjs +3 -8
  73. package/dist/utils/utils.cjs.map +1 -1
  74. package/dist/utils/utils.d.cts.map +1 -1
  75. package/dist/utils/utils.d.mts.map +1 -1
  76. package/dist/utils/utils.mjs +3 -8
  77. package/dist/utils/utils.mjs.map +1 -1
  78. package/dist/utils/validation.cjs +99 -31
  79. package/dist/utils/validation.cjs.map +1 -1
  80. package/dist/utils/validation.d.cts +15 -5
  81. package/dist/utils/validation.d.cts.map +1 -1
  82. package/dist/utils/validation.d.mts +15 -5
  83. package/dist/utils/validation.d.mts.map +1 -1
  84. package/dist/utils/validation.mjs +100 -32
  85. package/dist/utils/validation.mjs.map +1 -1
  86. package/package.json +11 -9
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [45.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add support for EIP-7702 / type 4 transactions ([#5285](https://github.com/MetaMask/core/pull/5285))
15
+ - Add `setCode` to `TransactionEnvelopeType`.
16
+ - Add `authorizationList` to `TransactionParams`.
17
+ - Export `Authorization` and `AuthorizationList` types.
18
+
19
+ ### Changed
20
+
21
+ - The TransactionController messenger must now allow the `KeyringController:signAuthorization` action ([#5285](https://github.com/MetaMask/core/pull/5285))
22
+ - Bump `@metamask/base-controller` from `^7.1.1` to `^8.0.0` ([#5305](https://github.com/MetaMask/core/pull/5305))
23
+ - Bump `ethereumjs/tx` from `^4.2.0` to `^5.4.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
24
+ - Bump `ethereumjs/common` from `^3.2.0` to `^4.5.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
25
+
10
26
  ## [45.0.0]
11
27
 
12
28
  ### Changed
@@ -1261,7 +1277,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1261
1277
 
1262
1278
  All changes listed after this point were applied to this package following the monorepo conversion.
1263
1279
 
1264
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...HEAD
1280
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...HEAD
1281
+ [45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
1265
1282
  [45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
1266
1283
  [44.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.0.0...@metamask/transaction-controller@44.1.0
1267
1284
  [44.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@43.0.0...@metamask/transaction-controller@44.0.0
@@ -13,12 +13,9 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
13
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
- var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionChainIds, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateFirstTimeInteraction, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_updateSubmitHistory;
16
+ var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionChainIds, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateFirstTimeInteraction, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_getInternalAccounts, _TransactionController_updateSubmitHistory;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
19
- const common_1 = require("@ethereumjs/common");
20
- const tx_1 = require("@ethereumjs/tx");
21
- const util_1 = require("@ethereumjs/util");
18
+ exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
22
19
  const base_controller_1 = require("@metamask/base-controller");
23
20
  const controller_utils_1 = require("@metamask/controller-utils");
24
21
  const eth_query_1 = __importDefault(require("@metamask/eth-query"));
@@ -46,6 +43,8 @@ const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.c
46
43
  const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
47
44
  const logger_1 = require("./logger.cjs");
48
45
  const types_1 = require("./types.cjs");
46
+ const batch_1 = require("./utils/batch.cjs");
47
+ const eip7702_1 = require("./utils/eip7702.cjs");
49
48
  const external_transactions_1 = require("./utils/external-transactions.cjs");
50
49
  const gas_1 = require("./utils/gas.cjs");
51
50
  const gas_fees_1 = require("./utils/gas-fees.cjs");
@@ -53,6 +52,7 @@ const gas_flow_1 = require("./utils/gas-flow.cjs");
53
52
  const history_1 = require("./utils/history.cjs");
54
53
  const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
55
54
  const nonce_1 = require("./utils/nonce.cjs");
55
+ const prepare_1 = require("./utils/prepare.cjs");
56
56
  const resimulate_1 = require("./utils/resimulate.cjs");
57
57
  const retry_1 = require("./utils/retry.cjs");
58
58
  const simulation_1 = require("./utils/simulation.cjs");
@@ -82,7 +82,6 @@ const metadata = {
82
82
  anonymous: false,
83
83
  },
84
84
  };
85
- exports.HARDFORK = common_1.Hardfork.London;
86
85
  const SUBMIT_HISTORY_LIMIT = 100;
87
86
  /**
88
87
  * Multiplier used to determine a transaction's increased gas fee during cancellation
@@ -323,6 +322,34 @@ class TransactionController extends base_controller_1.BaseController {
323
322
  async handleMethodData(fourBytePrefix, networkClientId) {
324
323
  return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
325
324
  }
325
+ /**
326
+ * Add a batch of transactions to be submitted after approval.
327
+ *
328
+ * @param request - Request object containing the transactions to add.
329
+ * @returns Result object containing the generated batch ID.
330
+ */
331
+ async addTransactionBatch(request) {
332
+ return await (0, batch_1.addTransactionBatch)({
333
+ addTransaction: this.addTransaction.bind(this),
334
+ getChainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).bind(this),
335
+ getEthQuery: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
336
+ messenger: this.messagingSystem,
337
+ request,
338
+ });
339
+ }
340
+ /**
341
+ * Determine which chains support atomic batch transactions with the given account address.
342
+ *
343
+ * @param address - The address of the account to check.
344
+ * @returns The supported chain IDs.
345
+ */
346
+ async isAtomicBatchSupported(address) {
347
+ return (0, batch_1.isAtomicBatchSupported)({
348
+ address,
349
+ getEthQuery: (chainId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { chainId }),
350
+ messenger: this.messagingSystem,
351
+ });
352
+ }
326
353
  /**
327
354
  * Add a new unapproved transaction to state. Parameters will be validated, a
328
355
  * unique transaction id will be generated, and gas and gasPrice will be calculated
@@ -333,6 +360,7 @@ class TransactionController extends base_controller_1.BaseController {
333
360
  * @param options.actionId - Unique ID to prevent duplicate requests.
334
361
  * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
335
362
  * @param options.method - RPC method that requested the transaction.
363
+ * @param options.nestedTransactions - Params for any nested transactions encoded in the data.
336
364
  * @param options.origin - The origin of the transaction request, such as a dApp hostname.
337
365
  * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
338
366
  * @param options.securityAlertResponse - Response from security validator.
@@ -347,16 +375,26 @@ class TransactionController extends base_controller_1.BaseController {
347
375
  */
348
376
  async addTransaction(txParams, options) {
349
377
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
350
- const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
378
+ const { actionId, deviceConfirmedOn, method, nestedTransactions, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
351
379
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
352
380
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
353
381
  throw new Error(`Network client not found - ${networkClientId}`);
354
382
  }
383
+ const permittedAddresses = origin === undefined
384
+ ? undefined
385
+ : await this.getPermittedAccounts?.(origin);
386
+ const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
387
+ const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
388
+ await (0, validation_1.validateTransactionOrigin)({
389
+ from: txParams.from,
390
+ internalAccounts,
391
+ origin,
392
+ permittedAddresses,
393
+ selectedAddress,
394
+ txParams,
395
+ });
355
396
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
356
397
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
357
- if (origin && this.getPermittedAccounts) {
358
- await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
359
- }
360
398
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
361
399
  const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
362
400
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
@@ -375,6 +413,7 @@ class TransactionController extends base_controller_1.BaseController {
375
413
  deviceConfirmedOn,
376
414
  id: (0, uuid_1.v1)(),
377
415
  isFirstTimeInteraction: undefined,
416
+ nestedTransactions,
378
417
  networkClientId,
379
418
  origin,
380
419
  securityAlertResponse,
@@ -806,12 +845,9 @@ class TransactionController extends base_controller_1.BaseController {
806
845
  }
807
846
  const initialTx = listOfTxParams[0];
808
847
  const { chainId } = initialTx;
809
- const common = this.getCommonConfiguration(chainId);
810
848
  const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
811
- const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
812
- common,
813
- });
814
- const initialTxAsSerializedHex = (0, util_1.bufferToHex)(initialTxAsEthTx.serialize());
849
+ const initialTxAsEthTx = (0, prepare_1.prepareTransaction)(chainId, initialTx);
850
+ const initialTxAsSerializedHex = (0, prepare_1.serializeTransaction)(initialTxAsEthTx);
815
851
  if (this.approvingTransactionIds.has(initialTxAsSerializedHex)) {
816
852
  return '';
817
853
  }
@@ -1025,10 +1061,9 @@ class TransactionController extends base_controller_1.BaseController {
1025
1061
  chainId,
1026
1062
  };
1027
1063
  const { from } = updatedTransactionParams;
1028
- const common = this.getCommonConfiguration(chainId);
1029
- const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
1064
+ const unsignedTransaction = (0, prepare_1.prepareTransaction)(chainId, updatedTransactionParams);
1030
1065
  const signedTransaction = await this.sign(unsignedTransaction, from);
1031
- const rawTransaction = (0, util_1.bufferToHex)(signedTransaction.serialize());
1066
+ const rawTransaction = (0, prepare_1.serializeTransaction)(signedTransaction);
1032
1067
  return rawTransaction;
1033
1068
  }
1034
1069
  /**
@@ -1043,6 +1078,7 @@ class TransactionController extends base_controller_1.BaseController {
1043
1078
  /**
1044
1079
  * Stop the signing process for a specific transaction.
1045
1080
  * Throws an error causing the transaction status to be set to failed.
1081
+ *
1046
1082
  * @param transactionId - The ID of the transaction to stop signing.
1047
1083
  */
1048
1084
  abortTransactionSigning(transactionId) {
@@ -1209,20 +1245,18 @@ class TransactionController extends base_controller_1.BaseController {
1209
1245
  transactionId,
1210
1246
  note: 'TransactionController#approveTransaction - Transaction approved',
1211
1247
  }, (draftTxMeta) => {
1212
- const { txParams, chainId } = draftTxMeta;
1248
+ const { chainId, txParams } = draftTxMeta;
1249
+ const { gas, type } = txParams;
1213
1250
  draftTxMeta.status = types_1.TransactionStatus.approved;
1214
- draftTxMeta.txParams = {
1215
- ...txParams,
1216
- nonce,
1217
- chainId,
1218
- gasLimit: txParams.gas,
1219
- ...((0, utils_2.isEIP1559Transaction)(txParams) && {
1220
- type: types_1.TransactionEnvelopeType.feeMarket,
1221
- }),
1222
- };
1251
+ draftTxMeta.txParams.chainId = chainId;
1252
+ draftTxMeta.txParams.gasLimit = gas;
1253
+ draftTxMeta.txParams.nonce = nonce;
1254
+ if (!type && (0, utils_2.isEIP1559Transaction)(txParams)) {
1255
+ draftTxMeta.txParams.type = types_1.TransactionEnvelopeType.feeMarket;
1256
+ }
1223
1257
  });
1224
1258
  this.onTransactionStatusChange(transactionMeta);
1225
- const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta, transactionMeta.txParams));
1259
+ const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta));
1226
1260
  if (!this.beforePublish(transactionMeta)) {
1227
1261
  (0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
1228
1262
  this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
@@ -1313,10 +1347,7 @@ class TransactionController extends base_controller_1.BaseController {
1313
1347
  status: types_1.TransactionStatus.rejected,
1314
1348
  };
1315
1349
  this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
1316
- __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(
1317
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1318
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1319
- `${transactionMeta.id}:finished`, updatedTransactionMeta);
1350
+ __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
1320
1351
  this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
1321
1352
  transactionMeta: updatedTransactionMeta,
1322
1353
  actionId,
@@ -1344,8 +1375,6 @@ class TransactionController extends base_controller_1.BaseController {
1344
1375
  .filter((tx) => {
1345
1376
  const { chainId, status, txParams, time } = tx;
1346
1377
  if (txParams) {
1347
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1348
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1349
1378
  const key = `${String(txParams.nonce)}-${(0, controller_utils_1.convertHexToDecimal)(chainId)}-${new Date(time).toDateString()}`;
1350
1379
  if (nonceNetworkSet.has(key)) {
1351
1380
  return true;
@@ -1426,29 +1455,6 @@ class TransactionController extends base_controller_1.BaseController {
1426
1455
  const isCompleted = this.isLocalFinalState(transaction.status);
1427
1456
  return { meta: transaction, isCompleted };
1428
1457
  }
1429
- prepareUnsignedEthTx(chainId, txParams) {
1430
- return tx_1.TransactionFactory.fromTxData(txParams, {
1431
- freeze: false,
1432
- common: this.getCommonConfiguration(chainId),
1433
- });
1434
- }
1435
- /**
1436
- * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for
1437
- * specifying which chain, network, hardfork and EIPs to support for
1438
- * a transaction. By referencing this configuration, and analyzing the fields
1439
- * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718
1440
- * transaction type to use.
1441
- *
1442
- * @param chainId - The chainId to use for the configuration.
1443
- * @returns common configuration object
1444
- */
1445
- getCommonConfiguration(chainId) {
1446
- const customChainParams = {
1447
- chainId: parseInt(chainId, 16),
1448
- defaultHardfork: exports.HARDFORK,
1449
- };
1450
- return common_1.Common.custom(customChainParams);
1451
- }
1452
1458
  onIncomingTransactions(transactions) {
1453
1459
  if (!transactions.length) {
1454
1460
  return;
@@ -1617,12 +1623,20 @@ class TransactionController extends base_controller_1.BaseController {
1617
1623
  const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
1618
1624
  return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
1619
1625
  }
1620
- async signTransaction(transactionMeta, txParams) {
1626
+ async signTransaction(transactionMeta) {
1627
+ const { txParams } = transactionMeta;
1621
1628
  (0, logger_1.projectLogger)('Signing transaction', txParams);
1622
- const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, txParams);
1629
+ const { authorizationList, from } = txParams;
1630
+ const finalTxParams = { ...txParams };
1631
+ finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
1632
+ authorizationList,
1633
+ messenger: this.messagingSystem,
1634
+ transactionMeta,
1635
+ });
1636
+ const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
1623
1637
  this.approvingTransactionIds.add(transactionMeta.id);
1624
1638
  const signedTx = await new Promise((resolve, reject) => {
1625
- this.sign?.(unsignedEthTx, txParams.from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
1639
+ this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
1626
1640
  this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
1627
1641
  });
1628
1642
  this.signAbortCallbacks.delete(transactionMeta.id);
@@ -1639,10 +1653,11 @@ class TransactionController extends base_controller_1.BaseController {
1639
1653
  const transactionMetaWithRsv = {
1640
1654
  ...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
1641
1655
  status: types_1.TransactionStatus.signed,
1656
+ txParams: finalTxParams,
1642
1657
  };
1643
1658
  this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
1644
1659
  this.onTransactionStatusChange(transactionMetaWithRsv);
1645
- const rawTx = (0, util_1.bufferToHex)(signedTx.serialize());
1660
+ const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
1646
1661
  const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
1647
1662
  rawTx,
1648
1663
  });
@@ -1738,10 +1753,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1738
1753
  }
1739
1754
  const newTxParams = (0, retry_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
1740
1755
  prepareTransactionParams?.(newTxParams);
1741
- const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, newTxParams);
1756
+ const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, newTxParams);
1742
1757
  const signedTx = await this.sign(unsignedEthTx, transactionMeta.txParams.from);
1743
1758
  const transactionMetaWithRsv = this.updateTransactionMetaRSV(transactionMeta, signedTx);
1744
- const rawTx = (0, util_1.bufferToHex)(signedTx.serialize());
1759
+ const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
1745
1760
  const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
1746
1761
  const oldFee = newTxParams.maxFeePerGas
1747
1762
  ? transactionMetaWithRsv.txParams.maxFeePerGas
@@ -1832,9 +1847,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1832
1847
  return pendingTransactionTracker;
1833
1848
  }, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
1834
1849
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
1835
- }, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
1836
- incomingTransactionHelper.hub.removeAllListeners('transactions');
1837
- incomingTransactionHelper.hub.removeAllListeners('updated-last-fetched-timestamp');
1838
1850
  }, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
1839
1851
  incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
1840
1852
  }, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
@@ -1987,6 +1999,11 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1987
1999
  });
1988
2000
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
1989
2001
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
2002
+ }, _TransactionController_getInternalAccounts = function _TransactionController_getInternalAccounts() {
2003
+ const state = this.messagingSystem.call('AccountsController:getState');
2004
+ return Object.values(state.internalAccounts?.accounts ?? {})
2005
+ .filter((account) => account.type === 'eip155:eoa')
2006
+ .map((account) => account.address);
1990
2007
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
1991
2008
  const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
1992
2009
  const { networkConfigurationsByChainId } = this.getNetworkState();