@metamask/transaction-controller 15.0.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/TransactionController.d.ts +22 -7
  3. package/dist/TransactionController.d.ts.map +1 -1
  4. package/dist/TransactionController.js +40 -80
  5. package/dist/TransactionController.js.map +1 -1
  6. package/dist/{EtherscanRemoteTransactionSource.d.ts → helpers/EtherscanRemoteTransactionSource.d.ts} +1 -1
  7. package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -0
  8. package/dist/{EtherscanRemoteTransactionSource.js → helpers/EtherscanRemoteTransactionSource.js} +4 -4
  9. package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -0
  10. package/dist/{IncomingTransactionHelper.d.ts → helpers/IncomingTransactionHelper.d.ts} +1 -1
  11. package/dist/helpers/IncomingTransactionHelper.d.ts.map +1 -0
  12. package/dist/{IncomingTransactionHelper.js → helpers/IncomingTransactionHelper.js} +1 -1
  13. package/dist/helpers/IncomingTransactionHelper.js.map +1 -0
  14. package/dist/{PendingTransactionTracker.d.ts → helpers/PendingTransactionTracker.d.ts} +4 -2
  15. package/dist/helpers/PendingTransactionTracker.d.ts.map +1 -0
  16. package/dist/{PendingTransactionTracker.js → helpers/PendingTransactionTracker.js} +47 -17
  17. package/dist/helpers/PendingTransactionTracker.js.map +1 -0
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/types.d.ts +71 -2
  23. package/dist/types.d.ts.map +1 -1
  24. package/dist/types.js +36 -1
  25. package/dist/types.js.map +1 -1
  26. package/dist/utils/etherscan.d.ts.map +1 -0
  27. package/dist/{etherscan.js → utils/etherscan.js} +3 -4
  28. package/dist/utils/etherscan.js.map +1 -0
  29. package/dist/{external-transactions.d.ts → utils/external-transactions.d.ts} +1 -1
  30. package/dist/utils/external-transactions.d.ts.map +1 -0
  31. package/dist/{external-transactions.js → utils/external-transactions.js} +1 -1
  32. package/dist/utils/external-transactions.js.map +1 -0
  33. package/dist/utils/gas-fees.d.ts +30 -0
  34. package/dist/utils/gas-fees.d.ts.map +1 -0
  35. package/dist/utils/gas-fees.js +194 -0
  36. package/dist/utils/gas-fees.js.map +1 -0
  37. package/dist/utils/gas.d.ts +25 -0
  38. package/dist/utils/gas.d.ts.map +1 -0
  39. package/dist/utils/gas.js +125 -0
  40. package/dist/utils/gas.js.map +1 -0
  41. package/dist/{history.d.ts → utils/history.d.ts} +1 -1
  42. package/dist/utils/history.d.ts.map +1 -0
  43. package/dist/utils/history.js.map +1 -0
  44. package/dist/{transaction-type.d.ts → utils/transaction-type.d.ts} +1 -1
  45. package/dist/utils/transaction-type.d.ts.map +1 -0
  46. package/dist/{transaction-type.js → utils/transaction-type.js} +1 -1
  47. package/dist/utils/transaction-type.js.map +1 -0
  48. package/dist/{utils.d.ts → utils/utils.d.ts} +3 -3
  49. package/dist/utils/utils.d.ts.map +1 -0
  50. package/dist/{utils.js → utils/utils.js} +3 -3
  51. package/dist/utils/utils.js.map +1 -0
  52. package/dist/{validation.d.ts → utils/validation.d.ts} +1 -1
  53. package/dist/utils/validation.d.ts.map +1 -0
  54. package/dist/utils/validation.js.map +1 -0
  55. package/package.json +8 -6
  56. package/dist/EtherscanRemoteTransactionSource.d.ts.map +0 -1
  57. package/dist/EtherscanRemoteTransactionSource.js.map +0 -1
  58. package/dist/IncomingTransactionHelper.d.ts.map +0 -1
  59. package/dist/IncomingTransactionHelper.js.map +0 -1
  60. package/dist/PendingTransactionTracker.d.ts.map +0 -1
  61. package/dist/PendingTransactionTracker.js.map +0 -1
  62. package/dist/etherscan.d.ts.map +0 -1
  63. package/dist/etherscan.js.map +0 -1
  64. package/dist/external-transactions.d.ts.map +0 -1
  65. package/dist/external-transactions.js.map +0 -1
  66. package/dist/history.d.ts.map +0 -1
  67. package/dist/history.js.map +0 -1
  68. package/dist/transaction-type.d.ts.map +0 -1
  69. package/dist/transaction-type.js.map +0 -1
  70. package/dist/utils.d.ts.map +0 -1
  71. package/dist/utils.js.map +0 -1
  72. package/dist/validation.d.ts.map +0 -1
  73. package/dist/validation.js.map +0 -1
  74. /package/dist/{etherscan.d.ts → utils/etherscan.d.ts} +0 -0
  75. /package/dist/{history.js → utils/history.js} +0 -0
  76. /package/dist/{validation.js → utils/validation.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [16.0.0]
10
+ ### Changed
11
+ - **BREAKING:** Bump dependency and peer dependency on `@metamask/gas-fee-controller` to ^10.0.0
12
+ - Bump dependency and peer dependency on `@metamask/network-controller` to ^15.1.0
13
+
9
14
  ## [15.0.0]
10
15
  ### Changed
11
16
  - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^15.0.0
@@ -243,7 +248,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
243
248
 
244
249
  All changes listed after this point were applied to this package following the monorepo conversion.
245
250
 
246
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@15.0.0...HEAD
251
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@16.0.0...HEAD
252
+ [16.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@15.0.0...@metamask/transaction-controller@16.0.0
247
253
  [15.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@14.0.0...@metamask/transaction-controller@15.0.0
248
254
  [14.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@13.0.0...@metamask/transaction-controller@14.0.0
249
255
  [13.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@12.0.0...@metamask/transaction-controller@13.0.0
@@ -4,9 +4,11 @@ import type { TypedTransaction } from '@ethereumjs/tx';
4
4
  import type { AddApprovalRequest } from '@metamask/approval-controller';
5
5
  import type { BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller';
6
6
  import { BaseController } from '@metamask/base-controller';
7
+ import type { GasFeeState } from '@metamask/gas-fee-controller';
7
8
  import type { BlockTracker, NetworkState, Provider } from '@metamask/network-controller';
8
9
  import type { Hex } from '@metamask/utils';
9
10
  import { EventEmitter } from 'events';
11
+ import type { NonceLock } from 'nonce-tracker/dist/NonceTracker';
10
12
  import type { TransactionParams, TransactionMeta, TransactionReceipt, SecurityProviderRequest, SendFlowHistoryEntry, WalletDevice } from './types';
11
13
  import { TransactionType } from './types';
12
14
  export declare const HARDFORK = Hardfork.London;
@@ -99,6 +101,7 @@ export declare class TransactionController extends BaseController<TransactionCon
99
101
  private readonly getNetworkState;
100
102
  private readonly getCurrentAccountEIP1559Compatibility;
101
103
  private readonly getCurrentNetworkEIP1559Compatibility;
104
+ private readonly getGasFeeEstimates;
102
105
  private readonly getPermittedAccounts;
103
106
  private readonly getSelectedAddress;
104
107
  private readonly messagingSystem;
@@ -128,6 +131,7 @@ export declare class TransactionController extends BaseController<TransactionCon
128
131
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
129
132
  * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
130
133
  * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
134
+ * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
131
135
  * @param options.getNetworkState - Gets the state of the network controller.
132
136
  * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
133
137
  * @param options.getSelectedAddress - Gets the address of the currently selected account.
@@ -143,12 +147,13 @@ export declare class TransactionController extends BaseController<TransactionCon
143
147
  * @param config - Initial options used to configure this controller.
144
148
  * @param state - Initial state to set on this controller.
145
149
  */
146
- constructor({ blockTracker, disableHistory, disableSendFlowHistory, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, provider, securityProviderRequest, }: {
150
+ constructor({ blockTracker, disableHistory, disableSendFlowHistory, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, provider, securityProviderRequest, }: {
147
151
  blockTracker: BlockTracker;
148
152
  disableHistory: boolean;
149
153
  disableSendFlowHistory: boolean;
150
154
  getCurrentAccountEIP1559Compatibility: () => Promise<boolean>;
151
155
  getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;
156
+ getGasFeeEstimates?: () => Promise<GasFeeState>;
152
157
  getNetworkState: () => NetworkState;
153
158
  getPermittedAccounts: (origin?: string) => Promise<string[]>;
154
159
  getSelectedAddress: () => string;
@@ -237,12 +242,14 @@ export declare class TransactionController extends BaseController<TransactionCon
237
242
  */
238
243
  estimateGas(transaction: TransactionParams): Promise<{
239
244
  gas: string;
240
- gasPrice: any;
241
- estimateGasError?: undefined;
242
- } | {
243
- gas: string;
244
- gasPrice: any;
245
- estimateGasError: string | undefined;
245
+ simulationFails: {
246
+ reason: any;
247
+ errorKey: any;
248
+ debug: {
249
+ blockNumber: string;
250
+ blockGasLimit: string;
251
+ };
252
+ } | undefined;
246
253
  }>;
247
254
  /**
248
255
  * Updates an existing transaction in state.
@@ -310,6 +317,14 @@ export declare class TransactionController extends BaseController<TransactionCon
310
317
  userEditedGasLimit?: boolean;
311
318
  userFeeLevel?: string;
312
319
  }): TransactionMeta;
320
+ /**
321
+ * Gets the next nonce according to the nonce-tracker.
322
+ * Ensure `releaseLock` is called once processing of the `nonce` value is complete.
323
+ *
324
+ * @param address - The hex string address for the transaction.
325
+ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.
326
+ */
327
+ getNonceLock(address: string): Promise<NonceLock>;
313
328
  private processApproval;
314
329
  /**
315
330
  * Approves a transaction and updates it's status in state. If this is not a
@@ -1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C;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;YAMpB,0BAA0B;IAUxC;;;;;;OAMG;YACW,wBAAwB;YAiBxB,uBAAuB;CAUtC;AAED,eAAe,qBAAqB,CAAC"}
@@ -26,16 +26,18 @@ const events_1 = require("events");
26
26
  const lodash_1 = require("lodash");
27
27
  const nonce_tracker_1 = __importDefault(require("nonce-tracker"));
28
28
  const uuid_1 = require("uuid");
29
- const EtherscanRemoteTransactionSource_1 = require("./EtherscanRemoteTransactionSource");
30
- const external_transactions_1 = require("./external-transactions");
31
- const history_1 = require("./history");
32
- const IncomingTransactionHelper_1 = require("./IncomingTransactionHelper");
29
+ const EtherscanRemoteTransactionSource_1 = require("./helpers/EtherscanRemoteTransactionSource");
30
+ const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper");
31
+ const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker");
33
32
  const logger_1 = require("./logger");
34
- const PendingTransactionTracker_1 = require("./PendingTransactionTracker");
35
- const transaction_type_1 = require("./transaction-type");
36
33
  const types_1 = require("./types");
37
- const utils_1 = require("./utils");
38
- const validation_1 = require("./validation");
34
+ const external_transactions_1 = require("./utils/external-transactions");
35
+ const gas_1 = require("./utils/gas");
36
+ const gas_fees_1 = require("./utils/gas-fees");
37
+ const history_1 = require("./utils/history");
38
+ const transaction_type_1 = require("./utils/transaction-type");
39
+ const utils_1 = require("./utils/utils");
40
+ const validation_1 = require("./utils/validation");
39
41
  exports.HARDFORK = common_1.Hardfork.London;
40
42
  /**
41
43
  * Multiplier used to determine a transaction's increased gas fee during cancellation
@@ -62,6 +64,7 @@ class TransactionController extends base_controller_1.BaseController {
62
64
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
63
65
  * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
64
66
  * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
67
+ * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
65
68
  * @param options.getNetworkState - Gets the state of the network controller.
66
69
  * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
67
70
  * @param options.getSelectedAddress - Gets the address of the currently selected account.
@@ -77,7 +80,7 @@ class TransactionController extends base_controller_1.BaseController {
77
80
  * @param config - Initial options used to configure this controller.
78
81
  * @param state - Initial state to set on this controller.
79
82
  */
80
- constructor({ blockTracker, disableHistory, disableSendFlowHistory, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, provider, securityProviderRequest, }, config, state) {
83
+ constructor({ blockTracker, disableHistory, disableSendFlowHistory, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, provider, securityProviderRequest, }, config, state) {
81
84
  super(config, state);
82
85
  this.mutex = new async_mutex_1.Mutex();
83
86
  /**
@@ -109,6 +112,8 @@ class TransactionController extends base_controller_1.BaseController {
109
112
  getCurrentAccountEIP1559Compatibility;
110
113
  this.getCurrentNetworkEIP1559Compatibility =
111
114
  getCurrentNetworkEIP1559Compatibility;
115
+ this.getGasFeeEstimates =
116
+ getGasFeeEstimates || (() => Promise.resolve({}));
112
117
  this.getPermittedAccounts = getPermittedAccounts;
113
118
  this.getSelectedAddress = getSelectedAddress;
114
119
  this.securityProviderRequest = securityProviderRequest;
@@ -139,6 +144,7 @@ class TransactionController extends base_controller_1.BaseController {
139
144
  getChainId: this.getChainId.bind(this),
140
145
  getEthQuery: () => this.ethQuery,
141
146
  getTransactions: () => this.state.transactions,
147
+ nonceTracker: this.nonceTracker,
142
148
  });
143
149
  this.pendingTransactionTracker.hub.on('transactions', this.onPendingTransactionsUpdate.bind(this));
144
150
  this.pendingTransactionTracker.hub.on('transaction-confirmed', (transactionMeta) => this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta));
@@ -234,16 +240,17 @@ class TransactionController extends base_controller_1.BaseController {
234
240
  verifiedOnBlockchain: false,
235
241
  type: transactionType,
236
242
  };
237
- try {
238
- const { gas, estimateGasError } = yield this.estimateGas(txParams);
239
- txParams.gas = gas;
240
- txParams.estimateGasError = estimateGasError;
241
- transactionMeta.originalGasEstimate = gas;
242
- }
243
- catch (error) {
244
- this.failTransaction(transactionMeta, error);
245
- return Promise.reject(error);
246
- }
243
+ yield (0, gas_1.updateGas)({
244
+ ethQuery: this.ethQuery,
245
+ providerConfig: this.getNetworkState().providerConfig,
246
+ txMeta: transactionMeta,
247
+ });
248
+ yield (0, gas_fees_1.updateGasFees)({
249
+ eip1559: isEIP1559Compatible,
250
+ ethQuery: this.ethQuery,
251
+ getGasFeeEstimates: this.getGasFeeEstimates.bind(this),
252
+ txMeta: transactionMeta,
253
+ });
247
254
  // Checks if a transaction already exists with a given actionId
248
255
  if (!existingTransactionMeta) {
249
256
  // Set security provider response
@@ -444,67 +451,8 @@ class TransactionController extends base_controller_1.BaseController {
444
451
  */
445
452
  estimateGas(transaction) {
446
453
  return __awaiter(this, void 0, void 0, function* () {
447
- const estimatedTransaction = Object.assign({}, transaction);
448
- const { gas, gasPrice: providedGasPrice, to, value, data, } = estimatedTransaction;
449
- const gasPrice = typeof providedGasPrice === 'undefined'
450
- ? yield (0, controller_utils_1.query)(this.ethQuery, 'gasPrice')
451
- : providedGasPrice;
452
- const { providerConfig } = this.getNetworkState();
453
- const isCustomNetwork = providerConfig.type === controller_utils_1.NetworkType.rpc;
454
- // 1. If gas is already defined on the transaction, use it
455
- if (typeof gas !== 'undefined') {
456
- return { gas, gasPrice };
457
- }
458
- const { gasLimit } = yield (0, controller_utils_1.query)(this.ethQuery, 'getBlockByNumber', [
459
- 'latest',
460
- false,
461
- ]);
462
- // 2. If to is not defined or this is not a contract address, and there is no data use 0x5208 / 21000.
463
- // If the network is a custom network then bypass this check and fetch 'estimateGas'.
464
- /* istanbul ignore next */
465
- const code = to ? yield (0, controller_utils_1.query)(this.ethQuery, 'getCode', [to]) : undefined;
466
- /* istanbul ignore next */
467
- if (!isCustomNetwork &&
468
- (!to || (to && !data && (!code || code === '0x')))) {
469
- return { gas: '0x5208', gasPrice };
470
- }
471
- // if data, should be hex string format
472
- estimatedTransaction.data = !data
473
- ? data
474
- : /* istanbul ignore next */ (0, ethereumjs_util_1.addHexPrefix)(data);
475
- // 3. If this is a contract address, safely estimate gas using RPC
476
- estimatedTransaction.value =
477
- typeof value === 'undefined' ? '0x0' : /* istanbul ignore next */ value;
478
- const gasLimitBN = (0, controller_utils_1.hexToBN)(gasLimit);
479
- estimatedTransaction.gas = (0, controller_utils_1.BNToHex)((0, controller_utils_1.fractionBN)(gasLimitBN, 19, 20));
480
- let gasHex;
481
- let estimateGasError;
482
- try {
483
- gasHex = yield (0, controller_utils_1.query)(this.ethQuery, 'estimateGas', [
484
- estimatedTransaction,
485
- ]);
486
- }
487
- catch (error) {
488
- estimateGasError = utils_1.ESTIMATE_GAS_ERROR;
489
- }
490
- // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a
491
- // a custom network then return the eth_estimateGas value.
492
- const gasBN = (0, controller_utils_1.hexToBN)(gasHex);
493
- const maxGasBN = gasLimitBN.muln(0.9);
494
- const paddedGasBN = gasBN.muln(1.5);
495
- /* istanbul ignore next */
496
- if (gasBN.gt(maxGasBN) || isCustomNetwork) {
497
- return { gas: (0, ethereumjs_util_1.addHexPrefix)(gasHex), gasPrice, estimateGasError };
498
- }
499
- /* istanbul ignore next */
500
- if (paddedGasBN.lt(maxGasBN)) {
501
- return {
502
- gas: (0, ethereumjs_util_1.addHexPrefix)((0, controller_utils_1.BNToHex)(paddedGasBN)),
503
- gasPrice,
504
- estimateGasError,
505
- };
506
- }
507
- return { gas: (0, ethereumjs_util_1.addHexPrefix)((0, controller_utils_1.BNToHex)(maxGasBN)), gasPrice, estimateGasError };
454
+ const { estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, this.ethQuery);
455
+ return { gas: estimatedGas, simulationFails };
508
456
  });
509
457
  }
510
458
  /**
@@ -662,6 +610,18 @@ class TransactionController extends base_controller_1.BaseController {
662
610
  this.updateTransaction(updatedMeta, 'TransactionController:updateTransactionGasFees - gas values updated');
663
611
  return this.getTransaction(transactionId);
664
612
  }
613
+ /**
614
+ * Gets the next nonce according to the nonce-tracker.
615
+ * Ensure `releaseLock` is called once processing of the `nonce` value is complete.
616
+ *
617
+ * @param address - The hex string address for the transaction.
618
+ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.
619
+ */
620
+ getNonceLock(address) {
621
+ return __awaiter(this, void 0, void 0, function* () {
622
+ return this.nonceTracker.getNonceLock(address);
623
+ });
624
+ }
665
625
  processApproval(transactionMeta, { isExisting = false, requireApproval, shouldShowRequest = true, }) {
666
626
  return __awaiter(this, void 0, void 0, function* () {
667
627
  const transactionId = transactionMeta.id;