@metamask-previews/transaction-controller 47.0.0-preview-047d5b0a → 47.0.0-preview-4fbfa93f
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 +4 -0
- package/dist/TransactionController.cjs +42 -10
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +26 -6
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +26 -6
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +40 -10
- 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 +1 -2
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts +1 -2
- 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 +0 -8
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +0 -8
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **BREAKING:** Bump `@ethereumjs/util` from `^8.1.0` to `^9.1.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
|
|
13
|
+
|
|
10
14
|
## [47.0.0]
|
|
11
15
|
|
|
12
16
|
### Added
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
// FIXME - remove above ignore
|
|
2
4
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
5
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
6
|
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");
|
|
@@ -211,10 +213,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
211
213
|
__classPrivateFieldSet(this, _TransactionController_trace, trace ?? ((_request, fn) => fn?.()), "f");
|
|
212
214
|
this.afterSign = hooks?.afterSign ?? (() => true);
|
|
213
215
|
this.beforeCheckPendingTransaction =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
this.beforePublish = hooks?.beforePublish ?? (() => true);
|
|
216
|
+
/* istanbul ignore next */
|
|
217
|
+
hooks?.beforeCheckPendingTransaction ?? (() => Promise.resolve(true));
|
|
218
|
+
this.beforePublish = hooks?.beforePublish ?? (() => Promise.resolve(true));
|
|
218
219
|
this.getAdditionalSignArguments =
|
|
219
220
|
hooks?.getAdditionalSignArguments ?? (() => []);
|
|
220
221
|
this.publish =
|
|
@@ -290,6 +291,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
290
291
|
});
|
|
291
292
|
this.onBootCleanup();
|
|
292
293
|
__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
|
|
294
|
+
this.registerMessageHandlers();
|
|
295
|
+
}
|
|
296
|
+
registerMessageHandlers() {
|
|
297
|
+
this.messagingSystem.registerActionHandler(`${controllerName}:updateCustodialTransaction`, this.updateCustodialTransaction.bind(this));
|
|
293
298
|
}
|
|
294
299
|
/**
|
|
295
300
|
* Stops polling and removes listeners to prepare the controller for garbage collection.
|
|
@@ -652,6 +657,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
652
657
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
653
658
|
// Intentional given potential duration of process.
|
|
654
659
|
this.updatePostBalance(updatedTransactionMeta).catch((error) => {
|
|
660
|
+
/* istanbul ignore next */
|
|
655
661
|
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
656
662
|
throw error;
|
|
657
663
|
});
|
|
@@ -900,15 +906,18 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
900
906
|
* @param options.errorMessage - The error message to be assigned in case transaction status update to failed.
|
|
901
907
|
* @param options.hash - The new hash value to be assigned.
|
|
902
908
|
* @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
|
|
903
915
|
*/
|
|
904
|
-
updateCustodialTransaction(transactionId, { errorMessage, hash, status, }) {
|
|
916
|
+
updateCustodialTransaction(transactionId, { errorMessage, hash, status, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, type, }) {
|
|
905
917
|
const transactionMeta = this.getTransaction(transactionId);
|
|
906
918
|
if (!transactionMeta) {
|
|
907
919
|
throw new Error(`Cannot update custodial transaction as no transaction metadata found`);
|
|
908
920
|
}
|
|
909
|
-
if (!transactionMeta.custodyId) {
|
|
910
|
-
throw new Error('Transaction must be a custodian transaction');
|
|
911
|
-
}
|
|
912
921
|
if (status &&
|
|
913
922
|
![
|
|
914
923
|
types_1.TransactionStatus.submitted,
|
|
@@ -924,6 +933,30 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
924
933
|
if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
|
|
925
934
|
updatedTransactionMeta.error = (0, utils_2.normalizeTxError)(new Error(errorMessage));
|
|
926
935
|
}
|
|
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
|
+
}
|
|
927
960
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
|
|
928
961
|
if ([types_1.TransactionStatus.submitted, types_1.TransactionStatus.failed].includes(status)) {
|
|
929
962
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
@@ -1312,7 +1345,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1312
1345
|
});
|
|
1313
1346
|
this.onTransactionStatusChange(transactionMeta);
|
|
1314
1347
|
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta));
|
|
1315
|
-
if (!this.beforePublish(transactionMeta)) {
|
|
1348
|
+
if (!(await this.beforePublish(transactionMeta))) {
|
|
1316
1349
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1317
1350
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1318
1351
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
@@ -1895,7 +1928,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1895
1928
|
}),
|
|
1896
1929
|
hooks: {
|
|
1897
1930
|
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
1898
|
-
beforePublish: this.beforePublish.bind(this),
|
|
1899
1931
|
},
|
|
1900
1932
|
});
|
|
1901
1933
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|