@metamask-previews/transaction-controller 49.0.0-preview-b4d33c51 → 49.0.0-preview-3db01c5
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 +0 -13
- package/dist/TransactionController.cjs +41 -48
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +8 -0
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +8 -0
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +42 -49
- 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 +12 -21
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +12 -21
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +1 -19
- package/dist/utils/batch.cjs.map +1 -1
- package/dist/utils/batch.d.cts +1 -1
- package/dist/utils/batch.d.cts.map +1 -1
- package/dist/utils/batch.d.mts +1 -1
- package/dist/utils/batch.d.mts.map +1 -1
- package/dist/utils/batch.mjs +1 -19
- package/dist/utils/batch.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,19 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Add additional metadata for batch metrics ([#5488](https://github.com/MetaMask/core/pull/5488))
|
|
13
|
-
- Add `delegationAddress` to `TransactionMetadata`.
|
|
14
|
-
- Add `NestedTransactionMetadata` type containing `BatchTransactionParams` and `type`.
|
|
15
|
-
- Add optional `type` to `TransactionBatchSingleRequest`.
|
|
16
|
-
|
|
17
|
-
### Changed
|
|
18
|
-
|
|
19
|
-
- **BREAKING:** Add additional metadata for batch metrics ([#5488](https://github.com/MetaMask/core/pull/5488))
|
|
20
|
-
- Change `error` in `TransactionMetadata` to optional for all statuses.
|
|
21
|
-
- Change `nestedTransactions` in `TransactionMetadata` to array of `NestedTransactionMetadata`.
|
|
22
|
-
|
|
23
10
|
## [49.0.0]
|
|
24
11
|
|
|
25
12
|
### Added
|
|
@@ -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_incomingTransactionChainIds, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction,
|
|
16
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionChainIds, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _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;
|
|
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");
|
|
@@ -395,7 +395,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
395
395
|
networkClientId,
|
|
396
396
|
});
|
|
397
397
|
const transactionType = type ?? (await (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
|
|
398
|
-
const { delegationAddress } = await (0, eip7702_1.isAccountUpgradedToEIP7702)(txParams.from, chainId, this.messagingSystem, ethQuery);
|
|
399
398
|
const existingTransactionMeta = this.getTransactionWithActionId(actionId);
|
|
400
399
|
// If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.
|
|
401
400
|
let addedTransactionMeta = existingTransactionMeta
|
|
@@ -406,7 +405,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
406
405
|
batchId,
|
|
407
406
|
chainId,
|
|
408
407
|
dappSuggestedGasFees,
|
|
409
|
-
delegationAddress,
|
|
410
408
|
deviceConfirmedOn,
|
|
411
409
|
id: (0, uuid_1.v1)(),
|
|
412
410
|
isFirstTimeInteraction: undefined,
|
|
@@ -441,7 +439,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
441
439
|
}
|
|
442
440
|
addedTransactionMeta = (0, swaps_1.updateSwapsTransaction)(addedTransactionMeta, transactionType, swaps, {
|
|
443
441
|
isSwapsDisabled: this.isSwapsDisabled,
|
|
444
|
-
cancelTransaction:
|
|
442
|
+
cancelTransaction: this.cancelTransaction.bind(this),
|
|
445
443
|
messenger: this.messagingSystem,
|
|
446
444
|
});
|
|
447
445
|
this.addMetadata(addedTransactionMeta);
|
|
@@ -1241,13 +1239,18 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1241
1239
|
actionId,
|
|
1242
1240
|
});
|
|
1243
1241
|
}
|
|
1242
|
+
// TODO: Replace `any` with type
|
|
1243
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1244
1244
|
}
|
|
1245
|
-
catch (
|
|
1246
|
-
const error = rawError;
|
|
1245
|
+
catch (error) {
|
|
1247
1246
|
const { isCompleted: isTxCompleted } = this.isTransactionCompleted(transactionId);
|
|
1248
1247
|
if (!isTxCompleted) {
|
|
1249
|
-
if (
|
|
1250
|
-
|
|
1248
|
+
if (error?.code === rpc_errors_1.errorCodes.provider.userRejectedRequest) {
|
|
1249
|
+
this.cancelTransaction(transactionId, actionId);
|
|
1250
|
+
throw rpc_errors_1.providerErrors.userRejectedRequest({
|
|
1251
|
+
message: 'MetaMask Tx Signature: User denied transaction signature.',
|
|
1252
|
+
data: error?.data,
|
|
1253
|
+
});
|
|
1251
1254
|
}
|
|
1252
1255
|
else {
|
|
1253
1256
|
this.failTransaction(meta, error, actionId);
|
|
@@ -1258,9 +1261,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1258
1261
|
const finalMeta = await finishedPromise;
|
|
1259
1262
|
switch (finalMeta?.status) {
|
|
1260
1263
|
case types_1.TransactionStatus.failed:
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
throw rpc_errors_1.rpcErrors.internal(error.message);
|
|
1264
|
+
resultCallbacks?.error(finalMeta.error);
|
|
1265
|
+
throw rpc_errors_1.rpcErrors.internal(finalMeta.error.message);
|
|
1264
1266
|
case types_1.TransactionStatus.submitted:
|
|
1265
1267
|
resultCallbacks?.success();
|
|
1266
1268
|
return finalMeta.hash;
|
|
@@ -1387,6 +1389,34 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1387
1389
|
}
|
|
1388
1390
|
return transactionHash;
|
|
1389
1391
|
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Cancels a transaction based on its ID by setting its status to "rejected"
|
|
1394
|
+
* and emitting a `<tx.id>:finished` hub event.
|
|
1395
|
+
*
|
|
1396
|
+
* @param transactionId - The ID of the transaction to cancel.
|
|
1397
|
+
* @param actionId - The actionId passed from UI
|
|
1398
|
+
*/
|
|
1399
|
+
cancelTransaction(transactionId, actionId) {
|
|
1400
|
+
const transactionMeta = this.state.transactions.find(({ id }) => id === transactionId);
|
|
1401
|
+
if (!transactionMeta) {
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
this.update((state) => {
|
|
1405
|
+
const transactions = state.transactions.filter(({ id }) => id !== transactionId);
|
|
1406
|
+
state.transactions = this.trimTransactionsForState(transactions);
|
|
1407
|
+
});
|
|
1408
|
+
const updatedTransactionMeta = {
|
|
1409
|
+
...transactionMeta,
|
|
1410
|
+
status: types_1.TransactionStatus.rejected,
|
|
1411
|
+
};
|
|
1412
|
+
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1413
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1414
|
+
this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
|
|
1415
|
+
transactionMeta: updatedTransactionMeta,
|
|
1416
|
+
actionId,
|
|
1417
|
+
});
|
|
1418
|
+
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
1419
|
+
}
|
|
1390
1420
|
/**
|
|
1391
1421
|
* Trim the amount of transactions that are set on the state. Checks
|
|
1392
1422
|
* if the length of the tx history is longer then desired persistence
|
|
@@ -1829,24 +1859,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1829
1859
|
actionId,
|
|
1830
1860
|
});
|
|
1831
1861
|
afterSubmit?.(newTransactionMeta);
|
|
1832
|
-
}, _TransactionController_rejectTransaction = function _TransactionController_rejectTransaction(transactionId, actionId, error) {
|
|
1833
|
-
const transactionMeta = this.getTransaction(transactionId);
|
|
1834
|
-
if (!transactionMeta) {
|
|
1835
|
-
return;
|
|
1836
|
-
}
|
|
1837
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_deleteTransaction).call(this, transactionId);
|
|
1838
|
-
const updatedTransactionMeta = {
|
|
1839
|
-
...transactionMeta,
|
|
1840
|
-
status: types_1.TransactionStatus.rejected,
|
|
1841
|
-
error: (0, utils_2.normalizeTxError)(error ?? rpc_errors_1.providerErrors.userRejectedRequest()),
|
|
1842
|
-
};
|
|
1843
|
-
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1844
|
-
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1845
|
-
this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
|
|
1846
|
-
transactionMeta: updatedTransactionMeta,
|
|
1847
|
-
actionId,
|
|
1848
|
-
});
|
|
1849
|
-
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
1850
1862
|
}, _TransactionController_getChainId = function _TransactionController_getChainId(networkClientId) {
|
|
1851
1863
|
return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
|
|
1852
1864
|
.configuration.chainId;
|
|
@@ -2094,24 +2106,5 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2094
2106
|
isCustomNetwork,
|
|
2095
2107
|
txMeta: transactionMeta,
|
|
2096
2108
|
});
|
|
2097
|
-
}, _TransactionController_deleteTransaction = function _TransactionController_deleteTransaction(transactionId) {
|
|
2098
|
-
this.update((state) => {
|
|
2099
|
-
const transactions = state.transactions.filter(({ id }) => id !== transactionId);
|
|
2100
|
-
state.transactions = this.trimTransactionsForState(transactions);
|
|
2101
|
-
});
|
|
2102
|
-
}, _TransactionController_isRejectError = function _TransactionController_isRejectError(error) {
|
|
2103
|
-
return [
|
|
2104
|
-
rpc_errors_1.errorCodes.provider.userRejectedRequest,
|
|
2105
|
-
rpc_errors_1.errorCodes.rpc.methodNotSupported,
|
|
2106
|
-
].includes(error.code);
|
|
2107
|
-
}, _TransactionController_rejectTransactionAndThrow = function _TransactionController_rejectTransactionAndThrow(transactionId, actionId, error) {
|
|
2108
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransaction).call(this, transactionId, actionId, error);
|
|
2109
|
-
if (error.code === rpc_errors_1.errorCodes.provider.userRejectedRequest) {
|
|
2110
|
-
throw rpc_errors_1.providerErrors.userRejectedRequest({
|
|
2111
|
-
message: 'MetaMask Tx Signature: User denied transaction signature.',
|
|
2112
|
-
data: error?.data,
|
|
2113
|
-
});
|
|
2114
|
-
}
|
|
2115
|
-
throw error;
|
|
2116
2109
|
};
|
|
2117
2110
|
//# sourceMappingURL=TransactionController.cjs.map
|