@metamask/transaction-controller 18.1.0 → 18.3.0
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 +15 -1
- package/dist/TransactionController.d.ts +8 -4
- package/dist/TransactionController.d.ts.map +1 -1
- package/dist/TransactionController.js +32 -17
- package/dist/TransactionController.js.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.js +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/nonce.d.ts +21 -0
- package/dist/utils/nonce.d.ts.map +1 -0
- package/dist/utils/nonce.js +76 -0
- package/dist/utils/nonce.js.map +1 -0
- package/dist/utils/utils.d.ts +0 -12
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +1 -33
- package/dist/utils/utils.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [18.3.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add optional `getExternalPendingTransactions` callback argument to constructor ([#3587](https://github.com/MetaMask/core/pull/3587))
|
|
12
|
+
|
|
13
|
+
## [18.2.0]
|
|
14
|
+
### Added
|
|
15
|
+
- Add the `customNonceValue` property to the transaction metadata ([#3579](https://github.com/MetaMask/core/pull/3579))
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- Update transaction metadata after approval if the approval result includes the `value.txMeta` property ([#3579](https://github.com/MetaMask/core/pull/3579))
|
|
19
|
+
- Add `type` property to all incoming transactions ([#3579](https://github.com/MetaMask/core/pull/3579))
|
|
20
|
+
|
|
9
21
|
## [18.1.0]
|
|
10
22
|
### Added
|
|
11
23
|
- Add `cancelMultiplier` and `speedUpMultiplier` constructor arguments to optionally override the default multipliers of `1.5` and `1.1` respectively ([#2678](https://github.com/MetaMask/core/pull/2678))
|
|
@@ -319,7 +331,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
319
331
|
|
|
320
332
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
321
333
|
|
|
322
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.
|
|
334
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.3.0...HEAD
|
|
335
|
+
[18.3.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.2.0...@metamask/transaction-controller@18.3.0
|
|
336
|
+
[18.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.1.0...@metamask/transaction-controller@18.2.0
|
|
323
337
|
[18.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.0.0...@metamask/transaction-controller@18.1.0
|
|
324
338
|
[18.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@17.0.0...@metamask/transaction-controller@18.0.0
|
|
325
339
|
[17.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@16.0.0...@metamask/transaction-controller@17.0.0
|
|
@@ -8,7 +8,7 @@ import type { GasFeeState } from '@metamask/gas-fee-controller';
|
|
|
8
8
|
import type { BlockTracker, NetworkState, Provider } from '@metamask/network-controller';
|
|
9
9
|
import type { Hex } from '@metamask/utils';
|
|
10
10
|
import { EventEmitter } from 'events';
|
|
11
|
-
import type { NonceLock } from 'nonce-tracker';
|
|
11
|
+
import type { NonceLock, Transaction as NonceTrackerTransaction } from 'nonce-tracker';
|
|
12
12
|
import type { Events, SavedGasFees, SecurityProviderRequest, SendFlowHistoryEntry, TransactionParams, TransactionMeta, TransactionReceipt, WalletDevice, SecurityAlertResponse } from './types';
|
|
13
13
|
import { TransactionType, TransactionStatus } from './types';
|
|
14
14
|
export declare const HARDFORK = Hardfork.London;
|
|
@@ -110,6 +110,7 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
|
|
|
110
110
|
private readonly getGasFeeEstimates;
|
|
111
111
|
private readonly getPermittedAccounts;
|
|
112
112
|
private readonly getSelectedAddress;
|
|
113
|
+
private readonly getExternalPendingTransactions;
|
|
113
114
|
private readonly messagingSystem;
|
|
114
115
|
private readonly incomingTransactionHelper;
|
|
115
116
|
private readonly securityProviderRequest?;
|
|
@@ -144,12 +145,13 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
|
|
|
144
145
|
* @param options.disableHistory - Whether to disable storing history in transaction metadata.
|
|
145
146
|
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
|
|
146
147
|
* @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
|
|
147
|
-
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
148
148
|
* @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
|
|
149
149
|
* @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
|
|
150
|
+
* @param options.getExternalPendingTransactions - Callback to retrieve pending transactions from external sources.
|
|
150
151
|
* @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
|
|
151
152
|
* @param options.getNetworkState - Gets the state of the network controller.
|
|
152
153
|
* @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
|
|
154
|
+
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
153
155
|
* @param options.getSelectedAddress - Gets the address of the currently selected account.
|
|
154
156
|
* @param options.incomingTransactions - Configuration options for incoming transaction support.
|
|
155
157
|
* @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.
|
|
@@ -172,18 +174,19 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
|
|
|
172
174
|
* @param config - Initial options used to configure this controller.
|
|
173
175
|
* @param state - Initial state to set on this controller.
|
|
174
176
|
*/
|
|
175
|
-
constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps,
|
|
177
|
+
constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSavedGasFees, getSelectedAddress, incomingTransactions, messenger, onNetworkStateChange, pendingTransactions, provider, securityProviderRequest, speedUpMultiplier, hooks, }: {
|
|
176
178
|
blockTracker: BlockTracker;
|
|
177
179
|
cancelMultiplier?: number;
|
|
178
180
|
disableHistory: boolean;
|
|
179
181
|
disableSendFlowHistory: boolean;
|
|
180
182
|
disableSwaps: boolean;
|
|
181
|
-
getSavedGasFees?: (chainId: Hex) => SavedGasFees | undefined;
|
|
182
183
|
getCurrentAccountEIP1559Compatibility?: () => Promise<boolean>;
|
|
183
184
|
getCurrentNetworkEIP1559Compatibility: () => Promise<boolean>;
|
|
185
|
+
getExternalPendingTransactions?: (address: string) => NonceTrackerTransaction[];
|
|
184
186
|
getGasFeeEstimates?: () => Promise<GasFeeState>;
|
|
185
187
|
getNetworkState: () => NetworkState;
|
|
186
188
|
getPermittedAccounts: (origin?: string) => Promise<string[]>;
|
|
189
|
+
getSavedGasFees?: (chainId: Hex) => SavedGasFees | undefined;
|
|
187
190
|
getSelectedAddress: () => string;
|
|
188
191
|
incomingTransactions?: {
|
|
189
192
|
includeTokenTransfers?: boolean;
|
|
@@ -593,6 +596,7 @@ export declare class TransactionController extends BaseControllerV1<TransactionC
|
|
|
593
596
|
private addPendingTransactionTrackerListeners;
|
|
594
597
|
private signTransaction;
|
|
595
598
|
private onTransactionStatusChange;
|
|
599
|
+
private getNonceTrackerPendingTransactions;
|
|
596
600
|
private getNonceTrackerTransactions;
|
|
597
601
|
private onConfirmedTransaction;
|
|
598
602
|
private updatePostBalance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA4B,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAU7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA4B,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAU7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE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AAkB;YAuHlB,kBAAkB;IAIhC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,wBAAwB;IAiChC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;YASX,eAAe;IAsB7B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,oBAAoB;IAO5B;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,gCAAgC;IAaxC,OAAO,CAAC,4BAA4B;IAsCpC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAmC9B;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA8BlC;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAYnC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;YAMpB,0BAA0B;IAUxC;;;;;;OAMG;YACW,wBAAwB;YAiBxB,uBAAuB;IAYrC,OAAO,CAAC,qCAAqC;YAsB/B,eAAe;IAuD7B,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,kCAAkC;IAY1C,OAAO,CAAC,2BAA2B;IAcnC,OAAO,CAAC,sBAAsB;YAehB,iBAAiB;CAsBhC"}
|
|
@@ -35,6 +35,7 @@ const external_transactions_1 = require("./utils/external-transactions");
|
|
|
35
35
|
const gas_1 = require("./utils/gas");
|
|
36
36
|
const gas_fees_1 = require("./utils/gas-fees");
|
|
37
37
|
const history_1 = require("./utils/history");
|
|
38
|
+
const nonce_1 = require("./utils/nonce");
|
|
38
39
|
const swaps_1 = require("./utils/swaps");
|
|
39
40
|
const transaction_type_1 = require("./utils/transaction-type");
|
|
40
41
|
const utils_1 = require("./utils/utils");
|
|
@@ -65,12 +66,13 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
65
66
|
* @param options.disableHistory - Whether to disable storing history in transaction metadata.
|
|
66
67
|
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
|
|
67
68
|
* @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
|
|
68
|
-
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
69
69
|
* @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
|
|
70
70
|
* @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
|
|
71
|
+
* @param options.getExternalPendingTransactions - Callback to retrieve pending transactions from external sources.
|
|
71
72
|
* @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
|
|
72
73
|
* @param options.getNetworkState - Gets the state of the network controller.
|
|
73
74
|
* @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
|
|
75
|
+
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
74
76
|
* @param options.getSelectedAddress - Gets the address of the currently selected account.
|
|
75
77
|
* @param options.incomingTransactions - Configuration options for incoming transaction support.
|
|
76
78
|
* @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.
|
|
@@ -93,7 +95,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
93
95
|
* @param config - Initial options used to configure this controller.
|
|
94
96
|
* @param state - Initial state to set on this controller.
|
|
95
97
|
*/
|
|
96
|
-
constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps,
|
|
98
|
+
constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSavedGasFees, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, speedUpMultiplier, hooks = {}, }, config, state) {
|
|
97
99
|
var _a, _b, _c, _d, _e;
|
|
98
100
|
super(config, state);
|
|
99
101
|
this.inProcessOfSigning = new Set();
|
|
@@ -132,6 +134,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
132
134
|
getGasFeeEstimates || (() => Promise.resolve({}));
|
|
133
135
|
this.getPermittedAccounts = getPermittedAccounts;
|
|
134
136
|
this.getSelectedAddress = getSelectedAddress;
|
|
137
|
+
this.getExternalPendingTransactions =
|
|
138
|
+
getExternalPendingTransactions !== null && getExternalPendingTransactions !== void 0 ? getExternalPendingTransactions : (() => []);
|
|
135
139
|
this.securityProviderRequest = securityProviderRequest;
|
|
136
140
|
this.cancelMultiplier = cancelMultiplier !== null && cancelMultiplier !== void 0 ? cancelMultiplier : exports.CANCEL_RATE;
|
|
137
141
|
this.speedUpMultiplier = speedUpMultiplier !== null && speedUpMultiplier !== void 0 ? speedUpMultiplier : exports.SPEED_UP_RATE;
|
|
@@ -148,7 +152,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
148
152
|
// @ts-expect-error provider types misaligned: SafeEventEmitterProvider vs Record<string,string>
|
|
149
153
|
provider,
|
|
150
154
|
blockTracker,
|
|
151
|
-
getPendingTransactions: this.
|
|
155
|
+
getPendingTransactions: this.getNonceTrackerPendingTransactions.bind(this),
|
|
152
156
|
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
|
|
153
157
|
});
|
|
154
158
|
this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
|
|
@@ -809,6 +813,9 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
809
813
|
*/
|
|
810
814
|
approveTransactionsWithSameNonce(listOfTxParams = []) {
|
|
811
815
|
return __awaiter(this, void 0, void 0, function* () {
|
|
816
|
+
(0, logger_1.projectLogger)('Approving transactions with same nonce', {
|
|
817
|
+
transactions: listOfTxParams,
|
|
818
|
+
});
|
|
812
819
|
if (listOfTxParams.length === 0) {
|
|
813
820
|
return '';
|
|
814
821
|
}
|
|
@@ -828,6 +835,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
828
835
|
const fromAddress = initialTx.from;
|
|
829
836
|
nonceLock = yield this.nonceTracker.getNonceLock(fromAddress);
|
|
830
837
|
const nonce = nonceLock.nextNonce;
|
|
838
|
+
(0, logger_1.projectLogger)('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);
|
|
831
839
|
rawTransactions = yield Promise.all(listOfTxParams.map((txParams) => {
|
|
832
840
|
txParams.nonce = (0, ethereumjs_util_1.addHexPrefix)(nonce.toString(16));
|
|
833
841
|
return this.signExternalTransaction(txParams);
|
|
@@ -1090,6 +1098,15 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1090
1098
|
resultCallbacks = undefined;
|
|
1091
1099
|
});
|
|
1092
1100
|
}
|
|
1101
|
+
const approvalValue = acceptResult.value;
|
|
1102
|
+
const updatedTransaction = approvalValue === null || approvalValue === void 0 ? void 0 : approvalValue.txMeta;
|
|
1103
|
+
if (updatedTransaction) {
|
|
1104
|
+
(0, logger_1.projectLogger)('Updating transaction with approval data', {
|
|
1105
|
+
customNonce: updatedTransaction.customNonceValue,
|
|
1106
|
+
params: updatedTransaction.txParams,
|
|
1107
|
+
});
|
|
1108
|
+
this.updateTransaction(updatedTransaction, 'TransactionController#processApproval - Updated with approval data');
|
|
1109
|
+
}
|
|
1093
1110
|
}
|
|
1094
1111
|
const { isCompleted: isTxCompleted } = this.isTransactionCompleted(transactionId);
|
|
1095
1112
|
if (!isTxCompleted) {
|
|
@@ -1144,8 +1161,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1144
1161
|
const chainId = this.getChainId();
|
|
1145
1162
|
const index = transactions.findIndex(({ id }) => transactionId === id);
|
|
1146
1163
|
const transactionMeta = transactions[index];
|
|
1147
|
-
const { txParams: {
|
|
1148
|
-
let
|
|
1164
|
+
const { txParams: { from }, } = transactionMeta;
|
|
1165
|
+
let releaseNonceLock;
|
|
1149
1166
|
try {
|
|
1150
1167
|
if (!this.sign) {
|
|
1151
1168
|
releaseLock();
|
|
@@ -1161,15 +1178,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1161
1178
|
(0, logger_1.projectLogger)('Skipping approval as signing in progress', transactionId);
|
|
1162
1179
|
return;
|
|
1163
1180
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
// so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce
|
|
1167
|
-
if (!nonceToUse) {
|
|
1168
|
-
nonceLock = yield this.nonceTracker.getNonceLock(from);
|
|
1169
|
-
nonceToUse = (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16));
|
|
1170
|
-
}
|
|
1181
|
+
const [nonce, releaseNonce] = yield (0, nonce_1.getNextNonce)(transactionMeta, this.nonceTracker);
|
|
1182
|
+
releaseNonceLock = releaseNonce;
|
|
1171
1183
|
transactionMeta.status = types_1.TransactionStatus.approved;
|
|
1172
|
-
transactionMeta.txParams.nonce =
|
|
1184
|
+
transactionMeta.txParams.nonce = nonce;
|
|
1173
1185
|
transactionMeta.txParams.chainId = chainId;
|
|
1174
1186
|
const baseTxParams = Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas });
|
|
1175
1187
|
this.updateTransaction(transactionMeta, 'TransactionController#approveTransaction - Transaction approved');
|
|
@@ -1211,9 +1223,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1211
1223
|
finally {
|
|
1212
1224
|
this.inProcessOfSigning.delete(transactionId);
|
|
1213
1225
|
// must set transaction to submitted/failed before releasing lock
|
|
1214
|
-
|
|
1215
|
-
nonceLock.releaseLock();
|
|
1216
|
-
}
|
|
1226
|
+
releaseNonceLock === null || releaseNonceLock === void 0 ? void 0 : releaseNonceLock();
|
|
1217
1227
|
releaseLock();
|
|
1218
1228
|
}
|
|
1219
1229
|
});
|
|
@@ -1561,9 +1571,14 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
|
|
|
1561
1571
|
onTransactionStatusChange(transactionMeta) {
|
|
1562
1572
|
this.hub.emit('transaction-status-update', { transactionMeta });
|
|
1563
1573
|
}
|
|
1574
|
+
getNonceTrackerPendingTransactions(address) {
|
|
1575
|
+
const standardPendingTransactions = this.getNonceTrackerTransactions(types_1.TransactionStatus.submitted, address);
|
|
1576
|
+
const externalPendingTransactions = this.getExternalPendingTransactions(address);
|
|
1577
|
+
return [...standardPendingTransactions, ...externalPendingTransactions];
|
|
1578
|
+
}
|
|
1564
1579
|
getNonceTrackerTransactions(status, address) {
|
|
1565
1580
|
const currentChainId = this.getChainId();
|
|
1566
|
-
return (0,
|
|
1581
|
+
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(currentChainId, address, status, this.state.transactions);
|
|
1567
1582
|
}
|
|
1568
1583
|
onConfirmedTransaction(transactionMeta) {
|
|
1569
1584
|
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|