@metamask-previews/transaction-controller 45.0.0-preview-224dff25 → 45.1.0-preview-1a21f764
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 +18 -1
- package/dist/TransactionController.cjs +90 -92
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +51 -81
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +51 -81
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +89 -91
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/abi/SimpleDelegateContract.cjs +50 -0
- package/dist/abi/SimpleDelegateContract.cjs.map +1 -0
- package/dist/abi/SimpleDelegateContract.d.cts +37 -0
- package/dist/abi/SimpleDelegateContract.d.cts.map +1 -0
- package/dist/abi/SimpleDelegateContract.d.mts +37 -0
- package/dist/abi/SimpleDelegateContract.d.mts.map +1 -0
- package/dist/abi/SimpleDelegateContract.mjs +47 -0
- package/dist/abi/SimpleDelegateContract.mjs.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +4 -13
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +4 -13
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +5 -3
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts +1 -0
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts +1 -0
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +5 -3
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +6 -37
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +101 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +101 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +6 -37
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +83 -0
- package/dist/utils/batch.cjs.map +1 -0
- package/dist/utils/batch.d.cts +32 -0
- package/dist/utils/batch.d.cts.map +1 -0
- package/dist/utils/batch.d.mts +32 -0
- package/dist/utils/batch.d.mts.map +1 -0
- package/dist/utils/batch.mjs +78 -0
- package/dist/utils/batch.mjs.map +1 -0
- package/dist/utils/eip7702.cjs +157 -0
- package/dist/utils/eip7702.cjs.map +1 -0
- package/dist/utils/eip7702.d.cts +63 -0
- package/dist/utils/eip7702.d.cts.map +1 -0
- package/dist/utils/eip7702.d.mts +63 -0
- package/dist/utils/eip7702.d.mts.map +1 -0
- package/dist/utils/eip7702.mjs +150 -0
- package/dist/utils/eip7702.mjs.map +1 -0
- package/dist/utils/feature-flags.cjs +53 -0
- package/dist/utils/feature-flags.cjs.map +1 -0
- package/dist/utils/feature-flags.d.cts +34 -0
- package/dist/utils/feature-flags.d.cts.map +1 -0
- package/dist/utils/feature-flags.d.mts +34 -0
- package/dist/utils/feature-flags.d.mts.map +1 -0
- package/dist/utils/feature-flags.mjs +47 -0
- package/dist/utils/feature-flags.mjs.map +1 -0
- package/dist/utils/prepare.cjs +49 -0
- package/dist/utils/prepare.cjs.map +1 -0
- package/dist/utils/prepare.d.cts +21 -0
- package/dist/utils/prepare.d.cts.map +1 -0
- package/dist/utils/prepare.d.mts +21 -0
- package/dist/utils/prepare.d.mts.map +1 -0
- package/dist/utils/prepare.mjs +44 -0
- package/dist/utils/prepare.mjs.map +1 -0
- package/dist/utils/utils.cjs +3 -8
- package/dist/utils/utils.cjs.map +1 -1
- package/dist/utils/utils.d.cts.map +1 -1
- package/dist/utils/utils.d.mts.map +1 -1
- package/dist/utils/utils.mjs +3 -8
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/validation.cjs +99 -31
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +15 -5
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +15 -5
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +100 -32
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [45.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add support for EIP-7702 / type 4 transactions ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
15
|
+
- Add `setCode` to `TransactionEnvelopeType`.
|
|
16
|
+
- Add `authorizationList` to `TransactionParams`.
|
|
17
|
+
- Export `Authorization` and `AuthorizationList` types.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- The TransactionController messenger must now allow the `KeyringController:signAuthorization` action ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
22
|
+
- Bump `@metamask/base-controller` from `^7.1.1` to `^8.0.0` ([#5305](https://github.com/MetaMask/core/pull/5305))
|
|
23
|
+
- Bump `ethereumjs/tx` from `^4.2.0` to `^5.4.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
24
|
+
- Bump `ethereumjs/common` from `^3.2.0` to `^4.5.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
25
|
+
|
|
10
26
|
## [45.0.0]
|
|
11
27
|
|
|
12
28
|
### Changed
|
|
@@ -1261,7 +1277,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1261
1277
|
|
|
1262
1278
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
1263
1279
|
|
|
1264
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.
|
|
1280
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...HEAD
|
|
1281
|
+
[45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
|
|
1265
1282
|
[45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
|
|
1266
1283
|
[44.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.0.0...@metamask/transaction-controller@44.1.0
|
|
1267
1284
|
[44.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@43.0.0...@metamask/transaction-controller@44.0.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");
|
|
@@ -15,12 +13,9 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
15
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
15
|
};
|
|
18
|
-
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,
|
|
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;
|
|
19
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE =
|
|
21
|
-
const common_1 = require("@ethereumjs/common");
|
|
22
|
-
const tx_1 = require("@ethereumjs/tx");
|
|
23
|
-
const util_1 = require("@ethereumjs/util");
|
|
18
|
+
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
24
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
25
20
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
26
21
|
const eth_query_1 = __importDefault(require("@metamask/eth-query"));
|
|
@@ -48,6 +43,8 @@ const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.c
|
|
|
48
43
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
49
44
|
const logger_1 = require("./logger.cjs");
|
|
50
45
|
const types_1 = require("./types.cjs");
|
|
46
|
+
const batch_1 = require("./utils/batch.cjs");
|
|
47
|
+
const eip7702_1 = require("./utils/eip7702.cjs");
|
|
51
48
|
const external_transactions_1 = require("./utils/external-transactions.cjs");
|
|
52
49
|
const gas_1 = require("./utils/gas.cjs");
|
|
53
50
|
const gas_fees_1 = require("./utils/gas-fees.cjs");
|
|
@@ -55,6 +52,7 @@ const gas_flow_1 = require("./utils/gas-flow.cjs");
|
|
|
55
52
|
const history_1 = require("./utils/history.cjs");
|
|
56
53
|
const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
|
|
57
54
|
const nonce_1 = require("./utils/nonce.cjs");
|
|
55
|
+
const prepare_1 = require("./utils/prepare.cjs");
|
|
58
56
|
const resimulate_1 = require("./utils/resimulate.cjs");
|
|
59
57
|
const retry_1 = require("./utils/retry.cjs");
|
|
60
58
|
const simulation_1 = require("./utils/simulation.cjs");
|
|
@@ -84,7 +82,6 @@ const metadata = {
|
|
|
84
82
|
anonymous: false,
|
|
85
83
|
},
|
|
86
84
|
};
|
|
87
|
-
exports.HARDFORK = common_1.Hardfork.London;
|
|
88
85
|
const SUBMIT_HISTORY_LIMIT = 100;
|
|
89
86
|
/**
|
|
90
87
|
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
@@ -239,7 +236,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
239
236
|
hooks?.beforeCheckPendingTransaction ??
|
|
240
237
|
/* istanbul ignore next */
|
|
241
238
|
(() => true);
|
|
242
|
-
this.beforePublish = hooks?.beforePublish ?? (() =>
|
|
239
|
+
this.beforePublish = hooks?.beforePublish ?? (() => true);
|
|
243
240
|
this.getAdditionalSignArguments =
|
|
244
241
|
hooks?.getAdditionalSignArguments ?? (() => []);
|
|
245
242
|
this.publish =
|
|
@@ -325,6 +322,34 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
325
322
|
async handleMethodData(fourBytePrefix, networkClientId) {
|
|
326
323
|
return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
|
|
327
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Add a batch of transactions to be submitted after approval.
|
|
327
|
+
*
|
|
328
|
+
* @param request - Request object containing the transactions to add.
|
|
329
|
+
* @returns Result object containing the generated batch ID.
|
|
330
|
+
*/
|
|
331
|
+
async addTransactionBatch(request) {
|
|
332
|
+
return await (0, batch_1.addTransactionBatch)({
|
|
333
|
+
addTransaction: this.addTransaction.bind(this),
|
|
334
|
+
getChainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).bind(this),
|
|
335
|
+
getEthQuery: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
|
|
336
|
+
messenger: this.messagingSystem,
|
|
337
|
+
request,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Determine which chains support atomic batch transactions with the given account address.
|
|
342
|
+
*
|
|
343
|
+
* @param address - The address of the account to check.
|
|
344
|
+
* @returns The supported chain IDs.
|
|
345
|
+
*/
|
|
346
|
+
async isAtomicBatchSupported(address) {
|
|
347
|
+
return (0, batch_1.isAtomicBatchSupported)({
|
|
348
|
+
address,
|
|
349
|
+
getEthQuery: (chainId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { chainId }),
|
|
350
|
+
messenger: this.messagingSystem,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
328
353
|
/**
|
|
329
354
|
* Add a new unapproved transaction to state. Parameters will be validated, a
|
|
330
355
|
* unique transaction id will be generated, and gas and gasPrice will be calculated
|
|
@@ -335,6 +360,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
335
360
|
* @param options.actionId - Unique ID to prevent duplicate requests.
|
|
336
361
|
* @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
|
|
337
362
|
* @param options.method - RPC method that requested the transaction.
|
|
363
|
+
* @param options.nestedTransactions - Params for any nested transactions encoded in the data.
|
|
338
364
|
* @param options.origin - The origin of the transaction request, such as a dApp hostname.
|
|
339
365
|
* @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
|
|
340
366
|
* @param options.securityAlertResponse - Response from security validator.
|
|
@@ -349,16 +375,26 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
349
375
|
*/
|
|
350
376
|
async addTransaction(txParams, options) {
|
|
351
377
|
(0, logger_1.projectLogger)('Adding transaction', txParams, options);
|
|
352
|
-
const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
378
|
+
const { actionId, deviceConfirmedOn, method, nestedTransactions, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
353
379
|
txParams = (0, utils_2.normalizeTransactionParams)(txParams);
|
|
354
380
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
355
381
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
356
382
|
}
|
|
383
|
+
const permittedAddresses = origin === undefined
|
|
384
|
+
? undefined
|
|
385
|
+
: await this.getPermittedAccounts?.(origin);
|
|
386
|
+
const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
|
|
387
|
+
const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
|
|
388
|
+
await (0, validation_1.validateTransactionOrigin)({
|
|
389
|
+
from: txParams.from,
|
|
390
|
+
internalAccounts,
|
|
391
|
+
origin,
|
|
392
|
+
permittedAddresses,
|
|
393
|
+
selectedAddress,
|
|
394
|
+
txParams,
|
|
395
|
+
});
|
|
357
396
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
|
|
358
397
|
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
|
|
359
|
-
if (origin && this.getPermittedAccounts) {
|
|
360
|
-
await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
|
|
361
|
-
}
|
|
362
398
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
363
399
|
const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
|
|
364
400
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
@@ -377,6 +413,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
377
413
|
deviceConfirmedOn,
|
|
378
414
|
id: (0, uuid_1.v1)(),
|
|
379
415
|
isFirstTimeInteraction: undefined,
|
|
416
|
+
nestedTransactions,
|
|
380
417
|
networkClientId,
|
|
381
418
|
origin,
|
|
382
419
|
securityAlertResponse,
|
|
@@ -627,7 +664,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
627
664
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
628
665
|
// Intentional given potential duration of process.
|
|
629
666
|
this.updatePostBalance(updatedTransactionMeta).catch((error) => {
|
|
630
|
-
/* istanbul ignore next */
|
|
631
667
|
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
632
668
|
throw error;
|
|
633
669
|
});
|
|
@@ -809,12 +845,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
809
845
|
}
|
|
810
846
|
const initialTx = listOfTxParams[0];
|
|
811
847
|
const { chainId } = initialTx;
|
|
812
|
-
const common = this.getCommonConfiguration(chainId);
|
|
813
848
|
const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
|
|
814
|
-
const initialTxAsEthTx =
|
|
815
|
-
|
|
816
|
-
});
|
|
817
|
-
const initialTxAsSerializedHex = (0, util_1.bufferToHex)(initialTxAsEthTx.serialize());
|
|
849
|
+
const initialTxAsEthTx = (0, prepare_1.prepareTransaction)(chainId, initialTx);
|
|
850
|
+
const initialTxAsSerializedHex = (0, prepare_1.serializeTransaction)(initialTxAsEthTx);
|
|
818
851
|
if (this.approvingTransactionIds.has(initialTxAsSerializedHex)) {
|
|
819
852
|
return '';
|
|
820
853
|
}
|
|
@@ -858,17 +891,15 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
858
891
|
* @param options.errorMessage - The error message to be assigned in case transaction status update to failed.
|
|
859
892
|
* @param options.hash - The new hash value to be assigned.
|
|
860
893
|
* @param options.status - The new status value to be assigned.
|
|
861
|
-
* @param options.gasLimit - The new gas limit value to be assigned
|
|
862
|
-
* @param options.gasPrice - The new gas price value to be assigned
|
|
863
|
-
* @param options.maxFeePerGas - The new max fee per gas value to be assigned
|
|
864
|
-
* @param options.maxPriorityFeePerGas - The new max priority fee per gas value to be assigned
|
|
865
|
-
* @param options.nonce - The new nonce value to be assigned
|
|
866
894
|
*/
|
|
867
|
-
updateCustodialTransaction(transactionId, { errorMessage, hash, status,
|
|
895
|
+
updateCustodialTransaction(transactionId, { errorMessage, hash, status, }) {
|
|
868
896
|
const transactionMeta = this.getTransaction(transactionId);
|
|
869
897
|
if (!transactionMeta) {
|
|
870
898
|
throw new Error(`Cannot update custodial transaction as no transaction metadata found`);
|
|
871
899
|
}
|
|
900
|
+
if (!transactionMeta.custodyId) {
|
|
901
|
+
throw new Error('Transaction must be a custodian transaction');
|
|
902
|
+
}
|
|
872
903
|
if (status &&
|
|
873
904
|
![
|
|
874
905
|
types_1.TransactionStatus.submitted,
|
|
@@ -884,22 +915,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
884
915
|
if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
|
|
885
916
|
updatedTransactionMeta.error = (0, utils_2.normalizeTxError)(new Error(errorMessage));
|
|
886
917
|
}
|
|
887
|
-
if (gasLimit) {
|
|
888
|
-
updatedTransactionMeta.txParams.gasLimit = gasLimit;
|
|
889
|
-
}
|
|
890
|
-
if (gasPrice) {
|
|
891
|
-
updatedTransactionMeta.txParams.gasPrice = gasPrice;
|
|
892
|
-
}
|
|
893
|
-
if (maxFeePerGas) {
|
|
894
|
-
updatedTransactionMeta.txParams.maxFeePerGas = maxFeePerGas;
|
|
895
|
-
}
|
|
896
|
-
if (maxPriorityFeePerGas) {
|
|
897
|
-
updatedTransactionMeta.txParams.maxPriorityFeePerGas =
|
|
898
|
-
maxPriorityFeePerGas;
|
|
899
|
-
}
|
|
900
|
-
if (nonce) {
|
|
901
|
-
updatedTransactionMeta.txParams.nonce = nonce;
|
|
902
|
-
}
|
|
903
918
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
|
|
904
919
|
if ([types_1.TransactionStatus.submitted, types_1.TransactionStatus.failed].includes(status)) {
|
|
905
920
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
@@ -1046,10 +1061,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1046
1061
|
chainId,
|
|
1047
1062
|
};
|
|
1048
1063
|
const { from } = updatedTransactionParams;
|
|
1049
|
-
const
|
|
1050
|
-
const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
|
|
1064
|
+
const unsignedTransaction = (0, prepare_1.prepareTransaction)(chainId, updatedTransactionParams);
|
|
1051
1065
|
const signedTransaction = await this.sign(unsignedTransaction, from);
|
|
1052
|
-
const rawTransaction = (0,
|
|
1066
|
+
const rawTransaction = (0, prepare_1.serializeTransaction)(signedTransaction);
|
|
1053
1067
|
return rawTransaction;
|
|
1054
1068
|
}
|
|
1055
1069
|
/**
|
|
@@ -1231,21 +1245,19 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1231
1245
|
transactionId,
|
|
1232
1246
|
note: 'TransactionController#approveTransaction - Transaction approved',
|
|
1233
1247
|
}, (draftTxMeta) => {
|
|
1234
|
-
const {
|
|
1248
|
+
const { chainId, txParams } = draftTxMeta;
|
|
1249
|
+
const { gas, type } = txParams;
|
|
1235
1250
|
draftTxMeta.status = types_1.TransactionStatus.approved;
|
|
1236
|
-
draftTxMeta.txParams =
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
type: types_1.TransactionEnvelopeType.feeMarket,
|
|
1243
|
-
}),
|
|
1244
|
-
};
|
|
1251
|
+
draftTxMeta.txParams.chainId = chainId;
|
|
1252
|
+
draftTxMeta.txParams.gasLimit = gas;
|
|
1253
|
+
draftTxMeta.txParams.nonce = nonce;
|
|
1254
|
+
if (!type && (0, utils_2.isEIP1559Transaction)(txParams)) {
|
|
1255
|
+
draftTxMeta.txParams.type = types_1.TransactionEnvelopeType.feeMarket;
|
|
1256
|
+
}
|
|
1245
1257
|
});
|
|
1246
1258
|
this.onTransactionStatusChange(transactionMeta);
|
|
1247
|
-
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta
|
|
1248
|
-
if (!
|
|
1259
|
+
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta));
|
|
1260
|
+
if (!this.beforePublish(transactionMeta)) {
|
|
1249
1261
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1250
1262
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1251
1263
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
@@ -1335,9 +1347,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1335
1347
|
status: types_1.TransactionStatus.rejected,
|
|
1336
1348
|
};
|
|
1337
1349
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1338
|
-
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(
|
|
1339
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
1340
|
-
`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1350
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1341
1351
|
this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
|
|
1342
1352
|
transactionMeta: updatedTransactionMeta,
|
|
1343
1353
|
actionId,
|
|
@@ -1365,7 +1375,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1365
1375
|
.filter((tx) => {
|
|
1366
1376
|
const { chainId, status, txParams, time } = tx;
|
|
1367
1377
|
if (txParams) {
|
|
1368
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
1369
1378
|
const key = `${String(txParams.nonce)}-${(0, controller_utils_1.convertHexToDecimal)(chainId)}-${new Date(time).toDateString()}`;
|
|
1370
1379
|
if (nonceNetworkSet.has(key)) {
|
|
1371
1380
|
return true;
|
|
@@ -1446,29 +1455,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1446
1455
|
const isCompleted = this.isLocalFinalState(transaction.status);
|
|
1447
1456
|
return { meta: transaction, isCompleted };
|
|
1448
1457
|
}
|
|
1449
|
-
prepareUnsignedEthTx(chainId, txParams) {
|
|
1450
|
-
return tx_1.TransactionFactory.fromTxData(txParams, {
|
|
1451
|
-
freeze: false,
|
|
1452
|
-
common: this.getCommonConfiguration(chainId),
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for
|
|
1457
|
-
* specifying which chain, network, hardfork and EIPs to support for
|
|
1458
|
-
* a transaction. By referencing this configuration, and analyzing the fields
|
|
1459
|
-
* specified in txParams, @ethereumjs/tx is able to determine which EIP-2718
|
|
1460
|
-
* transaction type to use.
|
|
1461
|
-
*
|
|
1462
|
-
* @param chainId - The chainId to use for the configuration.
|
|
1463
|
-
* @returns common configuration object
|
|
1464
|
-
*/
|
|
1465
|
-
getCommonConfiguration(chainId) {
|
|
1466
|
-
const customChainParams = {
|
|
1467
|
-
chainId: parseInt(chainId, 16),
|
|
1468
|
-
defaultHardfork: exports.HARDFORK,
|
|
1469
|
-
};
|
|
1470
|
-
return common_1.Common.custom(customChainParams);
|
|
1471
|
-
}
|
|
1472
1458
|
onIncomingTransactions(transactions) {
|
|
1473
1459
|
if (!transactions.length) {
|
|
1474
1460
|
return;
|
|
@@ -1637,12 +1623,20 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1637
1623
|
const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
|
|
1638
1624
|
return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
|
|
1639
1625
|
}
|
|
1640
|
-
async signTransaction(transactionMeta
|
|
1626
|
+
async signTransaction(transactionMeta) {
|
|
1627
|
+
const { txParams } = transactionMeta;
|
|
1641
1628
|
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1642
|
-
const
|
|
1629
|
+
const { authorizationList, from } = txParams;
|
|
1630
|
+
const finalTxParams = { ...txParams };
|
|
1631
|
+
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1632
|
+
authorizationList,
|
|
1633
|
+
messenger: this.messagingSystem,
|
|
1634
|
+
transactionMeta,
|
|
1635
|
+
});
|
|
1636
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1643
1637
|
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1644
1638
|
const signedTx = await new Promise((resolve, reject) => {
|
|
1645
|
-
this.sign?.(unsignedEthTx,
|
|
1639
|
+
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1646
1640
|
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1647
1641
|
});
|
|
1648
1642
|
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
@@ -1659,10 +1653,11 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1659
1653
|
const transactionMetaWithRsv = {
|
|
1660
1654
|
...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
|
|
1661
1655
|
status: types_1.TransactionStatus.signed,
|
|
1656
|
+
txParams: finalTxParams,
|
|
1662
1657
|
};
|
|
1663
1658
|
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1664
1659
|
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1665
|
-
const rawTx = (0,
|
|
1660
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1666
1661
|
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1667
1662
|
rawTx,
|
|
1668
1663
|
});
|
|
@@ -1758,10 +1753,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1758
1753
|
}
|
|
1759
1754
|
const newTxParams = (0, retry_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
|
|
1760
1755
|
prepareTransactionParams?.(newTxParams);
|
|
1761
|
-
const unsignedEthTx =
|
|
1756
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, newTxParams);
|
|
1762
1757
|
const signedTx = await this.sign(unsignedEthTx, transactionMeta.txParams.from);
|
|
1763
1758
|
const transactionMetaWithRsv = this.updateTransactionMetaRSV(transactionMeta, signedTx);
|
|
1764
|
-
const rawTx = (0,
|
|
1759
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1765
1760
|
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
1766
1761
|
const oldFee = newTxParams.maxFeePerGas
|
|
1767
1762
|
? transactionMetaWithRsv.txParams.maxFeePerGas
|
|
@@ -1845,15 +1840,13 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1845
1840
|
}),
|
|
1846
1841
|
hooks: {
|
|
1847
1842
|
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
1843
|
+
beforePublish: this.beforePublish.bind(this),
|
|
1848
1844
|
},
|
|
1849
1845
|
});
|
|
1850
1846
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|
|
1851
1847
|
return pendingTransactionTracker;
|
|
1852
1848
|
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
1853
1849
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
|
|
1854
|
-
}, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1855
|
-
incomingTransactionHelper.hub.removeAllListeners('transactions');
|
|
1856
|
-
incomingTransactionHelper.hub.removeAllListeners('updated-last-fetched-timestamp');
|
|
1857
1850
|
}, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1858
1851
|
incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
|
|
1859
1852
|
}, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
@@ -2006,6 +1999,11 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2006
1999
|
});
|
|
2007
2000
|
}, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
|
|
2008
2001
|
return this.messagingSystem.call('AccountsController:getSelectedAccount');
|
|
2002
|
+
}, _TransactionController_getInternalAccounts = function _TransactionController_getInternalAccounts() {
|
|
2003
|
+
const state = this.messagingSystem.call('AccountsController:getState');
|
|
2004
|
+
return Object.values(state.internalAccounts?.accounts ?? {})
|
|
2005
|
+
.filter((account) => account.type === 'eip155:eoa')
|
|
2006
|
+
.map((account) => account.address);
|
|
2009
2007
|
}, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
|
|
2010
2008
|
const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
|
|
2011
2009
|
const { networkConfigurationsByChainId } = this.getNetworkState();
|