@metamask-previews/transaction-controller 45.0.0-preview-83e41399 → 45.0.0-preview-1adbaffc

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.
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /* istanbul ignore file */
3
- // FIXME - remove above ignore
4
2
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5
3
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -627,7 +625,6 @@ class TransactionController extends base_controller_1.BaseController {
627
625
  this.onTransactionStatusChange(updatedTransactionMeta);
628
626
  // Intentional given potential duration of process.
629
627
  this.updatePostBalance(updatedTransactionMeta).catch((error) => {
630
- /* istanbul ignore next */
631
628
  (0, logger_1.projectLogger)('Error while updating post balance', error);
632
629
  throw error;
633
630
  });
@@ -858,17 +855,15 @@ class TransactionController extends base_controller_1.BaseController {
858
855
  * @param options.errorMessage - The error message to be assigned in case transaction status update to failed.
859
856
  * @param options.hash - The new hash value to be assigned.
860
857
  * @param options.status - The new status value to be assigned.
861
- * @param options.gasLimit - The new gas limit value to be assigned
862
- * @param options.gasPrice - The new gas price value to be assigned
863
- * @param options.maxFeePerGas - The new max fee per gas value to be assigned
864
- * @param options.maxPriorityFeePerGas - The new max priority fee per gas value to be assigned
865
- * @param options.nonce - The new nonce value to be assigned
866
858
  */
867
- updateCustodialTransaction(transactionId, { errorMessage, hash, status, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, }) {
859
+ updateCustodialTransaction(transactionId, { errorMessage, hash, status, }) {
868
860
  const transactionMeta = this.getTransaction(transactionId);
869
861
  if (!transactionMeta) {
870
862
  throw new Error(`Cannot update custodial transaction as no transaction metadata found`);
871
863
  }
864
+ if (!transactionMeta.custodyId) {
865
+ throw new Error('Transaction must be a custodian transaction');
866
+ }
872
867
  if (status &&
873
868
  ![
874
869
  types_1.TransactionStatus.submitted,
@@ -884,22 +879,6 @@ class TransactionController extends base_controller_1.BaseController {
884
879
  if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
885
880
  updatedTransactionMeta.error = (0, utils_2.normalizeTxError)(new Error(errorMessage));
886
881
  }
887
- if (gasLimit) {
888
- updatedTransactionMeta.txParams.gasLimit = gasLimit;
889
- }
890
- if (gasPrice) {
891
- updatedTransactionMeta.txParams.gasPrice = gasPrice;
892
- }
893
- if (maxFeePerGas) {
894
- updatedTransactionMeta.txParams.maxFeePerGas = maxFeePerGas;
895
- }
896
- if (maxPriorityFeePerGas) {
897
- updatedTransactionMeta.txParams.maxPriorityFeePerGas =
898
- maxPriorityFeePerGas;
899
- }
900
- if (nonce) {
901
- updatedTransactionMeta.txParams.nonce = nonce;
902
- }
903
882
  this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
904
883
  if ([types_1.TransactionStatus.submitted, types_1.TransactionStatus.failed].includes(status)) {
905
884
  this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
@@ -1244,7 +1223,7 @@ class TransactionController extends base_controller_1.BaseController {
1244
1223
  });
1245
1224
  this.onTransactionStatusChange(transactionMeta);
1246
1225
  const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta, transactionMeta.txParams));
1247
- if (!this.beforePublish(transactionMeta, rawTx)) {
1226
+ if (!this.beforePublish(transactionMeta)) {
1248
1227
  (0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
1249
1228
  this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
1250
1229
  return ApprovalState.SkippedViaBeforePublishHook;
@@ -1846,6 +1825,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
1846
1825
  }),
1847
1826
  hooks: {
1848
1827
  beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
1828
+ beforePublish: this.beforePublish.bind(this),
1849
1829
  },
1850
1830
  });
1851
1831
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);