Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7ac23a6
Align versions
matthewwalsh0 Feb 14, 2025
48cae7b
Fix unit tests
matthewwalsh0 Feb 14, 2025
772101d
Fix linting
matthewwalsh0 Feb 14, 2025
325d4c9
Update changelogs
matthewwalsh0 Feb 14, 2025
3a9b37e
Fix unit test
matthewwalsh0 Feb 15, 2025
4f15ad2
Merge branch 'main' into chore/upgrade-ethereumjs
matthewwalsh0 Feb 15, 2025
c0e7168
Fix changelog
matthewwalsh0 Feb 15, 2025
9c5ea25
Merge branch 'main' into chore/upgrade-ethereumjs
matthewwalsh0 Feb 26, 2025
9823377
Use accounts preview builds
matthewwalsh0 Feb 26, 2025
4dabc7d
chore: bump keyring packages
mikesposito Feb 27, 2025
f322f64
bump other controllers
mikesposito Feb 27, 2025
0d8e656
fix profile-sync-controller tests
mikesposito Feb 27, 2025
b8f2930
Update eslint-warning-thresholds.json
mikesposito Feb 27, 2025
499b800
Merge branch 'mikesposito/bump-keyrings' into chore/upgrade-ethereumjs
matthewwalsh0 Feb 27, 2025
4a9b4a9
Fix linting
matthewwalsh0 Feb 27, 2025
bb7863d
Fix changelogs
matthewwalsh0 Feb 28, 2025
23a52a9
update changelogs
mikesposito Mar 3, 2025
3ae7c49
Merge remote-tracking branch 'origin/main' into chore/upgrade-ethereumjs
matthewwalsh0 Mar 3, 2025
a7cf0a6
Use real versions
matthewwalsh0 Mar 3, 2025
91dd836
Merge branch 'main' into mikesposito/bump-keyrings
mikesposito Mar 3, 2025
a0f0d77
Merge remote-tracking branch 'origin/mikesposito/bump-keyrings' into …
matthewwalsh0 Mar 3, 2025
d0de840
Update keyring-internal-api version
matthewwalsh0 Mar 3, 2025
47033f3
Merge remote-tracking branch 'origin/main' into chore/upgrade-ethereumjs
matthewwalsh0 Mar 3, 2025
4b0cb25
Update changelogs
matthewwalsh0 Mar 3, 2025
d5d210a
Fix unit test
matthewwalsh0 Mar 5, 2025
3c1ec84
Merge branch 'main' into chore/upgrade-ethereumjs
matthewwalsh0 Mar 5, 2025
1480337
Fix getTokenSymbol
matthewwalsh0 Mar 5, 2025
6cb4b5d
Merge branch 'main' into chore/upgrade-ethereumjs
matthewwalsh0 Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/accounts-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** Bump `@metamask/keyring-utils` from `^2.3.1` to `^3.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- **BREAKING:** Bump `@metamask/keyring-internal-api` from `^5.0.0` to `^6.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- **BREAKING:** Bump `@metamask/eth-snap-keyring` from `^11.1.0` to `^12.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- **BREAKING:** Bump `@ethereumjs/util` from `^8.1.0` to `^9.1.0` ([#5347](https://github.com/MetaMask/core/pull/5347))

## [25.0.0]

### Changed
Expand Down
8 changes: 4 additions & 4 deletions packages/accounts-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@ethereumjs/util": "^9.1.0",
"@metamask/base-controller": "^8.0.0",
"@metamask/eth-snap-keyring": "^11.1.0",
"@metamask/eth-snap-keyring": "^12.0.0",
"@metamask/keyring-api": "^17.2.0",
"@metamask/keyring-internal-api": "^5.0.0",
"@metamask/keyring-utils": "^2.3.1",
"@metamask/keyring-internal-api": "^6.0.0",
"@metamask/keyring-utils": "^3.0.0",
"@metamask/network-controller": "^22.2.1",
"@metamask/snaps-sdk": "^6.17.1",
"@metamask/snaps-utils": "^8.10.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/accounts-controller/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toBuffer } from '@ethereumjs/util';
import { isCustodyKeyring, KeyringTypes } from '@metamask/keyring-controller';
import { hexToBytes } from '@metamask/utils';
import { sha256 } from 'ethereum-cryptography/sha256';
import type { V4Options } from 'uuid';
import { v4 as uuid } from 'uuid';
Expand Down Expand Up @@ -58,7 +58,7 @@ export function getUUIDOptionsFromAddressOfNormalAccount(
address: string,
): V4Options {
const v4options = {
random: sha256(toBuffer(address)).slice(0, 16),
random: sha256(hexToBytes(address)).slice(0, 16),
};

return v4options;
Expand Down
5 changes: 5 additions & 0 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** Bump `@metamask/keyring-internal-api` from `^5.0.0` to `^6.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- **BREAKING:** Bump `@ethereumjs/util` from `^8.1.0` to `^9.1.0` ([#5347](https://github.com/MetaMask/core/pull/5347))

## [52.0.0]

### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@ethereumjs/util": "^9.1.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/address": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
Expand Down Expand Up @@ -82,7 +82,7 @@
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-controller": "^20.0.0",
"@metamask/keyring-internal-api": "^5.0.0",
"@metamask/keyring-internal-api": "^6.0.0",
"@metamask/keyring-snap-client": "^4.0.1",
"@metamask/network-controller": "^22.2.1",
"@metamask/permission-controller": "^11.0.6",
Expand Down
14 changes: 11 additions & 3 deletions packages/assets-controllers/src/Standards/ERC20Standard.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { toUtf8 } from '@ethereumjs/util';
import { bytesToUtf8 } from '@ethereumjs/util';
import { Contract } from '@ethersproject/contracts';
import type { Web3Provider } from '@ethersproject/providers';
import { decodeSingle } from '@metamask/abi-utils';
import { ERC20 } from '@metamask/controller-utils';
import { abiERC20 } from '@metamask/metamask-eth-abis';
import { assertIsStrictHexString } from '@metamask/utils';
import { assertIsStrictHexString, hexToBytes } from '@metamask/utils';
import type BN from 'bn.js';

import { ethersBigNumberToBN } from '../assetsUtil';
Expand Down Expand Up @@ -98,7 +98,15 @@ export class ERC20Standard {

// Parse as bytes - treat empty string as failure
try {
const utf8 = toUtf8(result);
// Not done in bytesToUtf8 in ethereumjs/util.
const regexPreceedingAndTrailingZeroes = /^(00)+|(00)+$/gu;

const resultTrimmed = result?.replace(
regexPreceedingAndTrailingZeroes,
'',
);

const utf8 = bytesToUtf8(hexToBytes(resultTrimmed));
if (utf8.length > 0) {
return utf8;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/controller-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump `@ethereumjs/util` from `^8.1.0` to `^9.1.0` ([#5347](https://github.com/MetaMask/core/pull/5347))

## [11.5.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@ethereumjs/util": "^9.1.0",
"@metamask/eth-query": "^4.0.0",
"@metamask/ethjs-unit": "^0.3.0",
"@metamask/utils": "^11.2.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/keyring-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/keyring-internal-api` from `^5.0.0` to `^6.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- Bump `@metamask/eth-simple-keyring` from `^9.0.0` to `^10.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- Bump `@metamask/eth-hd-keyring` from `^11.0.0` to `^12.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- Bump `@ethereumjs/util` from `^8.1.0` to `^9.1.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- **BREAKING:** `addNewKeyring` method now returns `Promise<KeyringMetadata>` instead of `Promise<unknown>` ([#5372](https://github.com/MetaMask/core/pull/5372))
- Consumers can use the returned `KeyringMetadata.id` to access the created keyring instance via `withKeyring`.
- **BREAKING:** `withKeyring` method now requires a callback argument of type `({ keyring: SelectedKeyring; metadata: KeyringMetadata }) => Promise<CallbackResult>` ([#5372](https://github.com/MetaMask/core/pull/5372))
Expand Down
14 changes: 7 additions & 7 deletions packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,29 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@ethereumjs/util": "^9.1.0",
"@keystonehq/metamask-airgapped-keyring": "^0.14.1",
"@metamask/base-controller": "^8.0.0",
"@metamask/browser-passworder": "^4.3.0",
"@metamask/eth-hd-keyring": "^11.0.0",
"@metamask/eth-hd-keyring": "^12.0.0",
"@metamask/eth-sig-util": "^8.2.0",
"@metamask/eth-simple-keyring": "^9.0.0",
"@metamask/eth-simple-keyring": "^10.0.0",
"@metamask/keyring-api": "^17.2.0",
"@metamask/keyring-internal-api": "^5.0.0",
"@metamask/keyring-internal-api": "^6.0.0",
"@metamask/utils": "^11.2.0",
"async-mutex": "^0.5.0",
"ethereumjs-wallet": "^1.0.1",
"immer": "^9.0.6",
"ulid": "^2.3.0"
},
"devDependencies": {
"@ethereumjs/common": "^3.2.0",
"@ethereumjs/tx": "^4.2.0",
"@ethereumjs/common": "^4.4.0",
"@ethereumjs/tx": "^5.4.0",
"@keystonehq/bc-ur-registry-eth": "^0.19.0",
"@lavamoat/allow-scripts": "^3.0.4",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-utils": "^2.3.1",
"@metamask/keyring-utils": "^3.0.0",
"@metamask/scure-bip39": "^2.1.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
Expand Down
36 changes: 14 additions & 22 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Chain, Common, Hardfork } from '@ethereumjs/common';
import type { TypedTxData } from '@ethereumjs/tx';
import { TransactionFactory } from '@ethereumjs/tx';
import { CryptoHDKey, ETHSignature } from '@keystonehq/bc-ur-registry-eth';
import { MetaMaskKeyring as QRKeyring } from '@keystonehq/metamask-airgapped-keyring';
Expand All @@ -16,13 +17,7 @@ import SimpleKeyring from '@metamask/eth-simple-keyring';
import type { EthKeyring } from '@metamask/keyring-internal-api';
import type { KeyringClass } from '@metamask/keyring-utils';
import { wordlist } from '@metamask/scure-bip39/dist/wordlists/english';
import {
bytesToHex,
isValidHexAddress,
type Hex,
type Keyring,
type Json,
} from '@metamask/utils';
import { bytesToHex, isValidHexAddress, type Hex } from '@metamask/utils';
import * as sinon from 'sinon';
import * as uuid from 'uuid';

Expand Down Expand Up @@ -311,7 +306,7 @@ describe('KeyringController', () => {
await withController(async ({ controller, initialState }) => {
const [primaryKeyring] = controller.getKeyringsByType(
KeyringTypes.hd,
) as Keyring<Json>[];
) as EthKeyring[];
const addedAccountAddress =
await controller.addNewAccountForKeyring(primaryKeyring);
expect(initialState.keyrings).toHaveLength(1);
Expand Down Expand Up @@ -361,7 +356,7 @@ describe('KeyringController', () => {
await withController(async ({ controller, initialState }) => {
const [primaryKeyring] = controller.getKeyringsByType(
KeyringTypes.hd,
) as Keyring<Json>[];
) as EthKeyring[];
const addedAccountAddress =
await controller.addNewAccountForKeyring(primaryKeyring);
expect(initialState.keyrings).toHaveLength(1);
Expand All @@ -382,7 +377,7 @@ describe('KeyringController', () => {
await withController(async ({ controller, initialState }) => {
const [primaryKeyring] = controller.getKeyringsByType(
KeyringTypes.hd,
) as Keyring<Json>[];
) as EthKeyring[];
const accountCount = initialState.keyrings[0].accounts.length;
await expect(
controller.addNewAccountForKeyring(
Expand All @@ -398,7 +393,7 @@ describe('KeyringController', () => {
const accountCount = initialState.keyrings[0].accounts.length;
const [primaryKeyring] = controller.getKeyringsByType(
KeyringTypes.hd,
) as Keyring<Json>[];
) as EthKeyring[];
const firstAccountAdded = await controller.addNewAccountForKeyring(
primaryKeyring,
accountCount,
Expand Down Expand Up @@ -758,7 +753,7 @@ describe('KeyringController', () => {
await withController(async ({ controller }) => {
const primaryKeyring = controller.getKeyringsByType(
KeyringTypes.hd,
)[0] as Keyring<Json> & { mnemonic: string };
)[0] as EthKeyring & { mnemonic: string };

primaryKeyring.mnemonic = '';

Expand Down Expand Up @@ -1070,7 +1065,7 @@ describe('KeyringController', () => {
const keyring = (await controller.getKeyringForAccount(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
normalizedInitialAccounts[0]!,
)) as Keyring<Json>;
)) as EthKeyring;
expect(keyring.type).toBe('HD Key Tree');
expect(keyring.getAccounts()).toStrictEqual(
normalizedInitialAccounts,
Expand Down Expand Up @@ -1140,7 +1135,7 @@ describe('KeyringController', () => {
await withController(async ({ controller }) => {
const keyrings = controller.getKeyringsByType(
KeyringTypes.hd,
) as Keyring<Json>[];
) as EthKeyring[];
expect(keyrings).toHaveLength(1);
expect(keyrings[0].type).toBe(KeyringTypes.hd);
expect(keyrings[0].getAccounts()).toStrictEqual(
Expand Down Expand Up @@ -1175,7 +1170,7 @@ describe('KeyringController', () => {
await withController(async ({ controller }) => {
const primaryKeyring = controller.getKeyringsByType(
KeyringTypes.hd,
)[0] as Keyring<Json>;
)[0] as EthKeyring;
const [addedAccount] = await primaryKeyring.addAccounts(1);

await controller.persistAllKeyrings();
Expand Down Expand Up @@ -2081,10 +2076,9 @@ describe('KeyringController', () => {
it('should sign transaction', async () => {
await withController(async ({ controller, initialState }) => {
const account = initialState.keyrings[0].accounts[0];
const txParams = {
const txParams: TypedTxData = {
chainId: 5,
data: '0x1',
from: account,
gasLimit: '0x5108',
gasPrice: '0x5108',
to: '0x51253087e6f8358b5f10c0a94315d69db3357859',
Expand All @@ -2105,13 +2099,11 @@ describe('KeyringController', () => {
});

it('should not sign transaction if from account is not provided', async () => {
await withController(async ({ controller, initialState }) => {
await withController(async ({ controller }) => {
await expect(async () => {
const account = initialState.keyrings[0].accounts[0];
const txParams = {
const txParams: TypedTxData = {
chainId: 5,
data: '0x1',
from: account,
gasLimit: '0x5108',
gasPrice: '0x5108',
to: '0x51253087e6f8358b5f10c0a94315d69db3357859',
Expand Down Expand Up @@ -2780,7 +2772,7 @@ describe('KeyringController', () => {
await withController(async ({ controller }) => {
const primaryKeyring = controller.getKeyringsByType(
KeyringTypes.hd,
)[0] as Keyring<Json> & { mnemonic: string };
)[0] as EthKeyring & { mnemonic: string };

primaryKeyring.mnemonic = '';

Expand Down
9 changes: 5 additions & 4 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TxData, TypedTransaction } from '@ethereumjs/tx';
import { isValidPrivate, toBuffer, getBinarySize } from '@ethereumjs/util';
import type { TypedTransaction, TypedTxData } from '@ethereumjs/tx';
import { isValidPrivate, getBinarySize } from '@ethereumjs/util';
import type {
MetaMaskKeyring as QRKeyring,
IKeyringState as IQRKeyringState,
Expand All @@ -26,6 +26,7 @@ import {
assertIsStrictHexString,
bytesToHex,
hasProperty,
hexToBytes,
isObject,
isStrictHexString,
isValidHexAddress,
Expand Down Expand Up @@ -1053,7 +1054,7 @@ export class KeyringController extends BaseController<

let bufferedPrivateKey;
try {
bufferedPrivateKey = toBuffer(prefixed);
bufferedPrivateKey = hexToBytes(prefixed);
} catch {
throw new Error('Cannot import invalid private key.');
}
Expand Down Expand Up @@ -1298,7 +1299,7 @@ export class KeyringController extends BaseController<
transaction: TypedTransaction,
from: string,
opts?: Record<string, unknown>,
): Promise<TxData> {
): Promise<TypedTxData> {
this.#assertIsUnlocked();
const address = ethNormalize(from) as Hex;
const keyring = (await this.getKeyringForAccount(address)) as EthKeyring;
Expand Down
4 changes: 2 additions & 2 deletions packages/keyring-controller/tests/mocks/mockTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionFactory, type TxData } from '@ethereumjs/tx';
import { TransactionFactory, type TypedTxData } from '@ethereumjs/tx';

/**
* Build a mock transaction, optionally overriding
Expand All @@ -7,7 +7,7 @@ import { TransactionFactory, type TxData } from '@ethereumjs/tx';
* @param options - The transaction options to override.
* @returns The mock transaction.
*/
export const buildMockTransaction = (options: TxData = {}) =>
export const buildMockTransaction = (options: TypedTxData = {}) =>
TransactionFactory.fromTxData({
to: '0xB1A13aBECeB71b2E758c7e0Da404DF0C72Ca3a12',
value: '0x0',
Expand Down
1 change: 1 addition & 0 deletions packages/multichain-transactions-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/keyring-internal-api` from `^5.0.0` to `^6.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))
- Sort transactions (newest first) ([#5339](https://github.com/MetaMask/core/pull/5339))
- Bump `@metamask/keyring-controller"` from `^19.1.0` to `^19.2.0` ([#5357](https://github.com/MetaMask/core/pull/5357))
- Bump `@metamask/keyring-api"` from `^17.0.0` to `^17.2.0` ([#5366](https://github.com/MetaMask/core/pull/5366))
Expand Down
2 changes: 1 addition & 1 deletion packages/multichain-transactions-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"dependencies": {
"@metamask/base-controller": "^8.0.0",
"@metamask/keyring-api": "^17.2.0",
"@metamask/keyring-internal-api": "^5.0.0",
"@metamask/keyring-internal-api": "^6.0.0",
"@metamask/keyring-snap-client": "^4.0.1",
"@metamask/polling-controller": "^12.0.3",
"@metamask/snaps-controllers": "^9.19.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/profile-sync-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** Bump `@metamask/keyring-internal-api` from `^5.0.0` to `^6.0.0` ([#5347](https://github.com/MetaMask/core/pull/5347))

## [9.0.0]

### Changed
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 @@ -117,7 +117,7 @@
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/accounts-controller": "^25.0.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-internal-api": "^5.0.0",
"@metamask/keyring-internal-api": "^6.0.0",
"@metamask/providers": "^18.1.1",
"@metamask/snaps-controllers": "^9.19.0",
"@types/jest": "^27.4.1",
Expand Down
Loading
Loading