@metamask-previews/transaction-controller 44.0.0-preview-442894ce → 44.0.0-preview-43593c4e
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 +7 -0
- package/dist/TransactionController.cjs +38 -3
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +7 -0
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +7 -0
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +36 -1
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/{utils/resimulate.cjs → helpers/ResimulateHelper.cjs} +96 -4
- package/dist/helpers/ResimulateHelper.cjs.map +1 -0
- package/dist/{utils/resimulate.d.cts → helpers/ResimulateHelper.d.cts} +13 -1
- package/dist/helpers/ResimulateHelper.d.cts.map +1 -0
- package/dist/{utils/resimulate.d.mts → helpers/ResimulateHelper.d.mts} +13 -1
- package/dist/helpers/ResimulateHelper.d.mts.map +1 -0
- package/dist/{utils/resimulate.mjs → helpers/ResimulateHelper.mjs} +96 -5
- package/dist/helpers/ResimulateHelper.mjs.map +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +4 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/utils/resimulate.cjs.map +0 -1
- package/dist/utils/resimulate.d.cts.map +0 -1
- package/dist/utils/resimulate.d.mts.map +0 -1
- package/dist/utils/resimulate.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ 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
|
+
- Adds ability of re-simulating transaction depending on the `isActive` property on `transactionMeta` ([#5189](https://github.com/MetaMask/core/pull/5189))
|
|
13
|
+
- `isActive` property is expected to set by client.
|
|
14
|
+
- Re-simulation of transactions will occur every 3 seconds if `isActive` is `true`.
|
|
15
|
+
- Adds `setTransactionActive` function to update the `isActive` property on `transactionMeta`. ([#5189](https://github.com/MetaMask/core/pull/5189))
|
|
16
|
+
|
|
10
17
|
## [44.0.0]
|
|
11
18
|
|
|
12
19
|
### Changed
|
|
@@ -44,6 +44,7 @@ const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper
|
|
|
44
44
|
const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
|
|
45
45
|
const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
|
|
46
46
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
47
|
+
const ResimulateHelper_1 = require("./helpers/ResimulateHelper.cjs");
|
|
47
48
|
const logger_1 = require("./logger.cjs");
|
|
48
49
|
const types_1 = require("./types.cjs");
|
|
49
50
|
const external_transactions_1 = require("./utils/external-transactions.cjs");
|
|
@@ -53,7 +54,6 @@ const gas_flow_1 = require("./utils/gas-flow.cjs");
|
|
|
53
54
|
const history_1 = require("./utils/history.cjs");
|
|
54
55
|
const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
|
|
55
56
|
const nonce_1 = require("./utils/nonce.cjs");
|
|
56
|
-
const resimulate_1 = require("./utils/resimulate.cjs");
|
|
57
57
|
const retry_1 = require("./utils/retry.cjs");
|
|
58
58
|
const simulation_1 = require("./utils/simulation.cjs");
|
|
59
59
|
const swaps_1 = require("./utils/swaps.cjs");
|
|
@@ -304,6 +304,20 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
304
304
|
// when transactionsController state changes
|
|
305
305
|
// check for pending transactions and start polling if there are any
|
|
306
306
|
this.messagingSystem.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
|
|
307
|
+
new ResimulateHelper_1.ResimulateHelper({
|
|
308
|
+
simulateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).bind(this),
|
|
309
|
+
onTransactionsUpdate: (listener) => {
|
|
310
|
+
this.messagingSystem.subscribe('TransactionController:stateChange', (_newState, patches) => {
|
|
311
|
+
const hasTransactionPatches = patches.some((patch) => {
|
|
312
|
+
return patch.path.includes('transactions');
|
|
313
|
+
});
|
|
314
|
+
if (hasTransactionPatches) {
|
|
315
|
+
listener();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
getTransactions: () => this.state.transactions,
|
|
320
|
+
});
|
|
307
321
|
this.onBootCleanup();
|
|
308
322
|
__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
|
|
309
323
|
}
|
|
@@ -789,6 +803,27 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
789
803
|
this.updateTransaction(updatedTransaction, `Update Editable Params for ${txId}`);
|
|
790
804
|
return this.getTransaction(txId);
|
|
791
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Update the isActive state of a transaction.
|
|
808
|
+
*
|
|
809
|
+
* @param transactionId - The ID of the transaction to update.
|
|
810
|
+
* @param isActive - The active state.
|
|
811
|
+
*/
|
|
812
|
+
setTransactionActive(transactionId, isActive) {
|
|
813
|
+
const transactionMeta = this.getTransaction(transactionId);
|
|
814
|
+
if (!transactionMeta) {
|
|
815
|
+
throw new Error(`Transaction with id ${transactionId} not found`);
|
|
816
|
+
}
|
|
817
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
818
|
+
transactionId,
|
|
819
|
+
note: 'TransactionController#setTransactionActive - Transaction isActive updated',
|
|
820
|
+
skipHistory: true,
|
|
821
|
+
skipValidation: true,
|
|
822
|
+
skipResimulateCheck: true,
|
|
823
|
+
}, (updatedTransactionMeta) => {
|
|
824
|
+
updatedTransactionMeta.isActive = isActive;
|
|
825
|
+
});
|
|
826
|
+
}
|
|
792
827
|
/**
|
|
793
828
|
* Signs and returns the raw transaction data for provided transaction params list.
|
|
794
829
|
*
|
|
@@ -1869,7 +1904,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1869
1904
|
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
1870
1905
|
}
|
|
1871
1906
|
if (!skipResimulateCheck && __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
|
|
1872
|
-
resimulateResponse = (0,
|
|
1907
|
+
resimulateResponse = (0, ResimulateHelper_1.shouldResimulate)(originalTransactionMeta, transactionMeta);
|
|
1873
1908
|
}
|
|
1874
1909
|
const shouldSkipHistory = this.isHistoryDisabled || skipHistory;
|
|
1875
1910
|
if (!shouldSkipHistory) {
|
|
@@ -1951,7 +1986,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1951
1986
|
}));
|
|
1952
1987
|
if (blockTime &&
|
|
1953
1988
|
prevSimulationData &&
|
|
1954
|
-
(0,
|
|
1989
|
+
(0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
|
|
1955
1990
|
simulationData = {
|
|
1956
1991
|
...simulationData,
|
|
1957
1992
|
isUpdatedAfterSecurityCheck: true,
|