@metamask-previews/transaction-controller 52.1.0-preview-35da3ac → 52.1.0-preview-7ecf950
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 +8 -27
- package/dist/TransactionController.cjs +24 -89
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +5 -35
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +5 -35
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +24 -89
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +21 -120
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +21 -120
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +22 -121
- package/dist/utils/batch.cjs.map +1 -1
- package/dist/utils/batch.d.cts +1 -7
- package/dist/utils/batch.d.cts.map +1 -1
- package/dist/utils/batch.d.mts +1 -7
- package/dist/utils/batch.d.mts.map +1 -1
- package/dist/utils/batch.mjs +22 -121
- package/dist/utils/batch.mjs.map +1 -1
- package/dist/utils/eip7702.cjs +0 -12
- package/dist/utils/eip7702.cjs.map +1 -1
- package/dist/utils/eip7702.d.cts.map +1 -1
- package/dist/utils/eip7702.d.mts.map +1 -1
- package/dist/utils/eip7702.mjs +0 -12
- package/dist/utils/eip7702.mjs.map +1 -1
- package/dist/utils/gas.cjs +3 -7
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.mjs +3 -7
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/nonce.cjs +3 -3
- package/dist/utils/nonce.cjs.map +1 -1
- package/dist/utils/nonce.d.cts +2 -2
- package/dist/utils/nonce.d.cts.map +1 -1
- package/dist/utils/nonce.d.mts +2 -2
- package/dist/utils/nonce.d.mts.map +1 -1
- package/dist/utils/nonce.mjs +3 -3
- package/dist/utils/nonce.mjs.map +1 -1
- package/dist/utils/simulation-api.cjs.map +1 -1
- package/dist/utils/simulation-api.d.cts +0 -37
- package/dist/utils/simulation-api.d.cts.map +1 -1
- package/dist/utils/simulation-api.d.mts +0 -37
- package/dist/utils/simulation-api.d.mts.map +1 -1
- package/dist/utils/simulation-api.mjs.map +1 -1
- package/dist/utils/simulation.cjs +7 -46
- package/dist/utils/simulation.cjs.map +1 -1
- package/dist/utils/simulation.d.cts +2 -6
- package/dist/utils/simulation.d.cts.map +1 -1
- package/dist/utils/simulation.d.mts +2 -6
- package/dist/utils/simulation.d.mts.map +1 -1
- package/dist/utils/simulation.mjs +7 -46
- package/dist/utils/simulation.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/CollectPublishHook.cjs +0 -84
- package/dist/hooks/CollectPublishHook.cjs.map +0 -1
- package/dist/hooks/CollectPublishHook.d.cts +0 -29
- package/dist/hooks/CollectPublishHook.d.cts.map +0 -1
- package/dist/hooks/CollectPublishHook.d.mts +0 -29
- package/dist/hooks/CollectPublishHook.d.mts.map +0 -1
- package/dist/hooks/CollectPublishHook.mjs +0 -80
- package/dist/hooks/CollectPublishHook.mjs.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.cjs +0 -90
- package/dist/hooks/ExtraTransactionsPublishHook.cjs.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts +0 -18
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts +0 -18
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.mjs +0 -86
- package/dist/hooks/ExtraTransactionsPublishHook.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,30 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
- Add `
|
|
14
|
-
- Add `
|
|
15
|
-
- Add `
|
|
16
|
-
-
|
|
17
|
-
- Add `hooks.publishBatch` option to constructor.
|
|
18
|
-
- Add `updateBatchTransactions` method.
|
|
19
|
-
- Add `maxFeePerGas` and `maxPriorityFeePerGas` to `updateEditableParams` options.
|
|
20
|
-
- Add types.
|
|
21
|
-
- `PublishBatchHook`
|
|
22
|
-
- `PublishBatchHookRequest`
|
|
23
|
-
- `PublishBatchHookResult`
|
|
24
|
-
- `PublishBatchHookTransaction`
|
|
25
|
-
- `PublishHook`
|
|
26
|
-
- `PublishHookResult`
|
|
27
|
-
- Add optional properties to `TransactionMeta`.
|
|
28
|
-
- `batchTransactions`
|
|
29
|
-
- `disableGasBuffer`
|
|
30
|
-
- Add optional properties to `BatchTransactionParams`.
|
|
31
|
-
- `gas`
|
|
32
|
-
- `maxFeePerGas`
|
|
33
|
-
- `maxPriorityFeePerGas`
|
|
34
|
-
- Add optional `existingTransaction` property to `TransactionBatchSingleRequest`.
|
|
35
|
-
- Add optional `useHook` property to `TransactionBatchRequest`.
|
|
12
|
+
- Support security validation of transaction batches ([#5526](https://github.com/MetaMask/core/pull/5526))
|
|
13
|
+
- Add `ValidateSecurityRequest` type.
|
|
14
|
+
- Add optional `securityAlertId` to `SecurityAlertResponse`.
|
|
15
|
+
- Add optional `securityAlertId` to `TransactionBatchRequest`.
|
|
16
|
+
- Add optional `validateSecurity` callback to `TransactionBatchRequest`.
|
|
36
17
|
|
|
37
18
|
## [52.1.0]
|
|
38
19
|
|
|
@@ -68,7 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
68
49
|
### Added
|
|
69
50
|
|
|
70
51
|
- Add additional metadata for batch metrics ([#5488](https://github.com/MetaMask/core/pull/5488))
|
|
71
|
-
- Add `delegationAddress` to `
|
|
52
|
+
- Add `delegationAddress` to `TransactionMetadata`.
|
|
72
53
|
- Add `NestedTransactionMetadata` type containing `BatchTransactionParams` and `type`.
|
|
73
54
|
- Add optional `type` to `TransactionBatchSingleRequest`.
|
|
74
55
|
- Verify EIP-7702 contract address using signatures ([#5472](https://github.com/MetaMask/core/pull/5472))
|
|
@@ -79,8 +60,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
79
60
|
|
|
80
61
|
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency to `^26.1.0` ([#5481](https://github.com/MetaMask/core/pull/5481))
|
|
81
62
|
- **BREAKING:** Add additional metadata for batch metrics ([#5488](https://github.com/MetaMask/core/pull/5488))
|
|
82
|
-
- Change `error` in `
|
|
83
|
-
- Change `nestedTransactions` in `
|
|
63
|
+
- Change `error` in `TransactionMetadata` to optional for all statuses.
|
|
64
|
+
- Change `nestedTransactions` in `TransactionMetadata` to array of `NestedTransactionMetadata`.
|
|
84
65
|
- Throw if `addTransactionBatch` called with external origin and size limit exceeded ([#5489](https://github.com/MetaMask/core/pull/5489))
|
|
85
66
|
- Verify EIP-7702 contract address using signatures ([#5472](https://github.com/MetaMask/core/pull/5472))
|
|
86
67
|
- Use new `contracts` property from feature flags instead of `contractAddresses`.
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions,
|
|
16
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_publicKeyEIP7702, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_rejectTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateFirstTimeInteraction, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_getInternalAccounts, _TransactionController_updateSubmitHistory, _TransactionController_updateGasEstimate, _TransactionController_deleteTransaction, _TransactionController_isRejectError, _TransactionController_rejectTransactionAndThrow;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
19
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -23,6 +23,7 @@ const network_controller_1 = require("@metamask/network-controller");
|
|
|
23
23
|
const nonce_tracker_1 = require("@metamask/nonce-tracker");
|
|
24
24
|
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
25
25
|
const utils_1 = require("@metamask/utils");
|
|
26
|
+
const async_mutex_1 = require("async-mutex");
|
|
26
27
|
// This package purposefully relies on Node's EventEmitter module.
|
|
27
28
|
// eslint-disable-next-line import-x/no-nodejs-modules
|
|
28
29
|
const events_1 = require("events");
|
|
@@ -41,7 +42,6 @@ const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
|
|
|
41
42
|
const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
|
|
42
43
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
43
44
|
const ResimulateHelper_1 = require("./helpers/ResimulateHelper.cjs");
|
|
44
|
-
const ExtraTransactionsPublishHook_1 = require("./hooks/ExtraTransactionsPublishHook.cjs");
|
|
45
45
|
const logger_1 = require("./logger.cjs");
|
|
46
46
|
const types_1 = require("./types.cjs");
|
|
47
47
|
const batch_1 = require("./utils/batch.cjs");
|
|
@@ -170,10 +170,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
170
170
|
_TransactionController_internalEvents.set(this, new events_1.EventEmitter());
|
|
171
171
|
this.approvingTransactionIds = new Set();
|
|
172
172
|
_TransactionController_methodDataHelper.set(this, void 0);
|
|
173
|
+
this.mutex = new async_mutex_1.Mutex();
|
|
173
174
|
_TransactionController_incomingTransactionHelper.set(this, void 0);
|
|
174
175
|
_TransactionController_incomingTransactionOptions.set(this, void 0);
|
|
175
176
|
_TransactionController_pendingTransactionOptions.set(this, void 0);
|
|
176
|
-
_TransactionController_publishBatchHook.set(this, void 0);
|
|
177
177
|
_TransactionController_publicKeyEIP7702.set(this, void 0);
|
|
178
178
|
this.signAbortCallbacks = new Map();
|
|
179
179
|
_TransactionController_trace.set(this, void 0);
|
|
@@ -206,7 +206,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
206
206
|
this.securityProviderRequest = securityProviderRequest;
|
|
207
207
|
__classPrivateFieldSet(this, _TransactionController_incomingTransactionOptions, incomingTransactions, "f");
|
|
208
208
|
__classPrivateFieldSet(this, _TransactionController_pendingTransactionOptions, pendingTransactions, "f");
|
|
209
|
-
__classPrivateFieldSet(this, _TransactionController_publishBatchHook, hooks?.publishBatch, "f");
|
|
210
209
|
__classPrivateFieldSet(this, _TransactionController_publicKeyEIP7702, publicKeyEIP7702, "f");
|
|
211
210
|
__classPrivateFieldSet(this, _TransactionController_transactionHistoryLimit, transactionHistoryLimit, "f");
|
|
212
211
|
this.sign = sign;
|
|
@@ -321,12 +320,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
321
320
|
getChainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).bind(this),
|
|
322
321
|
getEthQuery: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
|
|
323
322
|
getInternalAccounts: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).bind(this),
|
|
324
|
-
getTransaction: (transactionId) => this.getTransactionOrThrow(transactionId),
|
|
325
323
|
messenger: this.messagingSystem,
|
|
326
|
-
publishBatchHook: __classPrivateFieldGet(this, _TransactionController_publishBatchHook, "f"),
|
|
327
324
|
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
328
325
|
request,
|
|
329
|
-
updateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).bind(this),
|
|
330
326
|
});
|
|
331
327
|
}
|
|
332
328
|
/**
|
|
@@ -353,11 +349,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
353
349
|
* @param options.actionId - Unique ID to prevent duplicate requests.
|
|
354
350
|
* @param options.batchId - A custom ID for the batch this transaction belongs to.
|
|
355
351
|
* @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
|
|
356
|
-
* @param options.disableGasBuffer - Whether to disable the gas estimation buffer.
|
|
357
352
|
* @param options.method - RPC method that requested the transaction.
|
|
358
353
|
* @param options.nestedTransactions - Params for any nested transactions encoded in the data.
|
|
359
354
|
* @param options.origin - The origin of the transaction request, such as a dApp hostname.
|
|
360
|
-
* @param options.publishHook - Custom logic to publish the transaction.
|
|
361
355
|
* @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
|
|
362
356
|
* @param options.securityAlertResponse - Response from security validator.
|
|
363
357
|
* @param options.sendFlowHistory - The sendFlowHistory entries to add.
|
|
@@ -371,7 +365,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
371
365
|
*/
|
|
372
366
|
async addTransaction(txParams, options) {
|
|
373
367
|
(0, logger_1.projectLogger)('Adding transaction', txParams, options);
|
|
374
|
-
const { actionId, batchId, deviceConfirmedOn,
|
|
368
|
+
const { actionId, batchId, deviceConfirmedOn, method, nestedTransactions, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
375
369
|
txParams = (0, utils_2.normalizeTransactionParams)(txParams);
|
|
376
370
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
377
371
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
@@ -400,7 +394,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
400
394
|
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
|
|
401
395
|
const isDuplicateBatchId = batchId?.length &&
|
|
402
396
|
this.state.transactions.some((tx) => tx.batchId?.toLowerCase() === batchId?.toLowerCase());
|
|
403
|
-
if (isDuplicateBatchId
|
|
397
|
+
if (isDuplicateBatchId) {
|
|
404
398
|
throw rpc_errors_1.rpcErrors.invalidInput('Batch ID already exists');
|
|
405
399
|
}
|
|
406
400
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
@@ -418,7 +412,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
418
412
|
dappSuggestedGasFees,
|
|
419
413
|
delegationAddress,
|
|
420
414
|
deviceConfirmedOn,
|
|
421
|
-
disableGasBuffer,
|
|
422
415
|
id: (0, uuid_1.v1)(),
|
|
423
416
|
isFirstTimeInteraction: undefined,
|
|
424
417
|
nestedTransactions,
|
|
@@ -476,10 +469,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
476
469
|
}
|
|
477
470
|
return {
|
|
478
471
|
result: this.processApproval(addedTransactionMeta, {
|
|
479
|
-
actionId,
|
|
480
472
|
isExisting: Boolean(existingTransactionMeta),
|
|
481
|
-
publishHook,
|
|
482
473
|
requireApproval,
|
|
474
|
+
actionId,
|
|
483
475
|
traceContext,
|
|
484
476
|
}),
|
|
485
477
|
transactionMeta: addedTransactionMeta,
|
|
@@ -802,16 +794,14 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
802
794
|
* @param txId - The ID of the transaction to update.
|
|
803
795
|
* @param params - The editable parameters to update.
|
|
804
796
|
* @param params.data - Data to pass with the transaction.
|
|
805
|
-
* @param params.from - Address to send the transaction from.
|
|
806
797
|
* @param params.gas - Maximum number of units of gas to use for the transaction.
|
|
807
798
|
* @param params.gasPrice - Price per gas for legacy transactions.
|
|
808
|
-
* @param params.
|
|
809
|
-
* @param params.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.
|
|
799
|
+
* @param params.from - Address to send the transaction from.
|
|
810
800
|
* @param params.to - Address to send the transaction to.
|
|
811
801
|
* @param params.value - Value associated with the transaction.
|
|
812
802
|
* @returns The updated transaction metadata.
|
|
813
803
|
*/
|
|
814
|
-
async updateEditableParams(txId, { data,
|
|
804
|
+
async updateEditableParams(txId, { data, gas, gasPrice, from, to, value, }) {
|
|
815
805
|
const transactionMeta = this.getTransaction(txId);
|
|
816
806
|
if (!transactionMeta) {
|
|
817
807
|
throw new Error(`Cannot update editable params as no transaction metadata found`);
|
|
@@ -825,8 +815,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
825
815
|
value,
|
|
826
816
|
gas,
|
|
827
817
|
gasPrice,
|
|
828
|
-
maxFeePerGas,
|
|
829
|
-
maxPriorityFeePerGas,
|
|
830
818
|
},
|
|
831
819
|
};
|
|
832
820
|
editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
|
|
@@ -1179,38 +1167,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1179
1167
|
});
|
|
1180
1168
|
return updatedTransactionMeta.txParams.data;
|
|
1181
1169
|
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Update the batch transactions associated with a transaction.
|
|
1184
|
-
* These transactions will be submitted with the main transaction as a batch.
|
|
1185
|
-
*
|
|
1186
|
-
* @param request - The request object.
|
|
1187
|
-
* @param request.transactionId - The ID of the transaction to update.
|
|
1188
|
-
* @param request.batchTransactions - The new batch transactions.
|
|
1189
|
-
*/
|
|
1190
|
-
updateBatchTransactions({ transactionId, batchTransactions, }) {
|
|
1191
|
-
(0, logger_1.projectLogger)('Updating batch transactions', { transactionId, batchTransactions });
|
|
1192
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1193
|
-
transactionId,
|
|
1194
|
-
note: 'TransactionController#updateBatchTransactions - Batch transactions updated',
|
|
1195
|
-
}, (transactionMeta) => {
|
|
1196
|
-
transactionMeta.batchTransactions = batchTransactions;
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
/**
|
|
1200
|
-
* Update the selected gas fee token for a transaction.
|
|
1201
|
-
*
|
|
1202
|
-
* @param transactionId - The ID of the transaction to update.
|
|
1203
|
-
* @param contractAddress - The contract address of the selected gas fee token.
|
|
1204
|
-
*/
|
|
1205
|
-
updateSelectedGasFeeToken(transactionId, contractAddress) {
|
|
1206
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1207
|
-
const hasMatchingGasFeeToken = transactionMeta.gasFeeTokens?.some((token) => token.tokenAddress.toLowerCase() === contractAddress.toLowerCase());
|
|
1208
|
-
if (!hasMatchingGasFeeToken) {
|
|
1209
|
-
throw new Error(`No matching gas fee token found with address - ${contractAddress}`);
|
|
1210
|
-
}
|
|
1211
|
-
transactionMeta.selectedGasFeeToken = contractAddress;
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
1170
|
addMetadata(transactionMeta) {
|
|
1215
1171
|
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
1216
1172
|
this.update((state) => {
|
|
@@ -1253,7 +1209,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1253
1209
|
this.failTransaction(transactionMeta, new Error('Transaction incomplete at startup'));
|
|
1254
1210
|
}
|
|
1255
1211
|
}
|
|
1256
|
-
async processApproval(transactionMeta, {
|
|
1212
|
+
async processApproval(transactionMeta, { isExisting = false, requireApproval, shouldShowRequest = true, actionId, traceContext, }) {
|
|
1257
1213
|
const transactionId = transactionMeta.id;
|
|
1258
1214
|
let resultCallbacks;
|
|
1259
1215
|
const { meta, isCompleted } = this.isTransactionCompleted(transactionId);
|
|
@@ -1280,7 +1236,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1280
1236
|
}
|
|
1281
1237
|
const { isCompleted: isTxCompleted } = this.isTransactionCompleted(transactionId);
|
|
1282
1238
|
if (!isTxCompleted) {
|
|
1283
|
-
const approvalResult = await this.approveTransaction(transactionId, traceContext
|
|
1239
|
+
const approvalResult = await this.approveTransaction(transactionId, traceContext);
|
|
1284
1240
|
if (approvalResult === ApprovalState.SkippedViaBeforePublishHook &&
|
|
1285
1241
|
resultCallbacks) {
|
|
1286
1242
|
resultCallbacks.success();
|
|
@@ -1328,14 +1284,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1328
1284
|
*
|
|
1329
1285
|
* @param transactionId - The ID of the transaction to approve.
|
|
1330
1286
|
* @param traceContext - The parent context for any new traces.
|
|
1331
|
-
* @param publishHookOverride - Custom logic to publish the transaction.
|
|
1332
1287
|
* @returns The state of the approval.
|
|
1333
1288
|
*/
|
|
1334
|
-
async approveTransaction(transactionId, traceContext
|
|
1335
|
-
|
|
1336
|
-
|
|
1289
|
+
async approveTransaction(transactionId, traceContext) {
|
|
1290
|
+
const cleanupTasks = new Array();
|
|
1291
|
+
cleanupTasks.push(await this.mutex.acquire());
|
|
1337
1292
|
let transactionMeta = this.getTransactionOrThrow(transactionId);
|
|
1338
|
-
(0, logger_1.projectLogger)('Approving transaction', transactionMeta);
|
|
1339
1293
|
try {
|
|
1340
1294
|
if (!this.sign) {
|
|
1341
1295
|
this.failTransaction(transactionMeta, new Error('No sign method defined.'));
|
|
@@ -1350,9 +1304,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1350
1304
|
return ApprovalState.NotApproved;
|
|
1351
1305
|
}
|
|
1352
1306
|
this.approvingTransactionIds.add(transactionId);
|
|
1353
|
-
|
|
1307
|
+
cleanupTasks.push(() => this.approvingTransactionIds.delete(transactionId));
|
|
1354
1308
|
const [nonce, releaseNonce] = await (0, nonce_1.getNextNonce)(transactionMeta, (address) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, transactionMeta.networkClientId));
|
|
1355
|
-
|
|
1309
|
+
// must set transaction to submitted/failed before releasing lock
|
|
1310
|
+
releaseNonce && cleanupTasks.push(releaseNonce);
|
|
1356
1311
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1357
1312
|
transactionId,
|
|
1358
1313
|
note: 'TransactionController#approveTransaction - Transaction approved',
|
|
@@ -1389,19 +1344,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1389
1344
|
}
|
|
1390
1345
|
(0, logger_1.projectLogger)('Publishing transaction', transactionMeta.txParams);
|
|
1391
1346
|
let hash;
|
|
1392
|
-
clearNonceLock?.();
|
|
1393
|
-
clearNonceLock = undefined;
|
|
1394
|
-
if (transactionMeta.batchTransactions?.length) {
|
|
1395
|
-
(0, logger_1.projectLogger)('Found batch transactions', transactionMeta.batchTransactions);
|
|
1396
|
-
const extraTransactionsPublishHook = new ExtraTransactionsPublishHook_1.ExtraTransactionsPublishHook({
|
|
1397
|
-
addTransactionBatch: this.addTransactionBatch.bind(this),
|
|
1398
|
-
transactions: transactionMeta.batchTransactions,
|
|
1399
|
-
});
|
|
1400
|
-
publishHookOverride = extraTransactionsPublishHook.getHook();
|
|
1401
|
-
}
|
|
1402
1347
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Publish', parentContext: traceContext }, async () => {
|
|
1403
|
-
|
|
1404
|
-
({ transactionHash: hash } = await publishHook(transactionMeta, rawTx));
|
|
1348
|
+
({ transactionHash: hash } = await this.publish(transactionMeta, rawTx));
|
|
1405
1349
|
if (hash === undefined) {
|
|
1406
1350
|
hash = await this.publishTransaction(ethQuery, {
|
|
1407
1351
|
...transactionMeta,
|
|
@@ -1437,8 +1381,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1437
1381
|
return ApprovalState.NotApproved;
|
|
1438
1382
|
}
|
|
1439
1383
|
finally {
|
|
1440
|
-
|
|
1441
|
-
clearNonceLock?.();
|
|
1384
|
+
cleanupTasks.forEach((task) => task());
|
|
1442
1385
|
}
|
|
1443
1386
|
}
|
|
1444
1387
|
async publishTransaction(ethQuery, transactionMeta, { skipSubmitHistory } = {}) {
|
|
@@ -1765,8 +1708,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1765
1708
|
transactionMeta,
|
|
1766
1709
|
});
|
|
1767
1710
|
}
|
|
1768
|
-
getNonceTrackerTransactions(
|
|
1769
|
-
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address,
|
|
1711
|
+
getNonceTrackerTransactions(status, address, chainId) {
|
|
1712
|
+
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, status, this.state.transactions);
|
|
1770
1713
|
}
|
|
1771
1714
|
onConfirmedTransaction(transactionMeta) {
|
|
1772
1715
|
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
@@ -1827,7 +1770,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1827
1770
|
}
|
|
1828
1771
|
}
|
|
1829
1772
|
exports.TransactionController = TransactionController;
|
|
1830
|
-
_TransactionController_internalEvents = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_incomingTransactionHelper = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(),
|
|
1773
|
+
_TransactionController_internalEvents = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_incomingTransactionHelper = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_publicKeyEIP7702 = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_transactionHistoryLimit = new WeakMap(), _TransactionController_isFirstTimeInteractionEnabled = new WeakMap(), _TransactionController_isSimulationEnabled = new WeakMap(), _TransactionController_testGasFeeFlows = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_retryTransaction = async function _TransactionController_retryTransaction({ actionId, afterSubmit, estimatedBaseFee, gasValues, label, prepareTransactionParams, rate, transactionId, transactionType, }) {
|
|
1831
1774
|
// If transaction is found for same action id, do not create a new transaction.
|
|
1832
1775
|
if (this.getTransactionWithActionId(actionId)) {
|
|
1833
1776
|
return;
|
|
@@ -1935,7 +1878,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1935
1878
|
// TODO: Fix types
|
|
1936
1879
|
blockTracker,
|
|
1937
1880
|
getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
|
|
1938
|
-
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this,
|
|
1881
|
+
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed, chainId),
|
|
1939
1882
|
});
|
|
1940
1883
|
}, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, networkClientId, }) {
|
|
1941
1884
|
const ethQuery = new eth_query_1.default(provider);
|
|
@@ -1974,11 +1917,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1974
1917
|
pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
|
|
1975
1918
|
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|
|
1976
1919
|
}, _TransactionController_getNonceTrackerPendingTransactions = function _TransactionController_getNonceTrackerPendingTransactions(chainId, address) {
|
|
1977
|
-
const standardPendingTransactions = this.getNonceTrackerTransactions(
|
|
1978
|
-
types_1.TransactionStatus.approved,
|
|
1979
|
-
types_1.TransactionStatus.signed,
|
|
1980
|
-
types_1.TransactionStatus.submitted,
|
|
1981
|
-
], address, chainId);
|
|
1920
|
+
const standardPendingTransactions = this.getNonceTrackerTransactions(types_1.TransactionStatus.submitted, address, chainId);
|
|
1982
1921
|
const externalPendingTransactions = this.getExternalPendingTransactions(address, chainId);
|
|
1983
1922
|
return [...standardPendingTransactions, ...externalPendingTransactions];
|
|
1984
1923
|
}, _TransactionController_getGasFeeFlows = function _TransactionController_getGasFeeFlows() {
|
|
@@ -2073,9 +2012,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2073
2012
|
},
|
|
2074
2013
|
tokenBalanceChanges: [],
|
|
2075
2014
|
};
|
|
2076
|
-
let gasFeeTokens = [];
|
|
2077
2015
|
if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
|
|
2078
|
-
|
|
2016
|
+
simulationData = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, simulation_1.getSimulationData)({
|
|
2079
2017
|
chainId,
|
|
2080
2018
|
from: from,
|
|
2081
2019
|
to: to,
|
|
@@ -2084,8 +2022,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2084
2022
|
}, {
|
|
2085
2023
|
blockTime,
|
|
2086
2024
|
}));
|
|
2087
|
-
gasFeeTokens = result?.gasFeeTokens;
|
|
2088
|
-
simulationData = result?.simulationData;
|
|
2089
2025
|
if (blockTime &&
|
|
2090
2026
|
prevSimulationData &&
|
|
2091
2027
|
(0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
|
|
@@ -2106,7 +2042,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2106
2042
|
note: 'TransactionController#updateSimulationData - Update simulation data',
|
|
2107
2043
|
skipResimulateCheck: Boolean(blockTime),
|
|
2108
2044
|
}, (txMeta) => {
|
|
2109
|
-
txMeta.gasFeeTokens = gasFeeTokens;
|
|
2110
2045
|
txMeta.simulationData = simulationData;
|
|
2111
2046
|
});
|
|
2112
2047
|
(0, logger_1.projectLogger)('Updated simulation data', transactionId, simulationData);
|