Skip to content

Commit

Permalink
Merge branch 'main' into MMI-5803-deferral-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-t authored Dec 6, 2024
2 parents 46ddf4c + 2fa588d commit a283708
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 81 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/core-monorepo",
"version": "263.0.0",
"version": "266.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^10.1.0",
"@metamask/keyring-controller": "^19.0.1",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@metamask/preferences-controller": "^15.0.1",
"@metamask/providers": "^18.1.1",
"@types/jest": "^27.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ens-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"devDependencies": {
"@babel/runtime": "^7.23.9",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@types/jest": "^27.4.1",
"@types/jest-when": "^2.7.3",
"deepmerge": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/multichain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@metamask/permission-controller": "^11.0.4",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
Expand Down
11 changes: 10 additions & 1 deletion packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [22.1.1]

### Changed

- Bump `@metamask/eth-json-rpc-middleware` from `^15.0.0` to `^15.0.1` ([#5037](https://github.com/MetaMask/core/pull/5037))
- Bump `swappable-obj-proxy` from `^2.2.0` to `^2.3.0` ([#5036](https://github.com/MetaMask/core/pull/5036))
- Bump `@metamask/eth-block-tracker` from `^11.0.2` to `^11.0.3` ([#5025](https://github.com/MetaMask/core/pull/5025))

## [22.1.0]

### Added
Expand Down Expand Up @@ -686,7 +694,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

All changes listed after this point were applied to this package following the monorepo conversion.

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[22.1.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[22.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[22.0.2]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[22.0.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions packages/network-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/network-controller",
"version": "22.1.0",
"version": "22.1.1",
"description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -51,12 +51,12 @@
"@metamask/controller-utils": "^11.4.4",
"@metamask/eth-block-tracker": "^11.0.3",
"@metamask/eth-json-rpc-infura": "^10.0.0",
"@metamask/eth-json-rpc-middleware": "^15.0.0",
"@metamask/eth-json-rpc-middleware": "^15.0.1",
"@metamask/eth-json-rpc-provider": "^4.1.6",
"@metamask/eth-query": "^4.0.0",
"@metamask/json-rpc-engine": "^10.0.1",
"@metamask/rpc-errors": "^7.0.1",
"@metamask/swappable-obj-proxy": "^2.2.0",
"@metamask/swappable-obj-proxy": "^2.3.0",
"@metamask/utils": "^10.0.0",
"async-mutex": "^0.5.0",
"fast-deep-equal": "^3.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/polling-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/profile-sync-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@metamask/base-controller": "^7.0.2",
"@metamask/keyring-api": "^10.1.0",
"@metamask/keyring-controller": "^19.0.1",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@metamask/snaps-sdk": "^6.7.0",
"@metamask/snaps-utils": "^8.3.0",
"@noble/ciphers": "^0.5.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/queued-request-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
"@metamask/controller-utils": "^11.4.4",
"@metamask/json-rpc-engine": "^10.0.1",
"@metamask/rpc-errors": "^7.0.1",
"@metamask/swappable-obj-proxy": "^2.2.0",
"@metamask/swappable-obj-proxy": "^2.3.0",
"@metamask/utils": "^10.0.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@metamask/selected-network-controller": "^20.0.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/selected-network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"dependencies": {
"@metamask/base-controller": "^7.0.2",
"@metamask/json-rpc-engine": "^10.0.1",
"@metamask/swappable-obj-proxy": "^2.2.0",
"@metamask/swappable-obj-proxy": "^2.3.0",
"@metamask/utils": "^10.0.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@metamask/permission-controller": "^11.0.4",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
Expand Down
12 changes: 11 additions & 1 deletion packages/signature-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [23.1.0]

### Changed

- fix: Fixes in signature decoding functionality ([#5028](https://github.com/MetaMask/core/pull/5028))
- fix: signature decoding api should be called for typed sign V3 also ([#5033](https://github.com/MetaMask/core/pull/5033))
- fix: Revert `eth-sig-util` package ([#5027](https://github.com/MetaMask/core/pull/5027))
- fix: Update `jsonschema` version & `eth-sig-util` ([#4998](https://github.com/MetaMask/core/pull/4998))

## [23.0.1]

### Changed
Expand Down Expand Up @@ -431,7 +440,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release ([#1214](https://github.com/MetaMask/core/pull/1214))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[23.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[23.0.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[23.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[22.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions packages/signature-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/signature-controller",
"version": "23.0.1",
"version": "23.1.0",
"description": "Processes signing requests in order to sign arbitrary and typed data",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -60,7 +60,7 @@
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-controller": "^19.0.1",
"@metamask/logging-controller": "^6.0.3",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand Down
21 changes: 19 additions & 2 deletions packages/signature-controller/src/utils/decoding-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,26 @@ describe('Decoding api', () => {
expect(result.error.type).toBe('DECODING_FAILED_WITH_ERROR');
});

it('return undefined for request not of method eth_signTypedData_v4', async () => {
it('return data if method is method eth_signTypedData_v3', async () => {
fetchMock = jest.spyOn(global, 'fetch') as jest.MockedFunction<
typeof fetch
>;
mockFetchResponse(MOCK_RESULT);
const result = await decodeSignature(
{
...PERMIT_REQUEST_MOCK,
method: 'eth_signTypedData_v3',
} as OriginalRequest,
'0x1',
'https://testdecodingurl.com',
);

expect(result.stateChanges).toStrictEqual(MOCK_RESULT.stateChanges);
});

it('return undefined for request not of method eth_signTypedData_v3 or eth_signTypedData_v4', async () => {
const result = await decodeSignature(
{ method: 'eth_signTypedData_v3' } as OriginalRequest,
{ method: 'eth_signTypedData_v1' } as OriginalRequest,
'0x1',
'https://testdecodingurl.com',
);
Expand Down
12 changes: 6 additions & 6 deletions packages/signature-controller/src/utils/decoding-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EthMethod, type OriginalRequest } from '../types';
import { convertNumericValuesToQuotedString } from './normalize';
import { normalizeParam } from './normalize';

export const DECODING_API_ERRORS = {
UNSUPPORTED_SIGNATURE: 'UNSUPPORTED_SIGNATURE',
Expand All @@ -21,18 +21,18 @@ export async function decodeSignature(
) {
try {
const { method, origin, params } = request;
if (request.method === EthMethod.SignTypedDataV4) {
if (
request.method === EthMethod.SignTypedDataV3 ||
request.method === EthMethod.SignTypedDataV4
) {
const response = await fetch(
`${decodingApiUrl}/signature?chainId=${chainId}`,
{
method: 'POST',
body: JSON.stringify({
method,
origin,
params: [
params[0],
JSON.parse(convertNumericValuesToQuotedString(params[1])),
],
params: [params[0], normalizeParam(params[1])],
}),
headers: { 'Content-Type': 'application/json' },
},
Expand Down
32 changes: 22 additions & 10 deletions packages/signature-controller/src/utils/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SignTypedDataVersion } from '@metamask/keyring-controller';

import type { MessageParamsPersonal, MessageParamsTyped } from '../types';
import {
convertNumericValuesToQuotedString,
normalizeParam,
normalizePersonalMessageParams,
normalizeTypedMessageParams,
} from './normalize';
Expand Down Expand Up @@ -42,15 +42,27 @@ describe('Normalize Utils', () => {
);
});

describe('convertNumericValuesToQuotedString', () => {
it('wraps numeric value in a json string in quotes', async () => {
expect(convertNumericValuesToQuotedString('{temp:123}')).toBe(
'{temp:"123"}',
);
expect(convertNumericValuesToQuotedString('{temp:{test:123}}')).toBe(
'{temp:{test:"123"}}',
);
expect(convertNumericValuesToQuotedString('')).toBe('');
describe('normalizeParam', () => {
it('convert numeric value in a stringified json to string', async () => {
expect(normalizeParam('{"temp":123}')).toMatchObject({ temp: '123' });
expect(normalizeParam('{"temp":[123,345,678]}')).toMatchObject({
temp: ['123', '345', '678'],
});
expect(normalizeParam('{"temp":{"test":123}}')).toMatchObject({
temp: { test: '123' },
});
expect(normalizeParam('')).toMatchObject({});
});
it('convert numeric value in a json to string', async () => {
expect(normalizeParam({ temp: 123 })).toMatchObject({ temp: '123' });
expect(normalizeParam({ temp: [123, 345, 678] })).toMatchObject({
temp: ['123', '345', '678'],
});
expect(normalizeParam({ temp: { test: 123 } })).toMatchObject({
temp: { test: '123' },
});
expect(normalizeParam({ temp: null })).toMatchObject({ temp: '' });
expect(normalizeParam({})).toMatchObject({});
});
});
});
42 changes: 34 additions & 8 deletions packages/signature-controller/src/utils/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignTypedDataVersion } from '@metamask/keyring-controller';
import { add0x, bytesToHex, remove0x } from '@metamask/utils';
import { add0x, bytesToHex, type Json, remove0x } from '@metamask/utils';

import type { MessageParamsPersonal, MessageParamsTyped } from '../types';

Expand Down Expand Up @@ -61,14 +61,40 @@ function normalizePersonalMessageData(data: string) {
}

/**
* Takes a stringified JSON and replaces all numeric values in it with quoted strings.
* The method will convery all values in a JSON to string.
* Currently decoding api is not able to take numeric values,
* once apiis fixed we can get rid of this normalization.
*
* @param str - String of JSON to be fixed.
* @returns String with all numeric values converted to quoted strings.
* @param value - JSON to be normalized.
* @returns JSON with all values converted to string.
*/
export function convertNumericValuesToQuotedString(str: string) {
if (!str) {
return '';
function convertJSONValuesToString(value: Json | unknown): Json | string {
if (Array.isArray(value)) {
return value.map((val) => convertJSONValuesToString(val));
}
return str?.replace(/(?<=:\s*)(-?\d+(\.\d+)?)(?=[,\]}])/gu, '"$1"');
if (typeof value === 'object' && value !== null) {
for (const key in value) {
if (Object.prototype.hasOwnProperty.call(value, key)) {
(value as Record<string, unknown>)[key] = convertJSONValuesToString(
(value as Record<string, unknown>)[key],
);
}
}
return value as Json;
}
return value?.toString() ?? '';
}

/**
* Takes a stringified JSON and replaces stringifying all values.
*
* @param param - of JSON to be fixed.
* @returns JSON with all values converted to quoted strings.
*/
export function normalizeParam(param: string | Record<string, unknown>) {
if (!param) {
return {};
}
const parsedParam = typeof param === 'string' ? JSON.parse(param) : param;
return convertJSONValuesToString(parsedParam);
}
6 changes: 5 additions & 1 deletion packages/transaction-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [42.0.0]

### Added

- Retrieve incoming transactions using Accounts API ([#4927](https://github.com/MetaMask/core/pull/4927))
Expand All @@ -20,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `startIncomingTransactionPolling`
- `stopIncomingTransactionPolling`
- `updateIncomingTransactions`
- Bump `@metamask/eth-block-tracker` from `^11.0.2` to `^11.0.3` ([#5025](https://github.com/MetaMask/core/pull/5025))

### Removed

Expand Down Expand Up @@ -1212,7 +1215,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
All changes listed after this point were applied to this package following the monorepo conversion.
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[42.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[41.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[41.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[40.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/transaction-controller",
"version": "41.1.0",
"version": "42.0.0",
"description": "Stores transactions alongside their periodically updated statuses and manages interactions such as approval and cancellation",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -76,7 +76,7 @@
"@metamask/eth-json-rpc-provider": "^4.1.6",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/gas-fee-controller": "^22.0.2",
"@metamask/network-controller": "^22.1.0",
"@metamask/network-controller": "^22.1.1",
"@types/bn.js": "^5.1.5",
"@types/jest": "^27.4.1",
"@types/node": "^16.18.54",
Expand Down
Loading

0 comments on commit a283708

Please sign in to comment.