@metamask-previews/transaction-controller 47.0.0-preview-4fbfa93f → 48.0.0-preview-22387993
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 +9 -1
- package/dist/TransactionController.cjs +11 -42
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +6 -26
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +6 -26
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +11 -40
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +7 -7
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts +2 -1
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts +2 -1
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +7 -7
- package/dist/helpers/PendingTransactionTracker.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 +8 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +8 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/validation.cjs +6 -3
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +3 -1
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +3 -1
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +6 -3
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
+
- Prevent external transactions to internal accounts if `data` included ([#5418](https://github.com/MetaMask/core/pull/5418))
|
|
13
|
+
|
|
14
|
+
## [48.0.0]
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency to `^26.0.0` ([#5439](https://github.com/MetaMask/core/pull/5439))
|
|
12
19
|
- **BREAKING:** Bump `@ethereumjs/util` from `^8.1.0` to `^9.1.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
|
|
13
20
|
|
|
14
21
|
## [47.0.0]
|
|
@@ -1323,7 +1330,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1323
1330
|
|
|
1324
1331
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
1325
1332
|
|
|
1326
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@
|
|
1333
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@48.0.0...HEAD
|
|
1334
|
+
[48.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@47.0.0...@metamask/transaction-controller@48.0.0
|
|
1327
1335
|
[47.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@46.0.0...@metamask/transaction-controller@47.0.0
|
|
1328
1336
|
[46.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...@metamask/transaction-controller@46.0.0
|
|
1329
1337
|
[45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* istanbul ignore file */
|
|
3
|
-
// FIXME - remove above ignore
|
|
4
2
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
5
3
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
6
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
@@ -213,9 +211,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
213
211
|
__classPrivateFieldSet(this, _TransactionController_trace, trace ?? ((_request, fn) => fn?.()), "f");
|
|
214
212
|
this.afterSign = hooks?.afterSign ?? (() => true);
|
|
215
213
|
this.beforeCheckPendingTransaction =
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
hooks?.beforeCheckPendingTransaction ??
|
|
215
|
+
/* istanbul ignore next */
|
|
216
|
+
(() => true);
|
|
217
|
+
this.beforePublish = hooks?.beforePublish ?? (() => true);
|
|
219
218
|
this.getAdditionalSignArguments =
|
|
220
219
|
hooks?.getAdditionalSignArguments ?? (() => []);
|
|
221
220
|
this.publish =
|
|
@@ -291,10 +290,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
291
290
|
});
|
|
292
291
|
this.onBootCleanup();
|
|
293
292
|
__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
|
|
294
|
-
this.registerMessageHandlers();
|
|
295
|
-
}
|
|
296
|
-
registerMessageHandlers() {
|
|
297
|
-
this.messagingSystem.registerActionHandler(`${controllerName}:updateCustodialTransaction`, this.updateCustodialTransaction.bind(this));
|
|
298
293
|
}
|
|
299
294
|
/**
|
|
300
295
|
* Stops polling and removes listeners to prepare the controller for garbage collection.
|
|
@@ -377,6 +372,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
377
372
|
const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
|
|
378
373
|
const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
|
|
379
374
|
await (0, validation_1.validateTransactionOrigin)({
|
|
375
|
+
data: txParams.data,
|
|
380
376
|
from: txParams.from,
|
|
381
377
|
internalAccounts,
|
|
382
378
|
origin,
|
|
@@ -657,7 +653,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
657
653
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
658
654
|
// Intentional given potential duration of process.
|
|
659
655
|
this.updatePostBalance(updatedTransactionMeta).catch((error) => {
|
|
660
|
-
/* istanbul ignore next */
|
|
661
656
|
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
662
657
|
throw error;
|
|
663
658
|
});
|
|
@@ -906,18 +901,15 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
906
901
|
* @param options.errorMessage - The error message to be assigned in case transaction status update to failed.
|
|
907
902
|
* @param options.hash - The new hash value to be assigned.
|
|
908
903
|
* @param options.status - The new status value to be assigned.
|
|
909
|
-
* @param options.gasLimit - The new gas limit value to be assigned
|
|
910
|
-
* @param options.gasPrice - The new gas price value to be assigned
|
|
911
|
-
* @param options.maxFeePerGas - The new max fee per gas value to be assigned
|
|
912
|
-
* @param options.maxPriorityFeePerGas - The new max priority fee per gas value to be assigned
|
|
913
|
-
* @param options.nonce - The new nonce value to be assigned
|
|
914
|
-
* @param options.type - The tranasction type (hardfork) to be assigned
|
|
915
904
|
*/
|
|
916
|
-
updateCustodialTransaction(transactionId, { errorMessage, hash, status,
|
|
905
|
+
updateCustodialTransaction(transactionId, { errorMessage, hash, status, }) {
|
|
917
906
|
const transactionMeta = this.getTransaction(transactionId);
|
|
918
907
|
if (!transactionMeta) {
|
|
919
908
|
throw new Error(`Cannot update custodial transaction as no transaction metadata found`);
|
|
920
909
|
}
|
|
910
|
+
if (!transactionMeta.custodyId) {
|
|
911
|
+
throw new Error('Transaction must be a custodian transaction');
|
|
912
|
+
}
|
|
921
913
|
if (status &&
|
|
922
914
|
![
|
|
923
915
|
types_1.TransactionStatus.submitted,
|
|
@@ -933,30 +925,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
933
925
|
if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
|
|
934
926
|
updatedTransactionMeta.error = (0, utils_2.normalizeTxError)(new Error(errorMessage));
|
|
935
927
|
}
|
|
936
|
-
if (gasLimit) {
|
|
937
|
-
updatedTransactionMeta.txParams.gasLimit = gasLimit;
|
|
938
|
-
}
|
|
939
|
-
if (gasPrice) {
|
|
940
|
-
updatedTransactionMeta.txParams.gasPrice = gasPrice;
|
|
941
|
-
}
|
|
942
|
-
if (maxFeePerGas) {
|
|
943
|
-
updatedTransactionMeta.txParams.maxFeePerGas = maxFeePerGas;
|
|
944
|
-
}
|
|
945
|
-
if (maxPriorityFeePerGas) {
|
|
946
|
-
updatedTransactionMeta.txParams.maxPriorityFeePerGas =
|
|
947
|
-
maxPriorityFeePerGas;
|
|
948
|
-
}
|
|
949
|
-
if (type) {
|
|
950
|
-
updatedTransactionMeta.txParams.type = type;
|
|
951
|
-
// If the type was reverted to legacy, we need to remove the maxFeePerGas and maxPriorityFeePerGas values
|
|
952
|
-
if (type === types_1.TransactionEnvelopeType.legacy) {
|
|
953
|
-
updatedTransactionMeta.txParams.maxFeePerGas = undefined;
|
|
954
|
-
updatedTransactionMeta.txParams.maxPriorityFeePerGas = undefined;
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
if (nonce) {
|
|
958
|
-
updatedTransactionMeta.txParams.nonce = nonce;
|
|
959
|
-
}
|
|
960
928
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
|
|
961
929
|
if ([types_1.TransactionStatus.submitted, types_1.TransactionStatus.failed].includes(status)) {
|
|
962
930
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
@@ -1345,7 +1313,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1345
1313
|
});
|
|
1346
1314
|
this.onTransactionStatusChange(transactionMeta);
|
|
1347
1315
|
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta));
|
|
1348
|
-
if (!
|
|
1316
|
+
if (!this.beforePublish(transactionMeta)) {
|
|
1349
1317
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1350
1318
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1351
1319
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
@@ -1928,6 +1896,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1928
1896
|
}),
|
|
1929
1897
|
hooks: {
|
|
1930
1898
|
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
1899
|
+
beforePublish: this.beforePublish.bind(this),
|
|
1931
1900
|
},
|
|
1932
1901
|
});
|
|
1933
1902
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|