@metamask-previews/transaction-controller 62.7.0-preview-3fa1672 → 62.7.0-preview-8cfea65a

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,6 +7,10 @@ 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 intent based transaction support ([#6547](https://github.com/MetaMask/core/pull/6547))
13
+
10
14
  ### Fixed
11
15
 
12
16
  - Include pending authorizations in nonce calculation ([#7446](https://github.com/MetaMask/core/pull/7446))
@@ -467,12 +467,26 @@ class TransactionController extends base_controller_1.BaseController {
467
467
  addedTransactionMeta.txParamsOriginal = (0, lodash_1.cloneDeep)(addedTransactionMeta.txParams);
468
468
  updateTransaction(addedTransactionMeta);
469
469
  }
470
- // eslint-disable-next-line no-negated-condition
471
470
  if (!skipInitialGasEstimate) {
472
471
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Estimate Gas Properties', parentContext: traceContext }, (context) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasProperties).call(this, addedTransactionMeta, {
473
472
  traceContext: context,
474
473
  }));
475
474
  }
475
+ else if (isEIP1559Compatible &&
476
+ addedTransactionMeta.txParams.gasPrice &&
477
+ !addedTransactionMeta.txParams.maxFeePerGas) {
478
+ // Convert legacy gasPrice to EIP-1559 fees for intent transactions on EIP-1559 networks
479
+ addedTransactionMeta.txParams.maxFeePerGas =
480
+ addedTransactionMeta.txParams.gasPrice;
481
+ addedTransactionMeta.txParams.maxPriorityFeePerGas =
482
+ addedTransactionMeta.txParams.gasPrice;
483
+ addedTransactionMeta.txParams.type = types_1.TransactionEnvelopeType.feeMarket;
484
+ delete addedTransactionMeta.txParams.gasPrice; // Remove legacy gas price
485
+ }
486
+ else if (!isEIP1559Compatible && addedTransactionMeta.txParams.gasPrice) {
487
+ // Ensure legacy type for non-EIP-1559 networks
488
+ addedTransactionMeta.txParams.type = types_1.TransactionEnvelopeType.legacy;
489
+ }
476
490
  else {
477
491
  const newTransactionMeta = (0, lodash_1.cloneDeep)(addedTransactionMeta);
478
492
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasProperties).call(this, newTransactionMeta)
@@ -1587,6 +1601,31 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_afterSig
1587
1601
  this.updateTransaction(updatedTransaction, 'TransactionController#processApproval - Updated with approval data');
1588
1602
  }
1589
1603
  }
1604
+ // For intent-based transactions (e.g., CoW intents) that are not meant to be
1605
+ // published on-chain by the TransactionController, skip the approve/publish flow.
1606
+ // These are tracked externally and should not be signed or sent.
1607
+ const isIntentTransaction = Boolean(
1608
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1609
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId)?.swapMetaData
1610
+ ?.isIntentTx === true);
1611
+ if (requireApproval === false && isIntentTransaction) {
1612
+ const submittedTxMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
1613
+ transactionId,
1614
+ note: 'TransactionController#processApproval - Intent transaction auto-submitted',
1615
+ skipValidation: true,
1616
+ }, (draftTxMeta) => {
1617
+ draftTxMeta.status = types_1.TransactionStatus.submitted;
1618
+ draftTxMeta.submittedTime = new Date().getTime();
1619
+ });
1620
+ this.messenger.publish(`${controllerName}:transactionSubmitted`, {
1621
+ transactionMeta: submittedTxMeta,
1622
+ });
1623
+ this.messenger.publish(`${controllerName}:transactionFinished`, submittedTxMeta);
1624
+ __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionId}:finished`, submittedTxMeta);
1625
+ // Short-circuit normal flow; result callbacks will be handled by the
1626
+ // finished promise below.
1627
+ return ApprovalState.Approved;
1628
+ }
1590
1629
  const { isCompleted: isTxCompleted } = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isTransactionCompleted).call(this, transactionId);
1591
1630
  if (!isTxCompleted) {
1592
1631
  const approvalResult = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_approveTransaction).call(this, transactionId, traceContext, publishHook);