Skip to content

Commit c4fd0d2

Browse files
authored
Merge branch 'main' into mms2102-bridge-migration
2 parents 5a1b44a + ce7aa93 commit c4fd0d2

File tree

7 files changed

+597
-39
lines changed

7 files changed

+597
-39
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [12.14.2]
10+
### Fixed
11+
- Fix state corruption resulting in inability to create/add accounts ([#31293](https://github.com/MetaMask/metamask-extension/pull/31293))
12+
- Fix infinite load for users who had added MetaETH testnet before v12.14.1 update ([#31298](https://github.com/MetaMask/metamask-extension/pull/31298))
13+
914
## [12.14.1]
1015
### Fixed
1116
- Remove `previousUserTraits` property from metametrics controller state ([#30621](https://github.com/MetaMask/metamask-extension/pull/30621))
@@ -5827,7 +5832,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
58275832
- Added the ability to restore accounts from seed words.
58285833

58295834

5830-
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.14.1...HEAD
5835+
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.14.2...HEAD
5836+
[12.14.2]: https://github.com/MetaMask/metamask-extension/compare/v12.14.1...v12.14.2
58315837
[12.14.1]: https://github.com/MetaMask/metamask-extension/compare/v12.14.0...v12.14.1
58325838
[12.14.0]: https://github.com/MetaMask/metamask-extension/compare/v12.13.1...v12.14.0
58335839
[12.13.1]: https://github.com/MetaMask/metamask-extension/compare/v12.13.0...v12.13.1

app/scripts/controller-init/confirmations/transaction-controller-init.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
22
CHAIN_IDS,
3+
type PublishBatchHookRequest,
4+
type PublishBatchHookTransaction,
35
TransactionController,
46
TransactionControllerMessenger,
57
TransactionMeta,
@@ -17,7 +19,9 @@ import {
1719
import {
1820
SmartTransactionHookMessenger,
1921
submitSmartTransactionHook,
22+
submitBatchSmartTransactionHook,
2023
} from '../../lib/transaction/smart-transactions';
24+
import { getTransactionById } from '../../lib/transaction/util';
2125
import { trace } from '../../../../shared/lib/trace';
2226
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
2327
import {
@@ -153,6 +157,15 @@ export const TransactionControllerInit: ControllerInitFunction<
153157
transactionMeta,
154158
rawTx,
155159
),
160+
publishBatch: async (_request: PublishBatchHookRequest) =>
161+
await publishBatchSmartTransactionHook({
162+
transactionController: controller,
163+
smartTransactionsController: smartTransactionsController(),
164+
hookControllerMessenger:
165+
initMessenger as SmartTransactionHookMessenger,
166+
flatState: getFlatState(),
167+
transactions: _request.transactions as PublishBatchHookTransaction[],
168+
}),
156169
},
157170
// @ts-expect-error Keyring controller expects TxData returned but TransactionController expects TypedTransaction
158171
sign: (...args) => keyringController().signTransaction(...args),
@@ -247,6 +260,62 @@ function publishSmartTransactionHook(
247260
});
248261
}
249262

263+
function publishBatchSmartTransactionHook({
264+
transactionController,
265+
smartTransactionsController,
266+
hookControllerMessenger,
267+
flatState,
268+
transactions,
269+
}: {
270+
transactionController: TransactionController;
271+
smartTransactionsController: SmartTransactionsController;
272+
hookControllerMessenger: SmartTransactionHookMessenger;
273+
flatState: ControllerFlatState;
274+
transactions: PublishBatchHookTransaction[];
275+
}) {
276+
// UI state is required to support shared selectors to avoid duplicate logic in frontend and backend.
277+
// Ideally all backend logic would instead rely on messenger event / state subscriptions.
278+
const uiState = getUIState(flatState);
279+
280+
// @ts-expect-error Smart transaction selector types does not match controller state
281+
const isSmartTransaction = getIsSmartTransaction(uiState);
282+
283+
if (!isSmartTransaction) {
284+
// Will cause TransactionController to publish to the RPC provider as normal.
285+
return undefined;
286+
}
287+
288+
// @ts-expect-error Smart transaction selector types does not match controller state
289+
const featureFlags = getFeatureFlagsByChainId(uiState);
290+
291+
// Get transactionMeta based on the last transaction ID
292+
const lastTransaction = transactions[transactions.length - 1];
293+
const transactionMeta = getTransactionById(
294+
lastTransaction.id ?? '',
295+
transactionController,
296+
);
297+
298+
// If we couldn't find the transaction, we should handle that gracefully
299+
if (!transactionMeta) {
300+
console.warn(
301+
`Publish batch hook: could not find transaction with id ${lastTransaction.id}`,
302+
);
303+
return undefined;
304+
}
305+
306+
return submitBatchSmartTransactionHook({
307+
transactions,
308+
transactionController,
309+
smartTransactionsController,
310+
controllerMessenger: hookControllerMessenger,
311+
isSmartTransaction,
312+
isHardwareWallet: isHardwareWallet(uiState),
313+
// @ts-expect-error Smart transaction selector return type does not match FeatureFlags type from hook
314+
featureFlags,
315+
transactionMeta,
316+
});
317+
}
318+
250319
function getExternalPendingTransactions(
251320
smartTransactionsController: SmartTransactionsController,
252321
address: string,

app/scripts/controller-init/messengers/transaction-controller-messenger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export function getTransactionControllerInitMessenger(
102102
'ApprovalController:endFlow',
103103
'ApprovalController:startFlow',
104104
'ApprovalController:updateRequestState',
105+
'ApprovalController:acceptRequest',
105106
'NetworkController:getEIP1559Compatibility',
106107
'RemoteFeatureFlagController:getState',
107108
'SwapsController:setApproveTxId',

0 commit comments

Comments
 (0)