@metamask-previews/transaction-controller 53.0.0-preview-714dae1 → 53.0.0-preview-7f6d1f4
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 +11 -3
- package/dist/TransactionController.cjs +97 -102
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +6 -18
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +6 -18
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +97 -102
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/helpers/GasFeePoller.cjs +1 -2
- package/dist/helpers/GasFeePoller.cjs.map +1 -1
- package/dist/helpers/GasFeePoller.d.cts +1 -1
- package/dist/helpers/GasFeePoller.d.cts.map +1 -1
- package/dist/helpers/GasFeePoller.d.mts +1 -1
- package/dist/helpers/GasFeePoller.d.mts.map +1 -1
- package/dist/helpers/GasFeePoller.mjs +1 -2
- package/dist/helpers/GasFeePoller.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,12 +7,20 @@ 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.
|
|
14
|
-
- This callback is invoked before performing `txParams` gas fee updates. The update will proceed only if the callback returns a truthy value.
|
|
15
|
-
- If not set it will default to return `false`.
|
|
16
24
|
|
|
17
25
|
## [53.0.0]
|
|
18
26
|
|
|
@@ -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");
|
|
@@ -187,8 +187,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
187
187
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
|
|
188
188
|
});
|
|
189
189
|
this.messagingSystem = messenger;
|
|
190
|
-
this.isTxParamsGasFeeUpdatesEnabled =
|
|
191
|
-
enableTxParamsGasFeeUpdates ?? ((_txMeta) => false);
|
|
190
|
+
this.isTxParamsGasFeeUpdatesEnabled = enableTxParamsGasFeeUpdates ?? false;
|
|
192
191
|
this.getNetworkState = getNetworkState;
|
|
193
192
|
this.isSendFlowHistoryDisabled = disableSendFlowHistory ?? false;
|
|
194
193
|
this.isHistoryDisabled = disableHistory ?? false;
|
|
@@ -335,12 +334,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
335
334
|
/**
|
|
336
335
|
* Determine which chains support atomic batch transactions with the given account address.
|
|
337
336
|
*
|
|
338
|
-
* @param
|
|
339
|
-
* @returns
|
|
337
|
+
* @param request - Request object containing the account address and other parameters.
|
|
338
|
+
* @returns Result object containing the supported chains and related information.
|
|
340
339
|
*/
|
|
341
|
-
async isAtomicBatchSupported(
|
|
340
|
+
async isAtomicBatchSupported(request) {
|
|
342
341
|
return (0, batch_1.isAtomicBatchSupported)({
|
|
343
|
-
|
|
342
|
+
...request,
|
|
344
343
|
getEthQuery: (chainId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { chainId }),
|
|
345
344
|
messenger: this.messagingSystem,
|
|
346
345
|
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
@@ -679,7 +678,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
679
678
|
updatedTransactionMeta.baseFeePerGas = baseFeePerGas;
|
|
680
679
|
}
|
|
681
680
|
// Update same nonce local transactions as dropped and define replacedBy properties.
|
|
682
|
-
this.
|
|
681
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionId);
|
|
683
682
|
// Update external provided transaction with updated gas values and confirmed status.
|
|
684
683
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:confirmExternalTransaction - Add external transaction`);
|
|
685
684
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
@@ -1395,13 +1394,13 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1395
1394
|
}
|
|
1396
1395
|
});
|
|
1397
1396
|
this.onTransactionStatusChange(transactionMeta);
|
|
1398
|
-
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.
|
|
1397
|
+
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
1398
|
if (!(await this.beforePublish(transactionMeta))) {
|
|
1400
1399
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1401
1400
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1402
1401
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
1403
1402
|
}
|
|
1404
|
-
if (!rawTx) {
|
|
1403
|
+
if (!rawTx && !transactionMeta.isExternalSign) {
|
|
1405
1404
|
return ApprovalState.NotApproved;
|
|
1406
1405
|
}
|
|
1407
1406
|
const { networkClientId } = transactionMeta;
|
|
@@ -1428,7 +1427,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1428
1427
|
}
|
|
1429
1428
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Publish', parentContext: traceContext }, async () => {
|
|
1430
1429
|
const publishHook = publishHookOverride ?? this.publish;
|
|
1431
|
-
({ transactionHash: hash } = await publishHook(transactionMeta, rawTx));
|
|
1430
|
+
({ transactionHash: hash } = await publishHook(transactionMeta, rawTx ?? '0x'));
|
|
1432
1431
|
if (hash === undefined) {
|
|
1433
1432
|
hash = await this.publishTransaction(ethQuery, {
|
|
1434
1433
|
...transactionMeta,
|
|
@@ -1652,44 +1651,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1652
1651
|
});
|
|
1653
1652
|
return newTransactionMeta;
|
|
1654
1653
|
}
|
|
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
1654
|
/**
|
|
1694
1655
|
* Method to set transaction status to dropped.
|
|
1695
1656
|
*
|
|
@@ -1746,47 +1707,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1746
1707
|
const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
|
|
1747
1708
|
return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
|
|
1748
1709
|
}
|
|
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
1710
|
onTransactionStatusChange(transactionMeta) {
|
|
1791
1711
|
this.messagingSystem.publish(`${controllerName}:transactionStatusUpdated`, {
|
|
1792
1712
|
transactionMeta,
|
|
@@ -1795,17 +1715,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1795
1715
|
getNonceTrackerTransactions(statuses, address, chainId) {
|
|
1796
1716
|
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, statuses, this.state.transactions);
|
|
1797
1717
|
}
|
|
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
1718
|
async updatePostBalance(transactionMeta) {
|
|
1810
1719
|
try {
|
|
1811
1720
|
const { networkClientId, type } = transactionMeta;
|
|
@@ -1954,6 +1863,92 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1954
1863
|
chainId,
|
|
1955
1864
|
networkClientId,
|
|
1956
1865
|
}).provider;
|
|
1866
|
+
}, _TransactionController_markNonceDuplicatesDropped = function _TransactionController_markNonceDuplicatesDropped(transactionId) {
|
|
1867
|
+
const transactionMeta = this.getTransaction(transactionId);
|
|
1868
|
+
if (!transactionMeta) {
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
const nonce = transactionMeta.txParams?.nonce;
|
|
1872
|
+
const from = transactionMeta.txParams?.from;
|
|
1873
|
+
const { chainId } = transactionMeta;
|
|
1874
|
+
const sameNonceTransactions = this.state.transactions.filter((transaction) => transaction.id !== transactionId &&
|
|
1875
|
+
transaction.txParams.from === from &&
|
|
1876
|
+
nonce &&
|
|
1877
|
+
transaction.txParams.nonce === nonce &&
|
|
1878
|
+
transaction.chainId === chainId &&
|
|
1879
|
+
transaction.type !== types_1.TransactionType.incoming);
|
|
1880
|
+
const sameNonceTransactionIds = sameNonceTransactions.map((transaction) => transaction.id);
|
|
1881
|
+
if (sameNonceTransactions.length === 0) {
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
this.update((state) => {
|
|
1885
|
+
for (const transaction of state.transactions) {
|
|
1886
|
+
if (sameNonceTransactionIds.includes(transaction.id)) {
|
|
1887
|
+
transaction.replacedBy = transactionMeta?.hash;
|
|
1888
|
+
transaction.replacedById = transactionMeta?.id;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
for (const transaction of this.state.transactions) {
|
|
1893
|
+
if (sameNonceTransactionIds.includes(transaction.id) &&
|
|
1894
|
+
transaction.status !== types_1.TransactionStatus.failed) {
|
|
1895
|
+
this.setTransactionStatusDropped(transaction);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
}, _TransactionController_signTransaction = async function _TransactionController_signTransaction(transactionMeta) {
|
|
1899
|
+
const { isExternalSign, txParams } = transactionMeta;
|
|
1900
|
+
if (isExternalSign) {
|
|
1901
|
+
(0, logger_1.projectLogger)('Skipping sign as signed externally');
|
|
1902
|
+
return undefined;
|
|
1903
|
+
}
|
|
1904
|
+
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1905
|
+
const { authorizationList, from } = txParams;
|
|
1906
|
+
const finalTxParams = { ...txParams };
|
|
1907
|
+
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1908
|
+
authorizationList,
|
|
1909
|
+
messenger: this.messagingSystem,
|
|
1910
|
+
transactionMeta,
|
|
1911
|
+
});
|
|
1912
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1913
|
+
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1914
|
+
const signedTx = await new Promise((resolve, reject) => {
|
|
1915
|
+
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1916
|
+
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1917
|
+
});
|
|
1918
|
+
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
1919
|
+
if (!signedTx) {
|
|
1920
|
+
(0, logger_1.projectLogger)('Skipping signed status as no signed transaction');
|
|
1921
|
+
return undefined;
|
|
1922
|
+
}
|
|
1923
|
+
const transactionMetaFromHook = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
1924
|
+
if (!this.afterSign(transactionMetaFromHook, signedTx)) {
|
|
1925
|
+
this.updateTransaction(transactionMetaFromHook, 'TransactionController#signTransaction - Update after sign');
|
|
1926
|
+
(0, logger_1.projectLogger)('Skipping signed status based on hook');
|
|
1927
|
+
return undefined;
|
|
1928
|
+
}
|
|
1929
|
+
const transactionMetaWithRsv = {
|
|
1930
|
+
...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
|
|
1931
|
+
status: types_1.TransactionStatus.signed,
|
|
1932
|
+
txParams: finalTxParams,
|
|
1933
|
+
};
|
|
1934
|
+
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1935
|
+
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1936
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1937
|
+
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1938
|
+
rawTx,
|
|
1939
|
+
});
|
|
1940
|
+
this.updateTransaction(transactionMetaWithRawTx, 'TransactionController#approveTransaction - RawTransaction added');
|
|
1941
|
+
return rawTx;
|
|
1942
|
+
}, _TransactionController_onConfirmedTransaction = function _TransactionController_onConfirmedTransaction(transactionMeta) {
|
|
1943
|
+
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
1944
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionMeta.id);
|
|
1945
|
+
this.messagingSystem.publish(`${controllerName}:transactionConfirmed`, transactionMeta);
|
|
1946
|
+
this.onTransactionStatusChange(transactionMeta);
|
|
1947
|
+
// Intentional given potential duration of process.
|
|
1948
|
+
this.updatePostBalance(transactionMeta).catch((error) => {
|
|
1949
|
+
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
1950
|
+
throw error;
|
|
1951
|
+
});
|
|
1957
1952
|
}, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
|
|
1958
1953
|
return new nonce_tracker_1.NonceTracker({
|
|
1959
1954
|
// TODO: Fix types
|
|
@@ -1996,7 +1991,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1996
1991
|
pendingTransactionTracker.hub.removeAllListeners('transaction-failed');
|
|
1997
1992
|
pendingTransactionTracker.hub.removeAllListeners('transaction-updated');
|
|
1998
1993
|
}, _TransactionController_addPendingTransactionTrackerListeners = function _TransactionController_addPendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
1999
|
-
pendingTransactionTracker.hub.on('transaction-confirmed', this.
|
|
1994
|
+
pendingTransactionTracker.hub.on('transaction-confirmed', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onConfirmedTransaction).bind(this));
|
|
2000
1995
|
pendingTransactionTracker.hub.on('transaction-dropped', this.setTransactionStatusDropped.bind(this));
|
|
2001
1996
|
pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
|
|
2002
1997
|
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|