@metamask-previews/transaction-controller 21.2.0-preview.280e51c7 → 21.2.0-preview.3b3808ff
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 +113 -113
- package/dist/TransactionController.d.ts.map +1 -1
- package/dist/TransactionController.js +181 -315
- package/dist/TransactionController.js.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.js +8 -28
- package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.ts +3 -17
- package/dist/helpers/IncomingTransactionHelper.d.ts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.js +14 -17
- package/dist/helpers/IncomingTransactionHelper.js.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.ts +7 -13
- package/dist/helpers/PendingTransactionTracker.d.ts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.js +23 -43
- package/dist/helpers/PendingTransactionTracker.js.map +1 -1
- package/dist/types.d.ts +0 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/etherscan.d.ts +0 -7
- package/dist/utils/etherscan.d.ts.map +1 -1
- package/dist/utils/etherscan.js +6 -17
- package/dist/utils/etherscan.js.map +1 -1
- package/dist/utils/gas-fees.d.ts +3 -4
- package/dist/utils/gas-fees.d.ts.map +1 -1
- package/dist/utils/gas-fees.js +2 -6
- package/dist/utils/gas-fees.js.map +1 -1
- package/dist/utils/gas.d.ts +2 -3
- package/dist/utils/gas.d.ts.map +1 -1
- package/dist/utils/gas.js +5 -4
- package/dist/utils/gas.js.map +1 -1
- package/dist/utils/nonce.d.ts +3 -3
- package/dist/utils/nonce.d.ts.map +1 -1
- package/dist/utils/nonce.js +3 -3
- package/dist/utils/nonce.js.map +1 -1
- package/package.json +1 -2
- package/dist/helpers/MultichainTrackingHelper.d.ts +0 -72
- package/dist/helpers/MultichainTrackingHelper.d.ts.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.js +0 -292
- package/dist/helpers/MultichainTrackingHelper.js.map +0 -1
|
@@ -8,21 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
13
|
};
|
|
25
|
-
var _TransactionController_instances, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_multichainTrackingHelper, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions;
|
|
26
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
15
|
exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
|
|
28
16
|
const common_1 = require("@ethereumjs/common");
|
|
@@ -30,7 +18,6 @@ const tx_1 = require("@ethereumjs/tx");
|
|
|
30
18
|
const base_controller_1 = require("@metamask/base-controller");
|
|
31
19
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
32
20
|
const eth_query_1 = __importDefault(require("@metamask/eth-query"));
|
|
33
|
-
const network_controller_1 = require("@metamask/network-controller");
|
|
34
21
|
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
35
22
|
const async_mutex_1 = require("async-mutex");
|
|
36
23
|
const eth_method_registry_1 = require("eth-method-registry");
|
|
@@ -41,7 +28,6 @@ const nonce_tracker_1 = require("nonce-tracker");
|
|
|
41
28
|
const uuid_1 = require("uuid");
|
|
42
29
|
const EtherscanRemoteTransactionSource_1 = require("./helpers/EtherscanRemoteTransactionSource");
|
|
43
30
|
const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper");
|
|
44
|
-
const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper");
|
|
45
31
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker");
|
|
46
32
|
const logger_1 = require("./logger");
|
|
47
33
|
const types_1 = require("./types");
|
|
@@ -58,7 +44,7 @@ exports.HARDFORK = common_1.Hardfork.London;
|
|
|
58
44
|
/**
|
|
59
45
|
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
60
46
|
*/
|
|
61
|
-
exports.CANCEL_RATE = 1.
|
|
47
|
+
exports.CANCEL_RATE = 1.5;
|
|
62
48
|
/**
|
|
63
49
|
* Multiplier used to determine a transaction's increased gas fee during speed up
|
|
64
50
|
*/
|
|
@@ -71,16 +57,51 @@ const controllerName = 'TransactionController';
|
|
|
71
57
|
* Controller responsible for submitting and managing transactions.
|
|
72
58
|
*/
|
|
73
59
|
class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
74
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Creates a TransactionController instance.
|
|
62
|
+
*
|
|
63
|
+
* @param options - The controller options.
|
|
64
|
+
* @param options.blockTracker - The block tracker used to poll for new blocks data.
|
|
65
|
+
* @param options.cancelMultiplier - Multiplier used to determine a transaction's increased gas fee during cancellation.
|
|
66
|
+
* @param options.disableHistory - Whether to disable storing history in transaction metadata.
|
|
67
|
+
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
|
|
68
|
+
* @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
|
|
69
|
+
* @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
|
|
70
|
+
* @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
|
|
71
|
+
* @param options.getExternalPendingTransactions - Callback to retrieve pending transactions from external sources.
|
|
72
|
+
* @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
|
|
73
|
+
* @param options.getNetworkState - Gets the state of the network controller.
|
|
74
|
+
* @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
|
|
75
|
+
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
76
|
+
* @param options.getSelectedAddress - Gets the address of the currently selected account.
|
|
77
|
+
* @param options.incomingTransactions - Configuration options for incoming transaction support.
|
|
78
|
+
* @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.
|
|
79
|
+
* @param options.incomingTransactions.isEnabled - Whether or not incoming transaction retrieval is enabled.
|
|
80
|
+
* @param options.incomingTransactions.queryEntireHistory - Whether to initially query the entire transaction history or only recent blocks.
|
|
81
|
+
* @param options.incomingTransactions.updateTransactions - Whether to update local transactions using remote transaction data.
|
|
82
|
+
* @param options.messenger - The controller messenger.
|
|
83
|
+
* @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
|
|
84
|
+
* @param options.pendingTransactions - Configuration options for pending transaction support.
|
|
85
|
+
* @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.
|
|
86
|
+
* @param options.provider - The provider used to create the underlying EthQuery instance.
|
|
87
|
+
* @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
|
|
88
|
+
* @param options.speedUpMultiplier - Multiplier used to determine a transaction's increased gas fee during speed up.
|
|
89
|
+
* @param options.hooks - The controller hooks.
|
|
90
|
+
* @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.
|
|
91
|
+
* @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.
|
|
92
|
+
* @param options.hooks.beforeCheckPendingTransaction - Additional logic to execute before checking pending transactions. Return false to prevent the broadcast of the transaction.
|
|
93
|
+
* @param options.hooks.beforePublish - Additional logic to execute before publishing a transaction. Return false to prevent the broadcast of the transaction.
|
|
94
|
+
* @param options.hooks.getAdditionalSignArguments - Returns additional arguments required to sign a transaction.
|
|
95
|
+
* @param options.hooks.publish - Alternate logic to publish a transaction.
|
|
96
|
+
* @param config - Initial options used to configure this controller.
|
|
97
|
+
* @param state - Initial state to set on this controller.
|
|
98
|
+
*/
|
|
99
|
+
constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSavedGasFees, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, speedUpMultiplier, hooks = {}, }, config, state) {
|
|
75
100
|
var _a, _b, _c, _d, _e, _f;
|
|
76
101
|
super(config, state);
|
|
77
|
-
_TransactionController_instances.add(this);
|
|
78
102
|
this.inProcessOfSigning = new Set();
|
|
79
103
|
this.mutex = new async_mutex_1.Mutex();
|
|
80
|
-
_TransactionController_incomingTransactionOptions.set(this, void 0);
|
|
81
|
-
_TransactionController_pendingTransactionOptions.set(this, void 0);
|
|
82
104
|
this.signAbortCallbacks = new Map();
|
|
83
|
-
_TransactionController_multichainTrackingHelper.set(this, void 0);
|
|
84
105
|
/**
|
|
85
106
|
* EventEmitter instance used to listen to specific transactional events
|
|
86
107
|
*/
|
|
@@ -89,11 +110,6 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
89
110
|
* Name of this controller used during composition
|
|
90
111
|
*/
|
|
91
112
|
this.name = 'TransactionController';
|
|
92
|
-
_TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
|
|
93
|
-
// PendingTransactionTracker reads state through its getTransactions hook
|
|
94
|
-
this.pendingTransactionTracker.startIfPendingTransactions();
|
|
95
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
|
|
96
|
-
});
|
|
97
113
|
this.defaultConfig = {
|
|
98
114
|
txHistoryLimit: 40,
|
|
99
115
|
};
|
|
@@ -103,8 +119,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
103
119
|
lastFetchedBlockNumbers: {},
|
|
104
120
|
};
|
|
105
121
|
this.initialize();
|
|
122
|
+
this.provider = provider;
|
|
106
123
|
this.messagingSystem = messenger;
|
|
107
124
|
this.getNetworkState = getNetworkState;
|
|
125
|
+
this.ethQuery = new eth_query_1.default(provider);
|
|
108
126
|
this.isSendFlowHistoryDisabled = disableSendFlowHistory !== null && disableSendFlowHistory !== void 0 ? disableSendFlowHistory : false;
|
|
109
127
|
this.isHistoryDisabled = disableHistory !== null && disableHistory !== void 0 ? disableHistory : false;
|
|
110
128
|
this.isSwapsDisabled = disableSwaps !== null && disableSwaps !== void 0 ? disableSwaps : false;
|
|
@@ -122,8 +140,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
122
140
|
this.getExternalPendingTransactions =
|
|
123
141
|
getExternalPendingTransactions !== null && getExternalPendingTransactions !== void 0 ? getExternalPendingTransactions : (() => []);
|
|
124
142
|
this.securityProviderRequest = securityProviderRequest;
|
|
125
|
-
|
|
126
|
-
|
|
143
|
+
this.cancelMultiplier = cancelMultiplier !== null && cancelMultiplier !== void 0 ? cancelMultiplier : exports.CANCEL_RATE;
|
|
144
|
+
this.speedUpMultiplier = speedUpMultiplier !== null && speedUpMultiplier !== void 0 ? speedUpMultiplier : exports.SPEED_UP_RATE;
|
|
127
145
|
this.afterSign = (_a = hooks === null || hooks === void 0 ? void 0 : hooks.afterSign) !== null && _a !== void 0 ? _a : (() => true);
|
|
128
146
|
this.beforeApproveOnInit = (_b = hooks === null || hooks === void 0 ? void 0 : hooks.beforeApproveOnInit) !== null && _b !== void 0 ? _b : (() => true);
|
|
129
147
|
this.beforeCheckPendingTransaction =
|
|
@@ -135,51 +153,50 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
135
153
|
(_e = hooks === null || hooks === void 0 ? void 0 : hooks.getAdditionalSignArguments) !== null && _e !== void 0 ? _e : (() => []);
|
|
136
154
|
this.publish =
|
|
137
155
|
(_f = hooks === null || hooks === void 0 ? void 0 : hooks.publish) !== null && _f !== void 0 ? _f : (() => Promise.resolve({ transactionHash: undefined }));
|
|
138
|
-
this.nonceTracker =
|
|
156
|
+
this.nonceTracker = new nonce_tracker_1.NonceTracker({
|
|
157
|
+
// @ts-expect-error provider types misaligned: SafeEventEmitterProvider vs Record<string,string>
|
|
139
158
|
provider,
|
|
140
159
|
blockTracker,
|
|
160
|
+
getPendingTransactions: this.getNonceTrackerPendingTransactions.bind(this),
|
|
161
|
+
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
|
|
141
162
|
});
|
|
142
|
-
|
|
143
|
-
isMultichainEnabled,
|
|
144
|
-
provider,
|
|
145
|
-
nonceTracker: this.nonceTracker,
|
|
146
|
-
incomingTransactionOptions: incomingTransactions,
|
|
147
|
-
findNetworkClientIdByChainId: (chainId) => {
|
|
148
|
-
return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
|
|
149
|
-
},
|
|
150
|
-
getNetworkClientById: ((networkClientId) => {
|
|
151
|
-
return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId);
|
|
152
|
-
}),
|
|
153
|
-
getNetworkClientRegistry,
|
|
154
|
-
removeIncomingTransactionHelperListeners: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).bind(this),
|
|
155
|
-
removePendingTransactionTrackerListeners: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).bind(this),
|
|
156
|
-
createNonceTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).bind(this),
|
|
157
|
-
createIncomingTransactionHelper: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).bind(this),
|
|
158
|
-
createPendingTransactionTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).bind(this),
|
|
159
|
-
onNetworkStateChange: (listener) => {
|
|
160
|
-
this.messagingSystem.subscribe('NetworkController:stateChange', listener);
|
|
161
|
-
},
|
|
162
|
-
}), "f");
|
|
163
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").initialize();
|
|
164
|
-
const etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
|
|
165
|
-
includeTokenTransfers: incomingTransactions.includeTokenTransfers,
|
|
166
|
-
});
|
|
167
|
-
this.incomingTransactionHelper = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).call(this, {
|
|
163
|
+
this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
|
|
168
164
|
blockTracker,
|
|
169
|
-
|
|
165
|
+
getCurrentAccount: getSelectedAddress,
|
|
166
|
+
getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
|
|
167
|
+
getNetworkState,
|
|
168
|
+
isEnabled: incomingTransactions.isEnabled,
|
|
169
|
+
queryEntireHistory: incomingTransactions.queryEntireHistory,
|
|
170
|
+
remoteTransactionSource: new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
|
|
171
|
+
includeTokenTransfers: incomingTransactions.includeTokenTransfers,
|
|
172
|
+
}),
|
|
173
|
+
transactionLimit: this.config.txHistoryLimit,
|
|
174
|
+
updateTransactions: incomingTransactions.updateTransactions,
|
|
170
175
|
});
|
|
171
|
-
this.
|
|
172
|
-
|
|
176
|
+
this.incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
|
|
177
|
+
this.incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this));
|
|
178
|
+
this.pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
|
|
179
|
+
approveTransaction: this.approveTransaction.bind(this),
|
|
173
180
|
blockTracker,
|
|
181
|
+
getChainId: this.getChainId.bind(this),
|
|
182
|
+
getEthQuery: () => this.ethQuery,
|
|
183
|
+
getTransactions: () => this.state.transactions,
|
|
184
|
+
isResubmitEnabled: pendingTransactions.isResubmitEnabled,
|
|
185
|
+
nonceTracker: this.nonceTracker,
|
|
186
|
+
onStateChange: (listener) => {
|
|
187
|
+
this.subscribe(listener);
|
|
188
|
+
onNetworkStateChange(listener);
|
|
189
|
+
listener();
|
|
190
|
+
},
|
|
191
|
+
publishTransaction: this.publishTransaction.bind(this),
|
|
192
|
+
hooks: {
|
|
193
|
+
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
194
|
+
beforePublish: this.beforePublish.bind(this),
|
|
195
|
+
},
|
|
174
196
|
});
|
|
175
|
-
|
|
176
|
-
// check for pending transactions and start polling if there are any
|
|
177
|
-
this.subscribe(__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
|
|
178
|
-
// TODO once v2 is merged make sure this only runs when
|
|
179
|
-
// selectedNetworkClientId changes
|
|
197
|
+
this.addPendingTransactionTrackerListeners();
|
|
180
198
|
onNetworkStateChange(() => {
|
|
181
199
|
(0, logger_1.projectLogger)('Detected network change', this.getChainId());
|
|
182
|
-
this.pendingTransactionTracker.startIfPendingTransactions();
|
|
183
200
|
this.onBootCleanup();
|
|
184
201
|
});
|
|
185
202
|
this.onBootCleanup();
|
|
@@ -202,12 +219,6 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
202
219
|
return { registryMethod, parsedRegistryMethod };
|
|
203
220
|
});
|
|
204
221
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Stops polling and removes listeners to prepare the controller for garbage collection.
|
|
207
|
-
*/
|
|
208
|
-
destroy() {
|
|
209
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_stopAllTracking).call(this);
|
|
210
|
-
}
|
|
211
222
|
/**
|
|
212
223
|
* Handle new method data request.
|
|
213
224
|
*
|
|
@@ -252,30 +263,21 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
252
263
|
* @param opts.swaps - Options for swaps transactions.
|
|
253
264
|
* @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.
|
|
254
265
|
* @param opts.swaps.meta - Metadata for swap transaction.
|
|
255
|
-
* @param opts.networkClientId - The id of the network client for this transaction.
|
|
256
266
|
* @returns Object containing a promise resolving to the transaction hash if approved.
|
|
257
267
|
*/
|
|
258
|
-
addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, type,
|
|
268
|
+
addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, type, } = {}) {
|
|
259
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
260
270
|
(0, logger_1.projectLogger)('Adding transaction', txParams);
|
|
261
271
|
txParams = (0, utils_1.normalizeTxParams)(txParams);
|
|
262
|
-
|
|
263
|
-
!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
264
|
-
throw new Error('The networkClientId for this transaction could not be found');
|
|
265
|
-
}
|
|
266
|
-
const isEIP1559Compatible = yield this.getEIP1559Compatibility(networkClientId);
|
|
272
|
+
const isEIP1559Compatible = yield this.getEIP1559Compatibility();
|
|
267
273
|
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
|
|
268
274
|
if (origin) {
|
|
269
275
|
yield (0, validation_1.validateTransactionOrigin)(yield this.getPermittedAccounts(origin), this.getSelectedAddress(), txParams.from, origin);
|
|
270
276
|
}
|
|
271
277
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
272
|
-
const
|
|
273
|
-
const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
|
|
274
|
-
networkClientId,
|
|
275
|
-
chainId,
|
|
276
|
-
});
|
|
277
|
-
const transactionType = type !== null && type !== void 0 ? type : (yield (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
|
|
278
|
+
const transactionType = type !== null && type !== void 0 ? type : (yield (0, transaction_type_1.determineTransactionType)(txParams, this.ethQuery)).type;
|
|
278
279
|
const existingTransactionMeta = this.getTransactionWithActionId(actionId);
|
|
280
|
+
const chainId = this.getChainId();
|
|
279
281
|
// If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.
|
|
280
282
|
const transactionMeta = existingTransactionMeta || {
|
|
281
283
|
// Add actionId to txMeta to check if same actionId is seen again
|
|
@@ -292,7 +294,6 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
292
294
|
userEditedGasLimit: false,
|
|
293
295
|
verifiedOnBlockchain: false,
|
|
294
296
|
type: transactionType,
|
|
295
|
-
networkClientId,
|
|
296
297
|
};
|
|
297
298
|
yield this.updateGasProperties(transactionMeta);
|
|
298
299
|
// Checks if a transaction already exists with a given actionId
|
|
@@ -329,31 +330,15 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
329
330
|
};
|
|
330
331
|
});
|
|
331
332
|
}
|
|
332
|
-
startIncomingTransactionPolling(
|
|
333
|
-
|
|
334
|
-
this.incomingTransactionHelper.start();
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
|
|
338
|
-
}
|
|
339
|
-
stopIncomingTransactionPolling(networkClientIds = []) {
|
|
340
|
-
if (networkClientIds.length === 0) {
|
|
341
|
-
this.incomingTransactionHelper.stop();
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
|
|
333
|
+
startIncomingTransactionPolling() {
|
|
334
|
+
this.incomingTransactionHelper.start();
|
|
345
335
|
}
|
|
346
|
-
|
|
336
|
+
stopIncomingTransactionPolling() {
|
|
347
337
|
this.incomingTransactionHelper.stop();
|
|
348
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
|
|
349
338
|
}
|
|
350
|
-
updateIncomingTransactions(
|
|
339
|
+
updateIncomingTransactions() {
|
|
351
340
|
return __awaiter(this, void 0, void 0, function* () {
|
|
352
|
-
|
|
353
|
-
yield this.incomingTransactionHelper.update();
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
yield __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
|
|
341
|
+
yield this.incomingTransactionHelper.update();
|
|
357
342
|
});
|
|
358
343
|
}
|
|
359
344
|
/**
|
|
@@ -387,21 +372,21 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
387
372
|
throw new Error('No sign method defined.');
|
|
388
373
|
}
|
|
389
374
|
// gasPrice (legacy non EIP1559)
|
|
390
|
-
const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice,
|
|
375
|
+
const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, this.cancelMultiplier);
|
|
391
376
|
const gasPriceFromValues = (0, utils_1.isGasPriceValue)(gasValues) && gasValues.gasPrice;
|
|
392
377
|
const newGasPrice = (gasPriceFromValues &&
|
|
393
378
|
(0, utils_1.validateMinimumIncrease)(gasPriceFromValues, minGasPrice)) ||
|
|
394
379
|
minGasPrice;
|
|
395
380
|
// maxFeePerGas (EIP1559)
|
|
396
381
|
const existingMaxFeePerGas = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.maxFeePerGas;
|
|
397
|
-
const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas,
|
|
382
|
+
const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, this.cancelMultiplier);
|
|
398
383
|
const maxFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxFeePerGas;
|
|
399
384
|
const newMaxFeePerGas = (maxFeePerGasValues &&
|
|
400
385
|
(0, utils_1.validateMinimumIncrease)(maxFeePerGasValues, minMaxFeePerGas)) ||
|
|
401
386
|
(existingMaxFeePerGas && minMaxFeePerGas);
|
|
402
387
|
// maxPriorityFeePerGas (EIP1559)
|
|
403
388
|
const existingMaxPriorityFeePerGas = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.maxPriorityFeePerGas;
|
|
404
|
-
const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas,
|
|
389
|
+
const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, this.cancelMultiplier);
|
|
405
390
|
const maxPriorityFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxPriorityFeePerGas;
|
|
406
391
|
const newMaxPriorityFeePerGas = (maxPriorityFeePerGasValues &&
|
|
407
392
|
(0, utils_1.validateMinimumIncrease)(maxPriorityFeePerGasValues, minMaxPriorityFeePerGas)) ||
|
|
@@ -425,7 +410,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
425
410
|
to: transactionMeta.txParams.from,
|
|
426
411
|
value: '0x0',
|
|
427
412
|
};
|
|
428
|
-
const unsignedEthTx = this.prepareUnsignedEthTx(
|
|
413
|
+
const unsignedEthTx = this.prepareUnsignedEthTx(newTxParams);
|
|
429
414
|
const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from);
|
|
430
415
|
const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
|
|
431
416
|
const newFee = (_c = newTxParams.maxFeePerGas) !== null && _c !== void 0 ? _c : newTxParams.gasPrice;
|
|
@@ -437,15 +422,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
437
422
|
newFee,
|
|
438
423
|
txParams: newTxParams,
|
|
439
424
|
});
|
|
440
|
-
const
|
|
441
|
-
networkClientId: transactionMeta.networkClientId,
|
|
442
|
-
chainId: transactionMeta.chainId,
|
|
443
|
-
});
|
|
444
|
-
const hash = yield this.publishTransactionForRetry(ethQuery, rawTx, transactionMeta);
|
|
425
|
+
const hash = yield this.publishTransaction(rawTx);
|
|
445
426
|
const cancelTransactionMeta = {
|
|
446
427
|
actionId,
|
|
447
428
|
chainId: transactionMeta.chainId,
|
|
448
|
-
networkClientId: transactionMeta.networkClientId,
|
|
449
429
|
estimatedBaseFee,
|
|
450
430
|
hash,
|
|
451
431
|
id: (0, uuid_1.v1)(),
|
|
@@ -500,28 +480,28 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
500
480
|
throw new Error('No sign method defined.');
|
|
501
481
|
}
|
|
502
482
|
// gasPrice (legacy non EIP1559)
|
|
503
|
-
const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice,
|
|
483
|
+
const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, this.speedUpMultiplier);
|
|
504
484
|
const gasPriceFromValues = (0, utils_1.isGasPriceValue)(gasValues) && gasValues.gasPrice;
|
|
505
485
|
const newGasPrice = (gasPriceFromValues &&
|
|
506
486
|
(0, utils_1.validateMinimumIncrease)(gasPriceFromValues, minGasPrice)) ||
|
|
507
487
|
minGasPrice;
|
|
508
488
|
// maxFeePerGas (EIP1559)
|
|
509
489
|
const existingMaxFeePerGas = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.maxFeePerGas;
|
|
510
|
-
const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas,
|
|
490
|
+
const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, this.speedUpMultiplier);
|
|
511
491
|
const maxFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxFeePerGas;
|
|
512
492
|
const newMaxFeePerGas = (maxFeePerGasValues &&
|
|
513
493
|
(0, utils_1.validateMinimumIncrease)(maxFeePerGasValues, minMaxFeePerGas)) ||
|
|
514
494
|
(existingMaxFeePerGas && minMaxFeePerGas);
|
|
515
495
|
// maxPriorityFeePerGas (EIP1559)
|
|
516
496
|
const existingMaxPriorityFeePerGas = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.maxPriorityFeePerGas;
|
|
517
|
-
const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas,
|
|
497
|
+
const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, this.speedUpMultiplier);
|
|
518
498
|
const maxPriorityFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxPriorityFeePerGas;
|
|
519
499
|
const newMaxPriorityFeePerGas = (maxPriorityFeePerGasValues &&
|
|
520
500
|
(0, utils_1.validateMinimumIncrease)(maxPriorityFeePerGasValues, minMaxPriorityFeePerGas)) ||
|
|
521
501
|
(existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);
|
|
522
502
|
const txParams = newMaxFeePerGas && newMaxPriorityFeePerGas
|
|
523
503
|
? Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas, maxFeePerGas: newMaxFeePerGas, maxPriorityFeePerGas: newMaxPriorityFeePerGas, type: types_1.TransactionEnvelopeType.feeMarket }) : Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas, gasPrice: newGasPrice });
|
|
524
|
-
const unsignedEthTx = this.prepareUnsignedEthTx(
|
|
504
|
+
const unsignedEthTx = this.prepareUnsignedEthTx(txParams);
|
|
525
505
|
const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from);
|
|
526
506
|
yield this.updateTransactionMetaRSV(transactionMeta, signedTx);
|
|
527
507
|
const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
|
|
@@ -530,11 +510,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
530
510
|
? transactionMeta.txParams.maxFeePerGas
|
|
531
511
|
: transactionMeta.txParams.gasPrice;
|
|
532
512
|
(0, logger_1.projectLogger)('Submitting speed up transaction', { oldFee, newFee, txParams });
|
|
533
|
-
const
|
|
534
|
-
networkClientId: transactionMeta.networkClientId,
|
|
535
|
-
chainId: transactionMeta.chainId,
|
|
536
|
-
});
|
|
537
|
-
const hash = yield this.publishTransactionForRetry(ethQuery, rawTx, transactionMeta);
|
|
513
|
+
const hash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTx]);
|
|
538
514
|
const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { estimatedBaseFee, id: (0, uuid_1.v1)(), time: Date.now(), hash,
|
|
539
515
|
actionId, originalGasEstimate: transactionMeta.txParams.gas, type: types_1.TransactionType.retry, originalType: transactionMeta.type });
|
|
540
516
|
const newTransactionMeta = newMaxFeePerGas && newMaxPriorityFeePerGas
|
|
@@ -556,15 +532,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
556
532
|
* Estimates required gas for a given transaction.
|
|
557
533
|
*
|
|
558
534
|
* @param transaction - The transaction to estimate gas for.
|
|
559
|
-
* @param networkClientId - The network client id to use for the estimate.
|
|
560
535
|
* @returns The gas and gas price.
|
|
561
536
|
*/
|
|
562
|
-
estimateGas(transaction
|
|
537
|
+
estimateGas(transaction) {
|
|
563
538
|
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
-
const
|
|
565
|
-
networkClientId,
|
|
566
|
-
});
|
|
567
|
-
const { estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, ethQuery);
|
|
539
|
+
const { estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, this.ethQuery);
|
|
568
540
|
return { gas: estimatedGas, simulationFails };
|
|
569
541
|
});
|
|
570
542
|
}
|
|
@@ -573,14 +545,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
573
545
|
*
|
|
574
546
|
* @param transaction - The transaction params to estimate gas for.
|
|
575
547
|
* @param multiplier - The multiplier to use for the gas buffer.
|
|
576
|
-
* @param networkClientId - The network client id to use for the estimate.
|
|
577
548
|
*/
|
|
578
|
-
estimateGasBuffered(transaction, multiplier
|
|
549
|
+
estimateGasBuffered(transaction, multiplier) {
|
|
579
550
|
return __awaiter(this, void 0, void 0, function* () {
|
|
580
|
-
const
|
|
581
|
-
networkClientId,
|
|
582
|
-
});
|
|
583
|
-
const { blockGasLimit, estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, ethQuery);
|
|
551
|
+
const { blockGasLimit, estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, this.ethQuery);
|
|
584
552
|
const gas = (0, gas_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
|
|
585
553
|
return {
|
|
586
554
|
gas,
|
|
@@ -650,6 +618,12 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
650
618
|
transactions: this.trimTransactionsForState(newTransactions),
|
|
651
619
|
});
|
|
652
620
|
}
|
|
621
|
+
startIncomingTransactionProcessing() {
|
|
622
|
+
this.incomingTransactionHelper.start();
|
|
623
|
+
}
|
|
624
|
+
stopIncomingTransactionProcessing() {
|
|
625
|
+
this.incomingTransactionHelper.stop();
|
|
626
|
+
}
|
|
653
627
|
/**
|
|
654
628
|
* Adds external provided transaction to state as confirmed transaction.
|
|
655
629
|
*
|
|
@@ -795,9 +769,16 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
795
769
|
this.updateTransaction(updatedMeta, 'TransactionController:updatePreviousGasParams - Previous gas values updated');
|
|
796
770
|
return this.getTransaction(transactionId);
|
|
797
771
|
}
|
|
798
|
-
|
|
772
|
+
/**
|
|
773
|
+
* Gets the next nonce according to the nonce-tracker.
|
|
774
|
+
* Ensure `releaseLock` is called once processing of the `nonce` value is complete.
|
|
775
|
+
*
|
|
776
|
+
* @param address - The hex string address for the transaction.
|
|
777
|
+
* @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.
|
|
778
|
+
*/
|
|
779
|
+
getNonceLock(address) {
|
|
799
780
|
return __awaiter(this, void 0, void 0, function* () {
|
|
800
|
-
return
|
|
781
|
+
return this.nonceTracker.getNonceLock(address);
|
|
801
782
|
});
|
|
802
783
|
}
|
|
803
784
|
/**
|
|
@@ -832,10 +813,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
832
813
|
};
|
|
833
814
|
editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
|
|
834
815
|
const updatedTransaction = (0, lodash_1.merge)(transactionMeta, editableParams);
|
|
835
|
-
const { type } = yield (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams,
|
|
836
|
-
networkClientId: transactionMeta.networkClientId,
|
|
837
|
-
chainId: transactionMeta.chainId,
|
|
838
|
-
}));
|
|
816
|
+
const { type } = yield (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, this.ethQuery);
|
|
839
817
|
updatedTransaction.type = type;
|
|
840
818
|
this.updateTransaction(updatedTransaction, `Update Editable Params for ${txId}`);
|
|
841
819
|
return this.getTransaction(txId);
|
|
@@ -858,19 +836,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
858
836
|
return '';
|
|
859
837
|
}
|
|
860
838
|
const initialTx = listOfTxParams[0];
|
|
861
|
-
const common = this.getCommonConfiguration(
|
|
862
|
-
// We need to ensure we get the nonce using the the NonceTracker on the chain matching
|
|
863
|
-
// the txParams. In this context we only have chainId available to us, but the
|
|
864
|
-
// NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
|
|
865
|
-
// a networkClientId that matches the chainId. As a fallback, the globally selected
|
|
866
|
-
// network's NonceTracker will be used instead.
|
|
867
|
-
let networkClientId;
|
|
868
|
-
try {
|
|
869
|
-
networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
|
|
870
|
-
}
|
|
871
|
-
catch (err) {
|
|
872
|
-
(0, logger_1.projectLogger)('failed to find networkClientId from chainId', err);
|
|
873
|
-
}
|
|
839
|
+
const common = this.getCommonConfiguration();
|
|
874
840
|
const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
|
|
875
841
|
common,
|
|
876
842
|
});
|
|
@@ -885,7 +851,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
885
851
|
const fromAddress = initialTx.from;
|
|
886
852
|
const requiresNonce = hasNonce !== true;
|
|
887
853
|
nonceLock = requiresNonce
|
|
888
|
-
? yield this.getNonceLock(fromAddress
|
|
854
|
+
? yield this.nonceTracker.getNonceLock(fromAddress)
|
|
889
855
|
: undefined;
|
|
890
856
|
const nonce = nonceLock
|
|
891
857
|
? (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16))
|
|
@@ -895,7 +861,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
895
861
|
}
|
|
896
862
|
rawTransactions = yield Promise.all(listOfTxParams.map((txParams) => {
|
|
897
863
|
txParams.nonce = nonce;
|
|
898
|
-
return this.signExternalTransaction(txParams
|
|
864
|
+
return this.signExternalTransaction(txParams);
|
|
899
865
|
}));
|
|
900
866
|
}
|
|
901
867
|
catch (err) {
|
|
@@ -1053,18 +1019,19 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1053
1019
|
}
|
|
1054
1020
|
return filteredTransactions;
|
|
1055
1021
|
}
|
|
1056
|
-
signExternalTransaction(
|
|
1022
|
+
signExternalTransaction(transactionParams) {
|
|
1057
1023
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1058
1024
|
if (!this.sign) {
|
|
1059
1025
|
throw new Error('No sign method defined.');
|
|
1060
1026
|
}
|
|
1061
1027
|
const normalizedTransactionParams = (0, utils_1.normalizeTxParams)(transactionParams);
|
|
1028
|
+
const chainId = this.getChainId();
|
|
1062
1029
|
const type = (0, utils_1.isEIP1559Transaction)(normalizedTransactionParams)
|
|
1063
1030
|
? types_1.TransactionEnvelopeType.feeMarket
|
|
1064
1031
|
: types_1.TransactionEnvelopeType.legacy;
|
|
1065
1032
|
const updatedTransactionParams = Object.assign(Object.assign({}, normalizedTransactionParams), { type, gasLimit: normalizedTransactionParams.gas, chainId });
|
|
1066
1033
|
const { from } = updatedTransactionParams;
|
|
1067
|
-
const common = this.getCommonConfiguration(
|
|
1034
|
+
const common = this.getCommonConfiguration();
|
|
1068
1035
|
const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
|
|
1069
1036
|
const signedTransaction = yield this.sign(unsignedTransaction, from);
|
|
1070
1037
|
const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTransaction.serialize());
|
|
@@ -1102,41 +1069,35 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1102
1069
|
}
|
|
1103
1070
|
updateGasProperties(transactionMeta) {
|
|
1104
1071
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1105
|
-
const isEIP1559Compatible = (yield this.getEIP1559Compatibility(
|
|
1072
|
+
const isEIP1559Compatible = (yield this.getEIP1559Compatibility()) &&
|
|
1106
1073
|
transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy;
|
|
1107
|
-
const
|
|
1108
|
-
const isCustomNetwork = networkClientId
|
|
1109
|
-
? this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === network_controller_1.NetworkClientType.Custom
|
|
1110
|
-
: this.getNetworkState().providerConfig.type === controller_utils_1.NetworkType.rpc;
|
|
1074
|
+
const chainId = this.getChainId();
|
|
1111
1075
|
yield (0, gas_1.updateGas)({
|
|
1112
|
-
ethQuery:
|
|
1113
|
-
|
|
1114
|
-
chainId,
|
|
1115
|
-
}),
|
|
1116
|
-
chainId,
|
|
1117
|
-
isCustomNetwork,
|
|
1076
|
+
ethQuery: this.ethQuery,
|
|
1077
|
+
providerConfig: this.getNetworkState().providerConfig,
|
|
1118
1078
|
txMeta: transactionMeta,
|
|
1119
1079
|
});
|
|
1120
1080
|
yield (0, gas_fees_1.updateGasFees)({
|
|
1121
1081
|
eip1559: isEIP1559Compatible,
|
|
1122
|
-
ethQuery:
|
|
1123
|
-
|
|
1124
|
-
chainId,
|
|
1125
|
-
}),
|
|
1126
|
-
getSavedGasFees: this.getSavedGasFees.bind(this),
|
|
1082
|
+
ethQuery: this.ethQuery,
|
|
1083
|
+
getSavedGasFees: this.getSavedGasFees.bind(this, chainId),
|
|
1127
1084
|
getGasFeeEstimates: this.getGasFeeEstimates.bind(this),
|
|
1128
1085
|
txMeta: transactionMeta,
|
|
1129
1086
|
});
|
|
1130
1087
|
});
|
|
1131
1088
|
}
|
|
1089
|
+
getCurrentChainTransactionsByStatus(status) {
|
|
1090
|
+
const chainId = this.getChainId();
|
|
1091
|
+
return this.state.transactions.filter((transaction) => transaction.status === status && transaction.chainId === chainId);
|
|
1092
|
+
}
|
|
1132
1093
|
onBootCleanup() {
|
|
1133
1094
|
this.submitApprovedTransactions();
|
|
1134
1095
|
}
|
|
1135
1096
|
/**
|
|
1136
|
-
* Force submit approved transactions
|
|
1097
|
+
* Force to submit approved transactions on current chain.
|
|
1137
1098
|
*/
|
|
1138
1099
|
submitApprovedTransactions() {
|
|
1139
|
-
const approvedTransactions = this.
|
|
1100
|
+
const approvedTransactions = this.getCurrentChainTransactionsByStatus(types_1.TransactionStatus.approved);
|
|
1140
1101
|
for (const transactionMeta of approvedTransactions) {
|
|
1141
1102
|
if (this.beforeApproveOnInit(transactionMeta)) {
|
|
1142
1103
|
this.approveTransaction(transactionMeta.id).catch((error) => {
|
|
@@ -1230,9 +1191,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1230
1191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1231
1192
|
const { transactions } = this.state;
|
|
1232
1193
|
const releaseLock = yield this.mutex.acquire();
|
|
1194
|
+
const chainId = this.getChainId();
|
|
1233
1195
|
const index = transactions.findIndex(({ id }) => transactionId === id);
|
|
1234
1196
|
const transactionMeta = transactions[index];
|
|
1235
|
-
const { txParams: { from },
|
|
1197
|
+
const { txParams: { from }, } = transactionMeta;
|
|
1236
1198
|
let releaseNonceLock;
|
|
1237
1199
|
try {
|
|
1238
1200
|
if (!this.sign) {
|
|
@@ -1240,7 +1202,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1240
1202
|
this.failTransaction(transactionMeta, new Error('No sign method defined.'));
|
|
1241
1203
|
return;
|
|
1242
1204
|
}
|
|
1243
|
-
else if (!
|
|
1205
|
+
else if (!chainId) {
|
|
1244
1206
|
releaseLock();
|
|
1245
1207
|
this.failTransaction(transactionMeta, new Error('No chainId defined.'));
|
|
1246
1208
|
return;
|
|
@@ -1249,11 +1211,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1249
1211
|
(0, logger_1.projectLogger)('Skipping approval as signing in progress', transactionId);
|
|
1250
1212
|
return;
|
|
1251
1213
|
}
|
|
1252
|
-
const [nonce, releaseNonce] = yield (0, nonce_1.getNextNonce)(transactionMeta,
|
|
1214
|
+
const [nonce, releaseNonce] = yield (0, nonce_1.getNextNonce)(transactionMeta, this.nonceTracker);
|
|
1253
1215
|
releaseNonceLock = releaseNonce;
|
|
1254
1216
|
transactionMeta.status = types_1.TransactionStatus.approved;
|
|
1255
1217
|
transactionMeta.txParams.nonce = nonce;
|
|
1256
|
-
transactionMeta.txParams.chainId =
|
|
1218
|
+
transactionMeta.txParams.chainId = chainId;
|
|
1257
1219
|
const baseTxParams = Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas });
|
|
1258
1220
|
this.updateTransaction(transactionMeta, 'TransactionController#approveTransaction - Transaction approved');
|
|
1259
1221
|
this.onTransactionStatusChange(transactionMeta);
|
|
@@ -1269,20 +1231,16 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1269
1231
|
if (!rawTx) {
|
|
1270
1232
|
return;
|
|
1271
1233
|
}
|
|
1272
|
-
const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
|
|
1273
|
-
networkClientId: transactionMeta.networkClientId,
|
|
1274
|
-
chainId: transactionMeta.chainId,
|
|
1275
|
-
});
|
|
1276
1234
|
if (transactionMeta.type === types_1.TransactionType.swap) {
|
|
1277
1235
|
(0, logger_1.projectLogger)('Determining pre-transaction balance');
|
|
1278
|
-
const preTxBalance = yield (0, controller_utils_1.query)(ethQuery, 'getBalance', [from]);
|
|
1236
|
+
const preTxBalance = yield (0, controller_utils_1.query)(this.ethQuery, 'getBalance', [from]);
|
|
1279
1237
|
transactionMeta.preTxBalance = preTxBalance;
|
|
1280
1238
|
(0, logger_1.projectLogger)('Updated pre-transaction balance', transactionMeta.preTxBalance);
|
|
1281
1239
|
}
|
|
1282
1240
|
(0, logger_1.projectLogger)('Publishing transaction', txParams);
|
|
1283
1241
|
let { transactionHash: hash } = yield this.publish(transactionMeta, rawTx);
|
|
1284
1242
|
if (hash === undefined) {
|
|
1285
|
-
hash = yield this.publishTransaction(
|
|
1243
|
+
hash = yield this.publishTransaction(rawTx);
|
|
1286
1244
|
}
|
|
1287
1245
|
(0, logger_1.projectLogger)('Publish successful', hash);
|
|
1288
1246
|
transactionMeta.hash = hash;
|
|
@@ -1308,9 +1266,9 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1308
1266
|
}
|
|
1309
1267
|
});
|
|
1310
1268
|
}
|
|
1311
|
-
publishTransaction(
|
|
1269
|
+
publishTransaction(rawTransaction) {
|
|
1312
1270
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1313
|
-
return yield (0, controller_utils_1.query)(ethQuery, 'sendRawTransaction', [rawTransaction]);
|
|
1271
|
+
return yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTransaction]);
|
|
1314
1272
|
});
|
|
1315
1273
|
}
|
|
1316
1274
|
/**
|
|
@@ -1426,17 +1384,14 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1426
1384
|
const isCompleted = this.isLocalFinalState(transaction.status);
|
|
1427
1385
|
return { meta: transaction, isCompleted };
|
|
1428
1386
|
}
|
|
1429
|
-
getChainId(
|
|
1430
|
-
if (networkClientId) {
|
|
1431
|
-
return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
|
|
1432
|
-
}
|
|
1387
|
+
getChainId() {
|
|
1433
1388
|
const { providerConfig } = this.getNetworkState();
|
|
1434
1389
|
return providerConfig.chainId;
|
|
1435
1390
|
}
|
|
1436
|
-
prepareUnsignedEthTx(
|
|
1391
|
+
prepareUnsignedEthTx(txParams) {
|
|
1437
1392
|
return tx_1.TransactionFactory.fromTxData(txParams, {
|
|
1393
|
+
common: this.getCommonConfiguration(),
|
|
1438
1394
|
freeze: false,
|
|
1439
|
-
common: this.getCommonConfiguration(chainId),
|
|
1440
1395
|
});
|
|
1441
1396
|
}
|
|
1442
1397
|
/**
|
|
@@ -1446,11 +1401,17 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1446
1401
|
* specified in txParams, @ethereumjs/tx is able to determine which EIP-2718
|
|
1447
1402
|
* transaction type to use.
|
|
1448
1403
|
*
|
|
1449
|
-
* @param chainId - The chainId to use for the configuration.
|
|
1450
1404
|
* @returns common configuration object
|
|
1451
1405
|
*/
|
|
1452
|
-
getCommonConfiguration(
|
|
1406
|
+
getCommonConfiguration() {
|
|
1407
|
+
const { providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState();
|
|
1408
|
+
if (chain !== controller_utils_1.RPC &&
|
|
1409
|
+
chain !== controller_utils_1.NetworkType['linea-goerli'] &&
|
|
1410
|
+
chain !== controller_utils_1.NetworkType['linea-mainnet']) {
|
|
1411
|
+
return new common_1.Common({ chain, hardfork: exports.HARDFORK });
|
|
1412
|
+
}
|
|
1453
1413
|
const customChainParams = {
|
|
1414
|
+
name,
|
|
1454
1415
|
chainId: parseInt(chainId, 16),
|
|
1455
1416
|
defaultHardfork: exports.HARDFORK,
|
|
1456
1417
|
};
|
|
@@ -1505,7 +1466,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1505
1466
|
*/
|
|
1506
1467
|
addExternalTransaction(transactionMeta) {
|
|
1507
1468
|
var _a, _b;
|
|
1508
|
-
const
|
|
1469
|
+
const chainId = this.getChainId();
|
|
1509
1470
|
const { transactions } = this.state;
|
|
1510
1471
|
const fromAddress = (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.from;
|
|
1511
1472
|
const sameFromAndNetworkTransactions = transactions.filter((transaction) => transaction.txParams.from === fromAddress &&
|
|
@@ -1532,13 +1493,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1532
1493
|
*/
|
|
1533
1494
|
markNonceDuplicatesDropped(transactionId) {
|
|
1534
1495
|
var _a, _b;
|
|
1496
|
+
const chainId = this.getChainId();
|
|
1535
1497
|
const transactionMeta = this.getTransaction(transactionId);
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
}
|
|
1539
|
-
const nonce = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.nonce;
|
|
1540
|
-
const from = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.from;
|
|
1541
|
-
const { chainId } = transactionMeta;
|
|
1498
|
+
const nonce = (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.nonce;
|
|
1499
|
+
const from = (_b = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.from;
|
|
1542
1500
|
const sameNonceTxs = this.state.transactions.filter((transaction) => transaction.id !== transactionId &&
|
|
1543
1501
|
transaction.txParams.from === from &&
|
|
1544
1502
|
transaction.txParams.nonce === nonce &&
|
|
@@ -1549,8 +1507,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1549
1507
|
}
|
|
1550
1508
|
// Mark all same nonce transactions as dropped and give it a replacedBy hash
|
|
1551
1509
|
for (const transaction of sameNonceTxs) {
|
|
1552
|
-
transaction.replacedBy = transactionMeta.hash;
|
|
1553
|
-
transaction.replacedById = transactionMeta.id;
|
|
1510
|
+
transaction.replacedBy = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.hash;
|
|
1511
|
+
transaction.replacedById = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.id;
|
|
1554
1512
|
// Drop any transaction that wasn't previously failed (off chain failure)
|
|
1555
1513
|
if (transaction.status !== types_1.TransactionStatus.failed) {
|
|
1556
1514
|
this.setTransactionStatusDropped(transaction);
|
|
@@ -1606,17 +1564,23 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1606
1564
|
}
|
|
1607
1565
|
});
|
|
1608
1566
|
}
|
|
1609
|
-
getEIP1559Compatibility(
|
|
1567
|
+
getEIP1559Compatibility() {
|
|
1610
1568
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1611
|
-
const currentNetworkIsEIP1559Compatible = yield this.getCurrentNetworkEIP1559Compatibility(
|
|
1569
|
+
const currentNetworkIsEIP1559Compatible = yield this.getCurrentNetworkEIP1559Compatibility();
|
|
1612
1570
|
const currentAccountIsEIP1559Compatible = yield this.getCurrentAccountEIP1559Compatibility();
|
|
1613
1571
|
return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
|
|
1614
1572
|
});
|
|
1615
1573
|
}
|
|
1574
|
+
addPendingTransactionTrackerListeners() {
|
|
1575
|
+
this.pendingTransactionTracker.hub.on('transaction-confirmed', this.onConfirmedTransaction.bind(this));
|
|
1576
|
+
this.pendingTransactionTracker.hub.on('transaction-dropped', this.setTransactionStatusDropped.bind(this));
|
|
1577
|
+
this.pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
|
|
1578
|
+
this.pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|
|
1579
|
+
}
|
|
1616
1580
|
signTransaction(transactionMeta, txParams) {
|
|
1617
1581
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1618
1582
|
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1619
|
-
const unsignedEthTx = this.prepareUnsignedEthTx(
|
|
1583
|
+
const unsignedEthTx = this.prepareUnsignedEthTx(txParams);
|
|
1620
1584
|
this.inProcessOfSigning.add(transactionMeta.id);
|
|
1621
1585
|
const signedTx = yield new Promise((resolve, reject) => {
|
|
1622
1586
|
var _a;
|
|
@@ -1646,8 +1610,14 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1646
1610
|
onTransactionStatusChange(transactionMeta) {
|
|
1647
1611
|
this.hub.emit('transaction-status-update', { transactionMeta });
|
|
1648
1612
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1613
|
+
getNonceTrackerPendingTransactions(address) {
|
|
1614
|
+
const standardPendingTransactions = this.getNonceTrackerTransactions(types_1.TransactionStatus.submitted, address);
|
|
1615
|
+
const externalPendingTransactions = this.getExternalPendingTransactions(address);
|
|
1616
|
+
return [...standardPendingTransactions, ...externalPendingTransactions];
|
|
1617
|
+
}
|
|
1618
|
+
getNonceTrackerTransactions(status, address) {
|
|
1619
|
+
const currentChainId = this.getChainId();
|
|
1620
|
+
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(currentChainId, address, status, this.state.transactions);
|
|
1651
1621
|
}
|
|
1652
1622
|
onConfirmedTransaction(transactionMeta) {
|
|
1653
1623
|
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
@@ -1665,12 +1635,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1665
1635
|
if (transactionMeta.type !== types_1.TransactionType.swap) {
|
|
1666
1636
|
return;
|
|
1667
1637
|
}
|
|
1668
|
-
const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
|
|
1669
|
-
networkClientId: transactionMeta.networkClientId,
|
|
1670
|
-
chainId: transactionMeta.chainId,
|
|
1671
|
-
});
|
|
1672
1638
|
const { updatedTransactionMeta, approvalTransactionMeta } = yield (0, swaps_1.updatePostTransactionBalance)(transactionMeta, {
|
|
1673
|
-
ethQuery,
|
|
1639
|
+
ethQuery: this.ethQuery,
|
|
1674
1640
|
getTransaction: this.getTransaction.bind(this),
|
|
1675
1641
|
updateTransaction: this.updateTransaction.bind(this),
|
|
1676
1642
|
});
|
|
@@ -1685,106 +1651,6 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1685
1651
|
}
|
|
1686
1652
|
});
|
|
1687
1653
|
}
|
|
1688
|
-
publishTransactionForRetry(ethQuery, rawTx, transactionMeta) {
|
|
1689
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1690
|
-
try {
|
|
1691
|
-
const hash = yield this.publishTransaction(ethQuery, rawTx);
|
|
1692
|
-
return hash;
|
|
1693
|
-
}
|
|
1694
|
-
catch (error) {
|
|
1695
|
-
if (this.isTransactionAlreadyConfirmedError(error)) {
|
|
1696
|
-
yield this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
|
|
1697
|
-
throw new Error('Previous transaction is already confirmed');
|
|
1698
|
-
}
|
|
1699
|
-
throw error;
|
|
1700
|
-
}
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
/**
|
|
1704
|
-
* Ensures that error is a nonce issue
|
|
1705
|
-
*
|
|
1706
|
-
* @param error - The error to check
|
|
1707
|
-
* @returns Whether or not the error is a nonce issue
|
|
1708
|
-
*/
|
|
1709
|
-
// TODO: Replace `any` with type
|
|
1710
|
-
// Some networks are returning original error in the data field
|
|
1711
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1712
|
-
isTransactionAlreadyConfirmedError(error) {
|
|
1713
|
-
var _a, _b, _c;
|
|
1714
|
-
return (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('nonce too low')) ||
|
|
1715
|
-
((_c = (_b = error === null || error === void 0 ? void 0 : error.data) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.includes('nonce too low')));
|
|
1716
|
-
}
|
|
1717
1654
|
}
|
|
1718
1655
|
exports.TransactionController = TransactionController;
|
|
1719
|
-
_TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
|
|
1720
|
-
return new nonce_tracker_1.NonceTracker({
|
|
1721
|
-
// TODO: Replace `any` with type
|
|
1722
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1723
|
-
provider: provider,
|
|
1724
|
-
blockTracker,
|
|
1725
|
-
getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
|
|
1726
|
-
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
|
|
1727
|
-
});
|
|
1728
|
-
}, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, etherscanRemoteTransactionSource, chainId, }) {
|
|
1729
|
-
const incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
|
|
1730
|
-
blockTracker,
|
|
1731
|
-
getCurrentAccount: this.getSelectedAddress,
|
|
1732
|
-
getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
|
|
1733
|
-
getChainId: chainId ? () => chainId : this.getChainId.bind(this),
|
|
1734
|
-
isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
|
|
1735
|
-
queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
|
|
1736
|
-
remoteTransactionSource: etherscanRemoteTransactionSource,
|
|
1737
|
-
transactionLimit: this.config.txHistoryLimit,
|
|
1738
|
-
updateTransactions: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").updateTransactions,
|
|
1739
|
-
});
|
|
1740
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addIncomingTransactionHelperListeners).call(this, incomingTransactionHelper);
|
|
1741
|
-
return incomingTransactionHelper;
|
|
1742
|
-
}, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
|
|
1743
|
-
const ethQuery = new eth_query_1.default(provider);
|
|
1744
|
-
const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
|
|
1745
|
-
const pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
|
|
1746
|
-
approveTransaction: this.approveTransaction.bind(this),
|
|
1747
|
-
blockTracker,
|
|
1748
|
-
getChainId,
|
|
1749
|
-
getEthQuery: () => ethQuery,
|
|
1750
|
-
getTransactions: () => this.state.transactions,
|
|
1751
|
-
isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
|
|
1752
|
-
getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
|
|
1753
|
-
chainId: getChainId(),
|
|
1754
|
-
}),
|
|
1755
|
-
publishTransaction: this.publishTransaction.bind(this),
|
|
1756
|
-
hooks: {
|
|
1757
|
-
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
1758
|
-
beforePublish: this.beforePublish.bind(this),
|
|
1759
|
-
},
|
|
1760
|
-
});
|
|
1761
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|
|
1762
|
-
return pendingTransactionTracker;
|
|
1763
|
-
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
1764
|
-
this.pendingTransactionTracker.stop();
|
|
1765
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
|
|
1766
|
-
this.incomingTransactionHelper.stop();
|
|
1767
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
|
|
1768
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
|
|
1769
|
-
}, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1770
|
-
incomingTransactionHelper.hub.removeAllListeners('transactions');
|
|
1771
|
-
incomingTransactionHelper.hub.removeAllListeners('updatedLastFetchedBlockNumbers');
|
|
1772
|
-
}, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1773
|
-
incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
|
|
1774
|
-
incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this));
|
|
1775
|
-
}, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
1776
|
-
pendingTransactionTracker.hub.removeAllListeners('transaction-confirmed');
|
|
1777
|
-
pendingTransactionTracker.hub.removeAllListeners('transaction-dropped');
|
|
1778
|
-
pendingTransactionTracker.hub.removeAllListeners('transaction-failed');
|
|
1779
|
-
pendingTransactionTracker.hub.removeAllListeners('transaction-updated');
|
|
1780
|
-
}, _TransactionController_addPendingTransactionTrackerListeners = function _TransactionController_addPendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
1781
|
-
pendingTransactionTracker.hub.on('transaction-confirmed', this.onConfirmedTransaction.bind(this));
|
|
1782
|
-
pendingTransactionTracker.hub.on('transaction-dropped', this.setTransactionStatusDropped.bind(this));
|
|
1783
|
-
pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
|
|
1784
|
-
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|
|
1785
|
-
}, _TransactionController_getNonceTrackerPendingTransactions = function _TransactionController_getNonceTrackerPendingTransactions(chainId, address) {
|
|
1786
|
-
const standardPendingTransactions = this.getNonceTrackerTransactions(types_1.TransactionStatus.submitted, address, chainId);
|
|
1787
|
-
const externalPendingTransactions = this.getExternalPendingTransactions(address, chainId);
|
|
1788
|
-
return [...standardPendingTransactions, ...externalPendingTransactions];
|
|
1789
|
-
};
|
|
1790
1656
|
//# sourceMappingURL=TransactionController.js.map
|