@metamask/transaction-controller 28.1.1 → 29.0.1
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 +40 -1
- package/dist/TransactionController.js +11 -10
- package/dist/TransactionController.mjs +10 -9
- package/dist/{chunk-HQAADNXH.mjs → chunk-26BABWPE.mjs} +201 -113
- package/dist/chunk-26BABWPE.mjs.map +1 -0
- package/dist/{chunk-LDXTSESK.mjs → chunk-4M7FHI4S.mjs} +20 -4
- package/dist/chunk-4M7FHI4S.mjs.map +1 -0
- package/dist/{chunk-FK7AP6SH.js → chunk-5C3CSQAD.js} +12 -5
- package/dist/{chunk-YEJJKWT2.mjs.map → chunk-5C3CSQAD.js.map} +1 -1
- package/dist/{chunk-V6UIRCOF.js → chunk-7DJO6UZA.js} +48 -13
- package/dist/chunk-7DJO6UZA.js.map +1 -0
- package/dist/{chunk-TWND5SFD.mjs → chunk-AGJNOOBN.mjs} +17 -12
- package/dist/chunk-AGJNOOBN.mjs.map +1 -0
- package/dist/{chunk-LNX4JTOL.js → chunk-DUFOYA4D.js} +7 -7
- package/dist/chunk-DUFOYA4D.js.map +1 -0
- package/dist/{chunk-UH7FNVKS.js → chunk-EMDU4XLM.js} +19 -14
- package/dist/chunk-EMDU4XLM.js.map +1 -0
- package/dist/chunk-FMRLPVFZ.mjs +66 -0
- package/dist/chunk-FMRLPVFZ.mjs.map +1 -0
- package/dist/{chunk-EQNKFFTM.js → chunk-KNYSD4JP.js} +21 -5
- package/dist/chunk-KNYSD4JP.js.map +1 -0
- package/dist/{chunk-FMCTVRU2.js → chunk-KT3F6CZP.js} +204 -116
- package/dist/chunk-KT3F6CZP.js.map +1 -0
- package/dist/{chunk-YEJJKWT2.mjs → chunk-N6JXPWLY.mjs} +11 -4
- package/dist/chunk-N6JXPWLY.mjs.map +1 -0
- package/dist/chunk-REOG6YD4.mjs +112 -0
- package/dist/chunk-REOG6YD4.mjs.map +1 -0
- package/dist/{chunk-HHK4QSNF.mjs → chunk-SL3GHHKG.mjs} +47 -12
- package/dist/chunk-SL3GHHKG.mjs.map +1 -0
- package/dist/chunk-TJMQEH57.js +66 -0
- package/dist/chunk-TJMQEH57.js.map +1 -0
- package/dist/chunk-VJYFB7BM.js +112 -0
- package/dist/chunk-VJYFB7BM.js.map +1 -0
- package/dist/{chunk-NCRWKI6Y.mjs → chunk-XL3HBKDE.mjs} +4 -4
- package/dist/chunk-XL3HBKDE.mjs.map +1 -0
- package/dist/errors.js +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.js +5 -5
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +4 -4
- package/dist/gas-flows/LineaGasFeeFlow.js +6 -6
- package/dist/gas-flows/LineaGasFeeFlow.mjs +5 -5
- package/dist/gas-flows/TestGasFeeFlow.js +9 -0
- package/dist/gas-flows/TestGasFeeFlow.js.map +1 -0
- package/dist/gas-flows/TestGasFeeFlow.mjs +9 -0
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -1
- package/dist/helpers/GasFeePoller.js +4 -4
- package/dist/helpers/GasFeePoller.mjs +3 -3
- package/dist/helpers/MultichainTrackingHelper.js +1 -1
- package/dist/helpers/MultichainTrackingHelper.mjs +1 -1
- package/dist/helpers/PendingTransactionTracker.js +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -1
- package/dist/index.js +15 -10
- package/dist/index.mjs +14 -9
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +16 -7
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +1 -1
- package/dist/types/gas-flows/TestGasFeeFlow.d.ts +12 -0
- package/dist/types/gas-flows/TestGasFeeFlow.d.ts.map +1 -0
- package/dist/types/helpers/GasFeePoller.d.ts +5 -3
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +36 -18
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/gas-flow.d.ts +8 -14
- package/dist/types/utils/gas-flow.d.ts.map +1 -1
- package/dist/types.js +4 -2
- package/dist/types.mjs +3 -1
- package/dist/utils/external-transactions.js +1 -1
- package/dist/utils/external-transactions.mjs +1 -1
- package/dist/utils/gas-fees.js +4 -4
- package/dist/utils/gas-fees.mjs +3 -3
- package/dist/utils/gas-flow.js +3 -3
- package/dist/utils/gas-flow.mjs +2 -2
- package/dist/utils/simulation-api.js +1 -1
- package/dist/utils/simulation-api.mjs +1 -1
- package/dist/utils/simulation.js +1 -1
- package/dist/utils/simulation.mjs +1 -1
- package/dist/utils/swaps.js +1 -1
- package/dist/utils/swaps.mjs +1 -1
- package/dist/utils/transaction-type.js +1 -1
- package/dist/utils/transaction-type.mjs +1 -1
- package/dist/utils/utils.js +1 -1
- package/dist/utils/utils.mjs +1 -1
- package/dist/utils/validation.js +1 -1
- package/dist/utils/validation.mjs +1 -1
- package/package.json +5 -5
- package/dist/chunk-4RJXBKSR.js +0 -90
- package/dist/chunk-4RJXBKSR.js.map +0 -1
- package/dist/chunk-EQNKFFTM.js.map +0 -1
- package/dist/chunk-FK7AP6SH.js.map +0 -1
- package/dist/chunk-FMCTVRU2.js.map +0 -1
- package/dist/chunk-HHK4QSNF.mjs.map +0 -1
- package/dist/chunk-HQAADNXH.mjs.map +0 -1
- package/dist/chunk-LDXTSESK.mjs.map +0 -1
- package/dist/chunk-LNX4JTOL.js.map +0 -1
- package/dist/chunk-NCRWKI6Y.mjs.map +0 -1
- package/dist/chunk-NPEXNXSY.mjs +0 -90
- package/dist/chunk-NPEXNXSY.mjs.map +0 -1
- package/dist/chunk-TWND5SFD.mjs.map +0 -1
- package/dist/chunk-UH7FNVKS.js.map +0 -1
- package/dist/chunk-V6UIRCOF.js.map +0 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAndFormatTransactionsForNonceTracker,
|
|
3
|
+
getNextNonce
|
|
4
|
+
} from "./chunk-NHRBO3LU.mjs";
|
|
1
5
|
import {
|
|
2
6
|
getSimulationData
|
|
3
7
|
} from "./chunk-MDRMMUMS.mjs";
|
|
@@ -8,6 +12,9 @@ import {
|
|
|
8
12
|
validateTransactionOrigin,
|
|
9
13
|
validateTxParams
|
|
10
14
|
} from "./chunk-NM6OYEPP.mjs";
|
|
15
|
+
import {
|
|
16
|
+
PendingTransactionTracker
|
|
17
|
+
} from "./chunk-5YES3V2R.mjs";
|
|
11
18
|
import {
|
|
12
19
|
validateConfirmedExternalTransaction
|
|
13
20
|
} from "./chunk-FRKQ3Z2L.mjs";
|
|
@@ -20,19 +27,18 @@ import {
|
|
|
20
27
|
addInitialHistorySnapshot,
|
|
21
28
|
updateTransactionHistory
|
|
22
29
|
} from "./chunk-XGRAHX6T.mjs";
|
|
23
|
-
import {
|
|
24
|
-
getAndFormatTransactionsForNonceTracker,
|
|
25
|
-
getNextNonce
|
|
26
|
-
} from "./chunk-NHRBO3LU.mjs";
|
|
27
30
|
import {
|
|
28
31
|
OptimismLayer1GasFeeFlow
|
|
29
32
|
} from "./chunk-VEVVBHP3.mjs";
|
|
30
33
|
import {
|
|
31
34
|
ScrollLayer1GasFeeFlow
|
|
32
35
|
} from "./chunk-Z4GV3YQQ.mjs";
|
|
36
|
+
import {
|
|
37
|
+
TestGasFeeFlow
|
|
38
|
+
} from "./chunk-FMRLPVFZ.mjs";
|
|
33
39
|
import {
|
|
34
40
|
GasFeePoller
|
|
35
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-SL3GHHKG.mjs";
|
|
36
42
|
import {
|
|
37
43
|
getTransactionLayer1GasFee,
|
|
38
44
|
updateTransactionLayer1GasFee
|
|
@@ -46,18 +52,15 @@ import {
|
|
|
46
52
|
import {
|
|
47
53
|
EtherscanRemoteTransactionSource
|
|
48
54
|
} from "./chunk-CPMTUMMZ.mjs";
|
|
49
|
-
import {
|
|
50
|
-
PendingTransactionTracker
|
|
51
|
-
} from "./chunk-5YES3V2R.mjs";
|
|
52
55
|
import {
|
|
53
56
|
LineaGasFeeFlow
|
|
54
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-XL3HBKDE.mjs";
|
|
55
58
|
import {
|
|
56
59
|
DefaultGasFeeFlow
|
|
57
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-REOG6YD4.mjs";
|
|
58
61
|
import {
|
|
59
62
|
updateGasFees
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-4M7FHI4S.mjs";
|
|
61
64
|
import {
|
|
62
65
|
updatePostTransactionBalance,
|
|
63
66
|
updateSwapsTransaction
|
|
@@ -74,6 +77,9 @@ import {
|
|
|
74
77
|
validateIfTransactionUnapproved,
|
|
75
78
|
validateMinimumIncrease
|
|
76
79
|
} from "./chunk-J56A7UCK.mjs";
|
|
80
|
+
import {
|
|
81
|
+
getGasFeeFlow
|
|
82
|
+
} from "./chunk-AGJNOOBN.mjs";
|
|
77
83
|
import {
|
|
78
84
|
projectLogger
|
|
79
85
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -137,7 +143,7 @@ function getDefaultTransactionControllerState() {
|
|
|
137
143
|
lastFetchedBlockNumbers: {}
|
|
138
144
|
};
|
|
139
145
|
}
|
|
140
|
-
var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _transactionHistoryLimit, _isSimulationEnabled, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn;
|
|
146
|
+
var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _transactionHistoryLimit, _isSimulationEnabled, _testGasFeeFlows, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn, _getNetworkClientId, getNetworkClientId_fn, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn, _getGlobalChainId, getGlobalChainId_fn, _isCustomNetwork, isCustomNetwork_fn;
|
|
141
147
|
var TransactionController = class extends BaseController {
|
|
142
148
|
/**
|
|
143
149
|
* Constructs a TransactionController.
|
|
@@ -166,6 +172,7 @@ var TransactionController = class extends BaseController {
|
|
|
166
172
|
* @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
|
|
167
173
|
* @param options.sign - Function used to sign transactions.
|
|
168
174
|
* @param options.state - Initial state to set on this controller.
|
|
175
|
+
* @param options.testGasFeeFlows - Whether to use the test gas fee flow.
|
|
169
176
|
* @param options.transactionHistoryLimit - Transaction history limit.
|
|
170
177
|
* @param options.hooks - The controller hooks.
|
|
171
178
|
*/
|
|
@@ -193,6 +200,7 @@ var TransactionController = class extends BaseController {
|
|
|
193
200
|
securityProviderRequest,
|
|
194
201
|
sign,
|
|
195
202
|
state,
|
|
203
|
+
testGasFeeFlows,
|
|
196
204
|
transactionHistoryLimit = 40,
|
|
197
205
|
hooks
|
|
198
206
|
}) {
|
|
@@ -221,14 +229,19 @@ var TransactionController = class extends BaseController {
|
|
|
221
229
|
__privateAdd(this, _onTransactionParamsUpdated);
|
|
222
230
|
__privateAdd(this, _updateSimulationData);
|
|
223
231
|
__privateAdd(this, _onGasFeePollerTransactionUpdate);
|
|
232
|
+
__privateAdd(this, _getNetworkClientId);
|
|
233
|
+
__privateAdd(this, _getGlobalNetworkClientId);
|
|
234
|
+
__privateAdd(this, _getGlobalChainId);
|
|
235
|
+
__privateAdd(this, _isCustomNetwork);
|
|
224
236
|
__privateAdd(this, _internalEvents, new EventEmitter());
|
|
225
|
-
this.
|
|
237
|
+
this.approvingTransactionIds = /* @__PURE__ */ new Set();
|
|
226
238
|
this.mutex = new Mutex();
|
|
227
239
|
__privateAdd(this, _incomingTransactionOptions, void 0);
|
|
228
240
|
__privateAdd(this, _pendingTransactionOptions, void 0);
|
|
229
241
|
this.signAbortCallbacks = /* @__PURE__ */ new Map();
|
|
230
242
|
__privateAdd(this, _transactionHistoryLimit, void 0);
|
|
231
243
|
__privateAdd(this, _isSimulationEnabled, void 0);
|
|
244
|
+
__privateAdd(this, _testGasFeeFlows, void 0);
|
|
232
245
|
__privateAdd(this, _multichainTrackingHelper, void 0);
|
|
233
246
|
__privateAdd(this, _checkForPendingTransactionAndStartPolling, () => {
|
|
234
247
|
this.pendingTransactionTracker.startIfPendingTransactions();
|
|
@@ -253,6 +266,7 @@ var TransactionController = class extends BaseController {
|
|
|
253
266
|
__privateSet(this, _pendingTransactionOptions, pendingTransactions);
|
|
254
267
|
__privateSet(this, _transactionHistoryLimit, transactionHistoryLimit);
|
|
255
268
|
this.sign = sign;
|
|
269
|
+
__privateSet(this, _testGasFeeFlows, testGasFeeFlows === true);
|
|
256
270
|
this.afterSign = hooks?.afterSign ?? (() => true);
|
|
257
271
|
this.beforeApproveOnInit = hooks?.beforeApproveOnInit ?? (() => true);
|
|
258
272
|
this.beforeCheckPendingTransaction = hooks?.beforeCheckPendingTransaction ?? /* istanbul ignore next */
|
|
@@ -264,17 +278,18 @@ var TransactionController = class extends BaseController {
|
|
|
264
278
|
provider,
|
|
265
279
|
blockTracker
|
|
266
280
|
});
|
|
281
|
+
const findNetworkClientIdByChainId = (chainId) => {
|
|
282
|
+
return this.messagingSystem.call(
|
|
283
|
+
`NetworkController:findNetworkClientIdByChainId`,
|
|
284
|
+
chainId
|
|
285
|
+
);
|
|
286
|
+
};
|
|
267
287
|
__privateSet(this, _multichainTrackingHelper, new MultichainTrackingHelper({
|
|
268
288
|
isMultichainEnabled,
|
|
269
289
|
provider,
|
|
270
290
|
nonceTracker: this.nonceTracker,
|
|
271
291
|
incomingTransactionOptions: incomingTransactions,
|
|
272
|
-
findNetworkClientIdByChainId
|
|
273
|
-
return this.messagingSystem.call(
|
|
274
|
-
`NetworkController:findNetworkClientIdByChainId`,
|
|
275
|
-
chainId
|
|
276
|
-
);
|
|
277
|
-
},
|
|
292
|
+
findNetworkClientIdByChainId,
|
|
278
293
|
getNetworkClientById: (networkClientId) => {
|
|
279
294
|
return this.messagingSystem.call(
|
|
280
295
|
`NetworkController:getNetworkClientById`,
|
|
@@ -309,8 +324,8 @@ var TransactionController = class extends BaseController {
|
|
|
309
324
|
this.gasFeeFlows = __privateMethod(this, _getGasFeeFlows, getGasFeeFlows_fn).call(this);
|
|
310
325
|
this.layer1GasFeeFlows = __privateMethod(this, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn).call(this);
|
|
311
326
|
const gasFeePoller = new GasFeePoller({
|
|
312
|
-
|
|
313
|
-
gasFeeFlows: this.gasFeeFlows
|
|
327
|
+
findNetworkClientIdByChainId,
|
|
328
|
+
gasFeeFlows: this.gasFeeFlows,
|
|
314
329
|
getGasFeeControllerEstimates: this.getGasFeeEstimates,
|
|
315
330
|
getProvider: (chainId, networkClientId) => __privateGet(this, _multichainTrackingHelper).getProvider({
|
|
316
331
|
networkClientId,
|
|
@@ -438,15 +453,16 @@ var TransactionController = class extends BaseController {
|
|
|
438
453
|
sendFlowHistory,
|
|
439
454
|
swaps = {},
|
|
440
455
|
type,
|
|
441
|
-
networkClientId
|
|
456
|
+
networkClientId: requestNetworkClientId
|
|
442
457
|
} = {}) {
|
|
443
458
|
projectLogger("Adding transaction", txParams);
|
|
444
459
|
txParams = normalizeTransactionParams(txParams);
|
|
445
|
-
if (
|
|
460
|
+
if (requestNetworkClientId && !__privateGet(this, _multichainTrackingHelper).has(requestNetworkClientId)) {
|
|
446
461
|
throw new Error(
|
|
447
462
|
"The networkClientId for this transaction could not be found"
|
|
448
463
|
);
|
|
449
464
|
}
|
|
465
|
+
const networkClientId = requestNetworkClientId ?? __privateMethod(this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
450
466
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(
|
|
451
467
|
networkClientId
|
|
452
468
|
);
|
|
@@ -709,9 +725,7 @@ var TransactionController = class extends BaseController {
|
|
|
709
725
|
validateGasValues(gasValues);
|
|
710
726
|
}
|
|
711
727
|
projectLogger("Creating speed up transaction", transactionId, gasValues);
|
|
712
|
-
const transactionMeta = this.
|
|
713
|
-
({ id }) => id === transactionId
|
|
714
|
-
);
|
|
728
|
+
const transactionMeta = this.getTransaction(transactionId);
|
|
715
729
|
if (!transactionMeta) {
|
|
716
730
|
return;
|
|
717
731
|
}
|
|
@@ -760,7 +774,7 @@ var TransactionController = class extends BaseController {
|
|
|
760
774
|
unsignedEthTx,
|
|
761
775
|
transactionMeta.txParams.from
|
|
762
776
|
);
|
|
763
|
-
const transactionMetaWithRsv =
|
|
777
|
+
const transactionMetaWithRsv = this.updateTransactionMetaRSV(
|
|
764
778
|
transactionMeta,
|
|
765
779
|
signedTx
|
|
766
780
|
);
|
|
@@ -1199,10 +1213,10 @@ var TransactionController = class extends BaseController {
|
|
|
1199
1213
|
common
|
|
1200
1214
|
});
|
|
1201
1215
|
const initialTxAsSerializedHex = bufferToHex(initialTxAsEthTx.serialize());
|
|
1202
|
-
if (this.
|
|
1216
|
+
if (this.approvingTransactionIds.has(initialTxAsSerializedHex)) {
|
|
1203
1217
|
return "";
|
|
1204
1218
|
}
|
|
1205
|
-
this.
|
|
1219
|
+
this.approvingTransactionIds.add(initialTxAsSerializedHex);
|
|
1206
1220
|
let rawTransactions, nonceLock;
|
|
1207
1221
|
try {
|
|
1208
1222
|
const fromAddress = initialTx.from;
|
|
@@ -1223,7 +1237,7 @@ var TransactionController = class extends BaseController {
|
|
|
1223
1237
|
throw err;
|
|
1224
1238
|
} finally {
|
|
1225
1239
|
nonceLock?.releaseLock();
|
|
1226
|
-
this.
|
|
1240
|
+
this.approvingTransactionIds.delete(initialTxAsSerializedHex);
|
|
1227
1241
|
}
|
|
1228
1242
|
return rawTransactions;
|
|
1229
1243
|
}
|
|
@@ -1264,10 +1278,10 @@ var TransactionController = class extends BaseController {
|
|
|
1264
1278
|
transactionMeta,
|
|
1265
1279
|
pickBy({ hash, status })
|
|
1266
1280
|
);
|
|
1267
|
-
if (status === "submitted" /* submitted */) {
|
|
1281
|
+
if (updatedTransactionMeta.status === "submitted" /* submitted */) {
|
|
1268
1282
|
updatedTransactionMeta.submittedTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1269
1283
|
}
|
|
1270
|
-
if (status === "failed" /* failed */) {
|
|
1284
|
+
if (updatedTransactionMeta.status === "failed" /* failed */) {
|
|
1271
1285
|
updatedTransactionMeta.error = normalizeTxError(new Error(errorMessage));
|
|
1272
1286
|
}
|
|
1273
1287
|
this.updateTransaction(
|
|
@@ -1368,6 +1382,37 @@ var TransactionController = class extends BaseController {
|
|
|
1368
1382
|
}
|
|
1369
1383
|
return filteredTransactions;
|
|
1370
1384
|
}
|
|
1385
|
+
async estimateGasFee({
|
|
1386
|
+
transactionParams,
|
|
1387
|
+
chainId,
|
|
1388
|
+
networkClientId: requestNetworkClientId
|
|
1389
|
+
}) {
|
|
1390
|
+
const networkClientId = __privateMethod(this, _getNetworkClientId, getNetworkClientId_fn).call(this, {
|
|
1391
|
+
networkClientId: requestNetworkClientId,
|
|
1392
|
+
chainId
|
|
1393
|
+
});
|
|
1394
|
+
const transactionMeta = {
|
|
1395
|
+
txParams: transactionParams,
|
|
1396
|
+
chainId,
|
|
1397
|
+
networkClientId
|
|
1398
|
+
};
|
|
1399
|
+
const gasFeeFlow = getGasFeeFlow(
|
|
1400
|
+
transactionMeta,
|
|
1401
|
+
this.gasFeeFlows
|
|
1402
|
+
);
|
|
1403
|
+
const ethQuery = __privateGet(this, _multichainTrackingHelper).getEthQuery({
|
|
1404
|
+
networkClientId,
|
|
1405
|
+
chainId
|
|
1406
|
+
});
|
|
1407
|
+
const gasFeeControllerData = await this.getGasFeeEstimates({
|
|
1408
|
+
networkClientId
|
|
1409
|
+
});
|
|
1410
|
+
return gasFeeFlow.getGasFees({
|
|
1411
|
+
ethQuery,
|
|
1412
|
+
gasFeeControllerData,
|
|
1413
|
+
transactionMeta
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1371
1416
|
/**
|
|
1372
1417
|
* Determine the layer 1 gas fee for the given transaction parameters.
|
|
1373
1418
|
*
|
|
@@ -1457,10 +1502,7 @@ var TransactionController = class extends BaseController {
|
|
|
1457
1502
|
async updateGasProperties(transactionMeta) {
|
|
1458
1503
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(transactionMeta.networkClientId) && transactionMeta.txParams.type !== "0x0" /* legacy */;
|
|
1459
1504
|
const { networkClientId, chainId } = transactionMeta;
|
|
1460
|
-
const isCustomNetwork =
|
|
1461
|
-
`NetworkController:getNetworkClientById`,
|
|
1462
|
-
networkClientId
|
|
1463
|
-
).configuration.type === NetworkClientType.Custom : this.getNetworkState().providerConfig.type === NetworkType.rpc;
|
|
1505
|
+
const isCustomNetwork = __privateMethod(this, _isCustomNetwork, isCustomNetwork_fn).call(this, networkClientId);
|
|
1464
1506
|
const ethQuery = __privateGet(this, _multichainTrackingHelper).getEthQuery({
|
|
1465
1507
|
networkClientId,
|
|
1466
1508
|
chainId
|
|
@@ -1595,68 +1637,62 @@ var TransactionController = class extends BaseController {
|
|
|
1595
1637
|
* @param transactionId - The ID of the transaction to approve.
|
|
1596
1638
|
*/
|
|
1597
1639
|
async approveTransaction(transactionId) {
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
const transactionMeta = transactions[index];
|
|
1602
|
-
const updatedTransactionMeta = cloneDeep(transactionMeta);
|
|
1603
|
-
const {
|
|
1604
|
-
txParams: { from },
|
|
1605
|
-
networkClientId
|
|
1606
|
-
} = transactionMeta;
|
|
1607
|
-
let releaseNonceLock;
|
|
1640
|
+
const cleanupTasks = new Array();
|
|
1641
|
+
cleanupTasks.push(await this.mutex.acquire());
|
|
1642
|
+
let transactionMeta = this.getTransactionOrThrow(transactionId);
|
|
1608
1643
|
try {
|
|
1609
1644
|
if (!this.sign) {
|
|
1610
|
-
releaseLock();
|
|
1611
1645
|
this.failTransaction(
|
|
1612
1646
|
transactionMeta,
|
|
1613
1647
|
new Error("No sign method defined.")
|
|
1614
1648
|
);
|
|
1615
1649
|
return "not-approved" /* NotApproved */;
|
|
1616
1650
|
} else if (!transactionMeta.chainId) {
|
|
1617
|
-
releaseLock();
|
|
1618
1651
|
this.failTransaction(transactionMeta, new Error("No chainId defined."));
|
|
1619
1652
|
return "not-approved" /* NotApproved */;
|
|
1620
1653
|
}
|
|
1621
|
-
if (this.
|
|
1654
|
+
if (this.approvingTransactionIds.has(transactionId)) {
|
|
1622
1655
|
projectLogger("Skipping approval as signing in progress", transactionId);
|
|
1623
1656
|
return "not-approved" /* NotApproved */;
|
|
1624
1657
|
}
|
|
1658
|
+
this.approvingTransactionIds.add(transactionId);
|
|
1659
|
+
cleanupTasks.push(
|
|
1660
|
+
() => this.approvingTransactionIds.delete(transactionId)
|
|
1661
|
+
);
|
|
1625
1662
|
const [nonce, releaseNonce] = await getNextNonce(
|
|
1626
1663
|
transactionMeta,
|
|
1627
|
-
(address) => __privateGet(this, _multichainTrackingHelper).getNonceLock(
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
updatedTransactionMeta.txParams = {
|
|
1632
|
-
...updatedTransactionMeta.txParams,
|
|
1633
|
-
nonce,
|
|
1634
|
-
chainId: transactionMeta.chainId
|
|
1635
|
-
};
|
|
1636
|
-
const baseTxParams = {
|
|
1637
|
-
...updatedTransactionMeta.txParams,
|
|
1638
|
-
gasLimit: updatedTransactionMeta.txParams.gas
|
|
1639
|
-
};
|
|
1640
|
-
this.updateTransaction(
|
|
1641
|
-
updatedTransactionMeta,
|
|
1642
|
-
"TransactionController#approveTransaction - Transaction approved"
|
|
1664
|
+
(address) => __privateGet(this, _multichainTrackingHelper).getNonceLock(
|
|
1665
|
+
address,
|
|
1666
|
+
transactionMeta.networkClientId
|
|
1667
|
+
)
|
|
1643
1668
|
);
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1669
|
+
releaseNonce && cleanupTasks.push(releaseNonce);
|
|
1670
|
+
transactionMeta = __privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, {
|
|
1671
|
+
transactionId,
|
|
1672
|
+
note: "TransactionController#approveTransaction - Transaction approved"
|
|
1673
|
+
}, (draftTxMeta) => {
|
|
1674
|
+
const { txParams, chainId } = draftTxMeta;
|
|
1675
|
+
draftTxMeta.status = "approved" /* approved */;
|
|
1676
|
+
draftTxMeta.txParams = {
|
|
1677
|
+
...txParams,
|
|
1678
|
+
nonce,
|
|
1679
|
+
chainId,
|
|
1680
|
+
gasLimit: txParams.gas,
|
|
1681
|
+
...isEIP1559Transaction(txParams) && {
|
|
1682
|
+
type: "0x2" /* feeMarket */
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
});
|
|
1686
|
+
this.onTransactionStatusChange(transactionMeta);
|
|
1651
1687
|
const rawTx = await this.signTransaction(
|
|
1652
|
-
|
|
1653
|
-
txParams
|
|
1688
|
+
transactionMeta,
|
|
1689
|
+
transactionMeta.txParams
|
|
1654
1690
|
);
|
|
1655
|
-
if (!this.beforePublish(
|
|
1691
|
+
if (!this.beforePublish(transactionMeta)) {
|
|
1656
1692
|
projectLogger("Skipping publishing transaction based on hook");
|
|
1657
1693
|
this.messagingSystem.publish(
|
|
1658
1694
|
`${controllerName}:transactionPublishingSkipped`,
|
|
1659
|
-
|
|
1695
|
+
transactionMeta
|
|
1660
1696
|
);
|
|
1661
1697
|
return "skipped-via-before-publish-hook" /* SkippedViaBeforePublishHook */;
|
|
1662
1698
|
}
|
|
@@ -1667,51 +1703,50 @@ var TransactionController = class extends BaseController {
|
|
|
1667
1703
|
networkClientId: transactionMeta.networkClientId,
|
|
1668
1704
|
chainId: transactionMeta.chainId
|
|
1669
1705
|
});
|
|
1670
|
-
|
|
1706
|
+
let preTxBalance;
|
|
1707
|
+
const shouldUpdatePreTxBalance = transactionMeta.type === "swap" /* swap */;
|
|
1708
|
+
if (shouldUpdatePreTxBalance) {
|
|
1671
1709
|
projectLogger("Determining pre-transaction balance");
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
"Updated pre-transaction balance",
|
|
1676
|
-
updatedTransactionMeta.preTxBalance
|
|
1677
|
-
);
|
|
1710
|
+
preTxBalance = await query(ethQuery, "getBalance", [
|
|
1711
|
+
transactionMeta.txParams.from
|
|
1712
|
+
]);
|
|
1678
1713
|
}
|
|
1679
|
-
projectLogger("Publishing transaction", txParams);
|
|
1714
|
+
projectLogger("Publishing transaction", transactionMeta.txParams);
|
|
1680
1715
|
let { transactionHash: hash } = await this.publish(
|
|
1681
|
-
|
|
1716
|
+
transactionMeta,
|
|
1682
1717
|
rawTx
|
|
1683
1718
|
);
|
|
1684
1719
|
if (hash === void 0) {
|
|
1685
1720
|
hash = await this.publishTransaction(ethQuery, rawTx);
|
|
1686
1721
|
}
|
|
1687
1722
|
projectLogger("Publish successful", hash);
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
"
|
|
1694
|
-
|
|
1723
|
+
transactionMeta = __privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, {
|
|
1724
|
+
transactionId,
|
|
1725
|
+
note: "TransactionController#approveTransaction - Transaction submitted"
|
|
1726
|
+
}, (draftTxMeta) => {
|
|
1727
|
+
draftTxMeta.hash = hash;
|
|
1728
|
+
draftTxMeta.status = "submitted" /* submitted */;
|
|
1729
|
+
draftTxMeta.submittedTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1730
|
+
if (shouldUpdatePreTxBalance) {
|
|
1731
|
+
draftTxMeta.preTxBalance = preTxBalance;
|
|
1732
|
+
projectLogger("Updated pre-transaction balance", preTxBalance);
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1695
1735
|
this.messagingSystem.publish(`${controllerName}:transactionSubmitted`, {
|
|
1696
|
-
transactionMeta
|
|
1736
|
+
transactionMeta
|
|
1697
1737
|
});
|
|
1698
1738
|
this.messagingSystem.publish(
|
|
1699
1739
|
`${controllerName}:transactionFinished`,
|
|
1700
|
-
|
|
1701
|
-
);
|
|
1702
|
-
__privateGet(this, _internalEvents).emit(
|
|
1703
|
-
`${updatedTransactionMeta.id}:finished`,
|
|
1704
|
-
updatedTransactionMeta
|
|
1740
|
+
transactionMeta
|
|
1705
1741
|
);
|
|
1706
|
-
this.
|
|
1742
|
+
__privateGet(this, _internalEvents).emit(`${transactionId}:finished`, transactionMeta);
|
|
1743
|
+
this.onTransactionStatusChange(transactionMeta);
|
|
1707
1744
|
return "approved" /* Approved */;
|
|
1708
1745
|
} catch (error) {
|
|
1709
1746
|
this.failTransaction(transactionMeta, error);
|
|
1710
1747
|
return "not-approved" /* NotApproved */;
|
|
1711
1748
|
} finally {
|
|
1712
|
-
|
|
1713
|
-
releaseNonceLock?.();
|
|
1714
|
-
releaseLock();
|
|
1749
|
+
cleanupTasks.forEach((task) => task());
|
|
1715
1750
|
}
|
|
1716
1751
|
}
|
|
1717
1752
|
async publishTransaction(ethQuery, rawTransaction) {
|
|
@@ -1833,6 +1868,15 @@ var TransactionController = class extends BaseController {
|
|
|
1833
1868
|
const { transactions } = this.state;
|
|
1834
1869
|
return transactions.find(({ id }) => id === transactionId);
|
|
1835
1870
|
}
|
|
1871
|
+
getTransactionOrThrow(transactionId, errorMessagePrefix = "TransactionController") {
|
|
1872
|
+
const txMeta = this.getTransaction(transactionId);
|
|
1873
|
+
if (!txMeta) {
|
|
1874
|
+
throw new Error(
|
|
1875
|
+
`${errorMessagePrefix}: No transaction found with id ${transactionId}`
|
|
1876
|
+
);
|
|
1877
|
+
}
|
|
1878
|
+
return txMeta;
|
|
1879
|
+
}
|
|
1836
1880
|
getApprovalId(txMeta) {
|
|
1837
1881
|
return String(txMeta.id);
|
|
1838
1882
|
}
|
|
@@ -1845,14 +1889,15 @@ var TransactionController = class extends BaseController {
|
|
|
1845
1889
|
return { meta: transaction, isCompleted };
|
|
1846
1890
|
}
|
|
1847
1891
|
getChainId(networkClientId) {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
).configuration.chainId;
|
|
1892
|
+
const globalChainId = __privateMethod(this, _getGlobalChainId, getGlobalChainId_fn).call(this);
|
|
1893
|
+
const globalNetworkClientId = __privateMethod(this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
1894
|
+
if (!networkClientId || networkClientId === globalNetworkClientId) {
|
|
1895
|
+
return globalChainId;
|
|
1853
1896
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1897
|
+
return this.messagingSystem.call(
|
|
1898
|
+
`NetworkController:getNetworkClientById`,
|
|
1899
|
+
networkClientId
|
|
1900
|
+
).configuration.chainId;
|
|
1856
1901
|
}
|
|
1857
1902
|
prepareUnsignedEthTx(chainId, txParams) {
|
|
1858
1903
|
return TransactionFactory.fromTxData(txParams, {
|
|
@@ -2040,8 +2085,9 @@ var TransactionController = class extends BaseController {
|
|
|
2040
2085
|
*
|
|
2041
2086
|
* @param transactionMeta - The TransactionMeta object to update.
|
|
2042
2087
|
* @param signedTx - The encompassing type for all transaction types containing r, s, and v values.
|
|
2088
|
+
* @returns The updated TransactionMeta object.
|
|
2043
2089
|
*/
|
|
2044
|
-
|
|
2090
|
+
updateTransactionMetaRSV(transactionMeta, signedTx) {
|
|
2045
2091
|
const transactionMetaWithRsv = cloneDeep(transactionMeta);
|
|
2046
2092
|
for (const key of ["r", "s", "v"]) {
|
|
2047
2093
|
const value = signedTx[key];
|
|
@@ -2063,7 +2109,7 @@ var TransactionController = class extends BaseController {
|
|
|
2063
2109
|
transactionMeta.chainId,
|
|
2064
2110
|
txParams
|
|
2065
2111
|
);
|
|
2066
|
-
this.
|
|
2112
|
+
this.approvingTransactionIds.add(transactionMeta.id);
|
|
2067
2113
|
const signedTx = await new Promise((resolve, reject) => {
|
|
2068
2114
|
this.sign?.(
|
|
2069
2115
|
unsignedEthTx,
|
|
@@ -2089,7 +2135,7 @@ var TransactionController = class extends BaseController {
|
|
|
2089
2135
|
return void 0;
|
|
2090
2136
|
}
|
|
2091
2137
|
const transactionMetaWithRsv = {
|
|
2092
|
-
...
|
|
2138
|
+
...this.updateTransactionMetaRSV(transactionMeta, signedTx),
|
|
2093
2139
|
status: "signed" /* signed */
|
|
2094
2140
|
};
|
|
2095
2141
|
this.updateTransaction(
|
|
@@ -2187,6 +2233,7 @@ _incomingTransactionOptions = new WeakMap();
|
|
|
2187
2233
|
_pendingTransactionOptions = new WeakMap();
|
|
2188
2234
|
_transactionHistoryLimit = new WeakMap();
|
|
2189
2235
|
_isSimulationEnabled = new WeakMap();
|
|
2236
|
+
_testGasFeeFlows = new WeakMap();
|
|
2190
2237
|
_multichainTrackingHelper = new WeakMap();
|
|
2191
2238
|
_createNonceTracker = new WeakSet();
|
|
2192
2239
|
createNonceTracker_fn = function({
|
|
@@ -2326,6 +2373,9 @@ getNonceTrackerPendingTransactions_fn = function(chainId, address) {
|
|
|
2326
2373
|
};
|
|
2327
2374
|
_getGasFeeFlows = new WeakSet();
|
|
2328
2375
|
getGasFeeFlows_fn = function() {
|
|
2376
|
+
if (__privateGet(this, _testGasFeeFlows)) {
|
|
2377
|
+
return [new TestGasFeeFlow()];
|
|
2378
|
+
}
|
|
2329
2379
|
return [new LineaGasFeeFlow(), new DefaultGasFeeFlow()];
|
|
2330
2380
|
};
|
|
2331
2381
|
_getLayer1GasFeeFlows = new WeakSet();
|
|
@@ -2364,6 +2414,7 @@ updateTransactionInternal_fn = function({
|
|
|
2364
2414
|
if (updatedTransactionParams.length > 0) {
|
|
2365
2415
|
__privateMethod(this, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn).call(this, transactionMeta, updatedTransactionParams);
|
|
2366
2416
|
}
|
|
2417
|
+
return transactionMeta;
|
|
2367
2418
|
};
|
|
2368
2419
|
_checkIfTransactionParamsUpdated = new WeakSet();
|
|
2369
2420
|
checkIfTransactionParamsUpdated_fn = function(newTransactionMeta) {
|
|
@@ -2453,6 +2504,43 @@ onGasFeePollerTransactionUpdate_fn = function({
|
|
|
2453
2504
|
}
|
|
2454
2505
|
});
|
|
2455
2506
|
};
|
|
2507
|
+
_getNetworkClientId = new WeakSet();
|
|
2508
|
+
getNetworkClientId_fn = function({
|
|
2509
|
+
networkClientId: requestNetworkClientId,
|
|
2510
|
+
chainId
|
|
2511
|
+
}) {
|
|
2512
|
+
const globalChainId = __privateMethod(this, _getGlobalChainId, getGlobalChainId_fn).call(this);
|
|
2513
|
+
const globalNetworkClientId = __privateMethod(this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
2514
|
+
if (requestNetworkClientId) {
|
|
2515
|
+
return requestNetworkClientId;
|
|
2516
|
+
}
|
|
2517
|
+
if (!chainId || chainId === globalChainId) {
|
|
2518
|
+
return globalNetworkClientId;
|
|
2519
|
+
}
|
|
2520
|
+
return this.messagingSystem.call(
|
|
2521
|
+
`NetworkController:findNetworkClientIdByChainId`,
|
|
2522
|
+
chainId
|
|
2523
|
+
);
|
|
2524
|
+
};
|
|
2525
|
+
_getGlobalNetworkClientId = new WeakSet();
|
|
2526
|
+
getGlobalNetworkClientId_fn = function() {
|
|
2527
|
+
return this.getNetworkState().selectedNetworkClientId;
|
|
2528
|
+
};
|
|
2529
|
+
_getGlobalChainId = new WeakSet();
|
|
2530
|
+
getGlobalChainId_fn = function() {
|
|
2531
|
+
return this.getNetworkState().providerConfig.chainId;
|
|
2532
|
+
};
|
|
2533
|
+
_isCustomNetwork = new WeakSet();
|
|
2534
|
+
isCustomNetwork_fn = function(networkClientId) {
|
|
2535
|
+
const globalNetworkClientId = __privateMethod(this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
2536
|
+
if (!networkClientId || networkClientId === globalNetworkClientId) {
|
|
2537
|
+
return this.getNetworkState().providerConfig.type === NetworkType.rpc;
|
|
2538
|
+
}
|
|
2539
|
+
return this.messagingSystem.call(
|
|
2540
|
+
`NetworkController:getNetworkClientById`,
|
|
2541
|
+
networkClientId
|
|
2542
|
+
).configuration.type === NetworkClientType.Custom;
|
|
2543
|
+
};
|
|
2456
2544
|
|
|
2457
2545
|
export {
|
|
2458
2546
|
HARDFORK,
|
|
@@ -2461,4 +2549,4 @@ export {
|
|
|
2461
2549
|
ApprovalState,
|
|
2462
2550
|
TransactionController
|
|
2463
2551
|
};
|
|
2464
|
-
//# sourceMappingURL=chunk-
|
|
2552
|
+
//# sourceMappingURL=chunk-26BABWPE.mjs.map
|