@metamask-previews/transaction-controller 65.0.0-preview-d8ff44d → 65.0.0-preview-156c8ccf7

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.
package/CHANGELOG.md CHANGED
@@ -7,10 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add optional `isInternal` flag to `addTransaction` and `addTransactionBatch` to explicitly mark a request as originating from trusted internal MetaMask code ([#8633](https://github.com/MetaMask/core/pull/8633))
13
+ - When `true`, the controller skips validations that only apply to external requests: permitted-address check, EIP-7702 authorization rejection, calls-with-data to internal accounts, duplicate batch ID, dapp-suggested gas fee handling, and batch size limit
14
+ - The flag is persisted on `TransactionMeta` and `TransactionBatchMeta` so downstream logic (e.g. `userFeeLevel` selection) does not need to re-derive trust from the origin
15
+ - Add `isInternal` field to `TransactionMeta`, `TransactionBatchMeta`, `AddTransactionOptions`, and `TransactionBatchRequest` ([#8633](https://github.com/MetaMask/core/pull/8633))
16
+
10
17
  ### Changed
11
18
 
19
+ - **BREAKING:** Internal-only validation behavior is now gated by the explicit `isInternal` flag rather than `origin === ORIGIN_METAMASK` ([#8633](https://github.com/MetaMask/core/pull/8633))
20
+ - Setting `origin` to `ORIGIN_METAMASK` (or omitting `origin`) no longer skips external-request validations
21
+ - Callers that previously relied on `origin: ORIGIN_METAMASK` to suppress these validations must pass `isInternal: true` explicitly
22
+ - `validateTransactionOrigin` and `validateBatchRequest` now accept an `isInternal` option
23
+ - `userFeeLevel` selection in `gas-fees.ts` now keys off `txMeta.isInternal` instead of `txMeta.origin === ORIGIN_METAMASK` ([#8633](https://github.com/MetaMask/core/pull/8633))
12
24
  - Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
13
- - Bump `@metamask/network-controller` from `^30.0.1` to `^30.1.0` ([#8636](https://github.com/MetaMask/core/pull/8636))
14
25
 
15
26
  ## [65.0.0]
16
27
 
@@ -407,7 +407,7 @@ class TransactionController extends base_controller_1.BaseController {
407
407
  */
408
408
  async addTransaction(txParams, options) {
409
409
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
410
- 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;
410
+ 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;
411
411
  // eslint-disable-next-line no-param-reassign
412
412
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
413
413
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
@@ -422,6 +422,7 @@ class TransactionController extends base_controller_1.BaseController {
422
422
  data: txParams.data,
423
423
  from: txParams.from,
424
424
  internalAccounts,
425
+ isInternal,
425
426
  origin,
426
427
  permittedAddresses,
427
428
  txParams,
@@ -436,10 +437,10 @@ class TransactionController extends base_controller_1.BaseController {
436
437
  }
437
438
  const isDuplicateBatchId = batchId?.length &&
438
439
  this.state.transactions.some((tx) => tx.batchId?.toLowerCase() === batchId?.toLowerCase());
439
- if (isDuplicateBatchId && origin && origin !== controller_utils_1.ORIGIN_METAMASK) {
440
+ if (isDuplicateBatchId && !isInternal) {
440
441
  throw new rpc_errors_1.JsonRpcError(validation_1.ErrorCode.DuplicateBundleId, 'Batch ID already exists');
441
442
  }
442
- const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin);
443
+ const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin, isInternal);
443
444
  const transactionType = type ??
444
445
  (await (0, transaction_type_1.determineTransactionType)(txParams, {
445
446
  messenger: this.messenger,
@@ -468,6 +469,7 @@ class TransactionController extends base_controller_1.BaseController {
468
469
  ? {}
469
470
  : { excludeNativeTokenForFee }),
470
471
  isFirstTimeInteraction: undefined,
472
+ isInternal,
471
473
  isStateOnly,
472
474
  nestedTransactions,
473
475
  networkClientId,
@@ -1935,8 +1937,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
1935
1937
  (0, logger_1.projectLogger)('Added incoming transactions to state', finalTransactions.length, finalTransactions);
1936
1938
  });
1937
1939
  this.messenger.publish(`${controllerName}:incomingTransactionsReceived`, finalTransactions);
1938
- }, _TransactionController_generateDappSuggestedGasFees = function _TransactionController_generateDappSuggestedGasFees(txParams, origin) {
1939
- if (!origin || origin === controller_utils_1.ORIGIN_METAMASK) {
1940
+ }, _TransactionController_generateDappSuggestedGasFees = function _TransactionController_generateDappSuggestedGasFees(txParams, origin, isInternal) {
1941
+ if (isInternal || !origin) {
1940
1942
  return undefined;
1941
1943
  }
1942
1944
  const { gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas } = txParams;