@metamask/transaction-controller 46.0.0 → 47.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.
Files changed (196) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/TransactionController.cjs +121 -40
  3. package/dist/TransactionController.cjs.map +1 -1
  4. package/dist/TransactionController.d.cts +81 -72
  5. package/dist/TransactionController.d.cts.map +1 -1
  6. package/dist/TransactionController.d.mts +81 -72
  7. package/dist/TransactionController.d.mts.map +1 -1
  8. package/dist/TransactionController.mjs +122 -41
  9. package/dist/TransactionController.mjs.map +1 -1
  10. package/dist/api/accounts-api.cjs +2 -0
  11. package/dist/api/accounts-api.cjs.map +1 -1
  12. package/dist/api/accounts-api.d.cts +2 -0
  13. package/dist/api/accounts-api.d.cts.map +1 -1
  14. package/dist/api/accounts-api.d.mts +2 -0
  15. package/dist/api/accounts-api.d.mts.map +1 -1
  16. package/dist/api/accounts-api.mjs +2 -0
  17. package/dist/api/accounts-api.mjs.map +1 -1
  18. package/dist/constants.cjs +20 -1
  19. package/dist/constants.cjs.map +1 -1
  20. package/dist/constants.d.cts +15 -0
  21. package/dist/constants.d.cts.map +1 -1
  22. package/dist/constants.d.mts +15 -0
  23. package/dist/constants.d.mts.map +1 -1
  24. package/dist/constants.mjs +19 -0
  25. package/dist/constants.mjs.map +1 -1
  26. package/dist/gas-flows/LineaGasFeeFlow.cjs +1 -1
  27. package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -1
  28. package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -1
  29. package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -1
  30. package/dist/gas-flows/LineaGasFeeFlow.mjs +1 -1
  31. package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -1
  32. package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +1 -1
  33. package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -1
  34. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts +1 -1
  35. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -1
  36. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +1 -1
  37. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -1
  38. package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +1 -1
  39. package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -1
  40. package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +1 -1
  41. package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -1
  42. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts +1 -1
  43. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -1
  44. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +1 -1
  45. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -1
  46. package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs +1 -1
  47. package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -1
  48. package/dist/helpers/GasFeePoller.cjs +1 -0
  49. package/dist/helpers/GasFeePoller.cjs.map +1 -1
  50. package/dist/helpers/GasFeePoller.d.cts +1 -0
  51. package/dist/helpers/GasFeePoller.d.cts.map +1 -1
  52. package/dist/helpers/GasFeePoller.d.mts +1 -0
  53. package/dist/helpers/GasFeePoller.d.mts.map +1 -1
  54. package/dist/helpers/GasFeePoller.mjs +1 -0
  55. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  56. package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
  57. package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
  58. package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
  59. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
  60. package/dist/helpers/MethodDataHelper.cjs.map +1 -1
  61. package/dist/helpers/MethodDataHelper.d.cts.map +1 -1
  62. package/dist/helpers/MethodDataHelper.d.mts.map +1 -1
  63. package/dist/helpers/MethodDataHelper.mjs.map +1 -1
  64. package/dist/helpers/MultichainTrackingHelper.cjs +1 -21
  65. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
  66. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
  67. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
  68. package/dist/helpers/MultichainTrackingHelper.mjs +1 -21
  69. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
  70. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
  71. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
  72. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
  73. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
  74. package/dist/helpers/TransactionPoller.cjs +2 -0
  75. package/dist/helpers/TransactionPoller.cjs.map +1 -1
  76. package/dist/helpers/TransactionPoller.d.cts +2 -0
  77. package/dist/helpers/TransactionPoller.d.cts.map +1 -1
  78. package/dist/helpers/TransactionPoller.d.mts +2 -0
  79. package/dist/helpers/TransactionPoller.d.mts.map +1 -1
  80. package/dist/helpers/TransactionPoller.mjs +2 -0
  81. package/dist/helpers/TransactionPoller.mjs.map +1 -1
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.d.cts +1 -1
  84. package/dist/index.d.cts.map +1 -1
  85. package/dist/index.d.mts +1 -1
  86. package/dist/index.d.mts.map +1 -1
  87. package/dist/index.mjs.map +1 -1
  88. package/dist/types.cjs +5 -0
  89. package/dist/types.cjs.map +1 -1
  90. package/dist/types.d.cts +51 -0
  91. package/dist/types.d.cts.map +1 -1
  92. package/dist/types.d.mts +51 -0
  93. package/dist/types.d.mts.map +1 -1
  94. package/dist/types.mjs +5 -0
  95. package/dist/types.mjs.map +1 -1
  96. package/dist/utils/batch.cjs +89 -0
  97. package/dist/utils/batch.cjs.map +1 -0
  98. package/dist/utils/batch.d.cts +33 -0
  99. package/dist/utils/batch.d.cts.map +1 -0
  100. package/dist/utils/batch.d.mts +33 -0
  101. package/dist/utils/batch.d.mts.map +1 -0
  102. package/dist/utils/batch.mjs +84 -0
  103. package/dist/utils/batch.mjs.map +1 -0
  104. package/dist/utils/eip7702.cjs +84 -2
  105. package/dist/utils/eip7702.cjs.map +1 -1
  106. package/dist/utils/eip7702.d.cts +35 -10
  107. package/dist/utils/eip7702.d.cts.map +1 -1
  108. package/dist/utils/eip7702.d.mts +35 -10
  109. package/dist/utils/eip7702.d.mts.map +1 -1
  110. package/dist/utils/eip7702.mjs +82 -3
  111. package/dist/utils/eip7702.mjs.map +1 -1
  112. package/dist/utils/feature-flags.cjs +53 -0
  113. package/dist/utils/feature-flags.cjs.map +1 -0
  114. package/dist/utils/feature-flags.d.cts +39 -0
  115. package/dist/utils/feature-flags.d.cts.map +1 -0
  116. package/dist/utils/feature-flags.d.mts +39 -0
  117. package/dist/utils/feature-flags.d.mts.map +1 -0
  118. package/dist/utils/feature-flags.mjs +47 -0
  119. package/dist/utils/feature-flags.mjs.map +1 -0
  120. package/dist/utils/gas-fees.cjs +48 -3
  121. package/dist/utils/gas-fees.cjs.map +1 -1
  122. package/dist/utils/gas-fees.d.cts +11 -0
  123. package/dist/utils/gas-fees.d.cts.map +1 -1
  124. package/dist/utils/gas-fees.d.mts +11 -0
  125. package/dist/utils/gas-fees.d.mts.map +1 -1
  126. package/dist/utils/gas-fees.mjs +48 -3
  127. package/dist/utils/gas-fees.mjs.map +1 -1
  128. package/dist/utils/gas-flow.cjs +4 -0
  129. package/dist/utils/gas-flow.cjs.map +1 -1
  130. package/dist/utils/gas-flow.d.cts +1 -0
  131. package/dist/utils/gas-flow.d.cts.map +1 -1
  132. package/dist/utils/gas-flow.d.mts +1 -0
  133. package/dist/utils/gas-flow.d.mts.map +1 -1
  134. package/dist/utils/gas-flow.mjs +4 -0
  135. package/dist/utils/gas-flow.mjs.map +1 -1
  136. package/dist/utils/gas.cjs +50 -1
  137. package/dist/utils/gas.cjs.map +1 -1
  138. package/dist/utils/gas.d.cts +22 -0
  139. package/dist/utils/gas.d.cts.map +1 -1
  140. package/dist/utils/gas.d.mts +22 -0
  141. package/dist/utils/gas.d.mts.map +1 -1
  142. package/dist/utils/gas.mjs +50 -1
  143. package/dist/utils/gas.mjs.map +1 -1
  144. package/dist/utils/layer1-gas-fee-flow.cjs +5 -1
  145. package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -1
  146. package/dist/utils/layer1-gas-fee-flow.d.cts +4 -1
  147. package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -1
  148. package/dist/utils/layer1-gas-fee-flow.d.mts +4 -1
  149. package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -1
  150. package/dist/utils/layer1-gas-fee-flow.mjs +5 -1
  151. package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
  152. package/dist/utils/retry.cjs +4 -0
  153. package/dist/utils/retry.cjs.map +1 -1
  154. package/dist/utils/retry.d.cts +1 -0
  155. package/dist/utils/retry.d.cts.map +1 -1
  156. package/dist/utils/retry.d.mts +1 -0
  157. package/dist/utils/retry.d.mts.map +1 -1
  158. package/dist/utils/retry.mjs +4 -0
  159. package/dist/utils/retry.mjs.map +1 -1
  160. package/dist/utils/simulation-api.cjs +6 -0
  161. package/dist/utils/simulation-api.cjs.map +1 -1
  162. package/dist/utils/simulation-api.d.cts +2 -0
  163. package/dist/utils/simulation-api.d.cts.map +1 -1
  164. package/dist/utils/simulation-api.d.mts +2 -0
  165. package/dist/utils/simulation-api.d.mts.map +1 -1
  166. package/dist/utils/simulation-api.mjs +6 -0
  167. package/dist/utils/simulation-api.mjs.map +1 -1
  168. package/dist/utils/simulation.cjs +19 -5
  169. package/dist/utils/simulation.cjs.map +1 -1
  170. package/dist/utils/simulation.d.cts +3 -1
  171. package/dist/utils/simulation.d.cts.map +1 -1
  172. package/dist/utils/simulation.d.mts +3 -1
  173. package/dist/utils/simulation.d.mts.map +1 -1
  174. package/dist/utils/simulation.mjs +19 -5
  175. package/dist/utils/simulation.mjs.map +1 -1
  176. package/dist/utils/swaps.cjs +2 -1
  177. package/dist/utils/swaps.cjs.map +1 -1
  178. package/dist/utils/swaps.d.cts +1 -0
  179. package/dist/utils/swaps.d.cts.map +1 -1
  180. package/dist/utils/swaps.d.mts +1 -0
  181. package/dist/utils/swaps.d.mts.map +1 -1
  182. package/dist/utils/swaps.mjs +2 -1
  183. package/dist/utils/swaps.mjs.map +1 -1
  184. package/dist/utils/transaction-type.cjs +3 -1
  185. package/dist/utils/transaction-type.cjs.map +1 -1
  186. package/dist/utils/transaction-type.mjs +3 -1
  187. package/dist/utils/transaction-type.mjs.map +1 -1
  188. package/dist/utils/validation.cjs +34 -5
  189. package/dist/utils/validation.cjs.map +1 -1
  190. package/dist/utils/validation.d.cts +19 -3
  191. package/dist/utils/validation.d.cts.map +1 -1
  192. package/dist/utils/validation.d.mts +19 -3
  193. package/dist/utils/validation.d.mts.map +1 -1
  194. package/dist/utils/validation.mjs +33 -5
  195. package/dist/utils/validation.mjs.map +1 -1
  196. package/package.json +7 -5
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [47.0.0]
11
+
12
+ ### Added
13
+
14
+ - Persist user rejection optional data in rejected error ([#5355](https://github.com/MetaMask/core/pull/5355))
15
+ - Add `updateAtomicBatchData` method ([#5380](https://github.com/MetaMask/core/pull/5380))
16
+ - Support atomic batch transactions ([#5306](https://github.com/MetaMask/core/pull/5306))
17
+ - Add methods:
18
+ - `addTransactionBatch`
19
+ - `isAtomicBatchSupported`
20
+ - Add `batch` to `TransactionType`.
21
+ - Add `nestedTransactions` to `TransactionMeta`.
22
+ - Add new types:
23
+ - `BatchTransactionParams`
24
+ - `TransactionBatchSingleRequest`
25
+ - `TransactionBatchRequest`
26
+ - `TransactionBatchResult`
27
+ - Add dependency on `@metamask/remote-feature-flag-controller:^1.4.0`.
28
+
29
+ ### Changed
30
+
31
+ - **BREAKING:** Bump `@metamask/accounts-controller` peer dependency to `^25.0.0` ([#5426](https://github.com/MetaMask/core/pull/5426))
32
+ - **BREAKING**: Require messenger permissions for `KeyringController:signEip7702Authorization` action ([#5410](https://github.com/MetaMask/core/pull/5410))
33
+ - **BREAKING:** Support atomic batch transactions ([#5306](https://github.com/MetaMask/core/pull/5306))
34
+ - Require `AccountsController:getState` action permission in messenger.
35
+ - Require `RemoteFeatureFlagController:getState` action permission in messenger.
36
+ - Bump `@metamask/utils` from `^11.1.0` to `^11.2.0` ([#5301](https://github.com/MetaMask/core/pull/5301))
37
+ - Throw if `addTransactionBatch` is called with any nested transaction with `to` matching internal account ([#5369](https://github.com/MetaMask/core/pull/5369))
38
+
10
39
  ## [46.0.0]
11
40
 
12
41
  ### Added
@@ -1290,7 +1319,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1290
1319
 
1291
1320
  All changes listed after this point were applied to this package following the monorepo conversion.
1292
1321
 
1293
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@46.0.0...HEAD
1322
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@47.0.0...HEAD
1323
+ [47.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@46.0.0...@metamask/transaction-controller@47.0.0
1294
1324
  [46.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...@metamask/transaction-controller@46.0.0
1295
1325
  [45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
1296
1326
  [45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
@@ -13,7 +13,7 @@ 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_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, _TransactionController_updateGasEstimate;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
19
19
  const base_controller_1 = require("@metamask/base-controller");
@@ -44,6 +44,7 @@ const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker
44
44
  const ResimulateHelper_1 = require("./helpers/ResimulateHelper.cjs");
45
45
  const logger_1 = require("./logger.cjs");
46
46
  const types_1 = require("./types.cjs");
47
+ const batch_1 = require("./utils/batch.cjs");
47
48
  const eip7702_1 = require("./utils/eip7702.cjs");
48
49
  const external_transactions_1 = require("./utils/external-transactions.cjs");
49
50
  const gas_1 = require("./utils/gas.cjs");
@@ -153,31 +154,9 @@ class TransactionController extends base_controller_1.BaseController {
153
154
  * Constructs a TransactionController.
154
155
  *
155
156
  * @param options - The controller options.
156
- * @param options.disableHistory - Whether to disable storing history in transaction metadata.
157
- * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
158
- * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
159
- * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
160
- * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
161
- * @param options.getExternalPendingTransactions - Callback to retrieve pending transactions from external sources.
162
- * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
163
- * @param options.getNetworkClientRegistry - Gets the network client registry.
164
- * @param options.getNetworkState - Gets the state of the network controller.
165
- * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
166
- * @param options.getSavedGasFees - Gets the saved gas fee config.
167
- * @param options.incomingTransactions - Configuration options for incoming transaction support.
168
- * @param options.isFirstTimeInteractionEnabled - Whether first time interaction checks are enabled.
169
- * @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
170
- * @param options.messenger - The controller messenger.
171
- * @param options.pendingTransactions - Configuration options for pending transaction support.
172
- * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
173
- * @param options.sign - Function used to sign transactions.
174
- * @param options.state - Initial state to set on this controller.
175
- * @param options.testGasFeeFlows - Whether to use the test gas fee flow.
176
- * @param options.trace - Callback to generate trace information.
177
- * @param options.transactionHistoryLimit - Transaction history limit.
178
- * @param options.hooks - The controller hooks.
179
157
  */
180
- constructor({ disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
158
+ constructor(options) {
159
+ const { disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, } = options;
181
160
  super({
182
161
  name: controllerName,
183
162
  metadata,
@@ -328,6 +307,35 @@ class TransactionController extends base_controller_1.BaseController {
328
307
  async handleMethodData(fourBytePrefix, networkClientId) {
329
308
  return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
330
309
  }
310
+ /**
311
+ * Add a batch of transactions to be submitted after approval.
312
+ *
313
+ * @param request - Request object containing the transactions to add.
314
+ * @returns Result object containing the generated batch ID.
315
+ */
316
+ async addTransactionBatch(request) {
317
+ return await (0, batch_1.addTransactionBatch)({
318
+ addTransaction: this.addTransaction.bind(this),
319
+ getChainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).bind(this),
320
+ getEthQuery: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
321
+ getInternalAccounts: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).bind(this),
322
+ messenger: this.messagingSystem,
323
+ request,
324
+ });
325
+ }
326
+ /**
327
+ * Determine which chains support atomic batch transactions with the given account address.
328
+ *
329
+ * @param address - The address of the account to check.
330
+ * @returns The supported chain IDs.
331
+ */
332
+ async isAtomicBatchSupported(address) {
333
+ return (0, batch_1.isAtomicBatchSupported)({
334
+ address,
335
+ getEthQuery: (chainId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { chainId }),
336
+ messenger: this.messagingSystem,
337
+ });
338
+ }
331
339
  /**
332
340
  * Add a new unapproved transaction to state. Parameters will be validated, a
333
341
  * unique transaction id will be generated, and gas and gasPrice will be calculated
@@ -338,6 +346,7 @@ class TransactionController extends base_controller_1.BaseController {
338
346
  * @param options.actionId - Unique ID to prevent duplicate requests.
339
347
  * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
340
348
  * @param options.method - RPC method that requested the transaction.
349
+ * @param options.nestedTransactions - Params for any nested transactions encoded in the data.
341
350
  * @param options.origin - The origin of the transaction request, such as a dApp hostname.
342
351
  * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
343
352
  * @param options.securityAlertResponse - Response from security validator.
@@ -352,7 +361,7 @@ class TransactionController extends base_controller_1.BaseController {
352
361
  */
353
362
  async addTransaction(txParams, options) {
354
363
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
355
- const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
364
+ const { actionId, deviceConfirmedOn, method, nestedTransactions, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
356
365
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
357
366
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
358
367
  throw new Error(`Network client not found - ${networkClientId}`);
@@ -361,12 +370,15 @@ class TransactionController extends base_controller_1.BaseController {
361
370
  ? undefined
362
371
  : await this.getPermittedAccounts?.(origin);
363
372
  const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
373
+ const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
364
374
  await (0, validation_1.validateTransactionOrigin)({
365
375
  from: txParams.from,
376
+ internalAccounts,
366
377
  origin,
367
378
  permittedAddresses,
368
379
  selectedAddress,
369
380
  txParams,
381
+ type,
370
382
  });
371
383
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
372
384
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
@@ -388,6 +400,7 @@ class TransactionController extends base_controller_1.BaseController {
388
400
  deviceConfirmedOn,
389
401
  id: (0, uuid_1.v1)(),
390
402
  isFirstTimeInteraction: undefined,
403
+ nestedTransactions,
391
404
  networkClientId,
392
405
  origin,
393
406
  securityAlertResponse,
@@ -478,7 +491,7 @@ class TransactionController extends base_controller_1.BaseController {
478
491
  * @param options.estimatedBaseFee - The estimated base fee of the transaction.
479
492
  */
480
493
  async stopTransaction(transactionId, gasValues, { estimatedBaseFee, actionId, } = {}) {
481
- return await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
494
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
482
495
  actionId,
483
496
  estimatedBaseFee,
484
497
  gasValues,
@@ -507,7 +520,7 @@ class TransactionController extends base_controller_1.BaseController {
507
520
  * @param options.estimatedBaseFee - The estimated base fee of the transaction.
508
521
  */
509
522
  async speedUpTransaction(transactionId, gasValues, { actionId, estimatedBaseFee, } = {}) {
510
- return await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
523
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
511
524
  actionId,
512
525
  estimatedBaseFee,
513
526
  gasValues,
@@ -540,6 +553,7 @@ class TransactionController extends base_controller_1.BaseController {
540
553
  * @param transaction - The transaction params to estimate gas for.
541
554
  * @param multiplier - The multiplier to use for the gas buffer.
542
555
  * @param networkClientId - The network client id to use for the estimate.
556
+ * @returns The buffered estimated gas and whether the estimation failed.
543
557
  */
544
558
  async estimateGasBuffered(transaction, multiplier, networkClientId) {
545
559
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
@@ -1026,6 +1040,7 @@ class TransactionController extends base_controller_1.BaseController {
1026
1040
  * @param request.transactionParams - The transaction parameters to estimate the layer 1 gas fee for.
1027
1041
  * @param request.chainId - The ID of the chain where the transaction will be executed.
1028
1042
  * @param request.networkClientId - The ID of a specific network client to process the transaction.
1043
+ * @returns The layer 1 gas fee.
1029
1044
  */
1030
1045
  async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
1031
1046
  const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
@@ -1088,6 +1103,54 @@ class TransactionController extends base_controller_1.BaseController {
1088
1103
  abortCallback();
1089
1104
  this.signAbortCallbacks.delete(transactionId);
1090
1105
  }
1106
+ /**
1107
+ * Update the transaction data of a single nested transaction within an atomic batch transaction.
1108
+ *
1109
+ * @param options - The options bag.
1110
+ * @param options.transactionId - ID of the atomic batch transaction.
1111
+ * @param options.transactionIndex - Index of the nested transaction within the atomic batch transaction.
1112
+ * @param options.transactionData - New data to set for the nested transaction.
1113
+ * @returns The updated data for the atomic batch transaction.
1114
+ */
1115
+ async updateAtomicBatchData({ transactionId, transactionIndex, transactionData, }) {
1116
+ (0, logger_1.projectLogger)('Updating atomic batch data', {
1117
+ transactionId,
1118
+ transactionIndex,
1119
+ transactionData,
1120
+ });
1121
+ const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
1122
+ transactionId,
1123
+ note: 'TransactionController#updateAtomicBatchData - Atomic batch data updated',
1124
+ }, (transactionMeta) => {
1125
+ const { nestedTransactions, txParams } = transactionMeta;
1126
+ const from = txParams.from;
1127
+ const nestedTransaction = nestedTransactions?.[transactionIndex];
1128
+ if (!nestedTransaction) {
1129
+ throw new Error(`Nested transaction not found with index - ${transactionIndex}`);
1130
+ }
1131
+ nestedTransaction.data = transactionData;
1132
+ const batchTransaction = (0, eip7702_1.generateEIP7702BatchTransaction)(from, nestedTransactions);
1133
+ transactionMeta.txParams.data = batchTransaction.data;
1134
+ });
1135
+ const draftTransaction = (0, lodash_1.cloneDeep)({
1136
+ ...updatedTransactionMeta,
1137
+ txParams: {
1138
+ ...updatedTransactionMeta.txParams,
1139
+ // Clear existing gas to force estimation
1140
+ gas: undefined,
1141
+ },
1142
+ });
1143
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasEstimate).call(this, draftTransaction);
1144
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
1145
+ transactionId,
1146
+ note: 'TransactionController#updateAtomicBatchData - Gas estimate updated',
1147
+ }, (transactionMeta) => {
1148
+ transactionMeta.txParams.gas = draftTransaction.txParams.gas;
1149
+ transactionMeta.simulationFails = draftTransaction.simulationFails;
1150
+ transactionMeta.gasLimitNoBuffer = draftTransaction.gasLimitNoBuffer;
1151
+ });
1152
+ return updatedTransactionMeta.txParams.data;
1153
+ }
1091
1154
  addMetadata(transactionMeta) {
1092
1155
  (0, validation_1.validateTxParams)(transactionMeta.txParams);
1093
1156
  this.update((state) => {
@@ -1100,18 +1163,11 @@ class TransactionController extends base_controller_1.BaseController {
1100
1163
  async updateGasProperties(transactionMeta, { traceContext } = {}) {
1101
1164
  const isEIP1559Compatible = transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy &&
1102
1165
  (await this.getEIP1559Compatibility(transactionMeta.networkClientId));
1103
- const { networkClientId, chainId } = transactionMeta;
1104
- const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1105
- .configuration.type === network_controller_1.NetworkClientType.Custom;
1166
+ const { networkClientId } = transactionMeta;
1106
1167
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1107
1168
  const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
1108
1169
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
1109
- await (0, gas_1.updateGas)({
1110
- ethQuery,
1111
- chainId,
1112
- isCustomNetwork,
1113
- txMeta: transactionMeta,
1114
- });
1170
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasEstimate).call(this, transactionMeta);
1115
1171
  });
1116
1172
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas Fees', parentContext: traceContext }, async () => await (0, gas_fees_1.updateGasFees)({
1117
1173
  eip1559: isEIP1559Compatible,
@@ -1183,7 +1239,10 @@ class TransactionController extends base_controller_1.BaseController {
1183
1239
  if (!isTxCompleted) {
1184
1240
  if (error?.code === rpc_errors_1.errorCodes.provider.userRejectedRequest) {
1185
1241
  this.cancelTransaction(transactionId, actionId);
1186
- throw rpc_errors_1.providerErrors.userRejectedRequest('MetaMask Tx Signature: User denied transaction signature.');
1242
+ throw rpc_errors_1.providerErrors.userRejectedRequest({
1243
+ message: 'MetaMask Tx Signature: User denied transaction signature.',
1244
+ data: error?.data,
1245
+ });
1187
1246
  }
1188
1247
  else {
1189
1248
  this.failTransaction(meta, error, actionId);
@@ -1213,6 +1272,7 @@ class TransactionController extends base_controller_1.BaseController {
1213
1272
  *
1214
1273
  * @param transactionId - The ID of the transaction to approve.
1215
1274
  * @param traceContext - The parent context for any new traces.
1275
+ * @returns The state of the approval.
1216
1276
  */
1217
1277
  async approveTransaction(transactionId, traceContext) {
1218
1278
  const cleanupTasks = new Array();
@@ -1251,7 +1311,7 @@ class TransactionController extends base_controller_1.BaseController {
1251
1311
  }
1252
1312
  });
1253
1313
  this.onTransactionStatusChange(transactionMeta);
1254
- const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta, transactionMeta.txParams));
1314
+ const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta));
1255
1315
  if (!this.beforePublish(transactionMeta)) {
1256
1316
  (0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
1257
1317
  this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
@@ -1618,7 +1678,8 @@ class TransactionController extends base_controller_1.BaseController {
1618
1678
  const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
1619
1679
  return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
1620
1680
  }
1621
- async signTransaction(transactionMeta, txParams) {
1681
+ async signTransaction(transactionMeta) {
1682
+ const { txParams } = transactionMeta;
1622
1683
  (0, logger_1.projectLogger)('Signing transaction', txParams);
1623
1684
  const { authorizationList, from } = txParams;
1624
1685
  const finalTxParams = { ...txParams };
@@ -1647,6 +1708,7 @@ class TransactionController extends base_controller_1.BaseController {
1647
1708
  const transactionMetaWithRsv = {
1648
1709
  ...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
1649
1710
  status: types_1.TransactionStatus.signed,
1711
+ txParams: finalTxParams,
1650
1712
  };
1651
1713
  this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
1652
1714
  this.onTransactionStatusChange(transactionMetaWithRsv);
@@ -1867,6 +1929,9 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1867
1929
  let resimulateResponse;
1868
1930
  this.update((state) => {
1869
1931
  const index = state.transactions.findIndex(({ id }) => id === transactionId);
1932
+ if (index === -1) {
1933
+ throw new Error(`Cannot update transaction as ID not found - ${transactionId}`);
1934
+ }
1870
1935
  let transactionMeta = state.transactions[index];
1871
1936
  const originalTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
1872
1937
  transactionMeta = callback(transactionMeta) ?? transactionMeta;
@@ -1992,6 +2057,11 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1992
2057
  });
1993
2058
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
1994
2059
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
2060
+ }, _TransactionController_getInternalAccounts = function _TransactionController_getInternalAccounts() {
2061
+ const state = this.messagingSystem.call('AccountsController:getState');
2062
+ return Object.values(state.internalAccounts?.accounts ?? {})
2063
+ .filter((account) => account.type === 'eip155:eoa')
2064
+ .map((account) => account.address);
1995
2065
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
1996
2066
  const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
1997
2067
  const { networkConfigurationsByChainId } = this.getNetworkState();
@@ -2017,5 +2087,16 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
2017
2087
  }
2018
2088
  submitHistory.unshift(submitHistoryEntry);
2019
2089
  });
2090
+ }, _TransactionController_updateGasEstimate = async function _TransactionController_updateGasEstimate(transactionMeta) {
2091
+ const { chainId, networkClientId } = transactionMeta;
2092
+ const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
2093
+ .configuration.type === network_controller_1.NetworkClientType.Custom;
2094
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
2095
+ await (0, gas_1.updateGas)({
2096
+ chainId,
2097
+ ethQuery,
2098
+ isCustomNetwork,
2099
+ txMeta: transactionMeta,
2100
+ });
2020
2101
  };
2021
2102
  //# sourceMappingURL=TransactionController.cjs.map