@metamask/transaction-controller 45.1.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 (208) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/dist/TransactionController.cjs +152 -43
  3. package/dist/TransactionController.cjs.map +1 -1
  4. package/dist/TransactionController.d.cts +88 -72
  5. package/dist/TransactionController.d.cts.map +1 -1
  6. package/dist/TransactionController.d.mts +88 -72
  7. package/dist/TransactionController.d.mts.map +1 -1
  8. package/dist/TransactionController.mjs +151 -42
  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/{utils/resimulate.cjs → helpers/ResimulateHelper.cjs} +93 -4
  75. package/dist/helpers/ResimulateHelper.cjs.map +1 -0
  76. package/dist/{utils/resimulate.d.cts → helpers/ResimulateHelper.d.cts} +13 -1
  77. package/dist/helpers/ResimulateHelper.d.cts.map +1 -0
  78. package/dist/{utils/resimulate.d.mts → helpers/ResimulateHelper.d.mts} +13 -1
  79. package/dist/helpers/ResimulateHelper.d.mts.map +1 -0
  80. package/dist/{utils/resimulate.mjs → helpers/ResimulateHelper.mjs} +93 -5
  81. package/dist/helpers/ResimulateHelper.mjs.map +1 -0
  82. package/dist/helpers/TransactionPoller.cjs +2 -0
  83. package/dist/helpers/TransactionPoller.cjs.map +1 -1
  84. package/dist/helpers/TransactionPoller.d.cts +2 -0
  85. package/dist/helpers/TransactionPoller.d.cts.map +1 -1
  86. package/dist/helpers/TransactionPoller.d.mts +2 -0
  87. package/dist/helpers/TransactionPoller.d.mts.map +1 -1
  88. package/dist/helpers/TransactionPoller.mjs +2 -0
  89. package/dist/helpers/TransactionPoller.mjs.map +1 -1
  90. package/dist/index.cjs.map +1 -1
  91. package/dist/index.d.cts +1 -1
  92. package/dist/index.d.cts.map +1 -1
  93. package/dist/index.d.mts +1 -1
  94. package/dist/index.d.mts.map +1 -1
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/types.cjs +5 -0
  97. package/dist/types.cjs.map +1 -1
  98. package/dist/types.d.cts +55 -0
  99. package/dist/types.d.cts.map +1 -1
  100. package/dist/types.d.mts +55 -0
  101. package/dist/types.d.mts.map +1 -1
  102. package/dist/types.mjs +5 -0
  103. package/dist/types.mjs.map +1 -1
  104. package/dist/utils/batch.cjs +89 -0
  105. package/dist/utils/batch.cjs.map +1 -0
  106. package/dist/utils/batch.d.cts +33 -0
  107. package/dist/utils/batch.d.cts.map +1 -0
  108. package/dist/utils/batch.d.mts +33 -0
  109. package/dist/utils/batch.d.mts.map +1 -0
  110. package/dist/utils/batch.mjs +84 -0
  111. package/dist/utils/batch.mjs.map +1 -0
  112. package/dist/utils/eip7702.cjs +84 -2
  113. package/dist/utils/eip7702.cjs.map +1 -1
  114. package/dist/utils/eip7702.d.cts +35 -10
  115. package/dist/utils/eip7702.d.cts.map +1 -1
  116. package/dist/utils/eip7702.d.mts +35 -10
  117. package/dist/utils/eip7702.d.mts.map +1 -1
  118. package/dist/utils/eip7702.mjs +82 -3
  119. package/dist/utils/eip7702.mjs.map +1 -1
  120. package/dist/utils/feature-flags.cjs +53 -0
  121. package/dist/utils/feature-flags.cjs.map +1 -0
  122. package/dist/utils/feature-flags.d.cts +39 -0
  123. package/dist/utils/feature-flags.d.cts.map +1 -0
  124. package/dist/utils/feature-flags.d.mts +39 -0
  125. package/dist/utils/feature-flags.d.mts.map +1 -0
  126. package/dist/utils/feature-flags.mjs +47 -0
  127. package/dist/utils/feature-flags.mjs.map +1 -0
  128. package/dist/utils/gas-fees.cjs +48 -3
  129. package/dist/utils/gas-fees.cjs.map +1 -1
  130. package/dist/utils/gas-fees.d.cts +11 -0
  131. package/dist/utils/gas-fees.d.cts.map +1 -1
  132. package/dist/utils/gas-fees.d.mts +11 -0
  133. package/dist/utils/gas-fees.d.mts.map +1 -1
  134. package/dist/utils/gas-fees.mjs +48 -3
  135. package/dist/utils/gas-fees.mjs.map +1 -1
  136. package/dist/utils/gas-flow.cjs +4 -0
  137. package/dist/utils/gas-flow.cjs.map +1 -1
  138. package/dist/utils/gas-flow.d.cts +1 -0
  139. package/dist/utils/gas-flow.d.cts.map +1 -1
  140. package/dist/utils/gas-flow.d.mts +1 -0
  141. package/dist/utils/gas-flow.d.mts.map +1 -1
  142. package/dist/utils/gas-flow.mjs +4 -0
  143. package/dist/utils/gas-flow.mjs.map +1 -1
  144. package/dist/utils/gas.cjs +50 -1
  145. package/dist/utils/gas.cjs.map +1 -1
  146. package/dist/utils/gas.d.cts +22 -0
  147. package/dist/utils/gas.d.cts.map +1 -1
  148. package/dist/utils/gas.d.mts +22 -0
  149. package/dist/utils/gas.d.mts.map +1 -1
  150. package/dist/utils/gas.mjs +50 -1
  151. package/dist/utils/gas.mjs.map +1 -1
  152. package/dist/utils/layer1-gas-fee-flow.cjs +5 -1
  153. package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -1
  154. package/dist/utils/layer1-gas-fee-flow.d.cts +4 -1
  155. package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -1
  156. package/dist/utils/layer1-gas-fee-flow.d.mts +4 -1
  157. package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -1
  158. package/dist/utils/layer1-gas-fee-flow.mjs +5 -1
  159. package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
  160. package/dist/utils/retry.cjs +4 -0
  161. package/dist/utils/retry.cjs.map +1 -1
  162. package/dist/utils/retry.d.cts +1 -0
  163. package/dist/utils/retry.d.cts.map +1 -1
  164. package/dist/utils/retry.d.mts +1 -0
  165. package/dist/utils/retry.d.mts.map +1 -1
  166. package/dist/utils/retry.mjs +4 -0
  167. package/dist/utils/retry.mjs.map +1 -1
  168. package/dist/utils/simulation-api.cjs +6 -0
  169. package/dist/utils/simulation-api.cjs.map +1 -1
  170. package/dist/utils/simulation-api.d.cts +2 -0
  171. package/dist/utils/simulation-api.d.cts.map +1 -1
  172. package/dist/utils/simulation-api.d.mts +2 -0
  173. package/dist/utils/simulation-api.d.mts.map +1 -1
  174. package/dist/utils/simulation-api.mjs +6 -0
  175. package/dist/utils/simulation-api.mjs.map +1 -1
  176. package/dist/utils/simulation.cjs +19 -5
  177. package/dist/utils/simulation.cjs.map +1 -1
  178. package/dist/utils/simulation.d.cts +3 -1
  179. package/dist/utils/simulation.d.cts.map +1 -1
  180. package/dist/utils/simulation.d.mts +3 -1
  181. package/dist/utils/simulation.d.mts.map +1 -1
  182. package/dist/utils/simulation.mjs +19 -5
  183. package/dist/utils/simulation.mjs.map +1 -1
  184. package/dist/utils/swaps.cjs +2 -1
  185. package/dist/utils/swaps.cjs.map +1 -1
  186. package/dist/utils/swaps.d.cts +1 -0
  187. package/dist/utils/swaps.d.cts.map +1 -1
  188. package/dist/utils/swaps.d.mts +1 -0
  189. package/dist/utils/swaps.d.mts.map +1 -1
  190. package/dist/utils/swaps.mjs +2 -1
  191. package/dist/utils/swaps.mjs.map +1 -1
  192. package/dist/utils/transaction-type.cjs +3 -1
  193. package/dist/utils/transaction-type.cjs.map +1 -1
  194. package/dist/utils/transaction-type.mjs +3 -1
  195. package/dist/utils/transaction-type.mjs.map +1 -1
  196. package/dist/utils/validation.cjs +34 -5
  197. package/dist/utils/validation.cjs.map +1 -1
  198. package/dist/utils/validation.d.cts +19 -3
  199. package/dist/utils/validation.d.cts.map +1 -1
  200. package/dist/utils/validation.d.mts +19 -3
  201. package/dist/utils/validation.d.mts.map +1 -1
  202. package/dist/utils/validation.mjs +33 -5
  203. package/dist/utils/validation.mjs.map +1 -1
  204. package/package.json +7 -5
  205. package/dist/utils/resimulate.cjs.map +0 -1
  206. package/dist/utils/resimulate.d.cts.map +0 -1
  207. package/dist/utils/resimulate.d.mts.map +0 -1
  208. package/dist/utils/resimulate.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,48 @@ 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
+
39
+ ## [46.0.0]
40
+
41
+ ### Added
42
+
43
+ - Adds ability of re-simulating transaction depending on the `isActive` property on `transactionMeta` ([#5189](https://github.com/MetaMask/core/pull/5189))
44
+ - `isActive` property is expected to set by client.
45
+ - Re-simulation of transactions will occur every 3 seconds if `isActive` is `true`.
46
+ - Adds `setTransactionActive` function to update the `isActive` property on `transactionMeta`. ([#5189](https://github.com/MetaMask/core/pull/5189))
47
+
48
+ ### Changed
49
+
50
+ - **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^23.0.0` to `^24.0.0` ([#5318](https://github.com/MetaMask/core/pull/5318))
51
+
10
52
  ## [45.1.0]
11
53
 
12
54
  ### Added
@@ -1277,7 +1319,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1277
1319
 
1278
1320
  All changes listed after this point were applied to this package following the monorepo conversion.
1279
1321
 
1280
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.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
1324
+ [46.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...@metamask/transaction-controller@46.0.0
1281
1325
  [45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
1282
1326
  [45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
1283
1327
  [44.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.0.0...@metamask/transaction-controller@44.1.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");
@@ -41,8 +41,10 @@ const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper
41
41
  const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
42
42
  const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
43
43
  const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
44
+ const ResimulateHelper_1 = require("./helpers/ResimulateHelper.cjs");
44
45
  const logger_1 = require("./logger.cjs");
45
46
  const types_1 = require("./types.cjs");
47
+ const batch_1 = require("./utils/batch.cjs");
46
48
  const eip7702_1 = require("./utils/eip7702.cjs");
47
49
  const external_transactions_1 = require("./utils/external-transactions.cjs");
48
50
  const gas_1 = require("./utils/gas.cjs");
@@ -52,7 +54,6 @@ const history_1 = require("./utils/history.cjs");
52
54
  const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
53
55
  const nonce_1 = require("./utils/nonce.cjs");
54
56
  const prepare_1 = require("./utils/prepare.cjs");
55
- const resimulate_1 = require("./utils/resimulate.cjs");
56
57
  const retry_1 = require("./utils/retry.cjs");
57
58
  const simulation_1 = require("./utils/simulation.cjs");
58
59
  const swaps_1 = require("./utils/swaps.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,
@@ -302,6 +281,13 @@ class TransactionController extends base_controller_1.BaseController {
302
281
  // when transactionsController state changes
303
282
  // check for pending transactions and start polling if there are any
304
283
  this.messagingSystem.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
284
+ new ResimulateHelper_1.ResimulateHelper({
285
+ simulateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).bind(this),
286
+ onTransactionsUpdate: (listener) => {
287
+ this.messagingSystem.subscribe('TransactionController:stateChange', listener, (controllerState) => controllerState.transactions);
288
+ },
289
+ getTransactions: () => this.state.transactions,
290
+ });
305
291
  this.onBootCleanup();
306
292
  __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
307
293
  }
@@ -321,6 +307,35 @@ class TransactionController extends base_controller_1.BaseController {
321
307
  async handleMethodData(fourBytePrefix, networkClientId) {
322
308
  return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
323
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
+ }
324
339
  /**
325
340
  * Add a new unapproved transaction to state. Parameters will be validated, a
326
341
  * unique transaction id will be generated, and gas and gasPrice will be calculated
@@ -331,6 +346,7 @@ class TransactionController extends base_controller_1.BaseController {
331
346
  * @param options.actionId - Unique ID to prevent duplicate requests.
332
347
  * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
333
348
  * @param options.method - RPC method that requested the transaction.
349
+ * @param options.nestedTransactions - Params for any nested transactions encoded in the data.
334
350
  * @param options.origin - The origin of the transaction request, such as a dApp hostname.
335
351
  * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
336
352
  * @param options.securityAlertResponse - Response from security validator.
@@ -345,7 +361,7 @@ class TransactionController extends base_controller_1.BaseController {
345
361
  */
346
362
  async addTransaction(txParams, options) {
347
363
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
348
- 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;
349
365
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
350
366
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
351
367
  throw new Error(`Network client not found - ${networkClientId}`);
@@ -354,12 +370,15 @@ class TransactionController extends base_controller_1.BaseController {
354
370
  ? undefined
355
371
  : await this.getPermittedAccounts?.(origin);
356
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);
357
374
  await (0, validation_1.validateTransactionOrigin)({
358
375
  from: txParams.from,
376
+ internalAccounts,
359
377
  origin,
360
378
  permittedAddresses,
361
379
  selectedAddress,
362
380
  txParams,
381
+ type,
363
382
  });
364
383
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
365
384
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
@@ -381,6 +400,7 @@ class TransactionController extends base_controller_1.BaseController {
381
400
  deviceConfirmedOn,
382
401
  id: (0, uuid_1.v1)(),
383
402
  isFirstTimeInteraction: undefined,
403
+ nestedTransactions,
384
404
  networkClientId,
385
405
  origin,
386
406
  securityAlertResponse,
@@ -471,7 +491,7 @@ class TransactionController extends base_controller_1.BaseController {
471
491
  * @param options.estimatedBaseFee - The estimated base fee of the transaction.
472
492
  */
473
493
  async stopTransaction(transactionId, gasValues, { estimatedBaseFee, actionId, } = {}) {
474
- return await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
494
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
475
495
  actionId,
476
496
  estimatedBaseFee,
477
497
  gasValues,
@@ -500,7 +520,7 @@ class TransactionController extends base_controller_1.BaseController {
500
520
  * @param options.estimatedBaseFee - The estimated base fee of the transaction.
501
521
  */
502
522
  async speedUpTransaction(transactionId, gasValues, { actionId, estimatedBaseFee, } = {}) {
503
- return await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
523
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
504
524
  actionId,
505
525
  estimatedBaseFee,
506
526
  gasValues,
@@ -533,6 +553,7 @@ class TransactionController extends base_controller_1.BaseController {
533
553
  * @param transaction - The transaction params to estimate gas for.
534
554
  * @param multiplier - The multiplier to use for the gas buffer.
535
555
  * @param networkClientId - The network client id to use for the estimate.
556
+ * @returns The buffered estimated gas and whether the estimation failed.
536
557
  */
537
558
  async estimateGasBuffered(transaction, multiplier, networkClientId) {
538
559
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
@@ -795,6 +816,27 @@ class TransactionController extends base_controller_1.BaseController {
795
816
  this.updateTransaction(updatedTransaction, `Update Editable Params for ${txId}`);
796
817
  return this.getTransaction(txId);
797
818
  }
819
+ /**
820
+ * Update the isActive state of a transaction.
821
+ *
822
+ * @param transactionId - The ID of the transaction to update.
823
+ * @param isActive - The active state.
824
+ */
825
+ setTransactionActive(transactionId, isActive) {
826
+ const transactionMeta = this.getTransaction(transactionId);
827
+ if (!transactionMeta) {
828
+ throw new Error(`Transaction with id ${transactionId} not found`);
829
+ }
830
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
831
+ transactionId,
832
+ note: 'TransactionController#setTransactionActive - Transaction isActive updated',
833
+ skipHistory: true,
834
+ skipValidation: true,
835
+ skipResimulateCheck: true,
836
+ }, (updatedTransactionMeta) => {
837
+ updatedTransactionMeta.isActive = isActive;
838
+ });
839
+ }
798
840
  /**
799
841
  * Signs and returns the raw transaction data for provided transaction params list.
800
842
  *
@@ -998,6 +1040,7 @@ class TransactionController extends base_controller_1.BaseController {
998
1040
  * @param request.transactionParams - The transaction parameters to estimate the layer 1 gas fee for.
999
1041
  * @param request.chainId - The ID of the chain where the transaction will be executed.
1000
1042
  * @param request.networkClientId - The ID of a specific network client to process the transaction.
1043
+ * @returns The layer 1 gas fee.
1001
1044
  */
1002
1045
  async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
1003
1046
  const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
@@ -1060,6 +1103,54 @@ class TransactionController extends base_controller_1.BaseController {
1060
1103
  abortCallback();
1061
1104
  this.signAbortCallbacks.delete(transactionId);
1062
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
+ }
1063
1154
  addMetadata(transactionMeta) {
1064
1155
  (0, validation_1.validateTxParams)(transactionMeta.txParams);
1065
1156
  this.update((state) => {
@@ -1072,18 +1163,11 @@ class TransactionController extends base_controller_1.BaseController {
1072
1163
  async updateGasProperties(transactionMeta, { traceContext } = {}) {
1073
1164
  const isEIP1559Compatible = transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy &&
1074
1165
  (await this.getEIP1559Compatibility(transactionMeta.networkClientId));
1075
- const { networkClientId, chainId } = transactionMeta;
1076
- const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1077
- .configuration.type === network_controller_1.NetworkClientType.Custom;
1166
+ const { networkClientId } = transactionMeta;
1078
1167
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1079
1168
  const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
1080
1169
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
1081
- await (0, gas_1.updateGas)({
1082
- ethQuery,
1083
- chainId,
1084
- isCustomNetwork,
1085
- txMeta: transactionMeta,
1086
- });
1170
+ await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasEstimate).call(this, transactionMeta);
1087
1171
  });
1088
1172
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas Fees', parentContext: traceContext }, async () => await (0, gas_fees_1.updateGasFees)({
1089
1173
  eip1559: isEIP1559Compatible,
@@ -1155,7 +1239,10 @@ class TransactionController extends base_controller_1.BaseController {
1155
1239
  if (!isTxCompleted) {
1156
1240
  if (error?.code === rpc_errors_1.errorCodes.provider.userRejectedRequest) {
1157
1241
  this.cancelTransaction(transactionId, actionId);
1158
- 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
+ });
1159
1246
  }
1160
1247
  else {
1161
1248
  this.failTransaction(meta, error, actionId);
@@ -1185,6 +1272,7 @@ class TransactionController extends base_controller_1.BaseController {
1185
1272
  *
1186
1273
  * @param transactionId - The ID of the transaction to approve.
1187
1274
  * @param traceContext - The parent context for any new traces.
1275
+ * @returns The state of the approval.
1188
1276
  */
1189
1277
  async approveTransaction(transactionId, traceContext) {
1190
1278
  const cleanupTasks = new Array();
@@ -1223,7 +1311,7 @@ class TransactionController extends base_controller_1.BaseController {
1223
1311
  }
1224
1312
  });
1225
1313
  this.onTransactionStatusChange(transactionMeta);
1226
- 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));
1227
1315
  if (!this.beforePublish(transactionMeta)) {
1228
1316
  (0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
1229
1317
  this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
@@ -1590,7 +1678,8 @@ class TransactionController extends base_controller_1.BaseController {
1590
1678
  const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
1591
1679
  return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
1592
1680
  }
1593
- async signTransaction(transactionMeta, txParams) {
1681
+ async signTransaction(transactionMeta) {
1682
+ const { txParams } = transactionMeta;
1594
1683
  (0, logger_1.projectLogger)('Signing transaction', txParams);
1595
1684
  const { authorizationList, from } = txParams;
1596
1685
  const finalTxParams = { ...txParams };
@@ -1619,6 +1708,7 @@ class TransactionController extends base_controller_1.BaseController {
1619
1708
  const transactionMetaWithRsv = {
1620
1709
  ...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
1621
1710
  status: types_1.TransactionStatus.signed,
1711
+ txParams: finalTxParams,
1622
1712
  };
1623
1713
  this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
1624
1714
  this.onTransactionStatusChange(transactionMetaWithRsv);
@@ -1839,6 +1929,9 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1839
1929
  let resimulateResponse;
1840
1930
  this.update((state) => {
1841
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
+ }
1842
1935
  let transactionMeta = state.transactions[index];
1843
1936
  const originalTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
1844
1937
  transactionMeta = callback(transactionMeta) ?? transactionMeta;
@@ -1847,7 +1940,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1847
1940
  (0, validation_1.validateTxParams)(transactionMeta.txParams);
1848
1941
  }
1849
1942
  if (!skipResimulateCheck && __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
1850
- resimulateResponse = (0, resimulate_1.shouldResimulate)(originalTransactionMeta, transactionMeta);
1943
+ resimulateResponse = (0, ResimulateHelper_1.shouldResimulate)(originalTransactionMeta, transactionMeta);
1851
1944
  }
1852
1945
  const shouldSkipHistory = this.isHistoryDisabled || skipHistory;
1853
1946
  if (!shouldSkipHistory) {
@@ -1929,7 +2022,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1929
2022
  }));
1930
2023
  if (blockTime &&
1931
2024
  prevSimulationData &&
1932
- (0, resimulate_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
2025
+ (0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
1933
2026
  simulationData = {
1934
2027
  ...simulationData,
1935
2028
  isUpdatedAfterSecurityCheck: true,
@@ -1964,6 +2057,11 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1964
2057
  });
1965
2058
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
1966
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);
1967
2065
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
1968
2066
  const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
1969
2067
  const { networkConfigurationsByChainId } = this.getNetworkState();
@@ -1989,5 +2087,16 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1989
2087
  }
1990
2088
  submitHistory.unshift(submitHistoryEntry);
1991
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
+ });
1992
2101
  };
1993
2102
  //# sourceMappingURL=TransactionController.cjs.map