Skip to content

Commit a31aa8a

Browse files
committed
Expose TransactionController methods needed by SmartTransactionsController through messenger
Currently, the `confirmExternalTransaction`, `getNonceLock`, `getTransactions`, and `updateTransaction` methods in `TransactionController` are accessed by the `SmartTransactionsController` constructor, but in a non-standard way: `SmartTransactionsController` takes function references, when we would like to call these methods via the messenger instead. This commit exposes these methods through TransactionController's messenger so we can do this.
1 parent ec00962 commit a31aa8a

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

packages/transaction-controller/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Expose `confirmExternalTransaction`, `getNonceLock`, `getTransactions`, and `updateTransaction` actions through the messenger ([#6615](https://github.com/MetaMask/core/pull/6615))
13+
- Like other action methods, they are callable as `TransactionController:*`
14+
- Also add associated types:
15+
- `TransactionControllerConfirmExternalTransactionAction`
16+
- `TransactionControllerGetNonceLockAction`
17+
- `TransactionControllerGetTransactionsAction`
18+
- `TransactionControllerUpdateTransactionAction`
19+
1020
### Changed
1121

1222
- Bump `@metamask/utils` from `^11.4.2` to `^11.8.0` ([#6588](https://github.com/MetaMask/core/pull/6588))

packages/transaction-controller/src/TransactionController.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,59 @@ export type TransactionControllerEstimateGasAction = {
308308
handler: TransactionController['estimateGas'];
309309
};
310310

311+
/**
312+
* Adds external provided transaction to state as confirmed transaction.
313+
*
314+
* @param transactionMeta - TransactionMeta to add transactions.
315+
* @param transactionReceipt - TransactionReceipt of the external transaction.
316+
* @param baseFeePerGas - Base fee per gas of the external transaction.
317+
*/
318+
export type TransactionControllerConfirmExternalTransactionAction = {
319+
type: `${typeof controllerName}:confirmExternalTransaction`;
320+
handler: TransactionController['confirmExternalTransaction'];
321+
};
322+
323+
export type TransactionControllerGetNonceLockAction = {
324+
type: `${typeof controllerName}:getNonceLock`;
325+
handler: TransactionController['getNonceLock'];
326+
};
327+
328+
/**
329+
* Search transaction metadata for matching entries.
330+
*
331+
* @param opts - Options bag.
332+
* @param opts.initialList - The transactions to search. Defaults to the current state.
333+
* @param opts.limit - The maximum number of transactions to return. No limit by default.
334+
* @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
335+
* @returns An array of transactions matching the provided options.
336+
*/
337+
export type TransactionControllerGetTransactionsAction = {
338+
type: `${typeof controllerName}:getTransactions`;
339+
handler: TransactionController['getTransactions'];
340+
};
341+
342+
/**
343+
* Updates an existing transaction in state.
344+
*
345+
* @param transactionMeta - The new transaction to store in state.
346+
* @param note - A note or update reason to include in the transaction history.
347+
*/
348+
export type TransactionControllerUpdateTransactionAction = {
349+
type: `${typeof controllerName}:updateTransaction`;
350+
handler: TransactionController['updateTransaction'];
351+
};
352+
311353
/**
312354
* The internal actions available to the TransactionController.
313355
*/
314356
export type TransactionControllerActions =
357+
| TransactionControllerConfirmExternalTransactionAction
315358
| TransactionControllerEstimateGasAction
359+
| TransactionControllerGetNonceLockAction
316360
| TransactionControllerGetStateAction
317-
| TransactionControllerUpdateCustodialTransactionAction;
361+
| TransactionControllerGetTransactionsAction
362+
| TransactionControllerUpdateCustodialTransactionAction
363+
| TransactionControllerUpdateTransactionAction;
318364

319365
/**
320366
* Configuration options for the PendingTransactionTracker

packages/transaction-controller/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ export type {
22
MethodData,
33
Result,
44
TransactionControllerActions,
5+
TransactionControllerConfirmExternalTransactionAction,
56
TransactionControllerEvents,
67
TransactionControllerEstimateGasAction,
8+
TransactionControllerGetNonceLockAction,
79
TransactionControllerGetStateAction,
10+
TransactionControllerGetTransactionsAction,
811
TransactionControllerIncomingTransactionsReceivedEvent,
912
TransactionControllerPostTransactionBalanceUpdatedEvent,
1013
TransactionControllerSpeedupTransactionAddedEvent,
@@ -23,6 +26,7 @@ export type {
2326
TransactionControllerTransactionSubmittedEvent,
2427
TransactionControllerUnapprovedTransactionAddedEvent,
2528
TransactionControllerUpdateCustodialTransactionAction,
29+
TransactionControllerUpdateTransactionAction,
2630
TransactionControllerMessenger,
2731
TransactionControllerOptions,
2832
} from './TransactionController';

0 commit comments

Comments
 (0)