@metamask/transaction-controller 65.3.0 → 66.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 (50) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/TransactionController.cjs +7 -5
  3. package/dist/TransactionController.cjs.map +1 -1
  4. package/dist/TransactionController.d.cts.map +1 -1
  5. package/dist/TransactionController.d.mts.map +1 -1
  6. package/dist/TransactionController.mjs +7 -5
  7. package/dist/TransactionController.mjs.map +1 -1
  8. package/dist/types.cjs +4 -0
  9. package/dist/types.cjs.map +1 -1
  10. package/dist/types.d.cts +19 -0
  11. package/dist/types.d.cts.map +1 -1
  12. package/dist/types.d.mts +19 -0
  13. package/dist/types.d.mts.map +1 -1
  14. package/dist/types.mjs +4 -0
  15. package/dist/types.mjs.map +1 -1
  16. package/dist/utils/batch.cjs +7 -3
  17. package/dist/utils/batch.cjs.map +1 -1
  18. package/dist/utils/batch.d.cts.map +1 -1
  19. package/dist/utils/batch.d.mts.map +1 -1
  20. package/dist/utils/batch.mjs +7 -3
  21. package/dist/utils/batch.mjs.map +1 -1
  22. package/dist/utils/gas-fee-tokens.cjs +13 -10
  23. package/dist/utils/gas-fee-tokens.cjs.map +1 -1
  24. package/dist/utils/gas-fee-tokens.d.cts.map +1 -1
  25. package/dist/utils/gas-fee-tokens.d.mts.map +1 -1
  26. package/dist/utils/gas-fee-tokens.mjs +13 -10
  27. package/dist/utils/gas-fee-tokens.mjs.map +1 -1
  28. package/dist/utils/gas-fees.cjs +2 -2
  29. package/dist/utils/gas-fees.cjs.map +1 -1
  30. package/dist/utils/gas-fees.d.cts.map +1 -1
  31. package/dist/utils/gas-fees.d.mts.map +1 -1
  32. package/dist/utils/gas-fees.mjs +3 -3
  33. package/dist/utils/gas-fees.mjs.map +1 -1
  34. package/dist/utils/gas.cjs +47 -8
  35. package/dist/utils/gas.cjs.map +1 -1
  36. package/dist/utils/gas.d.cts +22 -0
  37. package/dist/utils/gas.d.cts.map +1 -1
  38. package/dist/utils/gas.d.mts +22 -0
  39. package/dist/utils/gas.d.mts.map +1 -1
  40. package/dist/utils/gas.mjs +45 -7
  41. package/dist/utils/gas.mjs.map +1 -1
  42. package/dist/utils/validation.cjs +15 -14
  43. package/dist/utils/validation.cjs.map +1 -1
  44. package/dist/utils/validation.d.cts +6 -2
  45. package/dist/utils/validation.d.cts.map +1 -1
  46. package/dist/utils/validation.d.mts +6 -2
  47. package/dist/utils/validation.d.mts.map +1 -1
  48. package/dist/utils/validation.mjs +16 -15
  49. package/dist/utils/validation.mjs.map +1 -1
  50. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [66.0.0]
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** Replace implicit `origin === 'metamask'` trust checks with an explicit `isInternal` flag on `AddTransactionOptions`, `TransactionBatchRequest`, `TransactionMeta`, and `TransactionBatchMeta`; internal callers must now pass `isInternal: true` ([#8633](https://github.com/MetaMask/core/pull/8633))
15
+ - Bump `@metamask/core-backend` from `^6.2.2` to `^6.3.0` ([#8813](https://github.com/MetaMask/core/pull/8813))
16
+ - Bump `@metamask/gas-fee-controller` from `^26.2.1` to `^26.2.2` ([#8834](https://github.com/MetaMask/core/pull/8834))
17
+
18
+ ### Fixed
19
+
20
+ - Respect `excludeNativeTokenForFee` when publishing transactions with a selected gas fee token ([#8762](https://github.com/MetaMask/core/pull/8762))
21
+
22
+ ## [65.4.0]
23
+
24
+ ### Added
25
+
26
+ - Add optional `fiat` object (with `orderId` and `provider` properties) to `MetamaskPayMetadata` type for persisting fiat on-ramp order data on transactions ([#8694](https://github.com/MetaMask/core/pull/8694))
27
+ - Add `predictAcrossWithdraw` to the `TransactionType` enum ([#8759](https://github.com/MetaMask/core/pull/8759))
28
+
29
+ ### Changed
30
+
31
+ - Bump `@metamask/network-controller` from `^31.0.0` to `^32.0.0` ([#8765](https://github.com/MetaMask/core/pull/8765), [#8774](https://github.com/MetaMask/core/pull/8774))
32
+ - `estimateGasBatch` now falls back to the sum of per-tx `gas` values in the EIP-7702 path when node simulation fails, instead of returning the block-gas-limit fallback ([#8735](https://github.com/MetaMask/core/pull/8735))
33
+ - Real 7702 simulation is still preferred when it succeeds (the bundled call has no per-tx intrinsic gas cost so the estimate is typically tighter than summing per-tx limits).
34
+ - Required for callers that submit batches whose individual sub-calls cannot be simulated standalone, for example predict-withdraw, where the batch's first sub-call (`Safe.execTransaction`) provides source-token balance to subsequent sub-calls (approve + swap), and simulating the relay-only sub-calls in isolation reverts because the EOA has no balance until the Safe sub-call has run.
35
+ - Bump `@metamask/accounts-controller` from `^38.1.0` to `^38.1.1` ([#8774](https://github.com/MetaMask/core/pull/8774))
36
+ - Bump `@metamask/controller-utils` from `^12.0.0` to `^12.1.0` ([#8774](https://github.com/MetaMask/core/pull/8774))
37
+
10
38
  ## [65.3.0]
11
39
 
12
40
  ### Changed
@@ -2415,7 +2443,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2415
2443
 
2416
2444
  All changes listed after this point were applied to this package following the monorepo conversion.
2417
2445
 
2418
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@65.3.0...HEAD
2446
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@66.0.0...HEAD
2447
+ [66.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@65.4.0...@metamask/transaction-controller@66.0.0
2448
+ [65.4.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@65.3.0...@metamask/transaction-controller@65.4.0
2419
2449
  [65.3.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@65.2.0...@metamask/transaction-controller@65.3.0
2420
2450
  [65.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@65.1.0...@metamask/transaction-controller@65.2.0
2421
2451
  [65.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@65.0.0...@metamask/transaction-controller@65.1.0
@@ -412,7 +412,7 @@ class TransactionController extends base_controller_1.BaseController {
412
412
  */
413
413
  async addTransaction(txParams, options) {
414
414
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
415
- const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, excludeNativeTokenForFee, isGasFeeIncluded, isGasFeeSponsored, isStateOnly, method, nestedTransactions, networkClientId, origin, publishHook, requestId, requiredAssets, requireApproval, securityAlertResponse, skipInitialGasEstimate, swaps = {}, traceContext, type, } = options;
415
+ const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, excludeNativeTokenForFee, isGasFeeIncluded, isGasFeeSponsored, isInternal = false, isStateOnly, method, nestedTransactions, networkClientId, origin, publishHook, requestId, requiredAssets, requireApproval, securityAlertResponse, skipInitialGasEstimate, swaps = {}, traceContext, type, } = options;
416
416
  // eslint-disable-next-line no-param-reassign
417
417
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
418
418
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
@@ -427,6 +427,7 @@ class TransactionController extends base_controller_1.BaseController {
427
427
  data: txParams.data,
428
428
  from: txParams.from,
429
429
  internalAccounts,
430
+ isInternal,
430
431
  origin,
431
432
  permittedAddresses,
432
433
  txParams,
@@ -441,10 +442,10 @@ class TransactionController extends base_controller_1.BaseController {
441
442
  }
442
443
  const isDuplicateBatchId = batchId?.length &&
443
444
  this.state.transactions.some((tx) => tx.batchId?.toLowerCase() === batchId?.toLowerCase());
444
- if (isDuplicateBatchId && origin && origin !== controller_utils_1.ORIGIN_METAMASK) {
445
+ if (isDuplicateBatchId && !isInternal) {
445
446
  throw new rpc_errors_1.JsonRpcError(validation_1.ErrorCode.DuplicateBundleId, 'Batch ID already exists');
446
447
  }
447
- const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin);
448
+ const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin, isInternal);
448
449
  const transactionType = type ??
449
450
  (await (0, transaction_type_1.determineTransactionType)(txParams, {
450
451
  messenger: this.messenger,
@@ -473,6 +474,7 @@ class TransactionController extends base_controller_1.BaseController {
473
474
  ? {}
474
475
  : { excludeNativeTokenForFee }),
475
476
  isFirstTimeInteraction: undefined,
477
+ isInternal,
476
478
  isStateOnly,
477
479
  nestedTransactions,
478
480
  networkClientId,
@@ -1947,8 +1949,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
1947
1949
  (0, logger_1.projectLogger)('Added incoming transactions to state', finalTransactions.length, finalTransactions);
1948
1950
  });
1949
1951
  this.messenger.publish(`${controllerName}:incomingTransactionsReceived`, finalTransactions);
1950
- }, _TransactionController_generateDappSuggestedGasFees = function _TransactionController_generateDappSuggestedGasFees(txParams, origin) {
1951
- if (!origin || origin === controller_utils_1.ORIGIN_METAMASK) {
1952
+ }, _TransactionController_generateDappSuggestedGasFees = function _TransactionController_generateDappSuggestedGasFees(txParams, origin, isInternal) {
1953
+ if (isInternal || !origin) {
1952
1954
  return undefined;
1953
1955
  }
1954
1956
  const { gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas } = txParams;