Skip to content

Commit dd1b179

Browse files
authored
Merge pull request #26730 from MetaMask/Version-v12.1.1
Version v12.1.1 RC
2 parents 161bf0e + 00ebb93 commit dd1b179

File tree

60 files changed

+3019
-1401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3019
-1401
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff --git a/lib/impl/core-in-iframe.js b/lib/impl/core-in-iframe.js
2+
index c47cf3bff860d6b1855341c00b80fc6c40f9d6d5..275eb0f312ff396819fa406c154a3562842db49d 100644
3+
--- a/lib/impl/core-in-iframe.js
4+
+++ b/lib/impl/core-in-iframe.js
5+
@@ -116,7 +116,9 @@ class CoreInIframe {
6+
this._log.enabled = !!this._settings.debug;
7+
window.addEventListener('message', this.boundHandleMessage);
8+
window.addEventListener('unload', this.boundDispose);
9+
- await iframe.init(this._settings);
10+
+ const modifiedSettings = Object.assign({}, this.settings);
11+
+ modifiedSettings.env = 'webextension';
12+
+ await iframe.init(modifiedSettings);
13+
if (this._settings.sharedLogger !== false) {
14+
iframe.initIframeLogger();
15+
}
16+
diff --git a/lib/popup/index.js b/lib/popup/index.js
17+
index 9b13c370a5ac8b4e4fc0315ed40cdf615d0bb0cb..4dbd97fc28df49beb73379451974ec48a8a42ea7 100644
18+
--- a/lib/popup/index.js
19+
+++ b/lib/popup/index.js
20+
@@ -229,10 +229,12 @@ class PopupManager extends events_1.default {
21+
}
22+
else if (message.type === events_2.POPUP.LOADED) {
23+
this.handleMessage(message);
24+
+ const modifiedSettings = Object.assign({}, this.settings);
25+
+ modifiedSettings.env = 'webextension';
26+
this.channel.postMessage({
27+
type: events_2.POPUP.INIT,
28+
payload: {
29+
- settings: this.settings,
30+
+ settings: modifiedSettings,
31+
useCore: true,
32+
},
33+
});

CHANGELOG.md

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

77
## [Unreleased]
88

9+
## [12.1.1]
10+
### Changed
11+
- Update Polygon from MATIC to POL ([#26671](https://github.com/MetaMask/metamask-extension/pull/26671))
12+
13+
### Fixed
14+
- Fix signature confirmation UI crash ([#26143](https://github.com/MetaMask/metamask-extension/pull/26143))
15+
- Update current selected account when selected account is removed ([#26573](https://github.com/MetaMask/metamask-extension/pull/26573), [#26742](https://github.com/MetaMask/metamask-extension/pull/26742), [#26773](https://github.com/MetaMask/metamask-extension/pull/26773))
16+
- This also includes a migration to reset the selected account if it's currently invalid
17+
- Prevent pending confirmations from being inaccessible after attempting to add currently selected chain ([#26726](https://github.com/MetaMask/metamask-extension/pull/26726))
18+
919
## [12.1.0]
1020
### Added
1121
- Launched a feature displaying the percentage increase or decrease for tokens within the UI ([#24223](https://github.com/MetaMask/metamask-extension/pull/24223))
@@ -4996,7 +5006,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
49965006
- Added the ability to restore accounts from seed words.
49975007

49985008

4999-
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.1.0...HEAD
5009+
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.1.1...HEAD
5010+
[12.1.1]: https://github.com/MetaMask/metamask-extension/compare/v12.1.0...v12.1.1
50005011
[12.1.0]: https://github.com/MetaMask/metamask-extension/compare/v12.0.6...v12.1.0
50015012
[12.0.6]: https://github.com/MetaMask/metamask-extension/compare/v12.0.5...v12.0.6
50025013
[12.0.5]: https://github.com/MetaMask/metamask-extension/compare/v12.0.4...v12.0.5

app/images/matic-token.png

-15.9 KB
Binary file not shown.
File renamed without changes.

app/scripts/controllers/metamask-notifications/constants/notification-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const CHAIN_SYMBOLS = {
5555
[NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',
5656
[NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',
5757
[NOTIFICATION_CHAINS.BSC]: 'BNB',
58-
[NOTIFICATION_CHAINS.POLYGON]: 'MATIC',
58+
[NOTIFICATION_CHAINS.POLYGON]: 'POL',
5959
[NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',
6060
[NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',
6161
[NOTIFICATION_CHAINS.LINEA]: 'ETH',

app/scripts/lib/accounts/BalancesController.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { Poller } from './Poller';
1919
const mockBtcAccount = createMockInternalAccount({
2020
address: '',
2121
name: 'Btc Account',
22-
// @ts-expect-error - account type may be btc or eth, mock file is not typed
2322
type: BtcAccountType.P2wpkh,
2423
snapOptions: {
2524
id: 'mock-btc-snap',

app/scripts/lib/createDupeReqFilterStream.test.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import OurReadableStream from 'readable-stream';
33
import ReadableStream2 from 'readable-stream-2';
44
import ReadableStream3 from 'readable-stream-3';
55

6-
import type { JsonRpcRequest } from '@metamask/utils';
6+
import type { JsonRpcNotification, JsonRpcRequest } from '@metamask/utils';
77
import createDupeReqFilterStream, {
88
THREE_MINUTES,
99
} from './createDupeReqFilterStream';
@@ -26,7 +26,7 @@ function createTestStream(output: JsonRpcRequest[] = [], S = Transform) {
2626
}
2727

2828
function runStreamTest(
29-
requests: JsonRpcRequest[] = [],
29+
requests: (JsonRpcRequest | JsonRpcNotification)[] = [],
3030
advanceTimersTime = 10,
3131
S = Transform,
3232
) {
@@ -54,12 +54,12 @@ describe('createDupeReqFilterStream', () => {
5454
const requests = [
5555
{ id: 1, method: 'foo' },
5656
{ id: 2, method: 'bar' },
57-
];
57+
].map((request) => ({ ...request, jsonrpc: '2.0' as const }));
5858

5959
const expectedOutput = [
6060
{ id: 1, method: 'foo' },
6161
{ id: 2, method: 'bar' },
62-
];
62+
].map((output) => ({ ...output, jsonrpc: '2.0' }));
6363

6464
const output = await runStreamTest(requests);
6565
expect(output).toEqual(expectedOutput);
@@ -69,18 +69,25 @@ describe('createDupeReqFilterStream', () => {
6969
const requests = [
7070
{ id: 1, method: 'foo' },
7171
{ id: 1, method: 'foo' }, // duplicate
72-
];
72+
].map((request) => ({ ...request, jsonrpc: '2.0' as const }));
7373

74-
const expectedOutput = [{ id: 1, method: 'foo' }];
74+
const expectedOutput = [{ id: 1, method: 'foo' }].map((output) => ({
75+
...output,
76+
jsonrpc: '2.0',
77+
}));
7578

7679
const output = await runStreamTest(requests);
7780
expect(output).toEqual(expectedOutput);
7881
});
7982

8083
it("lets through requests if they don't have an id", async () => {
81-
const requests = [{ method: 'notify1' }, { method: 'notify2' }];
84+
const requests = [{ method: 'notify1' }, { method: 'notify2' }].map(
85+
(request) => ({ ...request, jsonrpc: '2.0' as const }),
86+
);
8287

83-
const expectedOutput = [{ method: 'notify1' }, { method: 'notify2' }];
88+
const expectedOutput = [{ method: 'notify1' }, { method: 'notify2' }].map(
89+
(output) => ({ ...output, jsonrpc: '2.0' }),
90+
);
8491

8592
const output = await runStreamTest(requests);
8693
expect(output).toEqual(expectedOutput);
@@ -95,15 +102,15 @@ describe('createDupeReqFilterStream', () => {
95102
{ method: 'notify2' },
96103
{ id: 2, method: 'bar' },
97104
{ id: 3, method: 'baz' },
98-
];
105+
].map((request) => ({ ...request, jsonrpc: '2.0' as const }));
99106

100107
const expectedOutput = [
101108
{ id: 1, method: 'foo' },
102109
{ method: 'notify1' },
103110
{ id: 2, method: 'bar' },
104111
{ method: 'notify2' },
105112
{ id: 3, method: 'baz' },
106-
];
113+
].map((output) => ({ ...output, jsonrpc: '2.0' }));
107114

108115
const output = await runStreamTest(requests);
109116
expect(output).toEqual(expectedOutput);

app/scripts/lib/createDupeReqFilterStream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const THREE_MINUTES = MINUTE * 3;
1111
* @returns The expiry set.
1212
*/
1313
const makeExpirySet = () => {
14-
const map: Map<string | number, number> = new Map();
14+
const map: Map<string | number | null, number> = new Map();
1515

1616
setInterval(() => {
1717
const cutoffTime = Date.now() - THREE_MINUTES;
@@ -32,7 +32,7 @@ const makeExpirySet = () => {
3232
* @param value - The value to add.
3333
* @returns `true` if the value was added, and `false` if it already existed.
3434
*/
35-
add(value: string | number) {
35+
add(value: string | number | null) {
3636
if (!map.has(value)) {
3737
map.set(value, Date.now());
3838
return true;

app/scripts/lib/ppom/ppom-middleware.test.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import {
2-
type Hex,
3-
JsonRpcRequestStruct,
4-
JsonRpcResponseStruct,
5-
} from '@metamask/utils';
1+
import { type Hex, JsonRpcResponseStruct } from '@metamask/utils';
62
import { CHAIN_IDS } from '../../../../shared/constants/network';
73

84
import {
95
BlockaidReason,
106
BlockaidResultType,
117
} from '../../../../shared/constants/security-provider';
128
import { flushPromises } from '../../../../test/lib/timer-helpers';
13-
import { createPPOMMiddleware } from './ppom-middleware';
9+
import { createPPOMMiddleware, PPOMMiddlewareRequest } from './ppom-middleware';
1410
import {
1511
generateSecurityAlertId,
1612
handlePPOMError,
@@ -28,6 +24,12 @@ const SECURITY_ALERT_RESPONSE_MOCK: SecurityAlertResponse = {
2824
reason: BlockaidReason.permitFarming,
2925
};
3026

27+
const REQUEST_MOCK = {
28+
params: [],
29+
id: '',
30+
jsonrpc: '2.0' as const,
31+
};
32+
3133
const createMiddleware = (
3234
options: {
3335
chainId?: Hex;
@@ -48,8 +50,7 @@ const createMiddleware = (
4850
const preferenceController = {
4951
store: {
5052
getState: () => ({
51-
securityAlertsEnabled:
52-
securityAlertsEnabled === undefined ?? securityAlertsEnabled,
53+
securityAlertsEnabled: securityAlertsEnabled ?? true,
5354
}),
5455
},
5556
};
@@ -106,14 +107,14 @@ describe('PPOMMiddleware', () => {
106107
});
107108

108109
const req = {
109-
...JsonRpcRequestStruct,
110+
...REQUEST_MOCK,
110111
method: 'eth_sendTransaction',
111112
securityAlertResponse: undefined,
112113
};
113114

114115
await middlewareFunction(
115116
req,
116-
{ ...JsonRpcResponseStruct },
117+
{ ...JsonRpcResponseStruct.TYPE },
117118
() => undefined,
118119
);
119120

@@ -130,20 +131,20 @@ describe('PPOMMiddleware', () => {
130131
it('adds loading response to confirmation requests while validation is in progress', async () => {
131132
const middlewareFunction = createMiddleware();
132133

133-
const req = {
134-
...JsonRpcRequestStruct,
134+
const req: PPOMMiddlewareRequest<(string | { to: string })[]> = {
135+
...REQUEST_MOCK,
135136
method: 'eth_sendTransaction',
136137
securityAlertResponse: undefined,
137138
};
138139

139140
await middlewareFunction(
140141
req,
141-
{ ...JsonRpcResponseStruct },
142+
{ ...JsonRpcResponseStruct.TYPE },
142143
() => undefined,
143144
);
144145

145-
expect(req.securityAlertResponse.reason).toBe(BlockaidReason.inProgress);
146-
expect(req.securityAlertResponse.result_type).toBe(
146+
expect(req.securityAlertResponse?.reason).toBe(BlockaidReason.inProgress);
147+
expect(req.securityAlertResponse?.result_type).toBe(
147148
BlockaidResultType.Loading,
148149
);
149150
});
@@ -154,7 +155,7 @@ describe('PPOMMiddleware', () => {
154155
});
155156

156157
const req = {
157-
...JsonRpcRequestStruct,
158+
...REQUEST_MOCK,
158159
method: 'eth_sendTransaction',
159160
securityAlertResponse: undefined,
160161
};
@@ -171,14 +172,14 @@ describe('PPOMMiddleware', () => {
171172
});
172173

173174
const req = {
174-
...JsonRpcRequestStruct,
175+
...REQUEST_MOCK,
175176
method: 'eth_sendTransaction',
176177
securityAlertResponse: undefined,
177178
};
178179

179180
await middlewareFunction(
180181
req,
181-
{ ...JsonRpcResponseStruct },
182+
{ ...JsonRpcResponseStruct.TYPE },
182183
() => undefined,
183184
);
184185

@@ -190,14 +191,14 @@ describe('PPOMMiddleware', () => {
190191
const middlewareFunction = createMiddleware();
191192

192193
const req = {
193-
...JsonRpcRequestStruct,
194+
...REQUEST_MOCK,
194195
method: 'eth_someRequest',
195196
securityAlertResponse: undefined,
196197
};
197198

198199
await middlewareFunction(
199200
req,
200-
{ ...JsonRpcResponseStruct },
201+
{ ...JsonRpcResponseStruct.TYPE },
201202
() => undefined,
202203
);
203204

@@ -210,8 +211,8 @@ describe('PPOMMiddleware', () => {
210211
const nextMock = jest.fn();
211212

212213
await middlewareFunction(
213-
{ ...JsonRpcRequestStruct, method: 'eth_sendTransaction' },
214-
{ ...JsonRpcResponseStruct },
214+
{ ...REQUEST_MOCK, method: 'eth_sendTransaction' },
215+
{ ...JsonRpcResponseStruct.TYPE },
215216
nextMock,
216217
);
217218

@@ -227,12 +228,12 @@ describe('PPOMMiddleware', () => {
227228
const middlewareFunction = createMiddleware({ error });
228229

229230
const req = {
230-
...JsonRpcRequestStruct,
231+
...REQUEST_MOCK,
231232
method: 'eth_sendTransaction',
232233
securityAlertResponse: undefined,
233234
};
234235

235-
await middlewareFunction(req, { ...JsonRpcResponseStruct }, nextMock);
236+
await middlewareFunction(req, { ...JsonRpcResponseStruct.TYPE }, nextMock);
236237

237238
expect(req.securityAlertResponse).toStrictEqual(
238239
SECURITY_ALERT_RESPONSE_MOCK,

app/scripts/lib/ppom/ppom-middleware.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ const CONFIRMATION_METHODS = Object.freeze([
2727
...SIGNING_METHODS,
2828
]);
2929

30+
export type PPOMMiddlewareRequest<
31+
Params extends JsonRpcParams = JsonRpcParams,
32+
> = Required<JsonRpcRequest<Params>> & {
33+
securityAlertResponse?: SecurityAlertResponse | undefined;
34+
};
35+
3036
/**
3137
* Middleware function that handles JSON RPC requests.
3238
* This function will be called for every JSON RPC request.
@@ -44,7 +50,7 @@ const CONFIRMATION_METHODS = Object.freeze([
4450
* @returns PPOMMiddleware function.
4551
*/
4652
export function createPPOMMiddleware<
47-
Params extends JsonRpcParams,
53+
Params extends (string | { to: string })[],
4854
Result extends Json,
4955
>(
5056
ppomController: PPOMController,
@@ -58,7 +64,7 @@ export function createPPOMMiddleware<
5864
) => void,
5965
) {
6066
return async (
61-
req: JsonRpcRequest<Params>,
67+
req: PPOMMiddlewareRequest<Params>,
6268
_res: JsonRpcResponse<Result>,
6369
next: () => void,
6470
) => {

0 commit comments

Comments
 (0)