@metamask-previews/transaction-controller 36.1.0-preview-9d310688 → 37.0.0-preview-e34879fb
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 +32 -1
- package/dist/TransactionController.cjs +11 -56
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +3 -4
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +3 -4
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +11 -56
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +2 -1
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +2 -1
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
- package/dist/index.cjs +1 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +0 -28
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +0 -28
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [37.0.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Remove unapproved transactions during initialisation ([#4658](https://github.com/MetaMask/core/pull/4658))
|
|
15
|
+
- Fail approved and signed transactions during initialisation ([#4658](https://github.com/MetaMask/core/pull/4658))
|
|
16
|
+
- Remove `TraceContext`, `TraceRequest`, and `TraceCallback` types ([#4655](https://github.com/MetaMask/core/pull/4655))
|
|
17
|
+
- These were moved to `@metamask/controller-utils`.
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
|
|
21
|
+
- **BREAKING:** Remove `initApprovals` method ([#4658](https://github.com/MetaMask/core/pull/4658))
|
|
22
|
+
- **BREAKING:** Remove `beforeApproveOnInit` hook ([#4658](https://github.com/MetaMask/core/pull/4658))
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files ([#4648](https://github.com/MetaMask/core/pull/4648))
|
|
27
|
+
- Previously, this package shipped with only one variant of type declaration
|
|
28
|
+
files, and these files were only CommonJS-compatible, and the `exports`
|
|
29
|
+
field in `package.json` linked to these files. This is an anti-pattern and
|
|
30
|
+
was rightfully flagged by the
|
|
31
|
+
["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as
|
|
32
|
+
["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md).
|
|
33
|
+
All of the ATTW checks now pass.
|
|
34
|
+
- Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648)).
|
|
35
|
+
- Previously, the build tool we used to generate JavaScript files extracted
|
|
36
|
+
common code to "chunk" files. While this was intended to make this package
|
|
37
|
+
more tree-shakeable, it also made debugging more difficult for our
|
|
38
|
+
development teams. These chunk files are no longer present.
|
|
39
|
+
|
|
10
40
|
## [36.1.0]
|
|
11
41
|
|
|
12
42
|
### Added
|
|
@@ -993,7 +1023,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
993
1023
|
|
|
994
1024
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
995
1025
|
|
|
996
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@
|
|
1026
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@37.0.0...HEAD
|
|
1027
|
+
[37.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@36.1.0...@metamask/transaction-controller@37.0.0
|
|
997
1028
|
[36.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@36.0.0...@metamask/transaction-controller@36.1.0
|
|
998
1029
|
[36.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.2.0...@metamask/transaction-controller@36.0.0
|
|
999
1030
|
[35.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.1.1...@metamask/transaction-controller@35.2.0
|
|
@@ -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_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_checkIfTransactionParamsUpdated, _TransactionController_onTransactionParamsUpdated, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getNetworkClientId, _TransactionController_getGlobalNetworkClientId, _TransactionController_getGlobalChainId, _TransactionController_isCustomNetwork, _TransactionController_getSelectedAccount
|
|
16
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_checkIfTransactionParamsUpdated, _TransactionController_onTransactionParamsUpdated, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getNetworkClientId, _TransactionController_getGlobalNetworkClientId, _TransactionController_getGlobalChainId, _TransactionController_isCustomNetwork, _TransactionController_getSelectedAccount;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
|
|
19
19
|
const common_1 = require("@ethereumjs/common");
|
|
@@ -73,13 +73,8 @@ const metadata = {
|
|
|
73
73
|
persist: true,
|
|
74
74
|
anonymous: false,
|
|
75
75
|
},
|
|
76
|
-
submitHistory: {
|
|
77
|
-
persist: true,
|
|
78
|
-
anonymous: false,
|
|
79
|
-
},
|
|
80
76
|
};
|
|
81
77
|
exports.HARDFORK = common_1.Hardfork.London;
|
|
82
|
-
const SUBMIT_HISTORY_LIMIT = 100;
|
|
83
78
|
/**
|
|
84
79
|
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
85
80
|
*/
|
|
@@ -111,7 +106,6 @@ function getDefaultTransactionControllerState() {
|
|
|
111
106
|
methodData: {},
|
|
112
107
|
transactions: [],
|
|
113
108
|
lastFetchedBlockNumbers: {},
|
|
114
|
-
submitHistory: [],
|
|
115
109
|
};
|
|
116
110
|
}
|
|
117
111
|
/**
|
|
@@ -381,7 +375,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
381
375
|
const networkClientId = requestNetworkClientId ?? __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
|
|
382
376
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
|
|
383
377
|
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
|
|
384
|
-
if (origin
|
|
378
|
+
if (origin) {
|
|
385
379
|
await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
|
|
386
380
|
}
|
|
387
381
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
@@ -1306,10 +1300,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1306
1300
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Publish', parentContext: traceContext }, async () => {
|
|
1307
1301
|
({ transactionHash: hash } = await this.publish(transactionMeta, rawTx));
|
|
1308
1302
|
if (hash === undefined) {
|
|
1309
|
-
hash = await this.publishTransaction(ethQuery,
|
|
1310
|
-
...transactionMeta,
|
|
1311
|
-
rawTx,
|
|
1312
|
-
});
|
|
1303
|
+
hash = await this.publishTransaction(ethQuery, rawTx);
|
|
1313
1304
|
}
|
|
1314
1305
|
});
|
|
1315
1306
|
(0, logger_1.projectLogger)('Publish successful', hash);
|
|
@@ -1343,14 +1334,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1343
1334
|
cleanupTasks.forEach((task) => task());
|
|
1344
1335
|
}
|
|
1345
1336
|
}
|
|
1346
|
-
async publishTransaction(ethQuery,
|
|
1347
|
-
|
|
1348
|
-
transactionMeta.rawTx,
|
|
1349
|
-
]);
|
|
1350
|
-
if (skipSubmitHistory !== true) {
|
|
1351
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSubmitHistory).call(this, transactionMeta, transactionHash);
|
|
1352
|
-
}
|
|
1353
|
-
return transactionHash;
|
|
1337
|
+
async publishTransaction(ethQuery, rawTransaction) {
|
|
1338
|
+
return await (0, controller_utils_1.query)(ethQuery, 'sendRawTransaction', [rawTransaction]);
|
|
1354
1339
|
}
|
|
1355
1340
|
/**
|
|
1356
1341
|
* Cancels a transaction based on its ID by setting its status to "rejected"
|
|
@@ -1757,9 +1742,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1757
1742
|
(0, logger_1.projectLogger)('Error while updating post transaction balance', error);
|
|
1758
1743
|
}
|
|
1759
1744
|
}
|
|
1760
|
-
async publishTransactionForRetry(ethQuery, transactionMeta) {
|
|
1745
|
+
async publishTransactionForRetry(ethQuery, rawTx, transactionMeta) {
|
|
1761
1746
|
try {
|
|
1762
|
-
|
|
1747
|
+
const hash = await this.publishTransaction(ethQuery, rawTx);
|
|
1748
|
+
return hash;
|
|
1763
1749
|
}
|
|
1764
1750
|
catch (error) {
|
|
1765
1751
|
if (this.isTransactionAlreadyConfirmedError(error)) {
|
|
@@ -1823,10 +1809,12 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1823
1809
|
networkClientId: transactionMeta.networkClientId,
|
|
1824
1810
|
chainId: transactionMeta.chainId,
|
|
1825
1811
|
});
|
|
1812
|
+
const hash = await this.publishTransactionForRetry(ethQuery, rawTx, transactionMeta);
|
|
1826
1813
|
const newTransactionMeta = {
|
|
1827
1814
|
...transactionMetaWithRsv,
|
|
1828
1815
|
actionId,
|
|
1829
1816
|
estimatedBaseFee,
|
|
1817
|
+
hash,
|
|
1830
1818
|
id: (0, uuid_1.v1)(),
|
|
1831
1819
|
originalGasEstimate: transactionMeta.txParams.gas,
|
|
1832
1820
|
originalType: transactionMeta.type,
|
|
@@ -1835,11 +1823,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1835
1823
|
txParams: newTxParams,
|
|
1836
1824
|
type: transactionType,
|
|
1837
1825
|
};
|
|
1838
|
-
const hash = await this.publishTransactionForRetry(ethQuery, {
|
|
1839
|
-
...newTransactionMeta,
|
|
1840
|
-
origin: label,
|
|
1841
|
-
});
|
|
1842
|
-
newTransactionMeta.hash = hash;
|
|
1843
1826
|
this.addMetadata(newTransactionMeta);
|
|
1844
1827
|
// speedUpTransaction has no approval request, so we assume the user has already approved the transaction
|
|
1845
1828
|
this.messagingSystem.publish(`${controllerName}:transactionApproved`, {
|
|
@@ -1866,7 +1849,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1866
1849
|
blockTracker,
|
|
1867
1850
|
getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
|
|
1868
1851
|
getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
|
|
1869
|
-
getLocalTransactions: () => this.state.transactions,
|
|
1870
1852
|
getChainId: chainId ? () => chainId : this.getChainId.bind(this),
|
|
1871
1853
|
isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
|
|
1872
1854
|
queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
|
|
@@ -1888,9 +1870,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1888
1870
|
getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
|
|
1889
1871
|
chainId: getChainId(),
|
|
1890
1872
|
}),
|
|
1891
|
-
publishTransaction:
|
|
1892
|
-
skipSubmitHistory: true,
|
|
1893
|
-
}),
|
|
1873
|
+
publishTransaction: this.publishTransaction.bind(this),
|
|
1894
1874
|
hooks: {
|
|
1895
1875
|
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
1896
1876
|
beforePublish: this.beforePublish.bind(this),
|
|
@@ -2042,30 +2022,5 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
2042
2022
|
return (this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === network_controller_1.NetworkClientType.Custom);
|
|
2043
2023
|
}, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
|
|
2044
2024
|
return this.messagingSystem.call('AccountsController:getSelectedAccount');
|
|
2045
|
-
}, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
|
|
2046
|
-
const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
|
|
2047
|
-
const { networkConfigurationsByChainId } = this.getNetworkState();
|
|
2048
|
-
const networkConfiguration = networkConfigurationsByChainId[chainId];
|
|
2049
|
-
const endpoint = networkConfiguration?.rpcEndpoints.find((currentEndpoint) => currentEndpoint.networkClientId === networkClientId);
|
|
2050
|
-
const networkUrl = endpoint?.url;
|
|
2051
|
-
const networkType = endpoint?.name ?? networkClientId;
|
|
2052
|
-
const submitHistoryEntry = {
|
|
2053
|
-
chainId,
|
|
2054
|
-
hash,
|
|
2055
|
-
networkType,
|
|
2056
|
-
networkUrl,
|
|
2057
|
-
origin,
|
|
2058
|
-
rawTransaction: rawTx,
|
|
2059
|
-
time: Date.now(),
|
|
2060
|
-
transaction: txParams,
|
|
2061
|
-
};
|
|
2062
|
-
(0, logger_1.projectLogger)('Updating submit history', submitHistoryEntry);
|
|
2063
|
-
this.update((state) => {
|
|
2064
|
-
const { submitHistory } = state;
|
|
2065
|
-
if (submitHistory.length === SUBMIT_HISTORY_LIMIT) {
|
|
2066
|
-
submitHistory.pop();
|
|
2067
|
-
}
|
|
2068
|
-
submitHistory.unshift(submitHistoryEntry);
|
|
2069
|
-
});
|
|
2070
2025
|
};
|
|
2071
2026
|
//# sourceMappingURL=TransactionController.cjs.map
|