@metamask-previews/transaction-controller 53.0.0-preview-714dae1 → 53.0.0-preview-c7dcfd5a
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 +12 -1
- package/dist/TransactionController.cjs +98 -102
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +5 -14
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +5 -14
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +98 -102
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +1 -0
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -0
- 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 +28 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +28 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +14 -7
- package/dist/utils/batch.cjs.map +1 -1
- package/dist/utils/batch.d.cts +4 -3
- package/dist/utils/batch.d.cts.map +1 -1
- package/dist/utils/batch.d.mts +4 -3
- package/dist/utils/batch.d.mts.map +1 -1
- package/dist/utils/batch.mjs +14 -7
- package/dist/utils/batch.mjs.map +1 -1
- package/dist/utils/nonce.cjs +4 -1
- package/dist/utils/nonce.cjs.map +1 -1
- package/dist/utils/nonce.d.cts +1 -1
- package/dist/utils/nonce.d.cts.map +1 -1
- package/dist/utils/nonce.d.mts +1 -1
- package/dist/utils/nonce.d.mts.map +1 -1
- package/dist/utils/nonce.mjs +4 -1
- package/dist/utils/nonce.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,21 @@ 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
|
+
- Add `isExternalSign` property to `TransactionMeta` to disable nonce generation and signing ([#5604](https://github.com/MetaMask/core/pull/5604))
|
|
13
|
+
- Add types for `isAtomicBatchSupported` method ([#5600](https://github.com/MetaMask/core/pull/5600))
|
|
14
|
+
- `IsAtomicBatchSupportedRequest`
|
|
15
|
+
- `IsAtomicBatchSupportedResult`
|
|
16
|
+
- `IsAtomicBatchSupportedResultEntry`
|
|
17
|
+
|
|
10
18
|
### Changed
|
|
11
19
|
|
|
20
|
+
- **BREAKING:** Update signature of `isAtomicBatchSupported` method ([#5600](https://github.com/MetaMask/core/pull/5600))
|
|
21
|
+
- Replace `address` argument with `request` object containing `address` and optional `chainIds`.
|
|
22
|
+
- Return array of `IsAtomicBatchSupportedResultEntry` objects.
|
|
12
23
|
- Skip `origin` validation for `batch` transaction type ([#5586](https://github.com/MetaMask/core/pull/5586))
|
|
13
|
-
- **BREAKING:** `enableTxParamsGasFeeUpdates` now expects a callback function instead of a boolean.
|
|
24
|
+
- **BREAKING:** `enableTxParamsGasFeeUpdates` is renamed to `isAutomaticGasFeeUpdateEnabled` now expects a callback function instead of a boolean.
|
|
14
25
|
- This callback is invoked before performing `txParams` gas fee updates. The update will proceed only if the callback returns a truthy value.
|
|
15
26
|
- If not set it will default to return `false`.
|
|
16
27
|
|
|
@@ -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_methodDataHelper, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_publishBatchHook, _TransactionController_publicKeyEIP7702, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_rejectTransaction, _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, _TransactionController_updateGasEstimate, _TransactionController_registerActionHandlers, _TransactionController_deleteTransaction, _TransactionController_isRejectError, _TransactionController_rejectTransactionAndThrow;
|
|
16
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_publishBatchHook, _TransactionController_publicKeyEIP7702, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_rejectTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_markNonceDuplicatesDropped, _TransactionController_signTransaction, _TransactionController_onConfirmedTransaction, _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, _TransactionController_updateGasEstimate, _TransactionController_registerActionHandlers, _TransactionController_deleteTransaction, _TransactionController_isRejectError, _TransactionController_rejectTransactionAndThrow;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
19
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -157,7 +157,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
157
157
|
* @param options - The controller options.
|
|
158
158
|
*/
|
|
159
159
|
constructor(options) {
|
|
160
|
-
const { disableHistory, disableSendFlowHistory, disableSwaps,
|
|
160
|
+
const { disableHistory, disableSendFlowHistory, disableSwaps, isAutomaticGasFeeUpdateEnabled, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, publicKeyEIP7702, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, } = options;
|
|
161
161
|
super({
|
|
162
162
|
name: controllerName,
|
|
163
163
|
metadata,
|
|
@@ -188,7 +188,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
188
188
|
});
|
|
189
189
|
this.messagingSystem = messenger;
|
|
190
190
|
this.isTxParamsGasFeeUpdatesEnabled =
|
|
191
|
-
|
|
191
|
+
isAutomaticGasFeeUpdateEnabled ?? ((_txMeta) => false);
|
|
192
192
|
this.getNetworkState = getNetworkState;
|
|
193
193
|
this.isSendFlowHistoryDisabled = disableSendFlowHistory ?? false;
|
|
194
194
|
this.isHistoryDisabled = disableHistory ?? false;
|
|
@@ -335,12 +335,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
335
335
|
/**
|
|
336
336
|
* Determine which chains support atomic batch transactions with the given account address.
|
|
337
337
|
*
|
|
338
|
-
* @param
|
|
339
|
-
* @returns
|
|
338
|
+
* @param request - Request object containing the account address and other parameters.
|
|
339
|
+
* @returns Result object containing the supported chains and related information.
|
|
340
340
|
*/
|
|
341
|
-
async isAtomicBatchSupported(
|
|
341
|
+
async isAtomicBatchSupported(request) {
|
|
342
342
|
return (0, batch_1.isAtomicBatchSupported)({
|
|
343
|
-
|
|
343
|
+
...request,
|
|
344
344
|
getEthQuery: (chainId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { chainId }),
|
|
345
345
|
messenger: this.messagingSystem,
|
|
346
346
|
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
@@ -679,7 +679,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
679
679
|
updatedTransactionMeta.baseFeePerGas = baseFeePerGas;
|
|
680
680
|
}
|
|
681
681
|
// Update same nonce local transactions as dropped and define replacedBy properties.
|
|
682
|
-
this.
|
|
682
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionId);
|
|
683
683
|
// Update external provided transaction with updated gas values and confirmed status.
|
|
684
684
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:confirmExternalTransaction - Add external transaction`);
|
|
685
685
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
@@ -1395,13 +1395,13 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
});
|
|
1397
1397
|
this.onTransactionStatusChange(transactionMeta);
|
|
1398
|
-
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.
|
|
1398
|
+
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_signTransaction).call(this, transactionMeta));
|
|
1399
1399
|
if (!(await this.beforePublish(transactionMeta))) {
|
|
1400
1400
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1401
1401
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1402
1402
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
1403
1403
|
}
|
|
1404
|
-
if (!rawTx) {
|
|
1404
|
+
if (!rawTx && !transactionMeta.isExternalSign) {
|
|
1405
1405
|
return ApprovalState.NotApproved;
|
|
1406
1406
|
}
|
|
1407
1407
|
const { networkClientId } = transactionMeta;
|
|
@@ -1428,7 +1428,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1428
1428
|
}
|
|
1429
1429
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Publish', parentContext: traceContext }, async () => {
|
|
1430
1430
|
const publishHook = publishHookOverride ?? this.publish;
|
|
1431
|
-
({ transactionHash: hash } = await publishHook(transactionMeta, rawTx));
|
|
1431
|
+
({ transactionHash: hash } = await publishHook(transactionMeta, rawTx ?? '0x'));
|
|
1432
1432
|
if (hash === undefined) {
|
|
1433
1433
|
hash = await this.publishTransaction(ethQuery, {
|
|
1434
1434
|
...transactionMeta,
|
|
@@ -1652,44 +1652,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1652
1652
|
});
|
|
1653
1653
|
return newTransactionMeta;
|
|
1654
1654
|
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions
|
|
1657
|
-
* in the transactions have the same nonce.
|
|
1658
|
-
*
|
|
1659
|
-
* @param transactionId - Used to identify original transaction.
|
|
1660
|
-
*/
|
|
1661
|
-
markNonceDuplicatesDropped(transactionId) {
|
|
1662
|
-
const transactionMeta = this.getTransaction(transactionId);
|
|
1663
|
-
if (!transactionMeta) {
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
const nonce = transactionMeta.txParams?.nonce;
|
|
1667
|
-
const from = transactionMeta.txParams?.from;
|
|
1668
|
-
const { chainId } = transactionMeta;
|
|
1669
|
-
const sameNonceTransactions = this.state.transactions.filter((transaction) => transaction.id !== transactionId &&
|
|
1670
|
-
transaction.txParams.from === from &&
|
|
1671
|
-
transaction.txParams.nonce === nonce &&
|
|
1672
|
-
transaction.chainId === chainId &&
|
|
1673
|
-
transaction.type !== types_1.TransactionType.incoming);
|
|
1674
|
-
const sameNonceTransactionIds = sameNonceTransactions.map((transaction) => transaction.id);
|
|
1675
|
-
if (sameNonceTransactions.length === 0) {
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
this.update((state) => {
|
|
1679
|
-
for (const transaction of state.transactions) {
|
|
1680
|
-
if (sameNonceTransactionIds.includes(transaction.id)) {
|
|
1681
|
-
transaction.replacedBy = transactionMeta?.hash;
|
|
1682
|
-
transaction.replacedById = transactionMeta?.id;
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
});
|
|
1686
|
-
for (const transaction of this.state.transactions) {
|
|
1687
|
-
if (sameNonceTransactionIds.includes(transaction.id) &&
|
|
1688
|
-
transaction.status !== types_1.TransactionStatus.failed) {
|
|
1689
|
-
this.setTransactionStatusDropped(transaction);
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
1655
|
/**
|
|
1694
1656
|
* Method to set transaction status to dropped.
|
|
1695
1657
|
*
|
|
@@ -1746,47 +1708,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1746
1708
|
const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
|
|
1747
1709
|
return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
|
|
1748
1710
|
}
|
|
1749
|
-
async signTransaction(transactionMeta) {
|
|
1750
|
-
const { txParams } = transactionMeta;
|
|
1751
|
-
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1752
|
-
const { authorizationList, from } = txParams;
|
|
1753
|
-
const finalTxParams = { ...txParams };
|
|
1754
|
-
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1755
|
-
authorizationList,
|
|
1756
|
-
messenger: this.messagingSystem,
|
|
1757
|
-
transactionMeta,
|
|
1758
|
-
});
|
|
1759
|
-
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1760
|
-
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1761
|
-
const signedTx = await new Promise((resolve, reject) => {
|
|
1762
|
-
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1763
|
-
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1764
|
-
});
|
|
1765
|
-
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
1766
|
-
if (!signedTx) {
|
|
1767
|
-
(0, logger_1.projectLogger)('Skipping signed status as no signed transaction');
|
|
1768
|
-
return undefined;
|
|
1769
|
-
}
|
|
1770
|
-
const transactionMetaFromHook = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
1771
|
-
if (!this.afterSign(transactionMetaFromHook, signedTx)) {
|
|
1772
|
-
this.updateTransaction(transactionMetaFromHook, 'TransactionController#signTransaction - Update after sign');
|
|
1773
|
-
(0, logger_1.projectLogger)('Skipping signed status based on hook');
|
|
1774
|
-
return undefined;
|
|
1775
|
-
}
|
|
1776
|
-
const transactionMetaWithRsv = {
|
|
1777
|
-
...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
|
|
1778
|
-
status: types_1.TransactionStatus.signed,
|
|
1779
|
-
txParams: finalTxParams,
|
|
1780
|
-
};
|
|
1781
|
-
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1782
|
-
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1783
|
-
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1784
|
-
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1785
|
-
rawTx,
|
|
1786
|
-
});
|
|
1787
|
-
this.updateTransaction(transactionMetaWithRawTx, 'TransactionController#approveTransaction - RawTransaction added');
|
|
1788
|
-
return rawTx;
|
|
1789
|
-
}
|
|
1790
1711
|
onTransactionStatusChange(transactionMeta) {
|
|
1791
1712
|
this.messagingSystem.publish(`${controllerName}:transactionStatusUpdated`, {
|
|
1792
1713
|
transactionMeta,
|
|
@@ -1795,17 +1716,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1795
1716
|
getNonceTrackerTransactions(statuses, address, chainId) {
|
|
1796
1717
|
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, statuses, this.state.transactions);
|
|
1797
1718
|
}
|
|
1798
|
-
onConfirmedTransaction(transactionMeta) {
|
|
1799
|
-
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
1800
|
-
this.markNonceDuplicatesDropped(transactionMeta.id);
|
|
1801
|
-
this.messagingSystem.publish(`${controllerName}:transactionConfirmed`, transactionMeta);
|
|
1802
|
-
this.onTransactionStatusChange(transactionMeta);
|
|
1803
|
-
// Intentional given potential duration of process.
|
|
1804
|
-
this.updatePostBalance(transactionMeta).catch((error) => {
|
|
1805
|
-
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
1806
|
-
throw error;
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
1719
|
async updatePostBalance(transactionMeta) {
|
|
1810
1720
|
try {
|
|
1811
1721
|
const { networkClientId, type } = transactionMeta;
|
|
@@ -1954,6 +1864,92 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1954
1864
|
chainId,
|
|
1955
1865
|
networkClientId,
|
|
1956
1866
|
}).provider;
|
|
1867
|
+
}, _TransactionController_markNonceDuplicatesDropped = function _TransactionController_markNonceDuplicatesDropped(transactionId) {
|
|
1868
|
+
const transactionMeta = this.getTransaction(transactionId);
|
|
1869
|
+
if (!transactionMeta) {
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
const nonce = transactionMeta.txParams?.nonce;
|
|
1873
|
+
const from = transactionMeta.txParams?.from;
|
|
1874
|
+
const { chainId } = transactionMeta;
|
|
1875
|
+
const sameNonceTransactions = this.state.transactions.filter((transaction) => transaction.id !== transactionId &&
|
|
1876
|
+
transaction.txParams.from === from &&
|
|
1877
|
+
nonce &&
|
|
1878
|
+
transaction.txParams.nonce === nonce &&
|
|
1879
|
+
transaction.chainId === chainId &&
|
|
1880
|
+
transaction.type !== types_1.TransactionType.incoming);
|
|
1881
|
+
const sameNonceTransactionIds = sameNonceTransactions.map((transaction) => transaction.id);
|
|
1882
|
+
if (sameNonceTransactions.length === 0) {
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
this.update((state) => {
|
|
1886
|
+
for (const transaction of state.transactions) {
|
|
1887
|
+
if (sameNonceTransactionIds.includes(transaction.id)) {
|
|
1888
|
+
transaction.replacedBy = transactionMeta?.hash;
|
|
1889
|
+
transaction.replacedById = transactionMeta?.id;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
for (const transaction of this.state.transactions) {
|
|
1894
|
+
if (sameNonceTransactionIds.includes(transaction.id) &&
|
|
1895
|
+
transaction.status !== types_1.TransactionStatus.failed) {
|
|
1896
|
+
this.setTransactionStatusDropped(transaction);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}, _TransactionController_signTransaction = async function _TransactionController_signTransaction(transactionMeta) {
|
|
1900
|
+
const { isExternalSign, txParams } = transactionMeta;
|
|
1901
|
+
if (isExternalSign) {
|
|
1902
|
+
(0, logger_1.projectLogger)('Skipping sign as signed externally');
|
|
1903
|
+
return undefined;
|
|
1904
|
+
}
|
|
1905
|
+
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1906
|
+
const { authorizationList, from } = txParams;
|
|
1907
|
+
const finalTxParams = { ...txParams };
|
|
1908
|
+
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1909
|
+
authorizationList,
|
|
1910
|
+
messenger: this.messagingSystem,
|
|
1911
|
+
transactionMeta,
|
|
1912
|
+
});
|
|
1913
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1914
|
+
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1915
|
+
const signedTx = await new Promise((resolve, reject) => {
|
|
1916
|
+
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1917
|
+
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1918
|
+
});
|
|
1919
|
+
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
1920
|
+
if (!signedTx) {
|
|
1921
|
+
(0, logger_1.projectLogger)('Skipping signed status as no signed transaction');
|
|
1922
|
+
return undefined;
|
|
1923
|
+
}
|
|
1924
|
+
const transactionMetaFromHook = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
1925
|
+
if (!this.afterSign(transactionMetaFromHook, signedTx)) {
|
|
1926
|
+
this.updateTransaction(transactionMetaFromHook, 'TransactionController#signTransaction - Update after sign');
|
|
1927
|
+
(0, logger_1.projectLogger)('Skipping signed status based on hook');
|
|
1928
|
+
return undefined;
|
|
1929
|
+
}
|
|
1930
|
+
const transactionMetaWithRsv = {
|
|
1931
|
+
...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
|
|
1932
|
+
status: types_1.TransactionStatus.signed,
|
|
1933
|
+
txParams: finalTxParams,
|
|
1934
|
+
};
|
|
1935
|
+
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1936
|
+
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1937
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1938
|
+
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1939
|
+
rawTx,
|
|
1940
|
+
});
|
|
1941
|
+
this.updateTransaction(transactionMetaWithRawTx, 'TransactionController#approveTransaction - RawTransaction added');
|
|
1942
|
+
return rawTx;
|
|
1943
|
+
}, _TransactionController_onConfirmedTransaction = function _TransactionController_onConfirmedTransaction(transactionMeta) {
|
|
1944
|
+
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
1945
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionMeta.id);
|
|
1946
|
+
this.messagingSystem.publish(`${controllerName}:transactionConfirmed`, transactionMeta);
|
|
1947
|
+
this.onTransactionStatusChange(transactionMeta);
|
|
1948
|
+
// Intentional given potential duration of process.
|
|
1949
|
+
this.updatePostBalance(transactionMeta).catch((error) => {
|
|
1950
|
+
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
1951
|
+
throw error;
|
|
1952
|
+
});
|
|
1957
1953
|
}, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
|
|
1958
1954
|
return new nonce_tracker_1.NonceTracker({
|
|
1959
1955
|
// TODO: Fix types
|
|
@@ -1996,7 +1992,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1996
1992
|
pendingTransactionTracker.hub.removeAllListeners('transaction-failed');
|
|
1997
1993
|
pendingTransactionTracker.hub.removeAllListeners('transaction-updated');
|
|
1998
1994
|
}, _TransactionController_addPendingTransactionTrackerListeners = function _TransactionController_addPendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
1999
|
-
pendingTransactionTracker.hub.on('transaction-confirmed', this.
|
|
1995
|
+
pendingTransactionTracker.hub.on('transaction-confirmed', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onConfirmedTransaction).bind(this));
|
|
2000
1996
|
pendingTransactionTracker.hub.on('transaction-dropped', this.setTransactionStatusDropped.bind(this));
|
|
2001
1997
|
pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
|
|
2002
1998
|
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|