@metamask/transaction-controller 18.0.0 → 18.1.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [18.1.0]
10
+ ### Added
11
+ - Add `cancelMultiplier` and `speedUpMultiplier` constructor arguments to optionally override the default multipliers of `1.5` and `1.1` respectively ([#2678](https://github.com/MetaMask/core/pull/2678))
12
+
13
+ ### Changed
14
+ - Populate the `preTxBalance` property before publishing transactions with the `swap` type ([#2678](https://github.com/MetaMask/core/pull/2678))
15
+ - Change the status of transactions with matching nonces to `dropped` when confirming a transaction ([#2678](https://github.com/MetaMask/core/pull/2678))
16
+
9
17
  ## [18.0.0]
10
18
  ### Added
11
19
  - Add `updateEditableParams` method ([#2056](https://github.com/MetaMask/core/pull/2056))
@@ -311,7 +319,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
311
319
 
312
320
  All changes listed after this point were applied to this package following the monorepo conversion.
313
321
 
314
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.0.0...HEAD
322
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.1.0...HEAD
323
+ [18.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.0.0...@metamask/transaction-controller@18.1.0
315
324
  [18.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@17.0.0...@metamask/transaction-controller@18.0.0
316
325
  [17.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@16.0.0...@metamask/transaction-controller@17.0.0
317
326
  [16.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@15.0.0...@metamask/transaction-controller@16.0.0
@@ -114,6 +114,8 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
114
114
  private readonly incomingTransactionHelper;
115
115
  private readonly securityProviderRequest?;
116
116
  private readonly pendingTransactionTracker;
117
+ private readonly cancelMultiplier;
118
+ private readonly speedUpMultiplier;
117
119
  private readonly afterSign;
118
120
  private readonly beforeApproveOnInit;
119
121
  private readonly beforeCheckPendingTransaction;
@@ -138,6 +140,7 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
138
140
  *
139
141
  * @param options - The controller options.
140
142
  * @param options.blockTracker - The block tracker used to poll for new blocks data.
143
+ * @param options.cancelMultiplier - Multiplier used to determine a transaction's increased gas fee during cancellation.
141
144
  * @param options.disableHistory - Whether to disable storing history in transaction metadata.
142
145
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
143
146
  * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
@@ -159,6 +162,7 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
159
162
  * @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.
160
163
  * @param options.provider - The provider used to create the underlying EthQuery instance.
161
164
  * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
165
+ * @param options.speedUpMultiplier - Multiplier used to determine a transaction's increased gas fee during speed up.
162
166
  * @param options.hooks - The controller hooks.
163
167
  * @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.
164
168
  * @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.
@@ -168,8 +172,9 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
168
172
  * @param config - Initial options used to configure this controller.
169
173
  * @param state - Initial state to set on this controller.
170
174
  */
171
- constructor({ blockTracker, disableHistory, disableSendFlowHistory, disableSwaps, getSavedGasFees, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, pendingTransactions, provider, securityProviderRequest, hooks, }: {
175
+ constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps, getSavedGasFees, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, pendingTransactions, provider, securityProviderRequest, speedUpMultiplier, hooks, }: {
172
176
  blockTracker: BlockTracker;
177
+ cancelMultiplier?: number;
173
178
  disableHistory: boolean;
174
179
  disableSendFlowHistory: boolean;
175
180
  disableSwaps: boolean;
@@ -193,6 +198,7 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
193
198
  };
194
199
  provider: Provider;
195
200
  securityProviderRequest?: SecurityProviderRequest;
201
+ speedUpMultiplier?: number;
196
202
  hooks: {
197
203
  afterSign?: (transactionMeta: TransactionMeta, signedTx: TypedTransaction) => boolean;
198
204
  beforeApproveOnInit?: (transactionMeta: TransactionMeta) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA4B,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAU7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,MA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;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,gCAAgC;IAaxC,OAAO,CAAC,4BAA4B;IAsCpC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAmC9B;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA8BlC;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAYnC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;YAMpB,0BAA0B;IAUxC;;;;;;OAMG;YACW,wBAAwB;YAiBxB,uBAAuB;IAYrC,OAAO,CAAC,qCAAqC;YAsB/B,eAAe;IAuD7B,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,2BAA2B;IAcnC,OAAO,CAAC,sBAAsB;YAehB,iBAAiB;CAsBhC"}
@@ -61,6 +61,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
61
61
  *
62
62
  * @param options - The controller options.
63
63
  * @param options.blockTracker - The block tracker used to poll for new blocks data.
64
+ * @param options.cancelMultiplier - Multiplier used to determine a transaction's increased gas fee during cancellation.
64
65
  * @param options.disableHistory - Whether to disable storing history in transaction metadata.
65
66
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
66
67
  * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
@@ -82,6 +83,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
82
83
  * @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.
83
84
  * @param options.provider - The provider used to create the underlying EthQuery instance.
84
85
  * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
86
+ * @param options.speedUpMultiplier - Multiplier used to determine a transaction's increased gas fee during speed up.
85
87
  * @param options.hooks - The controller hooks.
86
88
  * @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.
87
89
  * @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.
@@ -91,7 +93,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
91
93
  * @param config - Initial options used to configure this controller.
92
94
  * @param state - Initial state to set on this controller.
93
95
  */
94
- constructor({ blockTracker, disableHistory, disableSendFlowHistory, disableSwaps, getSavedGasFees, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, hooks = {}, }, config, state) {
96
+ constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps, getSavedGasFees, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, speedUpMultiplier, hooks = {}, }, config, state) {
95
97
  var _a, _b, _c, _d, _e;
96
98
  super(config, state);
97
99
  this.inProcessOfSigning = new Set();
@@ -131,6 +133,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
131
133
  this.getPermittedAccounts = getPermittedAccounts;
132
134
  this.getSelectedAddress = getSelectedAddress;
133
135
  this.securityProviderRequest = securityProviderRequest;
136
+ this.cancelMultiplier = cancelMultiplier !== null && cancelMultiplier !== void 0 ? cancelMultiplier : exports.CANCEL_RATE;
137
+ this.speedUpMultiplier = speedUpMultiplier !== null && speedUpMultiplier !== void 0 ? speedUpMultiplier : exports.SPEED_UP_RATE;
134
138
  this.afterSign = (_a = hooks === null || hooks === void 0 ? void 0 : hooks.afterSign) !== null && _a !== void 0 ? _a : (() => true);
135
139
  this.beforeApproveOnInit = (_b = hooks === null || hooks === void 0 ? void 0 : hooks.beforeApproveOnInit) !== null && _b !== void 0 ? _b : (() => true);
136
140
  this.beforeCheckPendingTransaction =
@@ -334,7 +338,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
334
338
  * @param options.estimatedBaseFee - The estimated base fee of the transaction.
335
339
  */
336
340
  stopTransaction(transactionId, gasValues, { estimatedBaseFee, actionId, } = {}) {
337
- var _a, _b;
341
+ var _a, _b, _c;
338
342
  return __awaiter(this, void 0, void 0, function* () {
339
343
  // If transaction is found for same action id, do not create a cancel transaction.
340
344
  if (this.getTransactionWithActionId(actionId)) {
@@ -345,6 +349,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
345
349
  gasValues = (0, utils_1.normalizeGasFeeValues)(gasValues);
346
350
  (0, utils_1.validateGasValues)(gasValues);
347
351
  }
352
+ (0, logger_1.projectLogger)('Creating cancel transaction', transactionId, gasValues);
348
353
  const transactionMeta = this.getTransaction(transactionId);
349
354
  if (!transactionMeta) {
350
355
  return;
@@ -353,21 +358,21 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
353
358
  throw new Error('No sign method defined.');
354
359
  }
355
360
  // gasPrice (legacy non EIP1559)
356
- const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, exports.CANCEL_RATE);
361
+ const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, this.cancelMultiplier);
357
362
  const gasPriceFromValues = (0, utils_1.isGasPriceValue)(gasValues) && gasValues.gasPrice;
358
363
  const newGasPrice = (gasPriceFromValues &&
359
364
  (0, utils_1.validateMinimumIncrease)(gasPriceFromValues, minGasPrice)) ||
360
365
  minGasPrice;
361
366
  // maxFeePerGas (EIP1559)
362
367
  const existingMaxFeePerGas = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.maxFeePerGas;
363
- const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, exports.CANCEL_RATE);
368
+ const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, this.cancelMultiplier);
364
369
  const maxFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxFeePerGas;
365
370
  const newMaxFeePerGas = (maxFeePerGasValues &&
366
371
  (0, utils_1.validateMinimumIncrease)(maxFeePerGasValues, minMaxFeePerGas)) ||
367
372
  (existingMaxFeePerGas && minMaxFeePerGas);
368
373
  // maxPriorityFeePerGas (EIP1559)
369
374
  const existingMaxPriorityFeePerGas = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.maxPriorityFeePerGas;
370
- const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, exports.CANCEL_RATE);
375
+ const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, this.cancelMultiplier);
371
376
  const maxPriorityFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxPriorityFeePerGas;
372
377
  const newMaxPriorityFeePerGas = (maxPriorityFeePerGasValues &&
373
378
  (0, utils_1.validateMinimumIncrease)(maxPriorityFeePerGasValues, minMaxPriorityFeePerGas)) ||
@@ -394,6 +399,15 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
394
399
  const unsignedEthTx = this.prepareUnsignedEthTx(newTxParams);
395
400
  const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from);
396
401
  const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
402
+ const newFee = (_c = newTxParams.maxFeePerGas) !== null && _c !== void 0 ? _c : newTxParams.gasPrice;
403
+ const oldFee = newTxParams.maxFeePerGas
404
+ ? transactionMeta.txParams.maxFeePerGas
405
+ : transactionMeta.txParams.gasPrice;
406
+ (0, logger_1.projectLogger)('Submitting cancel transaction', {
407
+ oldFee,
408
+ newFee,
409
+ txParams: newTxParams,
410
+ });
397
411
  const hash = yield this.publishTransaction(rawTx);
398
412
  const cancelTransactionMeta = {
399
413
  actionId,
@@ -430,7 +444,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
430
444
  * @param options.estimatedBaseFee - The estimated base fee of the transaction.
431
445
  */
432
446
  speedUpTransaction(transactionId, gasValues, { actionId, estimatedBaseFee, } = {}) {
433
- var _a, _b;
447
+ var _a, _b, _c;
434
448
  return __awaiter(this, void 0, void 0, function* () {
435
449
  // If transaction is found for same action id, do not create a new speed up transaction.
436
450
  if (this.getTransactionWithActionId(actionId)) {
@@ -441,6 +455,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
441
455
  gasValues = (0, utils_1.normalizeGasFeeValues)(gasValues);
442
456
  (0, utils_1.validateGasValues)(gasValues);
443
457
  }
458
+ (0, logger_1.projectLogger)('Creating speed up transaction', transactionId, gasValues);
444
459
  const transactionMeta = this.state.transactions.find(({ id }) => id === transactionId);
445
460
  /* istanbul ignore next */
446
461
  if (!transactionMeta) {
@@ -451,21 +466,21 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
451
466
  throw new Error('No sign method defined.');
452
467
  }
453
468
  // gasPrice (legacy non EIP1559)
454
- const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, exports.SPEED_UP_RATE);
469
+ const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, this.speedUpMultiplier);
455
470
  const gasPriceFromValues = (0, utils_1.isGasPriceValue)(gasValues) && gasValues.gasPrice;
456
471
  const newGasPrice = (gasPriceFromValues &&
457
472
  (0, utils_1.validateMinimumIncrease)(gasPriceFromValues, minGasPrice)) ||
458
473
  minGasPrice;
459
474
  // maxFeePerGas (EIP1559)
460
475
  const existingMaxFeePerGas = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.maxFeePerGas;
461
- const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, exports.SPEED_UP_RATE);
476
+ const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, this.speedUpMultiplier);
462
477
  const maxFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxFeePerGas;
463
478
  const newMaxFeePerGas = (maxFeePerGasValues &&
464
479
  (0, utils_1.validateMinimumIncrease)(maxFeePerGasValues, minMaxFeePerGas)) ||
465
480
  (existingMaxFeePerGas && minMaxFeePerGas);
466
481
  // maxPriorityFeePerGas (EIP1559)
467
482
  const existingMaxPriorityFeePerGas = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.maxPriorityFeePerGas;
468
- const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, exports.SPEED_UP_RATE);
483
+ const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, this.speedUpMultiplier);
469
484
  const maxPriorityFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxPriorityFeePerGas;
470
485
  const newMaxPriorityFeePerGas = (maxPriorityFeePerGasValues &&
471
486
  (0, utils_1.validateMinimumIncrease)(maxPriorityFeePerGasValues, minMaxPriorityFeePerGas)) ||
@@ -476,6 +491,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
476
491
  const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from);
477
492
  yield this.updateTransactionMetaRSV(transactionMeta, signedTx);
478
493
  const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
494
+ const newFee = (_c = txParams.maxFeePerGas) !== null && _c !== void 0 ? _c : txParams.gasPrice;
495
+ const oldFee = txParams.maxFeePerGas
496
+ ? transactionMeta.txParams.maxFeePerGas
497
+ : transactionMeta.txParams.gasPrice;
498
+ (0, logger_1.projectLogger)('Submitting speed up transaction', { oldFee, newFee, txParams });
479
499
  const hash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTx]);
480
500
  const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { estimatedBaseFee, id: (0, uuid_1.v1)(), time: Date.now(), hash,
481
501
  actionId, originalGasEstimate: transactionMeta.txParams.gas, type: types_1.TransactionType.retry, originalType: transactionMeta.type });
@@ -1166,7 +1186,15 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1166
1186
  if (!rawTx) {
1167
1187
  return;
1168
1188
  }
1189
+ if (transactionMeta.type === types_1.TransactionType.swap) {
1190
+ (0, logger_1.projectLogger)('Determining pre-transaction balance');
1191
+ const preTxBalance = yield (0, controller_utils_1.query)(this.ethQuery, 'getBalance', [from]);
1192
+ transactionMeta.preTxBalance = preTxBalance;
1193
+ (0, logger_1.projectLogger)('Updated pre-transaction balance', transactionMeta.preTxBalance);
1194
+ }
1195
+ (0, logger_1.projectLogger)('Publishing transaction', txParams);
1169
1196
  const hash = yield this.publishTransaction(rawTx);
1197
+ (0, logger_1.projectLogger)('Publish successful', hash);
1170
1198
  transactionMeta.hash = hash;
1171
1199
  transactionMeta.status = types_1.TransactionStatus.submitted;
1172
1200
  transactionMeta.submittedTime = new Date().getTime();
@@ -1539,6 +1567,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1539
1567
  }
1540
1568
  onConfirmedTransaction(transactionMeta) {
1541
1569
  (0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
1570
+ this.markNonceDuplicatesDropped(transactionMeta.id);
1542
1571
  this.hub.emit('transaction-confirmed', { transactionMeta });
1543
1572
  this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta);
1544
1573
  this.onTransactionStatusChange(transactionMeta);
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionController.js","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAwE;AAExE,uCAAoD;AAWpD,+DAA6D;AAC7D,iEAOoC;AACpC,oEAA2C;AAO3C,qDAA6E;AAE7E,6CAAoC;AACpC,8EAAiD;AACjD,qDAA4D;AAC5D,mCAAsC;AACtC,mCAA0D;AAC1D,iDAA6C;AAE7C,+BAAoC;AAEpC,iGAA8F;AAC9F,mFAAgF;AAChF,mFAAgF;AAChF,qCAAgD;AAahD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CAAC,CAAC;QAElE,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAEhD,mDAAmD;QACnD,mEAAmE;QACnE,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC;IAEa,iBAAiB,CAAC,eAAgC;;YAC9D,IAAI;gBACF,IAAI,eAAe,CAAC,IAAI,KAAK,uBAAe,CAAC,IAAI,EAAE;oBACjD,OAAO;iBACR;gBAED,MAAM,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,GACvD,MAAM,IAAA,oCAA4B,EAAC,eAAe,EAAE;oBAClD,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;oBAC9C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;iBACrD,CAAC,CAAC;gBAEL,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kCAAkC,EAAE;oBAChD,eAAe,EAAE,sBAAsB;oBACvC,uBAAuB;iBACxB,CAAC,CAAC;aACJ;YAAC,OAAO,KAAK,EAAE;gBACd,0BAA0B;gBAC1B,IAAA,sBAAG,EAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;aAC7D;QACH,CAAC;KAAA;CACF;AA9xED,sDA8xEC","sourcesContent":["import { Hardfork, Common, type ChainConfig } from '@ethereumjs/common';\nimport type { TypedTransaction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type {\n AcceptResultCallbacks,\n AddApprovalRequest,\n AddResult,\n} from '@metamask/approval-controller';\nimport type {\n BaseConfig,\n BaseState,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { BaseControllerV1 } from '@metamask/base-controller';\nimport {\n query,\n NetworkType,\n RPC,\n ApprovalType,\n ORIGIN_METAMASK,\n convertHexToDecimal,\n} from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n BlockTracker,\n NetworkState,\n Provider,\n} from '@metamask/network-controller';\nimport { errorCodes, rpcErrors, providerErrors } from '@metamask/rpc-errors';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport MethodRegistry from 'eth-method-registry';\nimport { addHexPrefix, bufferToHex } from 'ethereumjs-util';\nimport { EventEmitter } from 'events';\nimport { mapValues, merge, pickBy, sortBy } from 'lodash';\nimport { NonceTracker } from 'nonce-tracker';\nimport type { NonceLock } from 'nonce-tracker';\nimport { v1 as random } from 'uuid';\n\nimport { EtherscanRemoteTransactionSource } from './helpers/EtherscanRemoteTransactionSource';\nimport { IncomingTransactionHelper } from './helpers/IncomingTransactionHelper';\nimport { PendingTransactionTracker } from './helpers/PendingTransactionTracker';\nimport { projectLogger as log } from './logger';\nimport type {\n Events,\n DappSuggestedGasFees,\n SavedGasFees,\n SecurityProviderRequest,\n SendFlowHistoryEntry,\n TransactionParams,\n TransactionMeta,\n TransactionReceipt,\n WalletDevice,\n SecurityAlertResponse,\n} from './types';\nimport {\n TransactionEnvelopeType,\n TransactionType,\n TransactionStatus,\n} from './types';\nimport { validateConfirmedExternalTransaction } from './utils/external-transactions';\nimport { addGasBuffer, estimateGas, updateGas } from './utils/gas';\nimport { updateGasFees } from './utils/gas-fees';\nimport {\n addInitialHistorySnapshot,\n updateTransactionHistory,\n} from './utils/history';\nimport {\n updatePostTransactionBalance,\n updateSwapsTransaction,\n} from './utils/swaps';\nimport { determineTransactionType } from './utils/transaction-type';\nimport {\n getAndFormatTransactionsForNonceTracker,\n getIncreasedPriceFromExisting,\n normalizeTxParams,\n isEIP1559Transaction,\n isFeeMarketEIP1559Values,\n isGasPriceValue,\n validateGasValues,\n validateIfTransactionUnapproved,\n validateMinimumIncrease,\n normalizeTxError,\n normalizeGasFeeValues,\n} from './utils/utils';\nimport {\n validateTransactionOrigin,\n validateTxParams,\n} from './utils/validation';\n\nexport const HARDFORK = Hardfork.London;\n\n/**\n * @type Result\n * @property result - Promise resolving to a new transaction hash\n * @property transactionMeta - Meta information about this new transaction\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface Result {\n result: Promise<string>;\n transactionMeta: TransactionMeta;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface GasPriceValue {\n gasPrice: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface FeeMarketEIP1559Values {\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n}\n\n/**\n * @type TransactionConfig\n *\n * Transaction controller configuration\n * @property provider - Provider used to create a new underlying EthQuery instance\n * @property sign - Method used to sign transactions\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionConfig extends BaseConfig {\n sign?: (txParams: TransactionParams, from: string) => Promise<any>;\n txHistoryLimit: number;\n}\n\n/**\n * @type MethodData\n *\n * Method data registry object\n * @property registryMethod - Registry method raw string\n * @property parsedRegistryMethod - Registry method object, containing name and method arguments\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface MethodData {\n registryMethod: string;\n parsedRegistryMethod: Record<string, unknown>;\n}\n\n/**\n * @type TransactionState\n *\n * Transaction controller state\n * @property transactions - A list of TransactionMeta objects\n * @property methodData - Object containing all known method data information\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionState extends BaseState {\n transactions: TransactionMeta[];\n methodData: { [key: string]: MethodData };\n lastFetchedBlockNumbers: { [key: string]: number };\n}\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during cancellation\n */\nexport const CANCEL_RATE = 1.5;\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during speed up\n */\nexport const SPEED_UP_RATE = 1.1;\n\n/**\n * The name of the {@link TransactionController}.\n */\nconst controllerName = 'TransactionController';\n\n/**\n * The external actions available to the {@link TransactionController}.\n */\ntype AllowedActions = AddApprovalRequest;\n\n/**\n * The messenger of the {@link TransactionController}.\n */\nexport type TransactionControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionControllerEventEmitter extends EventEmitter {\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): this;\n\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n}\n\n/**\n * Controller responsible for submitting and managing transactions.\n */\nexport class TransactionController extends BaseControllerV1<\n TransactionConfig,\n TransactionState\n> {\n private ethQuery: EthQuery;\n\n private readonly isHistoryDisabled: boolean;\n\n private readonly isSwapsDisabled: boolean;\n\n private readonly isSendFlowHistoryDisabled: boolean;\n\n private readonly inProcessOfSigning: Set<string> = new Set();\n\n private readonly nonceTracker: NonceTracker;\n\n private registry: any;\n\n private readonly provider: Provider;\n\n private readonly mutex = new Mutex();\n\n private readonly getSavedGasFees: (chainId: Hex) => SavedGasFees | undefined;\n\n private readonly getNetworkState: () => NetworkState;\n\n private readonly getCurrentAccountEIP1559Compatibility: () => Promise<boolean>;\n\n private readonly getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;\n\n private readonly getGasFeeEstimates: () => Promise<GasFeeState>;\n\n private readonly getPermittedAccounts: (origin?: string) => Promise<string[]>;\n\n private readonly getSelectedAddress: () => string;\n\n private readonly messagingSystem: TransactionControllerMessenger;\n\n private readonly incomingTransactionHelper: IncomingTransactionHelper;\n\n private readonly securityProviderRequest?: SecurityProviderRequest;\n\n private readonly pendingTransactionTracker: PendingTransactionTracker;\n\n private readonly afterSign: (\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ) => boolean;\n\n private readonly beforeApproveOnInit: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n\n private readonly beforeCheckPendingTransaction: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n\n private readonly beforePublish: (transactionMeta: TransactionMeta) => boolean;\n\n private readonly getAdditionalSignArguments: (\n transactionMeta: TransactionMeta,\n ) => (TransactionMeta | undefined)[];\n\n private failTransaction(\n transactionMeta: TransactionMeta,\n error: Error,\n actionId?: string,\n ) {\n const newTransactionMeta = {\n ...transactionMeta,\n error: normalizeTxError(error),\n status: TransactionStatus.failed,\n };\n this.hub.emit('transaction-failed', {\n actionId,\n error: error.message,\n transactionMeta: newTransactionMeta,\n });\n this.updateTransaction(\n newTransactionMeta,\n 'TransactionController#failTransaction - Add error message and set status to failed',\n );\n this.onTransactionStatusChange(newTransactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);\n }\n\n private async registryLookup(fourBytePrefix: string): Promise<MethodData> {\n const registryMethod = await this.registry.lookup(fourBytePrefix);\n const parsedRegistryMethod = this.registry.parse(registryMethod);\n return { registryMethod, parsedRegistryMethod };\n }\n\n /**\n * EventEmitter instance used to listen to specific transactional events\n */\n hub = new EventEmitter() as TransactionControllerEventEmitter;\n\n /**\n * Name of this controller used during composition\n */\n override name = 'TransactionController';\n\n /**\n * Method used to sign transactions\n */\n sign?: (\n transaction: TypedTransaction,\n from: string,\n transactionMeta?: TransactionMeta,\n ) => Promise<TypedTransaction>;\n\n /**\n * Creates a TransactionController instance.\n *\n * @param options - The controller options.\n * @param options.blockTracker - The block tracker used to poll for new blocks data.\n * @param options.disableHistory - Whether to disable storing history in transaction metadata.\n * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.\n * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.\n * @param options.getSavedGasFees - Gets the saved gas fee config.\n * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.\n * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.\n * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.\n * @param options.getNetworkState - Gets the state of the network controller.\n * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.\n * @param options.getSelectedAddress - Gets the address of the currently selected account.\n * @param options.incomingTransactions - Configuration options for incoming transaction support.\n * @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.\n * @param options.incomingTransactions.isEnabled - Whether or not incoming transaction retrieval is enabled.\n * @param options.incomingTransactions.queryEntireHistory - Whether to initially query the entire transaction history or only recent blocks.\n * @param options.incomingTransactions.updateTransactions - Whether to update local transactions using remote transaction data.\n * @param options.messenger - The controller messenger.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.pendingTransactions - Configuration options for pending transaction support.\n * @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.\n * @param options.provider - The provider used to create the underlying EthQuery instance.\n * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.\n * @param options.hooks - The controller hooks.\n * @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.\n * @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.\n * @param options.hooks.beforeCheckPendingTransaction - Additional logic to execute before checking pending transactions. Return false to prevent the broadcast of the transaction.\n * @param options.hooks.beforePublish - Additional logic to execute before publishing a transaction. Return false to prevent the broadcast of the transaction.\n * @param options.hooks.getAdditionalSignArguments - Returns additional arguments required to sign a transaction.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n blockTracker,\n disableHistory,\n disableSendFlowHistory,\n disableSwaps,\n getSavedGasFees,\n getCurrentAccountEIP1559Compatibility,\n getCurrentNetworkEIP1559Compatibility,\n getGasFeeEstimates,\n getNetworkState,\n getPermittedAccounts,\n getSelectedAddress,\n incomingTransactions = {},\n messenger,\n onNetworkStateChange,\n pendingTransactions = {},\n provider,\n securityProviderRequest,\n hooks = {},\n }: {\n blockTracker: BlockTracker;\n disableHistory: boolean;\n disableSendFlowHistory: boolean;\n disableSwaps: boolean;\n getSavedGasFees?: (chainId: Hex) => SavedGasFees | undefined;\n getCurrentAccountEIP1559Compatibility?: () => Promise<boolean>;\n getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;\n getGasFeeEstimates?: () => Promise<GasFeeState>;\n getNetworkState: () => NetworkState;\n getPermittedAccounts: (origin?: string) => Promise<string[]>;\n getSelectedAddress: () => string;\n incomingTransactions?: {\n includeTokenTransfers?: boolean;\n isEnabled?: () => boolean;\n queryEntireHistory?: boolean;\n updateTransactions?: boolean;\n };\n messenger: TransactionControllerMessenger;\n onNetworkStateChange: (listener: (state: NetworkState) => void) => void;\n pendingTransactions?: {\n isResubmitEnabled?: boolean;\n };\n provider: Provider;\n securityProviderRequest?: SecurityProviderRequest;\n hooks: {\n afterSign?: (\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ) => boolean;\n beforeApproveOnInit?: (transactionMeta: TransactionMeta) => boolean;\n beforeCheckPendingTransaction?: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n beforePublish?: (transactionMeta: TransactionMeta) => boolean;\n getAdditionalSignArguments?: (\n transactionMeta: TransactionMeta,\n ) => (TransactionMeta | undefined)[];\n };\n },\n config?: Partial<TransactionConfig>,\n state?: Partial<TransactionState>,\n ) {\n super(config, state);\n\n this.defaultConfig = {\n txHistoryLimit: 40,\n };\n\n this.defaultState = {\n methodData: {},\n transactions: [],\n lastFetchedBlockNumbers: {},\n };\n\n this.initialize();\n\n this.provider = provider;\n this.messagingSystem = messenger;\n this.getNetworkState = getNetworkState;\n this.ethQuery = new EthQuery(provider);\n this.isSendFlowHistoryDisabled = disableSendFlowHistory ?? false;\n this.isHistoryDisabled = disableHistory ?? false;\n this.isSwapsDisabled = disableSwaps ?? false;\n this.registry = new MethodRegistry({ provider });\n this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);\n this.getCurrentAccountEIP1559Compatibility =\n getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));\n this.getCurrentNetworkEIP1559Compatibility =\n getCurrentNetworkEIP1559Compatibility;\n this.getGasFeeEstimates =\n getGasFeeEstimates || (() => Promise.resolve({} as GasFeeState));\n this.getPermittedAccounts = getPermittedAccounts;\n this.getSelectedAddress = getSelectedAddress;\n this.securityProviderRequest = securityProviderRequest;\n\n this.afterSign = hooks?.afterSign ?? (() => true);\n this.beforeApproveOnInit = hooks?.beforeApproveOnInit ?? (() => true);\n this.beforeCheckPendingTransaction =\n hooks?.beforeCheckPendingTransaction ??\n /* istanbul ignore next */\n (() => true);\n this.beforePublish = hooks?.beforePublish ?? (() => true);\n this.getAdditionalSignArguments =\n hooks?.getAdditionalSignArguments ?? (() => []);\n\n this.nonceTracker = new NonceTracker({\n // @ts-expect-error provider types misaligned: SafeEventEmitterProvider vs Record<string,string>\n provider,\n blockTracker,\n getPendingTransactions: this.getNonceTrackerTransactions.bind(\n this,\n TransactionStatus.submitted,\n ),\n getConfirmedTransactions: this.getNonceTrackerTransactions.bind(\n this,\n TransactionStatus.confirmed,\n ),\n });\n\n this.incomingTransactionHelper = new IncomingTransactionHelper({\n blockTracker,\n getCurrentAccount: getSelectedAddress,\n getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,\n getNetworkState,\n isEnabled: incomingTransactions.isEnabled,\n queryEntireHistory: incomingTransactions.queryEntireHistory,\n remoteTransactionSource: new EtherscanRemoteTransactionSource({\n includeTokenTransfers: incomingTransactions.includeTokenTransfers,\n }),\n transactionLimit: this.config.txHistoryLimit,\n updateTransactions: incomingTransactions.updateTransactions,\n });\n\n this.incomingTransactionHelper.hub.on(\n 'transactions',\n this.onIncomingTransactions.bind(this),\n );\n\n this.incomingTransactionHelper.hub.on(\n 'updatedLastFetchedBlockNumbers',\n this.onUpdatedLastFetchedBlockNumbers.bind(this),\n );\n\n this.pendingTransactionTracker = new PendingTransactionTracker({\n approveTransaction: this.approveTransaction.bind(this),\n blockTracker,\n getChainId: this.getChainId.bind(this),\n getEthQuery: () => this.ethQuery,\n getTransactions: () => this.state.transactions,\n isResubmitEnabled: pendingTransactions.isResubmitEnabled,\n nonceTracker: this.nonceTracker,\n onStateChange: this.subscribe.bind(this),\n publishTransaction: this.publishTransaction.bind(this),\n hooks: {\n beforeCheckPendingTransaction:\n this.beforeCheckPendingTransaction.bind(this),\n beforePublish: this.beforePublish.bind(this),\n },\n });\n\n this.addPendingTransactionTrackerListeners();\n\n onNetworkStateChange(() => {\n this.ethQuery = new EthQuery(this.provider);\n this.registry = new MethodRegistry({ provider: this.provider });\n this.onBootCleanup();\n });\n\n this.onBootCleanup();\n }\n\n /**\n * Handle new method data request.\n *\n * @param fourBytePrefix - The method prefix.\n * @returns The method data object corresponding to the given signature prefix.\n */\n async handleMethodData(fourBytePrefix: string): Promise<MethodData> {\n const releaseLock = await this.mutex.acquire();\n try {\n const { methodData } = this.state;\n const knownMethod = Object.keys(methodData).find(\n (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix,\n );\n if (knownMethod) {\n return methodData[fourBytePrefix];\n }\n const registry = await this.registryLookup(fourBytePrefix);\n this.update({\n methodData: { ...methodData, ...{ [fourBytePrefix]: registry } },\n });\n return registry;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Add a new unapproved transaction to state. Parameters will be validated, a\n * unique transaction id will be generated, and gas and gasPrice will be calculated\n * if not provided. If A `<tx.id>:unapproved` hub event will be emitted once added.\n *\n * @param txParams - Standard parameters for an Ethereum transaction.\n * @param opts - Additional options to control how the transaction is added.\n * @param opts.actionId - Unique ID to prevent duplicate requests.\n * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.\n * @param opts.method - RPC method that requested the transaction.\n * @param opts.origin - The origin of the transaction request, such as a dApp hostname.\n * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.\n * @param opts.securityAlertResponse - Response from security validator.\n * @param opts.sendFlowHistory - The sendFlowHistory entries to add.\n * @param opts.type - Type of transaction to add, such as 'cancel' or 'swap'.\n * @param opts.swaps - Options for swaps transactions.\n * @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.\n * @param opts.swaps.meta - Metadata for swap transaction.\n * @returns Object containing a promise resolving to the transaction hash if approved.\n */\n async addTransaction(\n txParams: TransactionParams,\n {\n actionId,\n deviceConfirmedOn,\n method,\n origin,\n requireApproval,\n securityAlertResponse,\n sendFlowHistory,\n swaps = {},\n type,\n }: {\n actionId?: string;\n deviceConfirmedOn?: WalletDevice;\n method?: string;\n origin?: string;\n requireApproval?: boolean | undefined;\n securityAlertResponse?: SecurityAlertResponse;\n sendFlowHistory?: SendFlowHistoryEntry[];\n swaps?: {\n hasApproveTx?: boolean;\n meta?: Partial<TransactionMeta>;\n };\n type?: TransactionType;\n } = {},\n ): Promise<Result> {\n log('Adding transaction', txParams);\n\n txParams = normalizeTxParams(txParams);\n\n const isEIP1559Compatible = await this.getEIP1559Compatibility();\n\n validateTxParams(txParams, isEIP1559Compatible);\n\n if (origin) {\n await validateTransactionOrigin(\n await this.getPermittedAccounts(origin),\n this.getSelectedAddress(),\n txParams.from,\n origin,\n );\n }\n\n const dappSuggestedGasFees = this.generateDappSuggestedGasFees(\n txParams,\n origin,\n );\n\n const transactionType =\n type ?? (await determineTransactionType(txParams, this.ethQuery)).type;\n\n const existingTransactionMeta = this.getTransactionWithActionId(actionId);\n const chainId = this.getChainId();\n\n // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.\n const transactionMeta: TransactionMeta = existingTransactionMeta || {\n // Add actionId to txMeta to check if same actionId is seen again\n actionId,\n chainId,\n dappSuggestedGasFees,\n deviceConfirmedOn,\n id: random(),\n origin,\n securityAlertResponse,\n status: TransactionStatus.unapproved as TransactionStatus.unapproved,\n time: Date.now(),\n txParams,\n userEditedGasLimit: false,\n verifiedOnBlockchain: false,\n type: transactionType,\n };\n\n await this.updateGasProperties(transactionMeta);\n\n // Checks if a transaction already exists with a given actionId\n if (!existingTransactionMeta) {\n // Set security provider response\n if (method && this.securityProviderRequest) {\n const securityProviderResponse = await this.securityProviderRequest(\n transactionMeta,\n method,\n );\n transactionMeta.securityProviderResponse = securityProviderResponse;\n }\n\n if (!this.isSendFlowHistoryDisabled) {\n transactionMeta.sendFlowHistory = sendFlowHistory ?? [];\n }\n // Initial history push\n if (!this.isHistoryDisabled) {\n addInitialHistorySnapshot(transactionMeta);\n }\n\n await updateSwapsTransaction(transactionMeta, transactionType, swaps, {\n isSwapsDisabled: this.isSwapsDisabled,\n cancelTransaction: this.cancelTransaction.bind(this),\n controllerHubEmitter: this.hub.emit.bind(this.hub) as any,\n });\n\n this.addMetadata(transactionMeta);\n this.hub.emit(`unapprovedTransaction`, transactionMeta);\n }\n\n return {\n result: this.processApproval(transactionMeta, {\n isExisting: Boolean(existingTransactionMeta),\n requireApproval,\n actionId,\n }),\n transactionMeta,\n };\n }\n\n startIncomingTransactionPolling() {\n this.incomingTransactionHelper.start();\n }\n\n stopIncomingTransactionPolling() {\n this.incomingTransactionHelper.stop();\n }\n\n async updateIncomingTransactions() {\n await this.incomingTransactionHelper.update();\n }\n\n /**\n * Attempts to cancel a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `<tx.id>:finished` hub event.\n *\n * @param transactionId - The ID of the transaction to cancel.\n * @param gasValues - The gas values to use for the cancellation transaction.\n * @param options - The options for the cancellation transaction.\n * @param options.actionId - Unique ID to prevent duplicate requests.\n * @param options.estimatedBaseFee - The estimated base fee of the transaction.\n */\n async stopTransaction(\n transactionId: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n {\n estimatedBaseFee,\n actionId,\n }: { estimatedBaseFee?: string; actionId?: string } = {},\n ) {\n // If transaction is found for same action id, do not create a cancel transaction.\n if (this.getTransactionWithActionId(actionId)) {\n return;\n }\n\n if (gasValues) {\n // Not good practice to reassign a parameter but temporarily avoiding a larger refactor.\n gasValues = normalizeGasFeeValues(gasValues);\n validateGasValues(gasValues);\n }\n\n const transactionMeta = this.getTransaction(transactionId);\n if (!transactionMeta) {\n return;\n }\n\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.txParams.gasPrice,\n CANCEL_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n CANCEL_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.txParams?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n CANCEL_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const newTxParams: TransactionParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n from: transactionMeta.txParams.from,\n gasLimit: transactionMeta.txParams.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: TransactionEnvelopeType.feeMarket,\n nonce: transactionMeta.txParams.nonce,\n to: transactionMeta.txParams.from,\n value: '0x0',\n }\n : {\n from: transactionMeta.txParams.from,\n gasLimit: transactionMeta.txParams.gas,\n gasPrice: newGasPrice,\n nonce: transactionMeta.txParams.nonce,\n to: transactionMeta.txParams.from,\n value: '0x0',\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(newTxParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.txParams.from,\n );\n const rawTx = bufferToHex(signedTx.serialize());\n const hash = await this.publishTransaction(rawTx);\n const cancelTransactionMeta: TransactionMeta = {\n actionId,\n chainId: transactionMeta.chainId,\n estimatedBaseFee,\n hash,\n id: random(),\n originalGasEstimate: transactionMeta.txParams.gas,\n status: TransactionStatus.submitted,\n time: Date.now(),\n type: TransactionType.cancel,\n txParams: newTxParams,\n };\n\n this.addMetadata(cancelTransactionMeta);\n\n // stopTransaction has no approval request, so we assume the user has already approved the transaction\n this.hub.emit('transaction-approved', {\n transactionMeta: cancelTransactionMeta,\n actionId,\n });\n this.hub.emit('transaction-submitted', {\n transactionMeta: cancelTransactionMeta,\n actionId,\n });\n\n this.hub.emit(\n `${cancelTransactionMeta.id}:finished`,\n cancelTransactionMeta,\n );\n }\n\n /**\n * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.\n *\n * @param transactionId - The ID of the transaction to speed up.\n * @param gasValues - The gas values to use for the speed up transaction.\n * @param options - The options for the speed up transaction.\n * @param options.actionId - Unique ID to prevent duplicate requests\n * @param options.estimatedBaseFee - The estimated base fee of the transaction.\n */\n async speedUpTransaction(\n transactionId: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n {\n actionId,\n estimatedBaseFee,\n }: { actionId?: string; estimatedBaseFee?: string } = {},\n ) {\n // If transaction is found for same action id, do not create a new speed up transaction.\n if (this.getTransactionWithActionId(actionId)) {\n return;\n }\n\n if (gasValues) {\n // Not good practice to reassign a parameter but temporarily avoiding a larger refactor.\n gasValues = normalizeGasFeeValues(gasValues);\n validateGasValues(gasValues);\n }\n\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n /* istanbul ignore next */\n if (!transactionMeta) {\n return;\n }\n\n /* istanbul ignore next */\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.txParams.gasPrice,\n SPEED_UP_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n SPEED_UP_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.txParams?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n SPEED_UP_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams: TransactionParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: TransactionEnvelopeType.feeMarket,\n }\n : {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n gasPrice: newGasPrice,\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.txParams.from,\n );\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n const rawTx = bufferToHex(signedTx.serialize());\n const hash = await query(this.ethQuery, 'sendRawTransaction', [rawTx]);\n const baseTransactionMeta: TransactionMeta = {\n ...transactionMeta,\n estimatedBaseFee,\n id: random(),\n time: Date.now(),\n hash,\n actionId,\n originalGasEstimate: transactionMeta.txParams.gas,\n type: TransactionType.retry,\n originalType: transactionMeta.type,\n };\n const newTransactionMeta =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...baseTransactionMeta,\n txParams: {\n ...transactionMeta.txParams,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n },\n }\n : {\n ...baseTransactionMeta,\n txParams: {\n ...transactionMeta.txParams,\n gasPrice: newGasPrice,\n },\n };\n this.addMetadata(newTransactionMeta);\n\n // speedUpTransaction has no approval request, so we assume the user has already approved the transaction\n this.hub.emit('transaction-approved', {\n transactionMeta: newTransactionMeta,\n actionId,\n });\n this.hub.emit('transaction-submitted', {\n transactionMeta: newTransactionMeta,\n actionId,\n });\n\n this.hub.emit(`${transactionMeta.id}:speedup`, newTransactionMeta);\n }\n\n /**\n * Estimates required gas for a given transaction.\n *\n * @param transaction - The transaction to estimate gas for.\n * @returns The gas and gas price.\n */\n async estimateGas(transaction: TransactionParams) {\n const { estimatedGas, simulationFails } = await estimateGas(\n transaction,\n this.ethQuery,\n );\n\n return { gas: estimatedGas, simulationFails };\n }\n\n /**\n * Estimates required gas for a given transaction and add additional gas buffer with the given multiplier.\n *\n * @param transaction - The transaction params to estimate gas for.\n * @param multiplier - The multiplier to use for the gas buffer.\n */\n async estimateGasBuffered(\n transaction: TransactionParams,\n multiplier: number,\n ) {\n const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(\n transaction,\n this.ethQuery,\n );\n\n const gas = addGasBuffer(estimatedGas, blockGasLimit, multiplier);\n\n return {\n gas,\n simulationFails,\n };\n }\n\n /**\n * Updates an existing transaction in state.\n *\n * @param transactionMeta - The new transaction to store in state.\n * @param note - A note or update reason to include in the transaction history.\n */\n updateTransaction(transactionMeta: TransactionMeta, note: string) {\n const { transactions } = this.state;\n transactionMeta.txParams = normalizeTxParams(transactionMeta.txParams);\n validateTxParams(transactionMeta.txParams);\n if (!this.isHistoryDisabled) {\n updateTransactionHistory(transactionMeta, note);\n }\n const index = transactions.findIndex(({ id }) => transactionMeta.id === id);\n transactions[index] = transactionMeta;\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Update the security alert response for a transaction.\n *\n * @param transactionId - ID of the transaction.\n * @param securityAlertResponse - The new security alert response for the transaction.\n */\n updateSecurityAlertResponse(\n transactionId: string,\n securityAlertResponse: SecurityAlertResponse,\n ) {\n if (!securityAlertResponse) {\n throw new Error(\n 'updateSecurityAlertResponse: securityAlertResponse should not be null',\n );\n }\n const transactionMeta = this.getTransaction(transactionId);\n if (!transactionMeta) {\n throw new Error(\n `Cannot update security alert response as no transaction metadata found`,\n );\n }\n const updatedMeta = merge(transactionMeta, { securityAlertResponse });\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updatesecurityAlertResponse - securityAlertResponse updated',\n );\n }\n\n /**\n * Removes all transactions from state, optionally based on the current network.\n *\n * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the\n * current network. If `true`, all transactions are wiped.\n * @param address - If specified, only transactions originating from this address will be\n * wiped on current network.\n */\n wipeTransactions(ignoreNetwork?: boolean, address?: string) {\n /* istanbul ignore next */\n if (ignoreNetwork && !address) {\n this.update({ transactions: [] });\n return;\n }\n const currentChainId = this.getChainId();\n const newTransactions = this.state.transactions.filter(\n ({ chainId, txParams }) => {\n const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;\n\n if (!isMatchingNetwork) {\n return true;\n }\n\n const isMatchingAddress =\n !address || txParams.from?.toLowerCase() === address.toLowerCase();\n\n return !isMatchingAddress;\n },\n );\n\n this.update({\n transactions: this.trimTransactionsForState(newTransactions),\n });\n }\n\n startIncomingTransactionProcessing() {\n this.incomingTransactionHelper.start();\n }\n\n stopIncomingTransactionProcessing() {\n this.incomingTransactionHelper.stop();\n }\n\n /**\n * Adds external provided transaction to state as confirmed transaction.\n *\n * @param transactionMeta - TransactionMeta to add transactions.\n * @param transactionReceipt - TransactionReceipt of the external transaction.\n * @param baseFeePerGas - Base fee per gas of the external transaction.\n */\n async confirmExternalTransaction(\n transactionMeta: TransactionMeta,\n transactionReceipt: TransactionReceipt,\n baseFeePerGas: Hex,\n ) {\n // Run validation and add external transaction to state.\n this.addExternalTransaction(transactionMeta);\n\n try {\n const transactionId = transactionMeta.id;\n\n // Make sure status is confirmed and define gasUsed as in receipt.\n transactionMeta.status = TransactionStatus.confirmed;\n transactionMeta.txReceipt = transactionReceipt;\n if (baseFeePerGas) {\n transactionMeta.baseFeePerGas = baseFeePerGas;\n }\n\n // Update same nonce local transactions as dropped and define replacedBy properties.\n this.markNonceDuplicatesDropped(transactionId);\n\n // Update external provided transaction with updated gas values and confirmed status.\n this.updateTransaction(\n transactionMeta,\n 'TransactionController:confirmExternalTransaction - Add external transaction',\n );\n this.onTransactionStatusChange(transactionMeta);\n\n // Intentional given potential duration of process.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.updatePostBalance(transactionMeta);\n\n this.hub.emit('transaction-confirmed', {\n transactionMeta,\n });\n } catch (error) {\n console.error('Failed to confirm external transaction', error);\n }\n }\n\n /**\n * Append new send flow history to a transaction.\n *\n * @param transactionID - The ID of the transaction to update.\n * @param currentSendFlowHistoryLength - The length of the current sendFlowHistory array.\n * @param sendFlowHistoryToAdd - The sendFlowHistory entries to add.\n * @returns The updated transactionMeta.\n */\n updateTransactionSendFlowHistory(\n transactionID: string,\n currentSendFlowHistoryLength: number,\n sendFlowHistoryToAdd: SendFlowHistoryEntry[],\n ): TransactionMeta {\n if (this.isSendFlowHistoryDisabled) {\n throw new Error(\n 'Send flow history is disabled for the current transaction controller',\n );\n }\n\n const transactionMeta = this.getTransaction(transactionID);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update send flow history as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateTransactionSendFlowHistory',\n );\n\n if (\n currentSendFlowHistoryLength ===\n (transactionMeta?.sendFlowHistory?.length || 0)\n ) {\n transactionMeta.sendFlowHistory = [\n ...(transactionMeta?.sendFlowHistory ?? []),\n ...sendFlowHistoryToAdd,\n ];\n this.updateTransaction(\n transactionMeta,\n 'TransactionController:updateTransactionSendFlowHistory - sendFlowHistory updated',\n );\n }\n\n return this.getTransaction(transactionID) as TransactionMeta;\n }\n\n /**\n * Update the gas values of a transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param gasValues - Gas values to update.\n * @param gasValues.gas - Same as transaction.gasLimit.\n * @param gasValues.gasLimit - Maxmimum number of units of gas to use for this transaction.\n * @param gasValues.gasPrice - Price per gas for legacy transactions.\n * @param gasValues.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.\n * @param gasValues.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.\n * @param gasValues.estimateUsed - Which estimate level was used.\n * @param gasValues.estimateSuggested - Which estimate level that the API suggested.\n * @param gasValues.defaultGasEstimates - The default estimate for gas.\n * @param gasValues.originalGasEstimate - Original estimate for gas.\n * @param gasValues.userEditedGasLimit - The gas limit supplied by user.\n * @param gasValues.userFeeLevel - Estimate level user selected.\n * @returns The updated transactionMeta.\n */\n updateTransactionGasFees(\n transactionId: string,\n {\n defaultGasEstimates,\n estimateUsed,\n estimateSuggested,\n gas,\n gasLimit,\n gasPrice,\n maxPriorityFeePerGas,\n maxFeePerGas,\n originalGasEstimate,\n userEditedGasLimit,\n userFeeLevel,\n }: {\n defaultGasEstimates?: string;\n estimateUsed?: string;\n estimateSuggested?: string;\n gas?: string;\n gasLimit?: string;\n gasPrice?: string;\n maxPriorityFeePerGas?: string;\n maxFeePerGas?: string;\n originalGasEstimate?: string;\n userEditedGasLimit?: boolean;\n userFeeLevel?: string;\n },\n ): TransactionMeta {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update transaction as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateTransactionGasFees',\n );\n\n let transactionGasFees = {\n txParams: {\n gas,\n gasLimit,\n gasPrice,\n maxPriorityFeePerGas,\n maxFeePerGas,\n },\n defaultGasEstimates,\n estimateUsed,\n estimateSuggested,\n originalGasEstimate,\n userEditedGasLimit,\n userFeeLevel,\n } as any;\n\n // only update what is defined\n transactionGasFees.txParams = pickBy(transactionGasFees.txParams);\n transactionGasFees = pickBy(transactionGasFees);\n\n // merge updated gas values with existing transaction meta\n const updatedMeta = merge(transactionMeta, transactionGasFees);\n\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updateTransactionGasFees - gas values updated',\n );\n\n return this.getTransaction(transactionId) as TransactionMeta;\n }\n\n /**\n * Update the previous gas values of a transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param previousGas - Previous gas values to update.\n * @param previousGas.gasLimit - Maxmimum number of units of gas to use for this transaction.\n * @param previousGas.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.\n * @param previousGas.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.\n * @returns The updated transactionMeta.\n */\n updatePreviousGasParams(\n transactionId: string,\n {\n gasLimit,\n maxFeePerGas,\n maxPriorityFeePerGas,\n }: {\n gasLimit?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n },\n ): TransactionMeta {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update transaction as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(transactionMeta, 'updatePreviousGasParams');\n\n const transactionPreviousGas = {\n previousGas: {\n gasLimit,\n maxFeePerGas,\n maxPriorityFeePerGas,\n },\n } as any;\n\n // only update what is defined\n transactionPreviousGas.previousGas = pickBy(\n transactionPreviousGas.previousGas,\n );\n\n // merge updated previous gas values with existing transaction meta\n const updatedMeta = merge(transactionMeta, transactionPreviousGas);\n\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updatePreviousGasParams - Previous gas values updated',\n );\n\n return this.getTransaction(transactionId) as TransactionMeta;\n }\n\n /**\n * Gets the next nonce according to the nonce-tracker.\n * Ensure `releaseLock` is called once processing of the `nonce` value is complete.\n *\n * @param address - The hex string address for the transaction.\n * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.\n */\n async getNonceLock(address: string): Promise<NonceLock> {\n return this.nonceTracker.getNonceLock(address);\n }\n\n /**\n * Updates the editable parameters of a transaction.\n *\n * @param txId - The ID of the transaction to update.\n * @param params - The editable parameters to update.\n * @param params.data - Data to pass with the transaction.\n * @param params.gas - Maximum number of units of gas to use for the transaction.\n * @param params.gasPrice - Price per gas for legacy transactions.\n * @param params.from - Address to send the transaction from.\n * @param params.to - Address to send the transaction to.\n * @param params.value - Value associated with the transaction.\n * @returns The updated transaction metadata.\n */\n async updateEditableParams(\n txId: string,\n {\n data,\n gas,\n gasPrice,\n from,\n to,\n value,\n }: {\n data?: string;\n gas?: string;\n gasPrice?: string;\n from?: string;\n to?: string;\n value?: string;\n },\n ) {\n const transactionMeta = this.getTransaction(txId);\n if (!transactionMeta) {\n throw new Error(\n `Cannot update editable params as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(transactionMeta, 'updateEditableParams');\n\n const editableParams = {\n txParams: {\n data,\n from,\n to,\n value,\n gas,\n gasPrice,\n },\n } as Partial<TransactionMeta>;\n\n editableParams.txParams = pickBy(\n editableParams.txParams,\n ) as TransactionParams;\n\n const updatedTransaction = merge(transactionMeta, editableParams);\n const { type } = await determineTransactionType(\n updatedTransaction.txParams,\n this.ethQuery,\n );\n updatedTransaction.type = type;\n\n this.updateTransaction(\n updatedTransaction,\n `Update Editable Params for ${txId}`,\n );\n return this.getTransaction(txId);\n }\n\n /**\n * Signs and returns the raw transaction data for provided transaction params list.\n *\n * @param listOfTxParams - The list of transaction params to approve.\n * @returns The raw transactions.\n */\n async approveTransactionsWithSameNonce(\n listOfTxParams: TransactionParams[] = [],\n ): Promise<string | string[]> {\n if (listOfTxParams.length === 0) {\n return '';\n }\n\n const initialTx = listOfTxParams[0];\n const common = this.getCommonConfiguration();\n\n const initialTxAsEthTx = TransactionFactory.fromTxData(initialTx, {\n common,\n });\n\n const initialTxAsSerializedHex = bufferToHex(initialTxAsEthTx.serialize());\n\n if (this.inProcessOfSigning.has(initialTxAsSerializedHex)) {\n return '';\n }\n\n this.inProcessOfSigning.add(initialTxAsSerializedHex);\n\n let rawTransactions, nonceLock;\n try {\n // TODO: we should add a check to verify that all transactions have the same from address\n const fromAddress = initialTx.from;\n nonceLock = await this.nonceTracker.getNonceLock(fromAddress);\n const nonce = nonceLock.nextNonce;\n\n rawTransactions = await Promise.all(\n listOfTxParams.map((txParams) => {\n txParams.nonce = addHexPrefix(nonce.toString(16));\n return this.signExternalTransaction(txParams);\n }),\n );\n } catch (err) {\n log('Error while signing transactions with same nonce', err);\n // Must set transaction to submitted/failed before releasing lock\n // continue with error chain\n throw err;\n } finally {\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n this.inProcessOfSigning.delete(initialTxAsSerializedHex);\n }\n return rawTransactions;\n }\n\n /**\n * Update a custodial transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param options - The custodial transaction options to update.\n * @param options.errorMessage - The error message to be assigned in case transaction status update to failed.\n * @param options.hash - The new hash value to be assigned.\n * @param options.status - The new status value to be assigned.\n */\n updateCustodialTransaction(\n transactionId: string,\n {\n errorMessage,\n hash,\n status,\n }: {\n errorMessage?: string;\n hash?: string;\n status?: TransactionStatus;\n },\n ) {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update custodial transaction as no transaction metadata found`,\n );\n }\n\n if (!transactionMeta.custodyId) {\n throw new Error('Transaction must be a custodian transaction');\n }\n\n if (\n status &&\n ![\n TransactionStatus.submitted,\n TransactionStatus.signed,\n TransactionStatus.failed,\n ].includes(status)\n ) {\n throw new Error(\n `Cannot update custodial transaction with status: ${status}`,\n );\n }\n\n const updatedTransactionMeta = merge(\n transactionMeta,\n pickBy({ hash, status }),\n );\n\n if (status === TransactionStatus.submitted) {\n updatedTransactionMeta.submittedTime = new Date().getTime();\n }\n\n if (status === TransactionStatus.failed) {\n updatedTransactionMeta.error = normalizeTxError(new Error(errorMessage));\n }\n\n this.updateTransaction(\n updatedTransactionMeta,\n `TransactionController:updateCustodialTransaction - Custodial transaction updated`,\n );\n }\n\n /**\n * Creates approvals for all unapproved transactions persisted.\n */\n initApprovals() {\n const chainId = this.getChainId();\n const unapprovedTxs = this.state.transactions.filter(\n (transaction) =>\n transaction.status === TransactionStatus.unapproved &&\n transaction.chainId === chainId,\n );\n\n for (const txMeta of unapprovedTxs) {\n this.processApproval(txMeta, {\n shouldShowRequest: false,\n }).catch((error) => {\n if (error?.code === errorCodes.provider.userRejectedRequest) {\n return;\n }\n console.error('Error during persisted transaction approval', error);\n });\n }\n }\n\n /**\n * Search transaction metadata for matching entries.\n *\n * @param opts - Options bag.\n * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.\n * @param opts.initialList - The transactions to search. Defaults to the current state.\n * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.\n * @param opts.limit - The maximum number of transactions to return. No limit by default.\n * @returns An array of transactions matching the provided options.\n */\n getTransactions({\n searchCriteria = {},\n initialList,\n filterToCurrentNetwork = true,\n limit,\n }: {\n searchCriteria?: any;\n initialList?: TransactionMeta[];\n filterToCurrentNetwork?: boolean;\n limit?: number;\n } = {}): TransactionMeta[] {\n const chainId = this.getChainId();\n // searchCriteria is an object that might have values that aren't predicate\n // methods. When providing any other value type (string, number, etc), we\n // consider this shorthand for \"check the value at key for strict equality\n // with the provided value\". To conform this object to be only methods, we\n // mapValues (lodash) such that every value on the object is a method that\n // returns a boolean.\n const predicateMethods = mapValues(searchCriteria, (predicate) => {\n return typeof predicate === 'function'\n ? predicate\n : (v: any) => v === predicate;\n });\n\n const transactionsToFilter = initialList ?? this.state.transactions;\n\n // Combine sortBy and pickBy to transform our state object into an array of\n // matching transactions that are sorted by time.\n const filteredTransactions = sortBy(\n pickBy(transactionsToFilter, (transaction) => {\n if (filterToCurrentNetwork && transaction.chainId !== chainId) {\n return false;\n }\n // iterate over the predicateMethods keys to check if the transaction\n // matches the searchCriteria\n for (const [key, predicate] of Object.entries(predicateMethods)) {\n // We return false early as soon as we know that one of the specified\n // search criteria do not match the transaction. This prevents\n // needlessly checking all criteria when we already know the criteria\n // are not fully satisfied. We check both txParams and the base\n // object as predicate keys can be either.\n if (key in transaction.txParams) {\n if (predicate((transaction.txParams as any)[key]) === false) {\n return false;\n }\n } else if (predicate((transaction as any)[key]) === false) {\n return false;\n }\n }\n\n return true;\n }),\n 'time',\n );\n if (limit !== undefined) {\n // We need to have all transactions of a given nonce in order to display\n // necessary details in the UI. We use the size of this set to determine\n // whether we have reached the limit provided, thus ensuring that all\n // transactions of nonces we include will be sent to the UI.\n const nonces = new Set();\n const txs = [];\n // By default, the transaction list we filter from is sorted by time ASC.\n // To ensure that filtered results prefers the newest transactions we\n // iterate from right to left, inserting transactions into front of a new\n // array. The original order is preserved, but we ensure that newest txs\n // are preferred.\n for (let i = filteredTransactions.length - 1; i > -1; i--) {\n const txMeta = filteredTransactions[i];\n const { nonce } = txMeta.txParams;\n if (!nonces.has(nonce)) {\n if (nonces.size < limit) {\n nonces.add(nonce);\n } else {\n continue;\n }\n }\n // Push transaction into the beginning of our array to ensure the\n // original order is preserved.\n txs.unshift(txMeta);\n }\n return txs;\n }\n return filteredTransactions;\n }\n\n private async signExternalTransaction(\n transactionParams: TransactionParams,\n ): Promise<string> {\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n const normalizedTransactionParams = normalizeTxParams(transactionParams);\n const chainId = this.getChainId();\n const type = isEIP1559Transaction(normalizedTransactionParams)\n ? TransactionEnvelopeType.feeMarket\n : TransactionEnvelopeType.legacy;\n const updatedTransactionParams = {\n ...normalizedTransactionParams,\n type,\n gasLimit: normalizedTransactionParams.gas,\n chainId,\n };\n\n const { from } = updatedTransactionParams;\n const common = this.getCommonConfiguration();\n const unsignedTransaction = TransactionFactory.fromTxData(\n updatedTransactionParams,\n { common },\n );\n const signedTransaction = await this.sign(unsignedTransaction, from);\n\n const rawTransaction = bufferToHex(signedTransaction.serialize());\n return rawTransaction;\n }\n\n /**\n * Removes unapproved transactions from state.\n */\n clearUnapprovedTransactions() {\n const transactions = this.state.transactions.filter(\n ({ status }) => status !== TransactionStatus.unapproved,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n private addMetadata(transactionMeta: TransactionMeta) {\n const { transactions } = this.state;\n transactions.push(transactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n private async updateGasProperties(transactionMeta: TransactionMeta) {\n const isEIP1559Compatible =\n (await this.getEIP1559Compatibility()) &&\n transactionMeta.txParams.type !== TransactionEnvelopeType.legacy;\n\n const chainId = this.getChainId();\n\n await updateGas({\n ethQuery: this.ethQuery,\n providerConfig: this.getNetworkState().providerConfig,\n txMeta: transactionMeta,\n });\n\n await updateGasFees({\n eip1559: isEIP1559Compatible,\n ethQuery: this.ethQuery,\n getSavedGasFees: this.getSavedGasFees.bind(this, chainId),\n getGasFeeEstimates: this.getGasFeeEstimates.bind(this),\n txMeta: transactionMeta,\n });\n }\n\n private getCurrentChainTransactionsByStatus(status: TransactionStatus) {\n const chainId = this.getChainId();\n return this.state.transactions.filter(\n (transaction) =>\n transaction.status === status && transaction.chainId === chainId,\n );\n }\n\n private onBootCleanup() {\n this.submitApprovedTransactions();\n }\n\n /**\n * Create approvals for all unapproved transactions on current chain.\n */\n private createApprovalsForUnapprovedTransactions() {\n const unapprovedTransactions = this.getCurrentChainTransactionsByStatus(\n TransactionStatus.unapproved,\n );\n\n for (const transactionMeta of unapprovedTransactions) {\n this.processApproval(transactionMeta, {\n shouldShowRequest: false,\n }).catch((error) => {\n if (error?.code === errorCodes.provider.userRejectedRequest) {\n return;\n }\n /* istanbul ignore next */\n console.error('Error during persisted transaction approval', error);\n });\n }\n }\n\n /**\n * Force to submit approved transactions on current chain.\n */\n private submitApprovedTransactions() {\n const approvedTransactions = this.getCurrentChainTransactionsByStatus(\n TransactionStatus.approved,\n );\n for (const transactionMeta of approvedTransactions) {\n if (this.beforeApproveOnInit(transactionMeta)) {\n this.approveTransaction(transactionMeta.id).catch((error) => {\n /* istanbul ignore next */\n console.error('Error while submitting persisted transaction', error);\n });\n }\n }\n }\n\n private async processApproval(\n transactionMeta: TransactionMeta,\n {\n isExisting = false,\n requireApproval,\n shouldShowRequest = true,\n actionId,\n }: {\n isExisting?: boolean;\n requireApproval?: boolean | undefined;\n shouldShowRequest?: boolean;\n actionId?: string;\n },\n ): Promise<string> {\n const transactionId = transactionMeta.id;\n let resultCallbacks: AcceptResultCallbacks | undefined;\n const { meta, isCompleted } = this.isTransactionCompleted(transactionId);\n const finishedPromise = isCompleted\n ? Promise.resolve(meta)\n : this.waitForTransactionFinished(transactionId);\n\n if (meta && !isExisting && !isCompleted) {\n try {\n if (requireApproval !== false) {\n const acceptResult = await this.requestApproval(transactionMeta, {\n shouldShowRequest,\n });\n\n resultCallbacks = acceptResult.resultCallbacks;\n\n if (resultCallbacks) {\n this.hub.once(`${transactionId}:publish-skip`, () => {\n resultCallbacks?.success();\n\n // Remove the reference to prevent additional reports once submitted.\n resultCallbacks = undefined;\n });\n }\n }\n\n const { isCompleted: isTxCompleted } =\n this.isTransactionCompleted(transactionId);\n\n if (!isTxCompleted) {\n await this.approveTransaction(transactionId);\n const updatedTransactionMeta = this.getTransaction(\n transactionId,\n ) as TransactionMeta;\n this.hub.emit('transaction-approved', {\n transactionMeta: updatedTransactionMeta,\n actionId,\n });\n }\n } catch (error: any) {\n const { isCompleted: isTxCompleted } =\n this.isTransactionCompleted(transactionId);\n if (!isTxCompleted) {\n if (error?.code === errorCodes.provider.userRejectedRequest) {\n this.cancelTransaction(transactionId, actionId);\n\n throw providerErrors.userRejectedRequest(\n 'MetaMask Tx Signature: User denied transaction signature.',\n );\n } else {\n this.failTransaction(meta, error, actionId);\n }\n }\n }\n }\n\n const finalMeta = await finishedPromise;\n\n switch (finalMeta?.status) {\n case TransactionStatus.failed:\n resultCallbacks?.error(finalMeta.error);\n throw rpcErrors.internal(finalMeta.error.message);\n\n case TransactionStatus.submitted:\n resultCallbacks?.success();\n return finalMeta.hash as string;\n\n default:\n const internalError = rpcErrors.internal(\n `MetaMask Tx Signature: Unknown problem: ${JSON.stringify(\n finalMeta || transactionId,\n )}`,\n );\n\n resultCallbacks?.error(internalError);\n throw internalError;\n }\n }\n\n /**\n * Approves a transaction and updates it's status in state. If this is not a\n * retry transaction, a nonce will be generated. The transaction is signed\n * using the sign configuration property, then published to the blockchain.\n * A `<tx.id>:finished` hub event is fired after success or failure.\n *\n * @param transactionId - The ID of the transaction to approve.\n */\n private async approveTransaction(transactionId: string) {\n const { transactions } = this.state;\n const releaseLock = await this.mutex.acquire();\n const chainId = this.getChainId();\n const index = transactions.findIndex(({ id }) => transactionId === id);\n const transactionMeta = transactions[index];\n const {\n txParams: { nonce, from },\n } = transactionMeta;\n let nonceLock;\n try {\n if (!this.sign) {\n releaseLock();\n this.failTransaction(\n transactionMeta,\n new Error('No sign method defined.'),\n );\n return;\n } else if (!chainId) {\n releaseLock();\n this.failTransaction(transactionMeta, new Error('No chainId defined.'));\n return;\n }\n\n if (this.inProcessOfSigning.has(transactionId)) {\n log('Skipping approval as signing in progress', transactionId);\n return;\n }\n\n let nonceToUse = nonce;\n // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction\n // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce\n if (!nonceToUse) {\n nonceLock = await this.nonceTracker.getNonceLock(from);\n nonceToUse = addHexPrefix(nonceLock.nextNonce.toString(16));\n }\n\n transactionMeta.status = TransactionStatus.approved;\n transactionMeta.txParams.nonce = nonceToUse;\n transactionMeta.txParams.chainId = chainId;\n\n const baseTxParams = {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n };\n\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction approved',\n );\n\n this.onTransactionStatusChange(transactionMeta);\n\n const isEIP1559 = isEIP1559Transaction(transactionMeta.txParams);\n\n const txParams: TransactionParams = isEIP1559\n ? {\n ...baseTxParams,\n estimatedBaseFee: transactionMeta.txParams.estimatedBaseFee,\n type: TransactionEnvelopeType.feeMarket,\n }\n : baseTxParams;\n\n const rawTx = await this.signTransaction(transactionMeta, txParams);\n\n if (!this.beforePublish(transactionMeta)) {\n log('Skipping publishing transaction based on hook');\n this.hub.emit(`${transactionMeta.id}:publish-skip`, transactionMeta);\n return;\n }\n\n if (!rawTx) {\n return;\n }\n\n const hash = await this.publishTransaction(rawTx);\n transactionMeta.hash = hash;\n transactionMeta.status = TransactionStatus.submitted;\n transactionMeta.submittedTime = new Date().getTime();\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction submitted',\n );\n this.hub.emit('transaction-submitted', {\n transactionMeta,\n });\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n this.onTransactionStatusChange(transactionMeta);\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n } finally {\n this.inProcessOfSigning.delete(transactionId);\n // must set transaction to submitted/failed before releasing lock\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n releaseLock();\n }\n }\n\n private async publishTransaction(rawTransaction: string): Promise<string> {\n return await query(this.ethQuery, 'sendRawTransaction', [rawTransaction]);\n }\n\n /**\n * Cancels a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `<tx.id>:finished` hub event.\n *\n * @param transactionId - The ID of the transaction to cancel.\n * @param actionId - The actionId passed from UI\n */\n private cancelTransaction(transactionId: string, actionId?: string) {\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n if (!transactionMeta) {\n return;\n }\n transactionMeta.status = TransactionStatus.rejected;\n const transactions = this.state.transactions.filter(\n ({ id }) => id !== transactionId,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n this.hub.emit('transaction-rejected', {\n transactionMeta,\n actionId,\n });\n this.onTransactionStatusChange(transactionMeta);\n }\n\n /**\n * Trim the amount of transactions that are set on the state. Checks\n * if the length of the tx history is longer then desired persistence\n * limit and then if it is removes the oldest confirmed or rejected tx.\n * Pending or unapproved transactions will not be removed by this\n * operation. For safety of presenting a fully functional transaction UI\n * representation, this function will not break apart transactions with the\n * same nonce, created on the same day, per network. Not accounting for transactions of the same\n * nonce, same day and network combo can result in confusing or broken experiences\n * in the UI. The transactions are then updated using the BaseControllerV1 update.\n *\n * @param transactions - The transactions to be applied to the state.\n * @returns The trimmed list of transactions.\n */\n private trimTransactionsForState(\n transactions: TransactionMeta[],\n ): TransactionMeta[] {\n const nonceNetworkSet = new Set();\n\n const txsToKeep = transactions\n .sort((a, b) => (a.time > b.time ? -1 : 1)) // Descending time order\n .filter((tx) => {\n const { chainId, status, txParams, time } = tx;\n\n if (txParams) {\n const key = `${txParams.nonce}-${convertHexToDecimal(\n chainId,\n )}-${new Date(time).toDateString()}`;\n\n if (nonceNetworkSet.has(key)) {\n return true;\n } else if (\n nonceNetworkSet.size < this.config.txHistoryLimit ||\n !this.isFinalState(status)\n ) {\n nonceNetworkSet.add(key);\n return true;\n }\n }\n\n return false;\n });\n\n txsToKeep.reverse(); // Ascending time order\n return txsToKeep;\n }\n\n /**\n * Determines if the transaction is in a final state.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isFinalState(status: TransactionStatus): boolean {\n return (\n status === TransactionStatus.rejected ||\n status === TransactionStatus.confirmed ||\n status === TransactionStatus.failed\n );\n }\n\n /**\n * Whether the transaction has at least completed all local processing.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isLocalFinalState(status: TransactionStatus): boolean {\n return [\n TransactionStatus.confirmed,\n TransactionStatus.failed,\n TransactionStatus.rejected,\n TransactionStatus.submitted,\n ].includes(status);\n }\n\n private async requestApproval(\n txMeta: TransactionMeta,\n { shouldShowRequest }: { shouldShowRequest: boolean },\n ): Promise<AddResult> {\n const id = this.getApprovalId(txMeta);\n const { origin } = txMeta;\n const type = ApprovalType.Transaction;\n const requestData = { txId: txMeta.id };\n\n return (await this.messagingSystem.call(\n 'ApprovalController:addRequest',\n {\n id,\n origin: origin || ORIGIN_METAMASK,\n type,\n requestData,\n expectsResult: true,\n },\n shouldShowRequest,\n )) as Promise<AddResult>;\n }\n\n private getTransaction(transactionId: string): TransactionMeta | undefined {\n const { transactions } = this.state;\n return transactions.find(({ id }) => id === transactionId);\n }\n\n private getApprovalId(txMeta: TransactionMeta) {\n return String(txMeta.id);\n }\n\n private isTransactionCompleted(transactionId: string): {\n meta?: TransactionMeta;\n isCompleted: boolean;\n } {\n const transaction = this.getTransaction(transactionId);\n\n if (!transaction) {\n return { meta: undefined, isCompleted: false };\n }\n\n const isCompleted = this.isLocalFinalState(transaction.status);\n\n return { meta: transaction, isCompleted };\n }\n\n private getChainId(): Hex {\n const { providerConfig } = this.getNetworkState();\n return providerConfig.chainId;\n }\n\n private prepareUnsignedEthTx(txParams: TransactionParams): TypedTransaction {\n return TransactionFactory.fromTxData(txParams, {\n common: this.getCommonConfiguration(),\n freeze: false,\n });\n }\n\n /**\n * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for\n * specifying which chain, network, hardfork and EIPs to support for\n * a transaction. By referencing this configuration, and analyzing the fields\n * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718\n * transaction type to use.\n *\n * @returns common configuration object\n */\n private getCommonConfiguration(): Common {\n const {\n providerConfig: { type: chain, chainId, nickname: name },\n } = this.getNetworkState();\n\n if (\n chain !== RPC &&\n chain !== NetworkType['linea-goerli'] &&\n chain !== NetworkType['linea-mainnet']\n ) {\n return new Common({ chain, hardfork: HARDFORK });\n }\n\n const customChainParams: Partial<ChainConfig> = {\n name,\n chainId: parseInt(chainId, 16),\n defaultHardfork: HARDFORK,\n };\n\n return Common.custom(customChainParams);\n }\n\n private onIncomingTransactions({\n added,\n updated,\n }: {\n added: TransactionMeta[];\n updated: TransactionMeta[];\n }) {\n const { transactions: currentTransactions } = this.state;\n\n const updatedTransactions = [\n ...added,\n ...currentTransactions.map((originalTransaction) => {\n const updatedTransaction = updated.find(\n ({ hash }) => hash === originalTransaction.hash,\n );\n\n return updatedTransaction ?? originalTransaction;\n }),\n ];\n\n this.update({\n transactions: this.trimTransactionsForState(updatedTransactions),\n });\n }\n\n private onUpdatedLastFetchedBlockNumbers({\n lastFetchedBlockNumbers,\n blockNumber,\n }: {\n lastFetchedBlockNumbers: {\n [key: string]: number;\n };\n blockNumber: number;\n }) {\n this.update({ lastFetchedBlockNumbers });\n this.hub.emit('incomingTransactionBlock', blockNumber);\n }\n\n private generateDappSuggestedGasFees(\n txParams: TransactionParams,\n origin?: string,\n ): DappSuggestedGasFees | undefined {\n if (!origin || origin === ORIGIN_METAMASK) {\n return undefined;\n }\n\n const { gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas } = txParams;\n\n if (\n gasPrice === undefined &&\n maxFeePerGas === undefined &&\n maxPriorityFeePerGas === undefined &&\n gas === undefined\n ) {\n return undefined;\n }\n\n const dappSuggestedGasFees: DappSuggestedGasFees = {};\n\n if (gasPrice !== undefined) {\n dappSuggestedGasFees.gasPrice = gasPrice;\n } else if (\n maxFeePerGas !== undefined ||\n maxPriorityFeePerGas !== undefined\n ) {\n dappSuggestedGasFees.maxFeePerGas = maxFeePerGas;\n dappSuggestedGasFees.maxPriorityFeePerGas = maxPriorityFeePerGas;\n }\n\n if (gas !== undefined) {\n dappSuggestedGasFees.gas = gas;\n }\n\n return dappSuggestedGasFees;\n }\n\n /**\n * Validates and adds external provided transaction to state.\n *\n * @param transactionMeta - Nominated external transaction to be added to state.\n */\n private addExternalTransaction(transactionMeta: TransactionMeta) {\n const chainId = this.getChainId();\n const { transactions } = this.state;\n const fromAddress = transactionMeta?.txParams?.from;\n const sameFromAndNetworkTransactions = transactions.filter(\n (transaction) =>\n transaction.txParams.from === fromAddress &&\n transaction.chainId === chainId,\n );\n const confirmedTxs = sameFromAndNetworkTransactions.filter(\n (transaction) => transaction.status === TransactionStatus.confirmed,\n );\n const pendingTxs = sameFromAndNetworkTransactions.filter(\n (transaction) => transaction.status === TransactionStatus.submitted,\n );\n\n validateConfirmedExternalTransaction(\n transactionMeta,\n confirmedTxs,\n pendingTxs,\n );\n\n // Make sure provided external transaction has non empty history array\n if (!(transactionMeta.history ?? []).length) {\n if (!this.isHistoryDisabled) {\n addInitialHistorySnapshot(transactionMeta);\n }\n }\n\n const updatedTransactions = [...transactions, transactionMeta];\n this.update({\n transactions: this.trimTransactionsForState(updatedTransactions),\n });\n }\n\n /**\n * Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions\n * in the transactions have the same nonce.\n *\n * @param transactionId - Used to identify original transaction.\n */\n private markNonceDuplicatesDropped(transactionId: string) {\n const chainId = this.getChainId();\n const transactionMeta = this.getTransaction(transactionId);\n const nonce = transactionMeta?.txParams?.nonce;\n const from = transactionMeta?.txParams?.from;\n const sameNonceTxs = this.state.transactions.filter(\n (transaction) =>\n transaction.txParams.from === from &&\n transaction.txParams.nonce === nonce &&\n transaction.chainId === chainId,\n );\n\n if (!sameNonceTxs.length) {\n return;\n }\n\n // Mark all same nonce transactions as dropped and give it a replacedBy hash\n for (const transaction of sameNonceTxs) {\n if (transaction.id === transactionId) {\n continue;\n }\n transaction.replacedBy = transactionMeta?.hash;\n transaction.replacedById = transactionMeta?.id;\n // Drop any transaction that wasn't previously failed (off chain failure)\n if (transaction.status !== TransactionStatus.failed) {\n this.setTransactionStatusDropped(transaction);\n }\n }\n }\n\n /**\n * Method to set transaction status to dropped.\n *\n * @param transactionMeta - TransactionMeta of transaction to be marked as dropped.\n */\n private setTransactionStatusDropped(transactionMeta: TransactionMeta) {\n transactionMeta.status = TransactionStatus.dropped;\n this.hub.emit('transaction-dropped', {\n transactionMeta,\n });\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#setTransactionStatusDropped - Transaction dropped',\n );\n this.onTransactionStatusChange(transactionMeta);\n }\n\n /**\n * Get transaction with provided actionId.\n *\n * @param actionId - Unique ID to prevent duplicate requests\n * @returns the filtered transaction\n */\n private getTransactionWithActionId(actionId?: string) {\n return this.state.transactions.find(\n (transaction) => actionId && transaction.actionId === actionId,\n );\n }\n\n private async waitForTransactionFinished(\n transactionId: string,\n ): Promise<TransactionMeta> {\n return new Promise((resolve) => {\n this.hub.once(`${transactionId}:finished`, (txMeta) => {\n resolve(txMeta);\n });\n });\n }\n\n /**\n * Updates the r, s, and v properties of a TransactionMeta object\n * with values from a signed transaction.\n *\n * @param transactionMeta - The TransactionMeta object to update.\n * @param signedTx - The encompassing type for all transaction types containing r, s, and v values.\n */\n private async updateTransactionMetaRSV(\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ): Promise<void> {\n if (signedTx.r) {\n transactionMeta.r = addHexPrefix(signedTx.r.toString(16));\n }\n\n if (signedTx.s) {\n transactionMeta.s = addHexPrefix(signedTx.s.toString(16));\n }\n\n if (signedTx.v) {\n transactionMeta.v = addHexPrefix(signedTx.v.toString(16));\n }\n }\n\n private async getEIP1559Compatibility() {\n const currentNetworkIsEIP1559Compatible =\n await this.getCurrentNetworkEIP1559Compatibility();\n\n const currentAccountIsEIP1559Compatible =\n await this.getCurrentAccountEIP1559Compatibility();\n\n return (\n currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible\n );\n }\n\n private addPendingTransactionTrackerListeners() {\n this.pendingTransactionTracker.hub.on(\n 'transaction-confirmed',\n this.onConfirmedTransaction.bind(this),\n );\n\n this.pendingTransactionTracker.hub.on(\n 'transaction-dropped',\n this.setTransactionStatusDropped.bind(this),\n );\n\n this.pendingTransactionTracker.hub.on(\n 'transaction-failed',\n this.failTransaction.bind(this),\n );\n\n this.pendingTransactionTracker.hub.on(\n 'transaction-updated',\n this.updateTransaction.bind(this),\n );\n }\n\n private async signTransaction(\n transactionMeta: TransactionMeta,\n txParams: TransactionParams,\n ): Promise<string | undefined> {\n log('Signing transaction', txParams);\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n this.inProcessOfSigning.add(transactionMeta.id);\n const signedTx = await this.sign?.(\n unsignedEthTx,\n txParams.from,\n ...this.getAdditionalSignArguments(transactionMeta),\n );\n\n if (!signedTx) {\n log('Skipping signed status as no signed transaction');\n return undefined;\n }\n\n if (!this.afterSign(transactionMeta, signedTx)) {\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#signTransaction - Update after sign',\n );\n\n log('Skipping signed status based on hook');\n\n return undefined;\n }\n\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n transactionMeta.status = TransactionStatus.signed;\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction signed',\n );\n this.onTransactionStatusChange(transactionMeta);\n\n const rawTx = bufferToHex(signedTx.serialize());\n transactionMeta.rawTx = rawTx;\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - RawTransaction added',\n );\n return rawTx;\n }\n\n private onTransactionStatusChange(transactionMeta: TransactionMeta) {\n this.hub.emit('transaction-status-update', { transactionMeta });\n }\n\n private getNonceTrackerTransactions(\n status: TransactionStatus,\n address: string,\n ) {\n const currentChainId = this.getChainId();\n\n return getAndFormatTransactionsForNonceTracker(\n currentChainId,\n address,\n status,\n this.state.transactions,\n );\n }\n\n private onConfirmedTransaction(transactionMeta: TransactionMeta) {\n log('Processing confirmed transaction', transactionMeta.id);\n\n this.hub.emit('transaction-confirmed', { transactionMeta });\n this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta);\n\n this.onTransactionStatusChange(transactionMeta);\n\n // Intentional given potential duration of process.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.updatePostBalance(transactionMeta);\n }\n\n private async updatePostBalance(transactionMeta: TransactionMeta) {\n try {\n if (transactionMeta.type !== TransactionType.swap) {\n return;\n }\n\n const { updatedTransactionMeta, approvalTransactionMeta } =\n await updatePostTransactionBalance(transactionMeta, {\n ethQuery: this.ethQuery,\n getTransaction: this.getTransaction.bind(this),\n updateTransaction: this.updateTransaction.bind(this),\n });\n\n this.hub.emit('post-transaction-balance-updated', {\n transactionMeta: updatedTransactionMeta,\n approvalTransactionMeta,\n });\n } catch (error) {\n /* istanbul ignore next */\n log('Error while updating post transaction balance', error);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"TransactionController.js","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAwE;AAExE,uCAAoD;AAWpD,+DAA6D;AAC7D,iEAOoC;AACpC,oEAA2C;AAO3C,qDAA6E;AAE7E,6CAAoC;AACpC,8EAAiD;AACjD,qDAA4D;AAC5D,mCAAsC;AACtC,mCAA0D;AAC1D,iDAA6C;AAE7C,+BAAoC;AAEpC,iGAA8F;AAC9F,mFAAgF;AAChF,mFAAgF;AAChF,qCAAgD;AAahD,mCAIiB;AACjB,yEAAqF;AACrF,qCAAmE;AACnE,+CAAiD;AACjD,6CAGyB;AACzB,yCAGuB;AACvB,+DAAoE;AACpE,yCAYuB;AACvB,mDAG4B;AAEf,QAAA,QAAQ,GAAG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AC,kCAAkC,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEpD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;QAElE,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAEhD,mDAAmD;QACnD,mEAAmE;QACnE,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC;IAEa,iBAAiB,CAAC,eAAgC;;YAC9D,IAAI;gBACF,IAAI,eAAe,CAAC,IAAI,KAAK,uBAAe,CAAC,IAAI,EAAE;oBACjD,OAAO;iBACR;gBAED,MAAM,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,GACvD,MAAM,IAAA,oCAA4B,EAAC,eAAe,EAAE;oBAClD,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;oBAC9C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;iBACrD,CAAC,CAAC;gBAEL,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kCAAkC,EAAE;oBAChD,eAAe,EAAE,sBAAsB;oBACvC,uBAAuB;iBACxB,CAAC,CAAC;aACJ;YAAC,OAAO,KAAK,EAAE;gBACd,0BAA0B;gBAC1B,IAAA,sBAAG,EAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;aAC7D;QACH,CAAC;KAAA;CACF;AAx2ED,sDAw2EC","sourcesContent":["import { Hardfork, Common, type ChainConfig } from '@ethereumjs/common';\nimport type { TypedTransaction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type {\n AcceptResultCallbacks,\n AddApprovalRequest,\n AddResult,\n} from '@metamask/approval-controller';\nimport type {\n BaseConfig,\n BaseState,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { BaseControllerV1 } from '@metamask/base-controller';\nimport {\n query,\n NetworkType,\n RPC,\n ApprovalType,\n ORIGIN_METAMASK,\n convertHexToDecimal,\n} from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n BlockTracker,\n NetworkState,\n Provider,\n} from '@metamask/network-controller';\nimport { errorCodes, rpcErrors, providerErrors } from '@metamask/rpc-errors';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport MethodRegistry from 'eth-method-registry';\nimport { addHexPrefix, bufferToHex } from 'ethereumjs-util';\nimport { EventEmitter } from 'events';\nimport { mapValues, merge, pickBy, sortBy } from 'lodash';\nimport { NonceTracker } from 'nonce-tracker';\nimport type { NonceLock } from 'nonce-tracker';\nimport { v1 as random } from 'uuid';\n\nimport { EtherscanRemoteTransactionSource } from './helpers/EtherscanRemoteTransactionSource';\nimport { IncomingTransactionHelper } from './helpers/IncomingTransactionHelper';\nimport { PendingTransactionTracker } from './helpers/PendingTransactionTracker';\nimport { projectLogger as log } from './logger';\nimport type {\n Events,\n DappSuggestedGasFees,\n SavedGasFees,\n SecurityProviderRequest,\n SendFlowHistoryEntry,\n TransactionParams,\n TransactionMeta,\n TransactionReceipt,\n WalletDevice,\n SecurityAlertResponse,\n} from './types';\nimport {\n TransactionEnvelopeType,\n TransactionType,\n TransactionStatus,\n} from './types';\nimport { validateConfirmedExternalTransaction } from './utils/external-transactions';\nimport { addGasBuffer, estimateGas, updateGas } from './utils/gas';\nimport { updateGasFees } from './utils/gas-fees';\nimport {\n addInitialHistorySnapshot,\n updateTransactionHistory,\n} from './utils/history';\nimport {\n updatePostTransactionBalance,\n updateSwapsTransaction,\n} from './utils/swaps';\nimport { determineTransactionType } from './utils/transaction-type';\nimport {\n getAndFormatTransactionsForNonceTracker,\n getIncreasedPriceFromExisting,\n normalizeTxParams,\n isEIP1559Transaction,\n isFeeMarketEIP1559Values,\n isGasPriceValue,\n validateGasValues,\n validateIfTransactionUnapproved,\n validateMinimumIncrease,\n normalizeTxError,\n normalizeGasFeeValues,\n} from './utils/utils';\nimport {\n validateTransactionOrigin,\n validateTxParams,\n} from './utils/validation';\n\nexport const HARDFORK = Hardfork.London;\n\n/**\n * @type Result\n * @property result - Promise resolving to a new transaction hash\n * @property transactionMeta - Meta information about this new transaction\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface Result {\n result: Promise<string>;\n transactionMeta: TransactionMeta;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface GasPriceValue {\n gasPrice: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface FeeMarketEIP1559Values {\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n}\n\n/**\n * @type TransactionConfig\n *\n * Transaction controller configuration\n * @property provider - Provider used to create a new underlying EthQuery instance\n * @property sign - Method used to sign transactions\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionConfig extends BaseConfig {\n sign?: (txParams: TransactionParams, from: string) => Promise<any>;\n txHistoryLimit: number;\n}\n\n/**\n * @type MethodData\n *\n * Method data registry object\n * @property registryMethod - Registry method raw string\n * @property parsedRegistryMethod - Registry method object, containing name and method arguments\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface MethodData {\n registryMethod: string;\n parsedRegistryMethod: Record<string, unknown>;\n}\n\n/**\n * @type TransactionState\n *\n * Transaction controller state\n * @property transactions - A list of TransactionMeta objects\n * @property methodData - Object containing all known method data information\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionState extends BaseState {\n transactions: TransactionMeta[];\n methodData: { [key: string]: MethodData };\n lastFetchedBlockNumbers: { [key: string]: number };\n}\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during cancellation\n */\nexport const CANCEL_RATE = 1.5;\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during speed up\n */\nexport const SPEED_UP_RATE = 1.1;\n\n/**\n * The name of the {@link TransactionController}.\n */\nconst controllerName = 'TransactionController';\n\n/**\n * The external actions available to the {@link TransactionController}.\n */\ntype AllowedActions = AddApprovalRequest;\n\n/**\n * The messenger of the {@link TransactionController}.\n */\nexport type TransactionControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionControllerEventEmitter extends EventEmitter {\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): this;\n\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n}\n\n/**\n * Controller responsible for submitting and managing transactions.\n */\nexport class TransactionController extends BaseControllerV1<\n TransactionConfig,\n TransactionState\n> {\n private ethQuery: EthQuery;\n\n private readonly isHistoryDisabled: boolean;\n\n private readonly isSwapsDisabled: boolean;\n\n private readonly isSendFlowHistoryDisabled: boolean;\n\n private readonly inProcessOfSigning: Set<string> = new Set();\n\n private readonly nonceTracker: NonceTracker;\n\n private registry: any;\n\n private readonly provider: Provider;\n\n private readonly mutex = new Mutex();\n\n private readonly getSavedGasFees: (chainId: Hex) => SavedGasFees | undefined;\n\n private readonly getNetworkState: () => NetworkState;\n\n private readonly getCurrentAccountEIP1559Compatibility: () => Promise<boolean>;\n\n private readonly getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;\n\n private readonly getGasFeeEstimates: () => Promise<GasFeeState>;\n\n private readonly getPermittedAccounts: (origin?: string) => Promise<string[]>;\n\n private readonly getSelectedAddress: () => string;\n\n private readonly messagingSystem: TransactionControllerMessenger;\n\n private readonly incomingTransactionHelper: IncomingTransactionHelper;\n\n private readonly securityProviderRequest?: SecurityProviderRequest;\n\n private readonly pendingTransactionTracker: PendingTransactionTracker;\n\n private readonly cancelMultiplier: number;\n\n private readonly speedUpMultiplier: number;\n\n private readonly afterSign: (\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ) => boolean;\n\n private readonly beforeApproveOnInit: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n\n private readonly beforeCheckPendingTransaction: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n\n private readonly beforePublish: (transactionMeta: TransactionMeta) => boolean;\n\n private readonly getAdditionalSignArguments: (\n transactionMeta: TransactionMeta,\n ) => (TransactionMeta | undefined)[];\n\n private failTransaction(\n transactionMeta: TransactionMeta,\n error: Error,\n actionId?: string,\n ) {\n const newTransactionMeta = {\n ...transactionMeta,\n error: normalizeTxError(error),\n status: TransactionStatus.failed,\n };\n this.hub.emit('transaction-failed', {\n actionId,\n error: error.message,\n transactionMeta: newTransactionMeta,\n });\n this.updateTransaction(\n newTransactionMeta,\n 'TransactionController#failTransaction - Add error message and set status to failed',\n );\n this.onTransactionStatusChange(newTransactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);\n }\n\n private async registryLookup(fourBytePrefix: string): Promise<MethodData> {\n const registryMethod = await this.registry.lookup(fourBytePrefix);\n const parsedRegistryMethod = this.registry.parse(registryMethod);\n return { registryMethod, parsedRegistryMethod };\n }\n\n /**\n * EventEmitter instance used to listen to specific transactional events\n */\n hub = new EventEmitter() as TransactionControllerEventEmitter;\n\n /**\n * Name of this controller used during composition\n */\n override name = 'TransactionController';\n\n /**\n * Method used to sign transactions\n */\n sign?: (\n transaction: TypedTransaction,\n from: string,\n transactionMeta?: TransactionMeta,\n ) => Promise<TypedTransaction>;\n\n /**\n * Creates a TransactionController instance.\n *\n * @param options - The controller options.\n * @param options.blockTracker - The block tracker used to poll for new blocks data.\n * @param options.cancelMultiplier - Multiplier used to determine a transaction's increased gas fee during cancellation.\n * @param options.disableHistory - Whether to disable storing history in transaction metadata.\n * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.\n * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.\n * @param options.getSavedGasFees - Gets the saved gas fee config.\n * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.\n * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.\n * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.\n * @param options.getNetworkState - Gets the state of the network controller.\n * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.\n * @param options.getSelectedAddress - Gets the address of the currently selected account.\n * @param options.incomingTransactions - Configuration options for incoming transaction support.\n * @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.\n * @param options.incomingTransactions.isEnabled - Whether or not incoming transaction retrieval is enabled.\n * @param options.incomingTransactions.queryEntireHistory - Whether to initially query the entire transaction history or only recent blocks.\n * @param options.incomingTransactions.updateTransactions - Whether to update local transactions using remote transaction data.\n * @param options.messenger - The controller messenger.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.pendingTransactions - Configuration options for pending transaction support.\n * @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.\n * @param options.provider - The provider used to create the underlying EthQuery instance.\n * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.\n * @param options.speedUpMultiplier - Multiplier used to determine a transaction's increased gas fee during speed up.\n * @param options.hooks - The controller hooks.\n * @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.\n * @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.\n * @param options.hooks.beforeCheckPendingTransaction - Additional logic to execute before checking pending transactions. Return false to prevent the broadcast of the transaction.\n * @param options.hooks.beforePublish - Additional logic to execute before publishing a transaction. Return false to prevent the broadcast of the transaction.\n * @param options.hooks.getAdditionalSignArguments - Returns additional arguments required to sign a transaction.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n blockTracker,\n cancelMultiplier,\n disableHistory,\n disableSendFlowHistory,\n disableSwaps,\n getSavedGasFees,\n getCurrentAccountEIP1559Compatibility,\n getCurrentNetworkEIP1559Compatibility,\n getGasFeeEstimates,\n getNetworkState,\n getPermittedAccounts,\n getSelectedAddress,\n incomingTransactions = {},\n messenger,\n onNetworkStateChange,\n pendingTransactions = {},\n provider,\n securityProviderRequest,\n speedUpMultiplier,\n hooks = {},\n }: {\n blockTracker: BlockTracker;\n cancelMultiplier?: number;\n disableHistory: boolean;\n disableSendFlowHistory: boolean;\n disableSwaps: boolean;\n getSavedGasFees?: (chainId: Hex) => SavedGasFees | undefined;\n getCurrentAccountEIP1559Compatibility?: () => Promise<boolean>;\n getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;\n getGasFeeEstimates?: () => Promise<GasFeeState>;\n getNetworkState: () => NetworkState;\n getPermittedAccounts: (origin?: string) => Promise<string[]>;\n getSelectedAddress: () => string;\n incomingTransactions?: {\n includeTokenTransfers?: boolean;\n isEnabled?: () => boolean;\n queryEntireHistory?: boolean;\n updateTransactions?: boolean;\n };\n messenger: TransactionControllerMessenger;\n onNetworkStateChange: (listener: (state: NetworkState) => void) => void;\n pendingTransactions?: {\n isResubmitEnabled?: boolean;\n };\n provider: Provider;\n securityProviderRequest?: SecurityProviderRequest;\n speedUpMultiplier?: number;\n hooks: {\n afterSign?: (\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ) => boolean;\n beforeApproveOnInit?: (transactionMeta: TransactionMeta) => boolean;\n beforeCheckPendingTransaction?: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n beforePublish?: (transactionMeta: TransactionMeta) => boolean;\n getAdditionalSignArguments?: (\n transactionMeta: TransactionMeta,\n ) => (TransactionMeta | undefined)[];\n };\n },\n config?: Partial<TransactionConfig>,\n state?: Partial<TransactionState>,\n ) {\n super(config, state);\n\n this.defaultConfig = {\n txHistoryLimit: 40,\n };\n\n this.defaultState = {\n methodData: {},\n transactions: [],\n lastFetchedBlockNumbers: {},\n };\n\n this.initialize();\n\n this.provider = provider;\n this.messagingSystem = messenger;\n this.getNetworkState = getNetworkState;\n this.ethQuery = new EthQuery(provider);\n this.isSendFlowHistoryDisabled = disableSendFlowHistory ?? false;\n this.isHistoryDisabled = disableHistory ?? false;\n this.isSwapsDisabled = disableSwaps ?? false;\n this.registry = new MethodRegistry({ provider });\n this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);\n this.getCurrentAccountEIP1559Compatibility =\n getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));\n this.getCurrentNetworkEIP1559Compatibility =\n getCurrentNetworkEIP1559Compatibility;\n this.getGasFeeEstimates =\n getGasFeeEstimates || (() => Promise.resolve({} as GasFeeState));\n this.getPermittedAccounts = getPermittedAccounts;\n this.getSelectedAddress = getSelectedAddress;\n this.securityProviderRequest = securityProviderRequest;\n this.cancelMultiplier = cancelMultiplier ?? CANCEL_RATE;\n this.speedUpMultiplier = speedUpMultiplier ?? SPEED_UP_RATE;\n\n this.afterSign = hooks?.afterSign ?? (() => true);\n this.beforeApproveOnInit = hooks?.beforeApproveOnInit ?? (() => true);\n this.beforeCheckPendingTransaction =\n hooks?.beforeCheckPendingTransaction ??\n /* istanbul ignore next */\n (() => true);\n this.beforePublish = hooks?.beforePublish ?? (() => true);\n this.getAdditionalSignArguments =\n hooks?.getAdditionalSignArguments ?? (() => []);\n\n this.nonceTracker = new NonceTracker({\n // @ts-expect-error provider types misaligned: SafeEventEmitterProvider vs Record<string,string>\n provider,\n blockTracker,\n getPendingTransactions: this.getNonceTrackerTransactions.bind(\n this,\n TransactionStatus.submitted,\n ),\n getConfirmedTransactions: this.getNonceTrackerTransactions.bind(\n this,\n TransactionStatus.confirmed,\n ),\n });\n\n this.incomingTransactionHelper = new IncomingTransactionHelper({\n blockTracker,\n getCurrentAccount: getSelectedAddress,\n getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,\n getNetworkState,\n isEnabled: incomingTransactions.isEnabled,\n queryEntireHistory: incomingTransactions.queryEntireHistory,\n remoteTransactionSource: new EtherscanRemoteTransactionSource({\n includeTokenTransfers: incomingTransactions.includeTokenTransfers,\n }),\n transactionLimit: this.config.txHistoryLimit,\n updateTransactions: incomingTransactions.updateTransactions,\n });\n\n this.incomingTransactionHelper.hub.on(\n 'transactions',\n this.onIncomingTransactions.bind(this),\n );\n\n this.incomingTransactionHelper.hub.on(\n 'updatedLastFetchedBlockNumbers',\n this.onUpdatedLastFetchedBlockNumbers.bind(this),\n );\n\n this.pendingTransactionTracker = new PendingTransactionTracker({\n approveTransaction: this.approveTransaction.bind(this),\n blockTracker,\n getChainId: this.getChainId.bind(this),\n getEthQuery: () => this.ethQuery,\n getTransactions: () => this.state.transactions,\n isResubmitEnabled: pendingTransactions.isResubmitEnabled,\n nonceTracker: this.nonceTracker,\n onStateChange: this.subscribe.bind(this),\n publishTransaction: this.publishTransaction.bind(this),\n hooks: {\n beforeCheckPendingTransaction:\n this.beforeCheckPendingTransaction.bind(this),\n beforePublish: this.beforePublish.bind(this),\n },\n });\n\n this.addPendingTransactionTrackerListeners();\n\n onNetworkStateChange(() => {\n this.ethQuery = new EthQuery(this.provider);\n this.registry = new MethodRegistry({ provider: this.provider });\n this.onBootCleanup();\n });\n\n this.onBootCleanup();\n }\n\n /**\n * Handle new method data request.\n *\n * @param fourBytePrefix - The method prefix.\n * @returns The method data object corresponding to the given signature prefix.\n */\n async handleMethodData(fourBytePrefix: string): Promise<MethodData> {\n const releaseLock = await this.mutex.acquire();\n try {\n const { methodData } = this.state;\n const knownMethod = Object.keys(methodData).find(\n (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix,\n );\n if (knownMethod) {\n return methodData[fourBytePrefix];\n }\n const registry = await this.registryLookup(fourBytePrefix);\n this.update({\n methodData: { ...methodData, ...{ [fourBytePrefix]: registry } },\n });\n return registry;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Add a new unapproved transaction to state. Parameters will be validated, a\n * unique transaction id will be generated, and gas and gasPrice will be calculated\n * if not provided. If A `<tx.id>:unapproved` hub event will be emitted once added.\n *\n * @param txParams - Standard parameters for an Ethereum transaction.\n * @param opts - Additional options to control how the transaction is added.\n * @param opts.actionId - Unique ID to prevent duplicate requests.\n * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.\n * @param opts.method - RPC method that requested the transaction.\n * @param opts.origin - The origin of the transaction request, such as a dApp hostname.\n * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.\n * @param opts.securityAlertResponse - Response from security validator.\n * @param opts.sendFlowHistory - The sendFlowHistory entries to add.\n * @param opts.type - Type of transaction to add, such as 'cancel' or 'swap'.\n * @param opts.swaps - Options for swaps transactions.\n * @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.\n * @param opts.swaps.meta - Metadata for swap transaction.\n * @returns Object containing a promise resolving to the transaction hash if approved.\n */\n async addTransaction(\n txParams: TransactionParams,\n {\n actionId,\n deviceConfirmedOn,\n method,\n origin,\n requireApproval,\n securityAlertResponse,\n sendFlowHistory,\n swaps = {},\n type,\n }: {\n actionId?: string;\n deviceConfirmedOn?: WalletDevice;\n method?: string;\n origin?: string;\n requireApproval?: boolean | undefined;\n securityAlertResponse?: SecurityAlertResponse;\n sendFlowHistory?: SendFlowHistoryEntry[];\n swaps?: {\n hasApproveTx?: boolean;\n meta?: Partial<TransactionMeta>;\n };\n type?: TransactionType;\n } = {},\n ): Promise<Result> {\n log('Adding transaction', txParams);\n\n txParams = normalizeTxParams(txParams);\n\n const isEIP1559Compatible = await this.getEIP1559Compatibility();\n\n validateTxParams(txParams, isEIP1559Compatible);\n\n if (origin) {\n await validateTransactionOrigin(\n await this.getPermittedAccounts(origin),\n this.getSelectedAddress(),\n txParams.from,\n origin,\n );\n }\n\n const dappSuggestedGasFees = this.generateDappSuggestedGasFees(\n txParams,\n origin,\n );\n\n const transactionType =\n type ?? (await determineTransactionType(txParams, this.ethQuery)).type;\n\n const existingTransactionMeta = this.getTransactionWithActionId(actionId);\n const chainId = this.getChainId();\n\n // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.\n const transactionMeta: TransactionMeta = existingTransactionMeta || {\n // Add actionId to txMeta to check if same actionId is seen again\n actionId,\n chainId,\n dappSuggestedGasFees,\n deviceConfirmedOn,\n id: random(),\n origin,\n securityAlertResponse,\n status: TransactionStatus.unapproved as TransactionStatus.unapproved,\n time: Date.now(),\n txParams,\n userEditedGasLimit: false,\n verifiedOnBlockchain: false,\n type: transactionType,\n };\n\n await this.updateGasProperties(transactionMeta);\n\n // Checks if a transaction already exists with a given actionId\n if (!existingTransactionMeta) {\n // Set security provider response\n if (method && this.securityProviderRequest) {\n const securityProviderResponse = await this.securityProviderRequest(\n transactionMeta,\n method,\n );\n transactionMeta.securityProviderResponse = securityProviderResponse;\n }\n\n if (!this.isSendFlowHistoryDisabled) {\n transactionMeta.sendFlowHistory = sendFlowHistory ?? [];\n }\n // Initial history push\n if (!this.isHistoryDisabled) {\n addInitialHistorySnapshot(transactionMeta);\n }\n\n await updateSwapsTransaction(transactionMeta, transactionType, swaps, {\n isSwapsDisabled: this.isSwapsDisabled,\n cancelTransaction: this.cancelTransaction.bind(this),\n controllerHubEmitter: this.hub.emit.bind(this.hub) as any,\n });\n\n this.addMetadata(transactionMeta);\n this.hub.emit(`unapprovedTransaction`, transactionMeta);\n }\n\n return {\n result: this.processApproval(transactionMeta, {\n isExisting: Boolean(existingTransactionMeta),\n requireApproval,\n actionId,\n }),\n transactionMeta,\n };\n }\n\n startIncomingTransactionPolling() {\n this.incomingTransactionHelper.start();\n }\n\n stopIncomingTransactionPolling() {\n this.incomingTransactionHelper.stop();\n }\n\n async updateIncomingTransactions() {\n await this.incomingTransactionHelper.update();\n }\n\n /**\n * Attempts to cancel a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `<tx.id>:finished` hub event.\n *\n * @param transactionId - The ID of the transaction to cancel.\n * @param gasValues - The gas values to use for the cancellation transaction.\n * @param options - The options for the cancellation transaction.\n * @param options.actionId - Unique ID to prevent duplicate requests.\n * @param options.estimatedBaseFee - The estimated base fee of the transaction.\n */\n async stopTransaction(\n transactionId: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n {\n estimatedBaseFee,\n actionId,\n }: { estimatedBaseFee?: string; actionId?: string } = {},\n ) {\n // If transaction is found for same action id, do not create a cancel transaction.\n if (this.getTransactionWithActionId(actionId)) {\n return;\n }\n\n if (gasValues) {\n // Not good practice to reassign a parameter but temporarily avoiding a larger refactor.\n gasValues = normalizeGasFeeValues(gasValues);\n validateGasValues(gasValues);\n }\n\n log('Creating cancel transaction', transactionId, gasValues);\n\n const transactionMeta = this.getTransaction(transactionId);\n if (!transactionMeta) {\n return;\n }\n\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.txParams.gasPrice,\n this.cancelMultiplier,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n this.cancelMultiplier,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.txParams?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n this.cancelMultiplier,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const newTxParams: TransactionParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n from: transactionMeta.txParams.from,\n gasLimit: transactionMeta.txParams.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: TransactionEnvelopeType.feeMarket,\n nonce: transactionMeta.txParams.nonce,\n to: transactionMeta.txParams.from,\n value: '0x0',\n }\n : {\n from: transactionMeta.txParams.from,\n gasLimit: transactionMeta.txParams.gas,\n gasPrice: newGasPrice,\n nonce: transactionMeta.txParams.nonce,\n to: transactionMeta.txParams.from,\n value: '0x0',\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(newTxParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.txParams.from,\n );\n\n const rawTx = bufferToHex(signedTx.serialize());\n\n const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;\n\n const oldFee = newTxParams.maxFeePerGas\n ? transactionMeta.txParams.maxFeePerGas\n : transactionMeta.txParams.gasPrice;\n\n log('Submitting cancel transaction', {\n oldFee,\n newFee,\n txParams: newTxParams,\n });\n\n const hash = await this.publishTransaction(rawTx);\n\n const cancelTransactionMeta: TransactionMeta = {\n actionId,\n chainId: transactionMeta.chainId,\n estimatedBaseFee,\n hash,\n id: random(),\n originalGasEstimate: transactionMeta.txParams.gas,\n status: TransactionStatus.submitted,\n time: Date.now(),\n type: TransactionType.cancel,\n txParams: newTxParams,\n };\n\n this.addMetadata(cancelTransactionMeta);\n\n // stopTransaction has no approval request, so we assume the user has already approved the transaction\n this.hub.emit('transaction-approved', {\n transactionMeta: cancelTransactionMeta,\n actionId,\n });\n this.hub.emit('transaction-submitted', {\n transactionMeta: cancelTransactionMeta,\n actionId,\n });\n\n this.hub.emit(\n `${cancelTransactionMeta.id}:finished`,\n cancelTransactionMeta,\n );\n }\n\n /**\n * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.\n *\n * @param transactionId - The ID of the transaction to speed up.\n * @param gasValues - The gas values to use for the speed up transaction.\n * @param options - The options for the speed up transaction.\n * @param options.actionId - Unique ID to prevent duplicate requests\n * @param options.estimatedBaseFee - The estimated base fee of the transaction.\n */\n async speedUpTransaction(\n transactionId: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n {\n actionId,\n estimatedBaseFee,\n }: { actionId?: string; estimatedBaseFee?: string } = {},\n ) {\n // If transaction is found for same action id, do not create a new speed up transaction.\n if (this.getTransactionWithActionId(actionId)) {\n return;\n }\n\n if (gasValues) {\n // Not good practice to reassign a parameter but temporarily avoiding a larger refactor.\n gasValues = normalizeGasFeeValues(gasValues);\n validateGasValues(gasValues);\n }\n\n log('Creating speed up transaction', transactionId, gasValues);\n\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n /* istanbul ignore next */\n if (!transactionMeta) {\n return;\n }\n\n /* istanbul ignore next */\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.txParams.gasPrice,\n this.speedUpMultiplier,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n this.speedUpMultiplier,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.txParams?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n this.speedUpMultiplier,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams: TransactionParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: TransactionEnvelopeType.feeMarket,\n }\n : {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n gasPrice: newGasPrice,\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.txParams.from,\n );\n\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n const rawTx = bufferToHex(signedTx.serialize());\n\n const newFee = txParams.maxFeePerGas ?? txParams.gasPrice;\n\n const oldFee = txParams.maxFeePerGas\n ? transactionMeta.txParams.maxFeePerGas\n : transactionMeta.txParams.gasPrice;\n\n log('Submitting speed up transaction', { oldFee, newFee, txParams });\n\n const hash = await query(this.ethQuery, 'sendRawTransaction', [rawTx]);\n\n const baseTransactionMeta: TransactionMeta = {\n ...transactionMeta,\n estimatedBaseFee,\n id: random(),\n time: Date.now(),\n hash,\n actionId,\n originalGasEstimate: transactionMeta.txParams.gas,\n type: TransactionType.retry,\n originalType: transactionMeta.type,\n };\n\n const newTransactionMeta =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...baseTransactionMeta,\n txParams: {\n ...transactionMeta.txParams,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n },\n }\n : {\n ...baseTransactionMeta,\n txParams: {\n ...transactionMeta.txParams,\n gasPrice: newGasPrice,\n },\n };\n\n this.addMetadata(newTransactionMeta);\n\n // speedUpTransaction has no approval request, so we assume the user has already approved the transaction\n this.hub.emit('transaction-approved', {\n transactionMeta: newTransactionMeta,\n actionId,\n });\n\n this.hub.emit('transaction-submitted', {\n transactionMeta: newTransactionMeta,\n actionId,\n });\n\n this.hub.emit(`${transactionMeta.id}:speedup`, newTransactionMeta);\n }\n\n /**\n * Estimates required gas for a given transaction.\n *\n * @param transaction - The transaction to estimate gas for.\n * @returns The gas and gas price.\n */\n async estimateGas(transaction: TransactionParams) {\n const { estimatedGas, simulationFails } = await estimateGas(\n transaction,\n this.ethQuery,\n );\n\n return { gas: estimatedGas, simulationFails };\n }\n\n /**\n * Estimates required gas for a given transaction and add additional gas buffer with the given multiplier.\n *\n * @param transaction - The transaction params to estimate gas for.\n * @param multiplier - The multiplier to use for the gas buffer.\n */\n async estimateGasBuffered(\n transaction: TransactionParams,\n multiplier: number,\n ) {\n const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(\n transaction,\n this.ethQuery,\n );\n\n const gas = addGasBuffer(estimatedGas, blockGasLimit, multiplier);\n\n return {\n gas,\n simulationFails,\n };\n }\n\n /**\n * Updates an existing transaction in state.\n *\n * @param transactionMeta - The new transaction to store in state.\n * @param note - A note or update reason to include in the transaction history.\n */\n updateTransaction(transactionMeta: TransactionMeta, note: string) {\n const { transactions } = this.state;\n transactionMeta.txParams = normalizeTxParams(transactionMeta.txParams);\n validateTxParams(transactionMeta.txParams);\n if (!this.isHistoryDisabled) {\n updateTransactionHistory(transactionMeta, note);\n }\n const index = transactions.findIndex(({ id }) => transactionMeta.id === id);\n transactions[index] = transactionMeta;\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Update the security alert response for a transaction.\n *\n * @param transactionId - ID of the transaction.\n * @param securityAlertResponse - The new security alert response for the transaction.\n */\n updateSecurityAlertResponse(\n transactionId: string,\n securityAlertResponse: SecurityAlertResponse,\n ) {\n if (!securityAlertResponse) {\n throw new Error(\n 'updateSecurityAlertResponse: securityAlertResponse should not be null',\n );\n }\n const transactionMeta = this.getTransaction(transactionId);\n if (!transactionMeta) {\n throw new Error(\n `Cannot update security alert response as no transaction metadata found`,\n );\n }\n const updatedMeta = merge(transactionMeta, { securityAlertResponse });\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updatesecurityAlertResponse - securityAlertResponse updated',\n );\n }\n\n /**\n * Removes all transactions from state, optionally based on the current network.\n *\n * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the\n * current network. If `true`, all transactions are wiped.\n * @param address - If specified, only transactions originating from this address will be\n * wiped on current network.\n */\n wipeTransactions(ignoreNetwork?: boolean, address?: string) {\n /* istanbul ignore next */\n if (ignoreNetwork && !address) {\n this.update({ transactions: [] });\n return;\n }\n const currentChainId = this.getChainId();\n const newTransactions = this.state.transactions.filter(\n ({ chainId, txParams }) => {\n const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;\n\n if (!isMatchingNetwork) {\n return true;\n }\n\n const isMatchingAddress =\n !address || txParams.from?.toLowerCase() === address.toLowerCase();\n\n return !isMatchingAddress;\n },\n );\n\n this.update({\n transactions: this.trimTransactionsForState(newTransactions),\n });\n }\n\n startIncomingTransactionProcessing() {\n this.incomingTransactionHelper.start();\n }\n\n stopIncomingTransactionProcessing() {\n this.incomingTransactionHelper.stop();\n }\n\n /**\n * Adds external provided transaction to state as confirmed transaction.\n *\n * @param transactionMeta - TransactionMeta to add transactions.\n * @param transactionReceipt - TransactionReceipt of the external transaction.\n * @param baseFeePerGas - Base fee per gas of the external transaction.\n */\n async confirmExternalTransaction(\n transactionMeta: TransactionMeta,\n transactionReceipt: TransactionReceipt,\n baseFeePerGas: Hex,\n ) {\n // Run validation and add external transaction to state.\n this.addExternalTransaction(transactionMeta);\n\n try {\n const transactionId = transactionMeta.id;\n\n // Make sure status is confirmed and define gasUsed as in receipt.\n transactionMeta.status = TransactionStatus.confirmed;\n transactionMeta.txReceipt = transactionReceipt;\n if (baseFeePerGas) {\n transactionMeta.baseFeePerGas = baseFeePerGas;\n }\n\n // Update same nonce local transactions as dropped and define replacedBy properties.\n this.markNonceDuplicatesDropped(transactionId);\n\n // Update external provided transaction with updated gas values and confirmed status.\n this.updateTransaction(\n transactionMeta,\n 'TransactionController:confirmExternalTransaction - Add external transaction',\n );\n this.onTransactionStatusChange(transactionMeta);\n\n // Intentional given potential duration of process.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.updatePostBalance(transactionMeta);\n\n this.hub.emit('transaction-confirmed', {\n transactionMeta,\n });\n } catch (error) {\n console.error('Failed to confirm external transaction', error);\n }\n }\n\n /**\n * Append new send flow history to a transaction.\n *\n * @param transactionID - The ID of the transaction to update.\n * @param currentSendFlowHistoryLength - The length of the current sendFlowHistory array.\n * @param sendFlowHistoryToAdd - The sendFlowHistory entries to add.\n * @returns The updated transactionMeta.\n */\n updateTransactionSendFlowHistory(\n transactionID: string,\n currentSendFlowHistoryLength: number,\n sendFlowHistoryToAdd: SendFlowHistoryEntry[],\n ): TransactionMeta {\n if (this.isSendFlowHistoryDisabled) {\n throw new Error(\n 'Send flow history is disabled for the current transaction controller',\n );\n }\n\n const transactionMeta = this.getTransaction(transactionID);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update send flow history as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateTransactionSendFlowHistory',\n );\n\n if (\n currentSendFlowHistoryLength ===\n (transactionMeta?.sendFlowHistory?.length || 0)\n ) {\n transactionMeta.sendFlowHistory = [\n ...(transactionMeta?.sendFlowHistory ?? []),\n ...sendFlowHistoryToAdd,\n ];\n this.updateTransaction(\n transactionMeta,\n 'TransactionController:updateTransactionSendFlowHistory - sendFlowHistory updated',\n );\n }\n\n return this.getTransaction(transactionID) as TransactionMeta;\n }\n\n /**\n * Update the gas values of a transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param gasValues - Gas values to update.\n * @param gasValues.gas - Same as transaction.gasLimit.\n * @param gasValues.gasLimit - Maxmimum number of units of gas to use for this transaction.\n * @param gasValues.gasPrice - Price per gas for legacy transactions.\n * @param gasValues.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.\n * @param gasValues.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.\n * @param gasValues.estimateUsed - Which estimate level was used.\n * @param gasValues.estimateSuggested - Which estimate level that the API suggested.\n * @param gasValues.defaultGasEstimates - The default estimate for gas.\n * @param gasValues.originalGasEstimate - Original estimate for gas.\n * @param gasValues.userEditedGasLimit - The gas limit supplied by user.\n * @param gasValues.userFeeLevel - Estimate level user selected.\n * @returns The updated transactionMeta.\n */\n updateTransactionGasFees(\n transactionId: string,\n {\n defaultGasEstimates,\n estimateUsed,\n estimateSuggested,\n gas,\n gasLimit,\n gasPrice,\n maxPriorityFeePerGas,\n maxFeePerGas,\n originalGasEstimate,\n userEditedGasLimit,\n userFeeLevel,\n }: {\n defaultGasEstimates?: string;\n estimateUsed?: string;\n estimateSuggested?: string;\n gas?: string;\n gasLimit?: string;\n gasPrice?: string;\n maxPriorityFeePerGas?: string;\n maxFeePerGas?: string;\n originalGasEstimate?: string;\n userEditedGasLimit?: boolean;\n userFeeLevel?: string;\n },\n ): TransactionMeta {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update transaction as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateTransactionGasFees',\n );\n\n let transactionGasFees = {\n txParams: {\n gas,\n gasLimit,\n gasPrice,\n maxPriorityFeePerGas,\n maxFeePerGas,\n },\n defaultGasEstimates,\n estimateUsed,\n estimateSuggested,\n originalGasEstimate,\n userEditedGasLimit,\n userFeeLevel,\n } as any;\n\n // only update what is defined\n transactionGasFees.txParams = pickBy(transactionGasFees.txParams);\n transactionGasFees = pickBy(transactionGasFees);\n\n // merge updated gas values with existing transaction meta\n const updatedMeta = merge(transactionMeta, transactionGasFees);\n\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updateTransactionGasFees - gas values updated',\n );\n\n return this.getTransaction(transactionId) as TransactionMeta;\n }\n\n /**\n * Update the previous gas values of a transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param previousGas - Previous gas values to update.\n * @param previousGas.gasLimit - Maxmimum number of units of gas to use for this transaction.\n * @param previousGas.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.\n * @param previousGas.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.\n * @returns The updated transactionMeta.\n */\n updatePreviousGasParams(\n transactionId: string,\n {\n gasLimit,\n maxFeePerGas,\n maxPriorityFeePerGas,\n }: {\n gasLimit?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n },\n ): TransactionMeta {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update transaction as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(transactionMeta, 'updatePreviousGasParams');\n\n const transactionPreviousGas = {\n previousGas: {\n gasLimit,\n maxFeePerGas,\n maxPriorityFeePerGas,\n },\n } as any;\n\n // only update what is defined\n transactionPreviousGas.previousGas = pickBy(\n transactionPreviousGas.previousGas,\n );\n\n // merge updated previous gas values with existing transaction meta\n const updatedMeta = merge(transactionMeta, transactionPreviousGas);\n\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updatePreviousGasParams - Previous gas values updated',\n );\n\n return this.getTransaction(transactionId) as TransactionMeta;\n }\n\n /**\n * Gets the next nonce according to the nonce-tracker.\n * Ensure `releaseLock` is called once processing of the `nonce` value is complete.\n *\n * @param address - The hex string address for the transaction.\n * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.\n */\n async getNonceLock(address: string): Promise<NonceLock> {\n return this.nonceTracker.getNonceLock(address);\n }\n\n /**\n * Updates the editable parameters of a transaction.\n *\n * @param txId - The ID of the transaction to update.\n * @param params - The editable parameters to update.\n * @param params.data - Data to pass with the transaction.\n * @param params.gas - Maximum number of units of gas to use for the transaction.\n * @param params.gasPrice - Price per gas for legacy transactions.\n * @param params.from - Address to send the transaction from.\n * @param params.to - Address to send the transaction to.\n * @param params.value - Value associated with the transaction.\n * @returns The updated transaction metadata.\n */\n async updateEditableParams(\n txId: string,\n {\n data,\n gas,\n gasPrice,\n from,\n to,\n value,\n }: {\n data?: string;\n gas?: string;\n gasPrice?: string;\n from?: string;\n to?: string;\n value?: string;\n },\n ) {\n const transactionMeta = this.getTransaction(txId);\n if (!transactionMeta) {\n throw new Error(\n `Cannot update editable params as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(transactionMeta, 'updateEditableParams');\n\n const editableParams = {\n txParams: {\n data,\n from,\n to,\n value,\n gas,\n gasPrice,\n },\n } as Partial<TransactionMeta>;\n\n editableParams.txParams = pickBy(\n editableParams.txParams,\n ) as TransactionParams;\n\n const updatedTransaction = merge(transactionMeta, editableParams);\n const { type } = await determineTransactionType(\n updatedTransaction.txParams,\n this.ethQuery,\n );\n updatedTransaction.type = type;\n\n this.updateTransaction(\n updatedTransaction,\n `Update Editable Params for ${txId}`,\n );\n return this.getTransaction(txId);\n }\n\n /**\n * Signs and returns the raw transaction data for provided transaction params list.\n *\n * @param listOfTxParams - The list of transaction params to approve.\n * @returns The raw transactions.\n */\n async approveTransactionsWithSameNonce(\n listOfTxParams: TransactionParams[] = [],\n ): Promise<string | string[]> {\n if (listOfTxParams.length === 0) {\n return '';\n }\n\n const initialTx = listOfTxParams[0];\n const common = this.getCommonConfiguration();\n\n const initialTxAsEthTx = TransactionFactory.fromTxData(initialTx, {\n common,\n });\n\n const initialTxAsSerializedHex = bufferToHex(initialTxAsEthTx.serialize());\n\n if (this.inProcessOfSigning.has(initialTxAsSerializedHex)) {\n return '';\n }\n\n this.inProcessOfSigning.add(initialTxAsSerializedHex);\n\n let rawTransactions, nonceLock;\n try {\n // TODO: we should add a check to verify that all transactions have the same from address\n const fromAddress = initialTx.from;\n nonceLock = await this.nonceTracker.getNonceLock(fromAddress);\n const nonce = nonceLock.nextNonce;\n\n rawTransactions = await Promise.all(\n listOfTxParams.map((txParams) => {\n txParams.nonce = addHexPrefix(nonce.toString(16));\n return this.signExternalTransaction(txParams);\n }),\n );\n } catch (err) {\n log('Error while signing transactions with same nonce', err);\n // Must set transaction to submitted/failed before releasing lock\n // continue with error chain\n throw err;\n } finally {\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n this.inProcessOfSigning.delete(initialTxAsSerializedHex);\n }\n return rawTransactions;\n }\n\n /**\n * Update a custodial transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param options - The custodial transaction options to update.\n * @param options.errorMessage - The error message to be assigned in case transaction status update to failed.\n * @param options.hash - The new hash value to be assigned.\n * @param options.status - The new status value to be assigned.\n */\n updateCustodialTransaction(\n transactionId: string,\n {\n errorMessage,\n hash,\n status,\n }: {\n errorMessage?: string;\n hash?: string;\n status?: TransactionStatus;\n },\n ) {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update custodial transaction as no transaction metadata found`,\n );\n }\n\n if (!transactionMeta.custodyId) {\n throw new Error('Transaction must be a custodian transaction');\n }\n\n if (\n status &&\n ![\n TransactionStatus.submitted,\n TransactionStatus.signed,\n TransactionStatus.failed,\n ].includes(status)\n ) {\n throw new Error(\n `Cannot update custodial transaction with status: ${status}`,\n );\n }\n\n const updatedTransactionMeta = merge(\n transactionMeta,\n pickBy({ hash, status }),\n );\n\n if (status === TransactionStatus.submitted) {\n updatedTransactionMeta.submittedTime = new Date().getTime();\n }\n\n if (status === TransactionStatus.failed) {\n updatedTransactionMeta.error = normalizeTxError(new Error(errorMessage));\n }\n\n this.updateTransaction(\n updatedTransactionMeta,\n `TransactionController:updateCustodialTransaction - Custodial transaction updated`,\n );\n }\n\n /**\n * Creates approvals for all unapproved transactions persisted.\n */\n initApprovals() {\n const chainId = this.getChainId();\n const unapprovedTxs = this.state.transactions.filter(\n (transaction) =>\n transaction.status === TransactionStatus.unapproved &&\n transaction.chainId === chainId,\n );\n\n for (const txMeta of unapprovedTxs) {\n this.processApproval(txMeta, {\n shouldShowRequest: false,\n }).catch((error) => {\n if (error?.code === errorCodes.provider.userRejectedRequest) {\n return;\n }\n console.error('Error during persisted transaction approval', error);\n });\n }\n }\n\n /**\n * Search transaction metadata for matching entries.\n *\n * @param opts - Options bag.\n * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.\n * @param opts.initialList - The transactions to search. Defaults to the current state.\n * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.\n * @param opts.limit - The maximum number of transactions to return. No limit by default.\n * @returns An array of transactions matching the provided options.\n */\n getTransactions({\n searchCriteria = {},\n initialList,\n filterToCurrentNetwork = true,\n limit,\n }: {\n searchCriteria?: any;\n initialList?: TransactionMeta[];\n filterToCurrentNetwork?: boolean;\n limit?: number;\n } = {}): TransactionMeta[] {\n const chainId = this.getChainId();\n // searchCriteria is an object that might have values that aren't predicate\n // methods. When providing any other value type (string, number, etc), we\n // consider this shorthand for \"check the value at key for strict equality\n // with the provided value\". To conform this object to be only methods, we\n // mapValues (lodash) such that every value on the object is a method that\n // returns a boolean.\n const predicateMethods = mapValues(searchCriteria, (predicate) => {\n return typeof predicate === 'function'\n ? predicate\n : (v: any) => v === predicate;\n });\n\n const transactionsToFilter = initialList ?? this.state.transactions;\n\n // Combine sortBy and pickBy to transform our state object into an array of\n // matching transactions that are sorted by time.\n const filteredTransactions = sortBy(\n pickBy(transactionsToFilter, (transaction) => {\n if (filterToCurrentNetwork && transaction.chainId !== chainId) {\n return false;\n }\n // iterate over the predicateMethods keys to check if the transaction\n // matches the searchCriteria\n for (const [key, predicate] of Object.entries(predicateMethods)) {\n // We return false early as soon as we know that one of the specified\n // search criteria do not match the transaction. This prevents\n // needlessly checking all criteria when we already know the criteria\n // are not fully satisfied. We check both txParams and the base\n // object as predicate keys can be either.\n if (key in transaction.txParams) {\n if (predicate((transaction.txParams as any)[key]) === false) {\n return false;\n }\n } else if (predicate((transaction as any)[key]) === false) {\n return false;\n }\n }\n\n return true;\n }),\n 'time',\n );\n if (limit !== undefined) {\n // We need to have all transactions of a given nonce in order to display\n // necessary details in the UI. We use the size of this set to determine\n // whether we have reached the limit provided, thus ensuring that all\n // transactions of nonces we include will be sent to the UI.\n const nonces = new Set();\n const txs = [];\n // By default, the transaction list we filter from is sorted by time ASC.\n // To ensure that filtered results prefers the newest transactions we\n // iterate from right to left, inserting transactions into front of a new\n // array. The original order is preserved, but we ensure that newest txs\n // are preferred.\n for (let i = filteredTransactions.length - 1; i > -1; i--) {\n const txMeta = filteredTransactions[i];\n const { nonce } = txMeta.txParams;\n if (!nonces.has(nonce)) {\n if (nonces.size < limit) {\n nonces.add(nonce);\n } else {\n continue;\n }\n }\n // Push transaction into the beginning of our array to ensure the\n // original order is preserved.\n txs.unshift(txMeta);\n }\n return txs;\n }\n return filteredTransactions;\n }\n\n private async signExternalTransaction(\n transactionParams: TransactionParams,\n ): Promise<string> {\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n const normalizedTransactionParams = normalizeTxParams(transactionParams);\n const chainId = this.getChainId();\n const type = isEIP1559Transaction(normalizedTransactionParams)\n ? TransactionEnvelopeType.feeMarket\n : TransactionEnvelopeType.legacy;\n const updatedTransactionParams = {\n ...normalizedTransactionParams,\n type,\n gasLimit: normalizedTransactionParams.gas,\n chainId,\n };\n\n const { from } = updatedTransactionParams;\n const common = this.getCommonConfiguration();\n const unsignedTransaction = TransactionFactory.fromTxData(\n updatedTransactionParams,\n { common },\n );\n const signedTransaction = await this.sign(unsignedTransaction, from);\n\n const rawTransaction = bufferToHex(signedTransaction.serialize());\n return rawTransaction;\n }\n\n /**\n * Removes unapproved transactions from state.\n */\n clearUnapprovedTransactions() {\n const transactions = this.state.transactions.filter(\n ({ status }) => status !== TransactionStatus.unapproved,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n private addMetadata(transactionMeta: TransactionMeta) {\n const { transactions } = this.state;\n transactions.push(transactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n private async updateGasProperties(transactionMeta: TransactionMeta) {\n const isEIP1559Compatible =\n (await this.getEIP1559Compatibility()) &&\n transactionMeta.txParams.type !== TransactionEnvelopeType.legacy;\n\n const chainId = this.getChainId();\n\n await updateGas({\n ethQuery: this.ethQuery,\n providerConfig: this.getNetworkState().providerConfig,\n txMeta: transactionMeta,\n });\n\n await updateGasFees({\n eip1559: isEIP1559Compatible,\n ethQuery: this.ethQuery,\n getSavedGasFees: this.getSavedGasFees.bind(this, chainId),\n getGasFeeEstimates: this.getGasFeeEstimates.bind(this),\n txMeta: transactionMeta,\n });\n }\n\n private getCurrentChainTransactionsByStatus(status: TransactionStatus) {\n const chainId = this.getChainId();\n return this.state.transactions.filter(\n (transaction) =>\n transaction.status === status && transaction.chainId === chainId,\n );\n }\n\n private onBootCleanup() {\n this.submitApprovedTransactions();\n }\n\n /**\n * Create approvals for all unapproved transactions on current chain.\n */\n private createApprovalsForUnapprovedTransactions() {\n const unapprovedTransactions = this.getCurrentChainTransactionsByStatus(\n TransactionStatus.unapproved,\n );\n\n for (const transactionMeta of unapprovedTransactions) {\n this.processApproval(transactionMeta, {\n shouldShowRequest: false,\n }).catch((error) => {\n if (error?.code === errorCodes.provider.userRejectedRequest) {\n return;\n }\n /* istanbul ignore next */\n console.error('Error during persisted transaction approval', error);\n });\n }\n }\n\n /**\n * Force to submit approved transactions on current chain.\n */\n private submitApprovedTransactions() {\n const approvedTransactions = this.getCurrentChainTransactionsByStatus(\n TransactionStatus.approved,\n );\n for (const transactionMeta of approvedTransactions) {\n if (this.beforeApproveOnInit(transactionMeta)) {\n this.approveTransaction(transactionMeta.id).catch((error) => {\n /* istanbul ignore next */\n console.error('Error while submitting persisted transaction', error);\n });\n }\n }\n }\n\n private async processApproval(\n transactionMeta: TransactionMeta,\n {\n isExisting = false,\n requireApproval,\n shouldShowRequest = true,\n actionId,\n }: {\n isExisting?: boolean;\n requireApproval?: boolean | undefined;\n shouldShowRequest?: boolean;\n actionId?: string;\n },\n ): Promise<string> {\n const transactionId = transactionMeta.id;\n let resultCallbacks: AcceptResultCallbacks | undefined;\n const { meta, isCompleted } = this.isTransactionCompleted(transactionId);\n const finishedPromise = isCompleted\n ? Promise.resolve(meta)\n : this.waitForTransactionFinished(transactionId);\n\n if (meta && !isExisting && !isCompleted) {\n try {\n if (requireApproval !== false) {\n const acceptResult = await this.requestApproval(transactionMeta, {\n shouldShowRequest,\n });\n\n resultCallbacks = acceptResult.resultCallbacks;\n\n if (resultCallbacks) {\n this.hub.once(`${transactionId}:publish-skip`, () => {\n resultCallbacks?.success();\n\n // Remove the reference to prevent additional reports once submitted.\n resultCallbacks = undefined;\n });\n }\n }\n\n const { isCompleted: isTxCompleted } =\n this.isTransactionCompleted(transactionId);\n\n if (!isTxCompleted) {\n await this.approveTransaction(transactionId);\n const updatedTransactionMeta = this.getTransaction(\n transactionId,\n ) as TransactionMeta;\n this.hub.emit('transaction-approved', {\n transactionMeta: updatedTransactionMeta,\n actionId,\n });\n }\n } catch (error: any) {\n const { isCompleted: isTxCompleted } =\n this.isTransactionCompleted(transactionId);\n if (!isTxCompleted) {\n if (error?.code === errorCodes.provider.userRejectedRequest) {\n this.cancelTransaction(transactionId, actionId);\n\n throw providerErrors.userRejectedRequest(\n 'MetaMask Tx Signature: User denied transaction signature.',\n );\n } else {\n this.failTransaction(meta, error, actionId);\n }\n }\n }\n }\n\n const finalMeta = await finishedPromise;\n\n switch (finalMeta?.status) {\n case TransactionStatus.failed:\n resultCallbacks?.error(finalMeta.error);\n throw rpcErrors.internal(finalMeta.error.message);\n\n case TransactionStatus.submitted:\n resultCallbacks?.success();\n return finalMeta.hash as string;\n\n default:\n const internalError = rpcErrors.internal(\n `MetaMask Tx Signature: Unknown problem: ${JSON.stringify(\n finalMeta || transactionId,\n )}`,\n );\n\n resultCallbacks?.error(internalError);\n throw internalError;\n }\n }\n\n /**\n * Approves a transaction and updates it's status in state. If this is not a\n * retry transaction, a nonce will be generated. The transaction is signed\n * using the sign configuration property, then published to the blockchain.\n * A `<tx.id>:finished` hub event is fired after success or failure.\n *\n * @param transactionId - The ID of the transaction to approve.\n */\n private async approveTransaction(transactionId: string) {\n const { transactions } = this.state;\n const releaseLock = await this.mutex.acquire();\n const chainId = this.getChainId();\n const index = transactions.findIndex(({ id }) => transactionId === id);\n const transactionMeta = transactions[index];\n const {\n txParams: { nonce, from },\n } = transactionMeta;\n let nonceLock;\n try {\n if (!this.sign) {\n releaseLock();\n this.failTransaction(\n transactionMeta,\n new Error('No sign method defined.'),\n );\n return;\n } else if (!chainId) {\n releaseLock();\n this.failTransaction(transactionMeta, new Error('No chainId defined.'));\n return;\n }\n\n if (this.inProcessOfSigning.has(transactionId)) {\n log('Skipping approval as signing in progress', transactionId);\n return;\n }\n\n let nonceToUse = nonce;\n // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction\n // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce\n if (!nonceToUse) {\n nonceLock = await this.nonceTracker.getNonceLock(from);\n nonceToUse = addHexPrefix(nonceLock.nextNonce.toString(16));\n }\n\n transactionMeta.status = TransactionStatus.approved;\n transactionMeta.txParams.nonce = nonceToUse;\n transactionMeta.txParams.chainId = chainId;\n\n const baseTxParams = {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n };\n\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction approved',\n );\n\n this.onTransactionStatusChange(transactionMeta);\n\n const isEIP1559 = isEIP1559Transaction(transactionMeta.txParams);\n\n const txParams: TransactionParams = isEIP1559\n ? {\n ...baseTxParams,\n estimatedBaseFee: transactionMeta.txParams.estimatedBaseFee,\n type: TransactionEnvelopeType.feeMarket,\n }\n : baseTxParams;\n\n const rawTx = await this.signTransaction(transactionMeta, txParams);\n\n if (!this.beforePublish(transactionMeta)) {\n log('Skipping publishing transaction based on hook');\n this.hub.emit(`${transactionMeta.id}:publish-skip`, transactionMeta);\n return;\n }\n\n if (!rawTx) {\n return;\n }\n\n if (transactionMeta.type === TransactionType.swap) {\n log('Determining pre-transaction balance');\n\n const preTxBalance = await query(this.ethQuery, 'getBalance', [from]);\n\n transactionMeta.preTxBalance = preTxBalance;\n\n log('Updated pre-transaction balance', transactionMeta.preTxBalance);\n }\n\n log('Publishing transaction', txParams);\n\n const hash = await this.publishTransaction(rawTx);\n\n log('Publish successful', hash);\n\n transactionMeta.hash = hash;\n transactionMeta.status = TransactionStatus.submitted;\n transactionMeta.submittedTime = new Date().getTime();\n\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction submitted',\n );\n\n this.hub.emit('transaction-submitted', {\n transactionMeta,\n });\n\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n\n this.onTransactionStatusChange(transactionMeta);\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n } finally {\n this.inProcessOfSigning.delete(transactionId);\n // must set transaction to submitted/failed before releasing lock\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n releaseLock();\n }\n }\n\n private async publishTransaction(rawTransaction: string): Promise<string> {\n return await query(this.ethQuery, 'sendRawTransaction', [rawTransaction]);\n }\n\n /**\n * Cancels a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `<tx.id>:finished` hub event.\n *\n * @param transactionId - The ID of the transaction to cancel.\n * @param actionId - The actionId passed from UI\n */\n private cancelTransaction(transactionId: string, actionId?: string) {\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n if (!transactionMeta) {\n return;\n }\n transactionMeta.status = TransactionStatus.rejected;\n const transactions = this.state.transactions.filter(\n ({ id }) => id !== transactionId,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n this.hub.emit('transaction-rejected', {\n transactionMeta,\n actionId,\n });\n this.onTransactionStatusChange(transactionMeta);\n }\n\n /**\n * Trim the amount of transactions that are set on the state. Checks\n * if the length of the tx history is longer then desired persistence\n * limit and then if it is removes the oldest confirmed or rejected tx.\n * Pending or unapproved transactions will not be removed by this\n * operation. For safety of presenting a fully functional transaction UI\n * representation, this function will not break apart transactions with the\n * same nonce, created on the same day, per network. Not accounting for transactions of the same\n * nonce, same day and network combo can result in confusing or broken experiences\n * in the UI. The transactions are then updated using the BaseControllerV1 update.\n *\n * @param transactions - The transactions to be applied to the state.\n * @returns The trimmed list of transactions.\n */\n private trimTransactionsForState(\n transactions: TransactionMeta[],\n ): TransactionMeta[] {\n const nonceNetworkSet = new Set();\n\n const txsToKeep = transactions\n .sort((a, b) => (a.time > b.time ? -1 : 1)) // Descending time order\n .filter((tx) => {\n const { chainId, status, txParams, time } = tx;\n\n if (txParams) {\n const key = `${txParams.nonce}-${convertHexToDecimal(\n chainId,\n )}-${new Date(time).toDateString()}`;\n\n if (nonceNetworkSet.has(key)) {\n return true;\n } else if (\n nonceNetworkSet.size < this.config.txHistoryLimit ||\n !this.isFinalState(status)\n ) {\n nonceNetworkSet.add(key);\n return true;\n }\n }\n\n return false;\n });\n\n txsToKeep.reverse(); // Ascending time order\n return txsToKeep;\n }\n\n /**\n * Determines if the transaction is in a final state.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isFinalState(status: TransactionStatus): boolean {\n return (\n status === TransactionStatus.rejected ||\n status === TransactionStatus.confirmed ||\n status === TransactionStatus.failed\n );\n }\n\n /**\n * Whether the transaction has at least completed all local processing.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isLocalFinalState(status: TransactionStatus): boolean {\n return [\n TransactionStatus.confirmed,\n TransactionStatus.failed,\n TransactionStatus.rejected,\n TransactionStatus.submitted,\n ].includes(status);\n }\n\n private async requestApproval(\n txMeta: TransactionMeta,\n { shouldShowRequest }: { shouldShowRequest: boolean },\n ): Promise<AddResult> {\n const id = this.getApprovalId(txMeta);\n const { origin } = txMeta;\n const type = ApprovalType.Transaction;\n const requestData = { txId: txMeta.id };\n\n return (await this.messagingSystem.call(\n 'ApprovalController:addRequest',\n {\n id,\n origin: origin || ORIGIN_METAMASK,\n type,\n requestData,\n expectsResult: true,\n },\n shouldShowRequest,\n )) as Promise<AddResult>;\n }\n\n private getTransaction(transactionId: string): TransactionMeta | undefined {\n const { transactions } = this.state;\n return transactions.find(({ id }) => id === transactionId);\n }\n\n private getApprovalId(txMeta: TransactionMeta) {\n return String(txMeta.id);\n }\n\n private isTransactionCompleted(transactionId: string): {\n meta?: TransactionMeta;\n isCompleted: boolean;\n } {\n const transaction = this.getTransaction(transactionId);\n\n if (!transaction) {\n return { meta: undefined, isCompleted: false };\n }\n\n const isCompleted = this.isLocalFinalState(transaction.status);\n\n return { meta: transaction, isCompleted };\n }\n\n private getChainId(): Hex {\n const { providerConfig } = this.getNetworkState();\n return providerConfig.chainId;\n }\n\n private prepareUnsignedEthTx(txParams: TransactionParams): TypedTransaction {\n return TransactionFactory.fromTxData(txParams, {\n common: this.getCommonConfiguration(),\n freeze: false,\n });\n }\n\n /**\n * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for\n * specifying which chain, network, hardfork and EIPs to support for\n * a transaction. By referencing this configuration, and analyzing the fields\n * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718\n * transaction type to use.\n *\n * @returns common configuration object\n */\n private getCommonConfiguration(): Common {\n const {\n providerConfig: { type: chain, chainId, nickname: name },\n } = this.getNetworkState();\n\n if (\n chain !== RPC &&\n chain !== NetworkType['linea-goerli'] &&\n chain !== NetworkType['linea-mainnet']\n ) {\n return new Common({ chain, hardfork: HARDFORK });\n }\n\n const customChainParams: Partial<ChainConfig> = {\n name,\n chainId: parseInt(chainId, 16),\n defaultHardfork: HARDFORK,\n };\n\n return Common.custom(customChainParams);\n }\n\n private onIncomingTransactions({\n added,\n updated,\n }: {\n added: TransactionMeta[];\n updated: TransactionMeta[];\n }) {\n const { transactions: currentTransactions } = this.state;\n\n const updatedTransactions = [\n ...added,\n ...currentTransactions.map((originalTransaction) => {\n const updatedTransaction = updated.find(\n ({ hash }) => hash === originalTransaction.hash,\n );\n\n return updatedTransaction ?? originalTransaction;\n }),\n ];\n\n this.update({\n transactions: this.trimTransactionsForState(updatedTransactions),\n });\n }\n\n private onUpdatedLastFetchedBlockNumbers({\n lastFetchedBlockNumbers,\n blockNumber,\n }: {\n lastFetchedBlockNumbers: {\n [key: string]: number;\n };\n blockNumber: number;\n }) {\n this.update({ lastFetchedBlockNumbers });\n this.hub.emit('incomingTransactionBlock', blockNumber);\n }\n\n private generateDappSuggestedGasFees(\n txParams: TransactionParams,\n origin?: string,\n ): DappSuggestedGasFees | undefined {\n if (!origin || origin === ORIGIN_METAMASK) {\n return undefined;\n }\n\n const { gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas } = txParams;\n\n if (\n gasPrice === undefined &&\n maxFeePerGas === undefined &&\n maxPriorityFeePerGas === undefined &&\n gas === undefined\n ) {\n return undefined;\n }\n\n const dappSuggestedGasFees: DappSuggestedGasFees = {};\n\n if (gasPrice !== undefined) {\n dappSuggestedGasFees.gasPrice = gasPrice;\n } else if (\n maxFeePerGas !== undefined ||\n maxPriorityFeePerGas !== undefined\n ) {\n dappSuggestedGasFees.maxFeePerGas = maxFeePerGas;\n dappSuggestedGasFees.maxPriorityFeePerGas = maxPriorityFeePerGas;\n }\n\n if (gas !== undefined) {\n dappSuggestedGasFees.gas = gas;\n }\n\n return dappSuggestedGasFees;\n }\n\n /**\n * Validates and adds external provided transaction to state.\n *\n * @param transactionMeta - Nominated external transaction to be added to state.\n */\n private addExternalTransaction(transactionMeta: TransactionMeta) {\n const chainId = this.getChainId();\n const { transactions } = this.state;\n const fromAddress = transactionMeta?.txParams?.from;\n const sameFromAndNetworkTransactions = transactions.filter(\n (transaction) =>\n transaction.txParams.from === fromAddress &&\n transaction.chainId === chainId,\n );\n const confirmedTxs = sameFromAndNetworkTransactions.filter(\n (transaction) => transaction.status === TransactionStatus.confirmed,\n );\n const pendingTxs = sameFromAndNetworkTransactions.filter(\n (transaction) => transaction.status === TransactionStatus.submitted,\n );\n\n validateConfirmedExternalTransaction(\n transactionMeta,\n confirmedTxs,\n pendingTxs,\n );\n\n // Make sure provided external transaction has non empty history array\n if (!(transactionMeta.history ?? []).length) {\n if (!this.isHistoryDisabled) {\n addInitialHistorySnapshot(transactionMeta);\n }\n }\n\n const updatedTransactions = [...transactions, transactionMeta];\n this.update({\n transactions: this.trimTransactionsForState(updatedTransactions),\n });\n }\n\n /**\n * Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions\n * in the transactions have the same nonce.\n *\n * @param transactionId - Used to identify original transaction.\n */\n private markNonceDuplicatesDropped(transactionId: string) {\n const chainId = this.getChainId();\n const transactionMeta = this.getTransaction(transactionId);\n const nonce = transactionMeta?.txParams?.nonce;\n const from = transactionMeta?.txParams?.from;\n const sameNonceTxs = this.state.transactions.filter(\n (transaction) =>\n transaction.txParams.from === from &&\n transaction.txParams.nonce === nonce &&\n transaction.chainId === chainId,\n );\n\n if (!sameNonceTxs.length) {\n return;\n }\n\n // Mark all same nonce transactions as dropped and give it a replacedBy hash\n for (const transaction of sameNonceTxs) {\n if (transaction.id === transactionId) {\n continue;\n }\n transaction.replacedBy = transactionMeta?.hash;\n transaction.replacedById = transactionMeta?.id;\n // Drop any transaction that wasn't previously failed (off chain failure)\n if (transaction.status !== TransactionStatus.failed) {\n this.setTransactionStatusDropped(transaction);\n }\n }\n }\n\n /**\n * Method to set transaction status to dropped.\n *\n * @param transactionMeta - TransactionMeta of transaction to be marked as dropped.\n */\n private setTransactionStatusDropped(transactionMeta: TransactionMeta) {\n transactionMeta.status = TransactionStatus.dropped;\n this.hub.emit('transaction-dropped', {\n transactionMeta,\n });\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#setTransactionStatusDropped - Transaction dropped',\n );\n this.onTransactionStatusChange(transactionMeta);\n }\n\n /**\n * Get transaction with provided actionId.\n *\n * @param actionId - Unique ID to prevent duplicate requests\n * @returns the filtered transaction\n */\n private getTransactionWithActionId(actionId?: string) {\n return this.state.transactions.find(\n (transaction) => actionId && transaction.actionId === actionId,\n );\n }\n\n private async waitForTransactionFinished(\n transactionId: string,\n ): Promise<TransactionMeta> {\n return new Promise((resolve) => {\n this.hub.once(`${transactionId}:finished`, (txMeta) => {\n resolve(txMeta);\n });\n });\n }\n\n /**\n * Updates the r, s, and v properties of a TransactionMeta object\n * with values from a signed transaction.\n *\n * @param transactionMeta - The TransactionMeta object to update.\n * @param signedTx - The encompassing type for all transaction types containing r, s, and v values.\n */\n private async updateTransactionMetaRSV(\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ): Promise<void> {\n if (signedTx.r) {\n transactionMeta.r = addHexPrefix(signedTx.r.toString(16));\n }\n\n if (signedTx.s) {\n transactionMeta.s = addHexPrefix(signedTx.s.toString(16));\n }\n\n if (signedTx.v) {\n transactionMeta.v = addHexPrefix(signedTx.v.toString(16));\n }\n }\n\n private async getEIP1559Compatibility() {\n const currentNetworkIsEIP1559Compatible =\n await this.getCurrentNetworkEIP1559Compatibility();\n\n const currentAccountIsEIP1559Compatible =\n await this.getCurrentAccountEIP1559Compatibility();\n\n return (\n currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible\n );\n }\n\n private addPendingTransactionTrackerListeners() {\n this.pendingTransactionTracker.hub.on(\n 'transaction-confirmed',\n this.onConfirmedTransaction.bind(this),\n );\n\n this.pendingTransactionTracker.hub.on(\n 'transaction-dropped',\n this.setTransactionStatusDropped.bind(this),\n );\n\n this.pendingTransactionTracker.hub.on(\n 'transaction-failed',\n this.failTransaction.bind(this),\n );\n\n this.pendingTransactionTracker.hub.on(\n 'transaction-updated',\n this.updateTransaction.bind(this),\n );\n }\n\n private async signTransaction(\n transactionMeta: TransactionMeta,\n txParams: TransactionParams,\n ): Promise<string | undefined> {\n log('Signing transaction', txParams);\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n this.inProcessOfSigning.add(transactionMeta.id);\n\n const signedTx = await this.sign?.(\n unsignedEthTx,\n txParams.from,\n ...this.getAdditionalSignArguments(transactionMeta),\n );\n\n if (!signedTx) {\n log('Skipping signed status as no signed transaction');\n return undefined;\n }\n\n if (!this.afterSign(transactionMeta, signedTx)) {\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#signTransaction - Update after sign',\n );\n\n log('Skipping signed status based on hook');\n\n return undefined;\n }\n\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n\n transactionMeta.status = TransactionStatus.signed;\n\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction signed',\n );\n\n this.onTransactionStatusChange(transactionMeta);\n\n const rawTx = bufferToHex(signedTx.serialize());\n\n transactionMeta.rawTx = rawTx;\n\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - RawTransaction added',\n );\n\n return rawTx;\n }\n\n private onTransactionStatusChange(transactionMeta: TransactionMeta) {\n this.hub.emit('transaction-status-update', { transactionMeta });\n }\n\n private getNonceTrackerTransactions(\n status: TransactionStatus,\n address: string,\n ) {\n const currentChainId = this.getChainId();\n\n return getAndFormatTransactionsForNonceTracker(\n currentChainId,\n address,\n status,\n this.state.transactions,\n );\n }\n\n private onConfirmedTransaction(transactionMeta: TransactionMeta) {\n log('Processing confirmed transaction', transactionMeta.id);\n\n this.markNonceDuplicatesDropped(transactionMeta.id);\n\n this.hub.emit('transaction-confirmed', { transactionMeta });\n this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta);\n\n this.onTransactionStatusChange(transactionMeta);\n\n // Intentional given potential duration of process.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.updatePostBalance(transactionMeta);\n }\n\n private async updatePostBalance(transactionMeta: TransactionMeta) {\n try {\n if (transactionMeta.type !== TransactionType.swap) {\n return;\n }\n\n const { updatedTransactionMeta, approvalTransactionMeta } =\n await updatePostTransactionBalance(transactionMeta, {\n ethQuery: this.ethQuery,\n getTransaction: this.getTransaction.bind(this),\n updateTransaction: this.updateTransaction.bind(this),\n });\n\n this.hub.emit('post-transaction-balance-updated', {\n transactionMeta: updatedTransactionMeta,\n approvalTransactionMeta,\n });\n } catch (error) {\n /* istanbul ignore next */\n log('Error while updating post transaction balance', error);\n }\n }\n}\n"]}
@@ -101,4 +101,8 @@ export declare const ETHERSCAN_SUPPORTED_NETWORKS: {
101
101
  subdomain: string;
102
102
  };
103
103
  };
104
+ export declare const GAS_BUFFER_CHAIN_OVERRIDES: {
105
+ "0xa": number;
106
+ "0x1a4": number;
107
+ };
104
108
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;CAsBZ,CAAC;AAEX,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,kCAAkC,QAAQ,CAAC;AAExD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ExC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;CAsBZ,CAAC;AAEX,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,kCAAkC,QAAQ,CAAC;AAExD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ExC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;CAGtC,CAAC"}
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ETHERSCAN_SUPPORTED_NETWORKS = exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = exports.DEFAULT_ETHERSCAN_DOMAIN = exports.CHAIN_IDS = void 0;
3
+ exports.GAS_BUFFER_CHAIN_OVERRIDES = exports.ETHERSCAN_SUPPORTED_NETWORKS = exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = exports.DEFAULT_ETHERSCAN_DOMAIN = exports.CHAIN_IDS = void 0;
4
4
  exports.CHAIN_IDS = {
5
5
  MAINNET: '0x1',
6
6
  GOERLI: '0x5',
@@ -104,4 +104,8 @@ exports.ETHERSCAN_SUPPORTED_NETWORKS = {
104
104
  subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,
105
105
  },
106
106
  };
107
+ exports.GAS_BUFFER_CHAIN_OVERRIDES = {
108
+ [exports.CHAIN_IDS.OPTIMISM]: 1,
109
+ [exports.CHAIN_IDS.OPTIMISM_TESTNET]: 1,
110
+ };
107
111
  //# sourceMappingURL=constants.js.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,WAAW;KAC5D;IACD,CAAC,iBAAS,CAAC,gBAAgB,CAAC,EAAE;QAC5B,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,GAAG,0CAAkC,WAAW;KAC5D;IACD,CAAC,iBAAS,CAAC,SAAS,CAAC,EAAE;QACrB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,GAAG,0CAAkC,YAAY;KAC7D;IACD,CAAC,iBAAS,CAAC,MAAM,CAAC,EAAE;QAClB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,GAAG,0CAAkC,SAAS;KAC1D;CACF,CAAC","sourcesContent":["export const CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_TESTNET: '0x1a4',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n ARBITRUM: '0xa4b1',\n ZKSYNC_ERA: '0x144',\n} as const;\n\nexport const DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';\nexport const DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';\n\nexport const ETHERSCAN_SUPPORTED_NETWORKS = {\n [CHAIN_IDS.GOERLI]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n },\n [CHAIN_IDS.MAINNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n },\n [CHAIN_IDS.LINEA_GOERLI]: {\n domain: 'lineascan.build',\n subdomain: 'goerli',\n },\n [CHAIN_IDS.LINEA_MAINNET]: {\n domain: 'lineascan.build',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC]: {\n domain: 'bscscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC_TESTNET]: {\n domain: 'bscscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.OPTIMISM]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,\n },\n [CHAIN_IDS.OPTIMISM_TESTNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,\n },\n [CHAIN_IDS.POLYGON]: {\n domain: 'polygonscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.POLYGON_TESTNET]: {\n domain: 'polygonscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,\n },\n [CHAIN_IDS.AVALANCHE]: {\n domain: 'snowtrace.io',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.AVALANCHE_TESTNET]: {\n domain: 'snowtrace.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.FANTOM]: {\n domain: 'ftmscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.FANTOM_TESTNET]: {\n domain: 'ftmscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.MOONBEAM]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,\n },\n [CHAIN_IDS.MOONBEAM_TESTNET]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,\n },\n [CHAIN_IDS.MOONRIVER]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,\n },\n [CHAIN_IDS.GNOSIS]: {\n domain: 'gnosisscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,\n },\n};\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,MAAM;IACX,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,KAAK;IACf,gBAAgB,EAAE,OAAO;IACzB,OAAO,EAAE,MAAM;IACf,eAAe,EAAE,SAAS;IAC1B,SAAS,EAAE,QAAQ;IACnB,iBAAiB,EAAE,QAAQ;IAC3B,MAAM,EAAE,MAAM;IACd,cAAc,EAAE,OAAO;IACvB,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,OAAO;IACjB,gBAAgB,EAAE,OAAO;IACzB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,OAAO;CACX,CAAC;AAEE,QAAA,wBAAwB,GAAG,cAAc,CAAC;AAC1C,QAAA,kCAAkC,GAAG,KAAK,CAAC;AA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TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n ARBITRUM: '0xa4b1',\n ZKSYNC_ERA: '0x144',\n} as const;\n\nexport const DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';\nexport const DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';\n\nexport const ETHERSCAN_SUPPORTED_NETWORKS = {\n [CHAIN_IDS.GOERLI]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n },\n [CHAIN_IDS.MAINNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n },\n [CHAIN_IDS.LINEA_GOERLI]: {\n domain: 'lineascan.build',\n subdomain: 'goerli',\n },\n [CHAIN_IDS.LINEA_MAINNET]: {\n domain: 'lineascan.build',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC]: {\n domain: 'bscscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC_TESTNET]: {\n domain: 'bscscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.OPTIMISM]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,\n },\n [CHAIN_IDS.OPTIMISM_TESTNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,\n },\n [CHAIN_IDS.POLYGON]: {\n domain: 'polygonscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.POLYGON_TESTNET]: {\n domain: 'polygonscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,\n },\n [CHAIN_IDS.AVALANCHE]: {\n domain: 'snowtrace.io',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.AVALANCHE_TESTNET]: {\n domain: 'snowtrace.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.FANTOM]: {\n domain: 'ftmscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.FANTOM_TESTNET]: {\n domain: 'ftmscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.MOONBEAM]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,\n },\n [CHAIN_IDS.MOONBEAM_TESTNET]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,\n },\n [CHAIN_IDS.MOONRIVER]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,\n },\n [CHAIN_IDS.GNOSIS]: {\n domain: 'gnosisscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,\n },\n};\n\nexport const GAS_BUFFER_CHAIN_OVERRIDES = {\n [CHAIN_IDS.OPTIMISM]: 1,\n [CHAIN_IDS.OPTIMISM_TESTNET]: 1,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";AASA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnE,oBAAY,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,GAAG,0BAA2C,CAAC;AAE5D,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,iBAkBxD;AAED,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,QAAQ;;;;;;;;;;;GAsCnB;AAED,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,UAqBnB"}
1
+ {"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";AASA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnE,oBAAY,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,GAAG,0BAA2C,CAAC;AAE5D,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,iBAkBxD;AAED,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,QAAQ;;;;;;;;;;;GAsCnB;AAED,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,UAqBnB"}
package/dist/utils/gas.js CHANGED
@@ -14,6 +14,7 @@ exports.addGasBuffer = exports.estimateGas = exports.updateGas = exports.DEFAULT
14
14
  const controller_utils_1 = require("@metamask/controller-utils");
15
15
  const utils_1 = require("@metamask/utils");
16
16
  const ethereumjs_util_1 = require("ethereumjs-util");
17
+ const constants_1 = require("../constants");
17
18
  const logger_1 = require("../logger");
18
19
  exports.log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'gas');
19
20
  exports.FIXED_GAS = '0x5208';
@@ -88,6 +89,7 @@ function addGasBuffer(estimatedGas, blockGasLimit, multiplier) {
88
89
  }
89
90
  exports.addGasBuffer = addGasBuffer;
90
91
  function getGas(request) {
92
+ var _a;
91
93
  return __awaiter(this, void 0, void 0, function* () {
92
94
  const { providerConfig, txMeta } = request;
93
95
  if (txMeta.txParams.gas) {
@@ -103,7 +105,8 @@ function getGas(request) {
103
105
  (0, exports.log)('Using original estimate as custom network');
104
106
  return [estimatedGas, simulationFails];
105
107
  }
106
- const bufferedGas = addGasBuffer(estimatedGas, blockGasLimit, exports.DEFAULT_GAS_MULTIPLIER);
108
+ const bufferMultiplier = (_a = constants_1.GAS_BUFFER_CHAIN_OVERRIDES[providerConfig.chainId]) !== null && _a !== void 0 ? _a : exports.DEFAULT_GAS_MULTIPLIER;
109
+ const bufferedGas = addGasBuffer(estimatedGas, blockGasLimit, bufferMultiplier);
107
110
  return [bufferedGas, simulationF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utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type { ProviderConfig } from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport { addHexPrefix } from 'ethereumjs-util';\n\nimport { projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionParams } from '../types';\n\nexport type UpdateGasRequest = {\n ethQuery: EthQuery;\n providerConfig: ProviderConfig;\n txMeta: TransactionMeta;\n};\n\nexport const log = createModuleLogger(projectLogger, 'gas');\n\nexport const FIXED_GAS = '0x5208';\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\nexport async function updateGas(request: UpdateGasRequest) {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const [gas, simulationFails] = await getGas(request);\n\n txMeta.txParams.gas = gas;\n txMeta.simulationFails = simulationFails;\n\n if (!initialParams.gas) {\n txMeta.originalGasEstimate = txMeta.txParams.gas;\n }\n\n if (!txMeta.defaultGasEstimates) {\n txMeta.defaultGasEstimates = {};\n }\n\n txMeta.defaultGasEstimates.gas = txMeta.txParams.gas;\n}\n\nexport async function estimateGas(\n txParams: TransactionParams,\n ethQuery: EthQuery,\n) {\n const request = { ...txParams };\n const { data, value } = request;\n\n const { gasLimit: gasLimitHex, number: blockNumber } = await getLatestBlock(\n ethQuery,\n );\n\n const gasLimitBN = hexToBN(gasLimitHex);\n\n request.data = data ? addHexPrefix(data) : data;\n request.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n request.value = value || '0x0';\n\n let estimatedGas = request.gas;\n let simulationFails;\n\n try {\n estimatedGas = await query(ethQuery, 'estimateGas', [request]);\n } catch (error: any) {\n simulationFails = {\n reason: error.message,\n errorKey: error.errorKey,\n debug: {\n blockNumber,\n blockGasLimit: gasLimitHex,\n },\n };\n\n log('Estimation failed', { ...simulationFails, fallback: estimateGas });\n }\n\n return {\n blockGasLimit: gasLimitHex,\n estimatedGas,\n simulationFails,\n };\n}\n\nexport function addGasBuffer(\n estimatedGas: string,\n blockGasLimit: string,\n multiplier: number,\n) {\n const estimatedGasBN = hexToBN(estimatedGas);\n const maxGasBN = hexToBN(blockGasLimit).muln(0.9);\n const paddedGasBN = estimatedGasBN.muln(multiplier);\n\n if (estimatedGasBN.gt(maxGasBN)) {\n const estimatedGasHex = addHexPrefix(estimatedGas);\n log('Using estimated value', estimatedGasHex);\n return estimatedGasHex;\n }\n\n if (paddedGasBN.lt(maxGasBN)) {\n const paddedHex = addHexPrefix(BNToHex(paddedGasBN));\n log('Using padded estimate', paddedHex, multiplier);\n return paddedHex;\n }\n\n const maxHex = addHexPrefix(BNToHex(maxGasBN));\n log('Using 90% of block gas limit', maxHex);\n return maxHex;\n}\n\nasync function getGas(\n request: UpdateGasRequest,\n): Promise<[string, TransactionMeta['simulationFails']?]> {\n const { providerConfig, txMeta } = request;\n\n if (txMeta.txParams.gas) {\n log('Using value from request', txMeta.txParams.gas);\n return [txMeta.txParams.gas];\n }\n\n if (await requiresFixedGas(request)) {\n log('Using fixed value', FIXED_GAS);\n return [FIXED_GAS];\n }\n\n const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(\n txMeta.txParams,\n request.ethQuery,\n );\n\n if (providerConfig.type === NetworkType.rpc) {\n log('Using original estimate as custom network');\n return [estimatedGas, simulationFails];\n }\n\n const bufferedGas = addGasBuffer(\n estimatedGas,\n blockGasLimit,\n DEFAULT_GAS_MULTIPLIER,\n );\n\n return [bufferedGas, simulationFails];\n}\n\nasync function requiresFixedGas({\n ethQuery,\n txMeta,\n providerConfig,\n}: UpdateGasRequest): Promise<boolean> {\n const isCustomNetwork = providerConfig.type === NetworkType.rpc;\n\n const {\n txParams: { to, data },\n } = txMeta;\n\n if (isCustomNetwork) {\n return false;\n }\n\n if (!to) {\n return true;\n }\n\n const code = await getCode(ethQuery, to);\n\n return !data && (!code || code === '0x');\n}\n\nasync function getCode(\n ethQuery: EthQuery,\n address: string,\n): Promise<string | undefined> {\n return await query(ethQuery, 'getCode', [address]);\n}\n\nasync function getLatestBlock(\n ethQuery: EthQuery,\n): Promise<{ gasLimit: string; number: string }> {\n return await query(ethQuery, 'getBlockByNumber', ['latest', false]);\n}\n"]}
1
+ {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;;;;;;;;;;AAExC,iEAMoC;AAGpC,2CAAqD;AACrD,qDAA+C;AAE/C,4CAA0D;AAC1D,sCAA0C;AAS7B,QAAA,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,KAAK,CAAC,CAAC;AAE/C,QAAA,SAAS,GAAG,QAAQ,CAAC;AACrB,QAAA,sBAAsB,GAAG,GAAG,CAAC;AAE1C,SAAsB,SAAS,CAAC,OAAyB;;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,MAAM,aAAa,qBAAQ,MAAM,CAAC,QAAQ,CAAE,CAAC;QAE7C,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QAErD,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;QAC1B,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;YACtB,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;SAClD;QAED,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE;YAC/B,MAAM,CAAC,mBAAmB,GAAG,EAAE,CAAC;SACjC;QAED,MAAM,CAAC,mBAAmB,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;IACvD,CAAC;CAAA;AAlBD,8BAkBC;AAED,SAAsB,WAAW,CAC/B,QAA2B,EAC3B,QAAkB;;QAElB,MAAM,OAAO,qBAAQ,QAAQ,CAAE,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAEhC,MAAM,EAAE,QA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AK,CAAC,CAAC,CAAC;IACtE,CAAC;CAAA","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport {\n BNToHex,\n NetworkType,\n fractionBN,\n hexToBN,\n query,\n} from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type { ProviderConfig } from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport { addHexPrefix } from 'ethereumjs-util';\n\nimport { GAS_BUFFER_CHAIN_OVERRIDES } from '../constants';\nimport { projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionParams } from '../types';\n\nexport type UpdateGasRequest = {\n ethQuery: EthQuery;\n providerConfig: ProviderConfig;\n txMeta: TransactionMeta;\n};\n\nexport const log = createModuleLogger(projectLogger, 'gas');\n\nexport const FIXED_GAS = '0x5208';\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\nexport async function updateGas(request: UpdateGasRequest) {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const [gas, simulationFails] = await getGas(request);\n\n txMeta.txParams.gas = gas;\n txMeta.simulationFails = simulationFails;\n\n if (!initialParams.gas) {\n txMeta.originalGasEstimate = txMeta.txParams.gas;\n }\n\n if (!txMeta.defaultGasEstimates) {\n txMeta.defaultGasEstimates = {};\n }\n\n txMeta.defaultGasEstimates.gas = txMeta.txParams.gas;\n}\n\nexport async function estimateGas(\n txParams: TransactionParams,\n ethQuery: EthQuery,\n) {\n const request = { ...txParams };\n const { data, value } = request;\n\n const { gasLimit: gasLimitHex, number: blockNumber } = await getLatestBlock(\n ethQuery,\n );\n\n const gasLimitBN = hexToBN(gasLimitHex);\n\n request.data = data ? addHexPrefix(data) : data;\n request.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n request.value = value || '0x0';\n\n let estimatedGas = request.gas;\n let simulationFails;\n\n try {\n estimatedGas = await query(ethQuery, 'estimateGas', [request]);\n } catch (error: any) {\n simulationFails = {\n reason: error.message,\n errorKey: error.errorKey,\n debug: {\n blockNumber,\n blockGasLimit: gasLimitHex,\n },\n };\n\n log('Estimation failed', { ...simulationFails, fallback: estimateGas });\n }\n\n return {\n blockGasLimit: gasLimitHex,\n estimatedGas,\n simulationFails,\n };\n}\n\nexport function addGasBuffer(\n estimatedGas: string,\n blockGasLimit: string,\n multiplier: number,\n) {\n const estimatedGasBN = hexToBN(estimatedGas);\n const maxGasBN = hexToBN(blockGasLimit).muln(0.9);\n const paddedGasBN = estimatedGasBN.muln(multiplier);\n\n if (estimatedGasBN.gt(maxGasBN)) {\n const estimatedGasHex = addHexPrefix(estimatedGas);\n log('Using estimated value', estimatedGasHex);\n return estimatedGasHex;\n }\n\n if (paddedGasBN.lt(maxGasBN)) {\n const paddedHex = addHexPrefix(BNToHex(paddedGasBN));\n log('Using padded estimate', paddedHex, multiplier);\n return paddedHex;\n }\n\n const maxHex = addHexPrefix(BNToHex(maxGasBN));\n log('Using 90% of block gas limit', maxHex);\n return maxHex;\n}\n\nasync function getGas(\n request: UpdateGasRequest,\n): Promise<[string, TransactionMeta['simulationFails']?]> {\n const { providerConfig, txMeta } = request;\n\n if (txMeta.txParams.gas) {\n log('Using value from request', txMeta.txParams.gas);\n return [txMeta.txParams.gas];\n }\n\n if (await requiresFixedGas(request)) {\n log('Using fixed value', FIXED_GAS);\n return [FIXED_GAS];\n }\n\n const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(\n txMeta.txParams,\n request.ethQuery,\n );\n\n if (providerConfig.type === NetworkType.rpc) {\n log('Using original estimate as custom network');\n return [estimatedGas, simulationFails];\n }\n\n const bufferMultiplier =\n GAS_BUFFER_CHAIN_OVERRIDES[\n providerConfig.chainId as keyof typeof GAS_BUFFER_CHAIN_OVERRIDES\n ] ?? DEFAULT_GAS_MULTIPLIER;\n\n const bufferedGas = addGasBuffer(\n estimatedGas,\n blockGasLimit,\n bufferMultiplier,\n );\n\n return [bufferedGas, simulationFails];\n}\n\nasync function requiresFixedGas({\n ethQuery,\n txMeta,\n providerConfig,\n}: UpdateGasRequest): Promise<boolean> {\n const isCustomNetwork = providerConfig.type === NetworkType.rpc;\n\n const {\n txParams: { to, data },\n } = txMeta;\n\n if (isCustomNetwork) {\n return false;\n }\n\n if (!to) {\n return true;\n }\n\n const code = await getCode(ethQuery, to);\n\n return !data && (!code || code === '0x');\n}\n\nasync function getCode(\n ethQuery: EthQuery,\n address: string,\n): Promise<string | undefined> {\n return await query(ethQuery, 'getCode', [address]);\n}\n\nasync function getLatestBlock(\n ethQuery: EthQuery,\n): Promise<{ gasLimit: string; number: string }> {\n return await query(ethQuery, 'getBlockByNumber', ['latest', false]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/utils/history.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,eAAe,QAGzE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,MAAM,GACX,IAAI,CAWN"}
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/utils/history.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,eAAe,QAGzE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,MAAM,GACX,IAAI,CAeN"}
@@ -24,6 +24,9 @@ exports.addInitialHistorySnapshot = addInitialHistorySnapshot;
24
24
  */
25
25
  function updateTransactionHistory(transactionMeta, note) {
26
26
  var _a;
27
+ if (!transactionMeta.history) {
28
+ return;
29
+ }
27
30
  const currentState = snapshotFromTransactionMeta(transactionMeta);
28
31
  const previousState = replayHistory(transactionMeta.history);
29
32
  const historyEntry = generateHistoryEntry(previousState,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,MAAM,YAAY,GAAG,IAAA,kBAAS,EAAC,kBAAkB,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,KAAU,EAAE,EAAE,CAAC,yBAAU,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,WAAW,CAChD,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAClC,eAAgC;IAEhC,MAAM,QAAQ,qBAAQ,eAAe,CAAE,CAAC;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC;IACxB,OAAO,IAAA,kBAAS,EAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import jsonDiffer from 'fast-json-patch';\nimport { cloneDeep } from 'lodash';\n\nimport type {\n TransactionHistory,\n TransactionHistoryEntry,\n TransactionMeta,\n} from '../types';\n\n/**\n * Add initial history snapshot to the provided transactionMeta history.\n *\n * @param transactionMeta - TransactionMeta to add initial history snapshot to.\n */\nexport function addInitialHistorySnapshot(transactionMeta: TransactionMeta) {\n const snapshot = snapshotFromTransactionMeta(transactionMeta);\n transactionMeta.history = [snapshot];\n}\n\n/**\n * Compares and adds history entry to the provided transactionMeta history.\n *\n * @param transactionMeta - TransactionMeta to add history entry to.\n * @param note - Note to add to history entry.\n */\nexport function updateTransactionHistory(\n transactionMeta: TransactionMeta,\n note: string,\n): void {\n const currentState = snapshotFromTransactionMeta(transactionMeta);\n const previousState = replayHistory(\n transactionMeta.history as TransactionHistory,\n );\n\n const historyEntry = generateHistoryEntry(previousState, currentState, note);\n\n if (historyEntry.length) {\n transactionMeta?.history?.push(historyEntry);\n }\n}\n\n/**\n * Generates a history entry from the previous and new transaction metadata.\n *\n * @param previousState - The previous transaction metadata.\n * @param currentState - The new transaction metadata.\n * @param note - A note for the transaction metada update.\n * @returns An array of history operation.\n */\nfunction generateHistoryEntry(\n previousState: any,\n currentState: TransactionMeta,\n note: string,\n): TransactionHistoryEntry {\n const historyOperationsEntry = jsonDiffer.compare(\n previousState,\n currentState,\n ) as TransactionHistoryEntry;\n // Add a note to the first operation, since it breaks if we append it to the entry\n if (historyOperationsEntry[0]) {\n if (note) {\n historyOperationsEntry[0].note = note;\n }\n historyOperationsEntry[0].timestamp = Date.now();\n }\n return historyOperationsEntry;\n}\n\n/**\n * Recovers previous transactionMeta from passed history array.\n *\n * @param transactionHistory - The transaction metadata to replay.\n * @returns The transaction metadata.\n */\nfunction replayHistory(\n transactionHistory: TransactionHistory,\n): TransactionMeta {\n const shortHistory = cloneDeep(transactionHistory);\n return shortHistory.reduce(\n (val, entry: any) => jsonDiffer.applyPatch(val, entry).newDocument,\n ) as TransactionMeta;\n}\n\n/**\n * Clone the transaction meta data without the history property.\n *\n * @param transactionMeta - The transaction metadata to snapshot.\n * @returns A deep clone of transaction metadata without history property.\n */\nfunction snapshotFromTransactionMeta(\n transactionMeta: TransactionMeta,\n): TransactionMeta {\n const snapshot = { ...transactionMeta };\n delete snapshot.history;\n return cloneDeep(snapshot);\n}\n"]}
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/utils/history.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAyC;AACzC,mCAAmC;AAQnC;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,eAAgC;IACxE,MAAM,QAAQ,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC9D,eAAe,CAAC,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC;AACvC,CAAC;AAHD,8DAGC;AAED;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,eAAgC,EAChC,IAAY;;IAEZ,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;QAC5B,OAAO;KACR;IAED,MAAM,YAAY,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,aAAa,CACjC,eAAe,CAAC,OAA6B,CAC9C,CAAC;IAEF,MAAM,YAAY,GAAG,oBAAoB,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IAE7E,IAAI,YAAY,CAAC,MAAM,EAAE;QACvB,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAO,0CAAE,IAAI,CAAC,YAAY,CAAC,CAAC;KAC9C;AACH,CAAC;AAlBD,4DAkBC;AAED;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAC3B,aAAkB,EAClB,YAA6B,EAC7B,IAAY;IAEZ,MAAM,sBAAsB,GAAG,yBAAU,CAAC,OAAO,CAC/C,aAAa,EACb,YAAY,CACc,CAAC;IAC7B,kFAAkF;IAClF,IAAI,sBAAsB,CAAC,CAAC,CAAC,EAAE;QAC7B,IAAI,IAAI,EAAE;YACR,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;SACvC;QACD,sBAAsB,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;KAClD;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CACpB,kBAAsC;IAEtC,MAAM,YAAY,GAAG,IAAA,kBAAS,EAAC,kBAAkB,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,KAAU,EAAE,EAAE,CAAC,yBAAU,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,WAAW,CAChD,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAClC,eAAgC;IAEhC,MAAM,QAAQ,qBAAQ,eAAe,CAAE,CAAC;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC;IACxB,OAAO,IAAA,kBAAS,EAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import jsonDiffer from 'fast-json-patch';\nimport { cloneDeep } from 'lodash';\n\nimport type {\n TransactionHistory,\n TransactionHistoryEntry,\n TransactionMeta,\n} from '../types';\n\n/**\n * Add initial history snapshot to the provided transactionMeta history.\n *\n * @param transactionMeta - TransactionMeta to add initial history snapshot to.\n */\nexport function addInitialHistorySnapshot(transactionMeta: TransactionMeta) {\n const snapshot = snapshotFromTransactionMeta(transactionMeta);\n transactionMeta.history = [snapshot];\n}\n\n/**\n * Compares and adds history entry to the provided transactionMeta history.\n *\n * @param transactionMeta - TransactionMeta to add history entry to.\n * @param note - Note to add to history entry.\n */\nexport function updateTransactionHistory(\n transactionMeta: TransactionMeta,\n note: string,\n): void {\n if (!transactionMeta.history) {\n return;\n }\n\n const currentState = snapshotFromTransactionMeta(transactionMeta);\n const previousState = replayHistory(\n transactionMeta.history as TransactionHistory,\n );\n\n const historyEntry = generateHistoryEntry(previousState, currentState, note);\n\n if (historyEntry.length) {\n transactionMeta?.history?.push(historyEntry);\n }\n}\n\n/**\n * Generates a history entry from the previous and new transaction metadata.\n *\n * @param previousState - The previous transaction metadata.\n * @param currentState - The new transaction metadata.\n * @param note - A note for the transaction metada update.\n * @returns An array of history operation.\n */\nfunction generateHistoryEntry(\n previousState: any,\n currentState: TransactionMeta,\n note: string,\n): TransactionHistoryEntry {\n const historyOperationsEntry = jsonDiffer.compare(\n previousState,\n currentState,\n ) as TransactionHistoryEntry;\n // Add a note to the first operation, since it breaks if we append it to the entry\n if (historyOperationsEntry[0]) {\n if (note) {\n historyOperationsEntry[0].note = note;\n }\n historyOperationsEntry[0].timestamp = Date.now();\n }\n return historyOperationsEntry;\n}\n\n/**\n * Recovers previous transactionMeta from passed history array.\n *\n * @param transactionHistory - The transaction metadata to replay.\n * @returns The transaction metadata.\n */\nfunction replayHistory(\n transactionHistory: TransactionHistory,\n): TransactionMeta {\n const shortHistory = cloneDeep(transactionHistory);\n return shortHistory.reduce(\n (val, entry: any) => jsonDiffer.applyPatch(val, entry).newDocument,\n ) as TransactionMeta;\n}\n\n/**\n * Clone the transaction meta data without the history property.\n *\n * @param transactionMeta - The transaction metadata to snapshot.\n * @returns A deep clone of transaction metadata without history property.\n */\nfunction snapshotFromTransactionMeta(\n transactionMeta: TransactionMeta,\n): TransactionMeta {\n const snapshot = { ...transactionMeta };\n delete snapshot.history;\n return cloneDeep(snapshot);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/transaction-controller",
3
- "version": "18.0.0",
3
+ "version": "18.1.0",
4
4
  "description": "Stores transactions alongside their periodically updated statuses and manages interactions such as approval and cancellation",
5
5
  "keywords": [
6
6
  "MetaMask",