@metamask/transaction-controller 14.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.
- package/CHANGELOG.md +14 -1
- package/dist/TransactionController.d.ts +22 -7
- package/dist/TransactionController.d.ts.map +1 -1
- package/dist/TransactionController.js +42 -80
- package/dist/TransactionController.js.map +1 -1
- package/dist/{EtherscanRemoteTransactionSource.d.ts → helpers/EtherscanRemoteTransactionSource.d.ts} +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -0
- package/dist/{EtherscanRemoteTransactionSource.js → helpers/EtherscanRemoteTransactionSource.js} +4 -4
- package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -0
- package/dist/{IncomingTransactionHelper.d.ts → helpers/IncomingTransactionHelper.d.ts} +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.ts.map +1 -0
- package/dist/{IncomingTransactionHelper.js → helpers/IncomingTransactionHelper.js} +1 -1
- package/dist/helpers/IncomingTransactionHelper.js.map +1 -0
- package/dist/{PendingTransactionTracker.d.ts → helpers/PendingTransactionTracker.d.ts} +4 -2
- package/dist/helpers/PendingTransactionTracker.d.ts.map +1 -0
- package/dist/{PendingTransactionTracker.js → helpers/PendingTransactionTracker.js} +47 -17
- package/dist/helpers/PendingTransactionTracker.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +71 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +36 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/etherscan.d.ts.map +1 -0
- package/dist/{etherscan.js → utils/etherscan.js} +3 -4
- package/dist/utils/etherscan.js.map +1 -0
- package/dist/{external-transactions.d.ts → utils/external-transactions.d.ts} +1 -1
- package/dist/utils/external-transactions.d.ts.map +1 -0
- package/dist/{external-transactions.js → utils/external-transactions.js} +1 -1
- package/dist/utils/external-transactions.js.map +1 -0
- package/dist/utils/gas-fees.d.ts +30 -0
- package/dist/utils/gas-fees.d.ts.map +1 -0
- package/dist/utils/gas-fees.js +194 -0
- package/dist/utils/gas-fees.js.map +1 -0
- package/dist/utils/gas.d.ts +25 -0
- package/dist/utils/gas.d.ts.map +1 -0
- package/dist/utils/gas.js +125 -0
- package/dist/utils/gas.js.map +1 -0
- package/dist/{history.d.ts → utils/history.d.ts} +1 -1
- package/dist/utils/history.d.ts.map +1 -0
- package/dist/utils/history.js.map +1 -0
- package/dist/{transaction-type.d.ts → utils/transaction-type.d.ts} +1 -1
- package/dist/utils/transaction-type.d.ts.map +1 -0
- package/dist/{transaction-type.js → utils/transaction-type.js} +1 -1
- package/dist/utils/transaction-type.js.map +1 -0
- package/dist/{utils.d.ts → utils/utils.d.ts} +3 -3
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/{utils.js → utils/utils.js} +3 -3
- package/dist/utils/utils.js.map +1 -0
- package/dist/{validation.d.ts → utils/validation.d.ts} +1 -1
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +9 -7
- package/dist/EtherscanRemoteTransactionSource.d.ts.map +0 -1
- package/dist/EtherscanRemoteTransactionSource.js.map +0 -1
- package/dist/IncomingTransactionHelper.d.ts.map +0 -1
- package/dist/IncomingTransactionHelper.js.map +0 -1
- package/dist/PendingTransactionTracker.d.ts.map +0 -1
- package/dist/PendingTransactionTracker.js.map +0 -1
- package/dist/etherscan.d.ts.map +0 -1
- package/dist/etherscan.js.map +0 -1
- package/dist/external-transactions.d.ts.map +0 -1
- package/dist/external-transactions.js.map +0 -1
- package/dist/history.d.ts.map +0 -1
- package/dist/history.js.map +0 -1
- package/dist/transaction-type.d.ts.map +0 -1
- package/dist/transaction-type.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js.map +0 -1
- /package/dist/{etherscan.d.ts → utils/etherscan.d.ts} +0 -0
- /package/dist/{history.js → utils/history.js} +0 -0
- /package/dist/{validation.js → utils/validation.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ 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
|
+
|
|
14
|
+
## [15.0.0]
|
|
15
|
+
### Changed
|
|
16
|
+
- **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^15.0.0
|
|
17
|
+
- Bump dependency on `@metamask/rpc-errors` to ^6.1.0 ([#1653](https://github.com/MetaMask/core/pull/1653))
|
|
18
|
+
- Bump dependency and peer dependency on `@metamask/approval-controller` to ^4.0.1
|
|
19
|
+
|
|
9
20
|
## [14.0.0]
|
|
10
21
|
### Added
|
|
11
22
|
- **BREAKING:** Add required `getPermittedAccounts` argument to constructor, used to validate `from` addresses ([#1722](https://github.com/MetaMask/core/pull/1722))
|
|
@@ -237,7 +248,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
237
248
|
|
|
238
249
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
239
250
|
|
|
240
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@
|
|
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
|
|
253
|
+
[15.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@14.0.0...@metamask/transaction-controller@15.0.0
|
|
241
254
|
[14.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@13.0.0...@metamask/transaction-controller@14.0.0
|
|
242
255
|
[13.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@12.0.0...@metamask/transaction-controller@13.0.0
|
|
243
256
|
[12.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@11.1.0...@metamask/transaction-controller@12.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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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 +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,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"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O,CAAC,2BAA2B;IAQnC;;;;;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
|
|
31
|
-
const
|
|
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
|
|
38
|
-
const
|
|
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
|
/**
|
|
@@ -100,6 +103,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
100
103
|
this.provider = provider;
|
|
101
104
|
this.messagingSystem = messenger;
|
|
102
105
|
this.getNetworkState = getNetworkState;
|
|
106
|
+
// @ts-expect-error TODO: Provider type alignment
|
|
103
107
|
this.ethQuery = new eth_query_1.default(provider);
|
|
104
108
|
this.isSendFlowHistoryDisabled = disableSendFlowHistory !== null && disableSendFlowHistory !== void 0 ? disableSendFlowHistory : false;
|
|
105
109
|
this.isHistoryDisabled = disableHistory !== null && disableHistory !== void 0 ? disableHistory : false;
|
|
@@ -108,6 +112,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
108
112
|
getCurrentAccountEIP1559Compatibility;
|
|
109
113
|
this.getCurrentNetworkEIP1559Compatibility =
|
|
110
114
|
getCurrentNetworkEIP1559Compatibility;
|
|
115
|
+
this.getGasFeeEstimates =
|
|
116
|
+
getGasFeeEstimates || (() => Promise.resolve({}));
|
|
111
117
|
this.getPermittedAccounts = getPermittedAccounts;
|
|
112
118
|
this.getSelectedAddress = getSelectedAddress;
|
|
113
119
|
this.securityProviderRequest = securityProviderRequest;
|
|
@@ -138,10 +144,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
138
144
|
getChainId: this.getChainId.bind(this),
|
|
139
145
|
getEthQuery: () => this.ethQuery,
|
|
140
146
|
getTransactions: () => this.state.transactions,
|
|
147
|
+
nonceTracker: this.nonceTracker,
|
|
141
148
|
});
|
|
142
149
|
this.pendingTransactionTracker.hub.on('transactions', this.onPendingTransactionsUpdate.bind(this));
|
|
143
150
|
this.pendingTransactionTracker.hub.on('transaction-confirmed', (transactionMeta) => this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta));
|
|
144
151
|
onNetworkStateChange(() => {
|
|
152
|
+
// @ts-expect-error TODO: Provider type alignment
|
|
145
153
|
this.ethQuery = new eth_query_1.default(this.provider);
|
|
146
154
|
this.registry = new eth_method_registry_1.default({ provider: this.provider });
|
|
147
155
|
});
|
|
@@ -232,16 +240,17 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
232
240
|
verifiedOnBlockchain: false,
|
|
233
241
|
type: transactionType,
|
|
234
242
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
|
|
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
|
+
});
|
|
245
254
|
// Checks if a transaction already exists with a given actionId
|
|
246
255
|
if (!existingTransactionMeta) {
|
|
247
256
|
// Set security provider response
|
|
@@ -442,67 +451,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
442
451
|
*/
|
|
443
452
|
estimateGas(transaction) {
|
|
444
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
const gasPrice = typeof providedGasPrice === 'undefined'
|
|
448
|
-
? yield (0, controller_utils_1.query)(this.ethQuery, 'gasPrice')
|
|
449
|
-
: providedGasPrice;
|
|
450
|
-
const { providerConfig } = this.getNetworkState();
|
|
451
|
-
const isCustomNetwork = providerConfig.type === controller_utils_1.NetworkType.rpc;
|
|
452
|
-
// 1. If gas is already defined on the transaction, use it
|
|
453
|
-
if (typeof gas !== 'undefined') {
|
|
454
|
-
return { gas, gasPrice };
|
|
455
|
-
}
|
|
456
|
-
const { gasLimit } = yield (0, controller_utils_1.query)(this.ethQuery, 'getBlockByNumber', [
|
|
457
|
-
'latest',
|
|
458
|
-
false,
|
|
459
|
-
]);
|
|
460
|
-
// 2. If to is not defined or this is not a contract address, and there is no data use 0x5208 / 21000.
|
|
461
|
-
// If the network is a custom network then bypass this check and fetch 'estimateGas'.
|
|
462
|
-
/* istanbul ignore next */
|
|
463
|
-
const code = to ? yield (0, controller_utils_1.query)(this.ethQuery, 'getCode', [to]) : undefined;
|
|
464
|
-
/* istanbul ignore next */
|
|
465
|
-
if (!isCustomNetwork &&
|
|
466
|
-
(!to || (to && !data && (!code || code === '0x')))) {
|
|
467
|
-
return { gas: '0x5208', gasPrice };
|
|
468
|
-
}
|
|
469
|
-
// if data, should be hex string format
|
|
470
|
-
estimatedTransaction.data = !data
|
|
471
|
-
? data
|
|
472
|
-
: /* istanbul ignore next */ (0, ethereumjs_util_1.addHexPrefix)(data);
|
|
473
|
-
// 3. If this is a contract address, safely estimate gas using RPC
|
|
474
|
-
estimatedTransaction.value =
|
|
475
|
-
typeof value === 'undefined' ? '0x0' : /* istanbul ignore next */ value;
|
|
476
|
-
const gasLimitBN = (0, controller_utils_1.hexToBN)(gasLimit);
|
|
477
|
-
estimatedTransaction.gas = (0, controller_utils_1.BNToHex)((0, controller_utils_1.fractionBN)(gasLimitBN, 19, 20));
|
|
478
|
-
let gasHex;
|
|
479
|
-
let estimateGasError;
|
|
480
|
-
try {
|
|
481
|
-
gasHex = yield (0, controller_utils_1.query)(this.ethQuery, 'estimateGas', [
|
|
482
|
-
estimatedTransaction,
|
|
483
|
-
]);
|
|
484
|
-
}
|
|
485
|
-
catch (error) {
|
|
486
|
-
estimateGasError = utils_1.ESTIMATE_GAS_ERROR;
|
|
487
|
-
}
|
|
488
|
-
// 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a
|
|
489
|
-
// a custom network then return the eth_estimateGas value.
|
|
490
|
-
const gasBN = (0, controller_utils_1.hexToBN)(gasHex);
|
|
491
|
-
const maxGasBN = gasLimitBN.muln(0.9);
|
|
492
|
-
const paddedGasBN = gasBN.muln(1.5);
|
|
493
|
-
/* istanbul ignore next */
|
|
494
|
-
if (gasBN.gt(maxGasBN) || isCustomNetwork) {
|
|
495
|
-
return { gas: (0, ethereumjs_util_1.addHexPrefix)(gasHex), gasPrice, estimateGasError };
|
|
496
|
-
}
|
|
497
|
-
/* istanbul ignore next */
|
|
498
|
-
if (paddedGasBN.lt(maxGasBN)) {
|
|
499
|
-
return {
|
|
500
|
-
gas: (0, ethereumjs_util_1.addHexPrefix)((0, controller_utils_1.BNToHex)(paddedGasBN)),
|
|
501
|
-
gasPrice,
|
|
502
|
-
estimateGasError,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
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 };
|
|
506
456
|
});
|
|
507
457
|
}
|
|
508
458
|
/**
|
|
@@ -660,6 +610,18 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
660
610
|
this.updateTransaction(updatedMeta, 'TransactionController:updateTransactionGasFees - gas values updated');
|
|
661
611
|
return this.getTransaction(transactionId);
|
|
662
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
|
+
}
|
|
663
625
|
processApproval(transactionMeta, { isExisting = false, requireApproval, shouldShowRequest = true, }) {
|
|
664
626
|
return __awaiter(this, void 0, void 0, function* () {
|
|
665
627
|
const transactionId = transactionMeta.id;
|