@metamask-previews/transaction-controller 15.0.0-preview.72e94e9 → 15.0.0-preview.e3b05ea
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/dist/TransactionController.d.ts +13 -7
- package/dist/TransactionController.d.ts.map +1 -1
- package/dist/TransactionController.js +27 -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} +1 -1
- package/dist/helpers/PendingTransactionTracker.d.ts.map +1 -0
- package/dist/{PendingTransactionTracker.js → helpers/PendingTransactionTracker.js} +14 -5
- 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 +4 -2
- 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
|
@@ -4,6 +4,7 @@ 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';
|
|
@@ -99,6 +100,7 @@ export declare class TransactionController extends BaseController<TransactionCon
|
|
|
99
100
|
private readonly getNetworkState;
|
|
100
101
|
private readonly getCurrentAccountEIP1559Compatibility;
|
|
101
102
|
private readonly getCurrentNetworkEIP1559Compatibility;
|
|
103
|
+
private readonly getGasFeeEstimates;
|
|
102
104
|
private readonly getPermittedAccounts;
|
|
103
105
|
private readonly getSelectedAddress;
|
|
104
106
|
private readonly messagingSystem;
|
|
@@ -128,6 +130,7 @@ export declare class TransactionController extends BaseController<TransactionCon
|
|
|
128
130
|
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
|
|
129
131
|
* @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
|
|
130
132
|
* @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
|
|
133
|
+
* @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
|
|
131
134
|
* @param options.getNetworkState - Gets the state of the network controller.
|
|
132
135
|
* @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
|
|
133
136
|
* @param options.getSelectedAddress - Gets the address of the currently selected account.
|
|
@@ -143,12 +146,13 @@ export declare class TransactionController extends BaseController<TransactionCon
|
|
|
143
146
|
* @param config - Initial options used to configure this controller.
|
|
144
147
|
* @param state - Initial state to set on this controller.
|
|
145
148
|
*/
|
|
146
|
-
constructor({ blockTracker, disableHistory, disableSendFlowHistory, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, provider, securityProviderRequest, }: {
|
|
149
|
+
constructor({ blockTracker, disableHistory, disableSendFlowHistory, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, provider, securityProviderRequest, }: {
|
|
147
150
|
blockTracker: BlockTracker;
|
|
148
151
|
disableHistory: boolean;
|
|
149
152
|
disableSendFlowHistory: boolean;
|
|
150
153
|
getCurrentAccountEIP1559Compatibility: () => Promise<boolean>;
|
|
151
154
|
getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;
|
|
155
|
+
getGasFeeEstimates?: () => Promise<GasFeeState>;
|
|
152
156
|
getNetworkState: () => NetworkState;
|
|
153
157
|
getPermittedAccounts: (origin?: string) => Promise<string[]>;
|
|
154
158
|
getSelectedAddress: () => string;
|
|
@@ -237,12 +241,14 @@ export declare class TransactionController extends BaseController<TransactionCon
|
|
|
237
241
|
*/
|
|
238
242
|
estimateGas(transaction: TransactionParams): Promise<{
|
|
239
243
|
gas: string;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
simulationFails: {
|
|
245
|
+
reason: any;
|
|
246
|
+
errorKey: any;
|
|
247
|
+
debug: {
|
|
248
|
+
blockNumber: string;
|
|
249
|
+
blockGasLimit: string;
|
|
250
|
+
};
|
|
251
|
+
} | undefined;
|
|
246
252
|
}>;
|
|
247
253
|
/**
|
|
248
254
|
* Updates an existing transaction in state.
|
|
@@ -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":[],"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;AAU3D,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;AAStC,OAAO,KAAK,EAEV,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;AAyB7D,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACr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,CAAC,oBAAoB;IAS5B;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,gCAAgC;IAaxC,OAAO,CAAC,2BAA2B;IAKnC,OAAO,CAAC,4BAA4B;IAsCpC;;;;OAIG;YACW,sBAAsB;IAmCpC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA8BlC;;;;OAIG;IACH,OAAO,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
|
/**
|
|
@@ -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;
|
|
@@ -234,16 +239,17 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
234
239
|
verifiedOnBlockchain: false,
|
|
235
240
|
type: transactionType,
|
|
236
241
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
this.
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
yield (0, gas_1.updateGas)({
|
|
243
|
+
ethQuery: this.ethQuery,
|
|
244
|
+
providerConfig: this.getNetworkState().providerConfig,
|
|
245
|
+
txMeta: transactionMeta,
|
|
246
|
+
});
|
|
247
|
+
yield (0, gas_fees_1.updateGasFees)({
|
|
248
|
+
eip1559: isEIP1559Compatible,
|
|
249
|
+
ethQuery: this.ethQuery,
|
|
250
|
+
getGasFeeEstimates: this.getGasFeeEstimates.bind(this),
|
|
251
|
+
txMeta: transactionMeta,
|
|
252
|
+
});
|
|
247
253
|
// Checks if a transaction already exists with a given actionId
|
|
248
254
|
if (!existingTransactionMeta) {
|
|
249
255
|
// Set security provider response
|
|
@@ -444,67 +450,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
444
450
|
*/
|
|
445
451
|
estimateGas(transaction) {
|
|
446
452
|
return __awaiter(this, void 0, void 0, function* () {
|
|
447
|
-
const
|
|
448
|
-
|
|
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 };
|
|
453
|
+
const { estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, this.ethQuery);
|
|
454
|
+
return { gas: estimatedGas, simulationFails };
|
|
508
455
|
});
|
|
509
456
|
}
|
|
510
457
|
/**
|