Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: align ethereumjs versions #5347

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions packages/accounts-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

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

## [24.0.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts-controller/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/base-controller": "^8.0.0",
"@metamask/eth-snap-keyring": "^10.0.0",
"@metamask/keyring-api": "^17.0.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
4 changes: 4 additions & 0 deletions packages/assets-controllers/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))

## [50.0.0]

### Changed
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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('ERC20Standard', () => {
const decimals = await erc20Standard.getTokenDecimals(MKR_ADDRESS);
const symbol = await erc20Standard.getTokenSymbol(MKR_ADDRESS);
expect(decimals).toBe('18');
expect(symbol).toBe('MKR');
expect(symbol).toStrictEqual(expect.stringContaining('MKR'));
});

it('should fail on on empty responses', async () => {
Expand Down
6 changes: 3 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,7 @@ export class ERC20Standard {

// Parse as bytes - treat empty string as failure
try {
const utf8 = toUtf8(result);
const utf8 = bytesToUtf8(hexToBytes(result));
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.1.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 @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `KeyringController:withKeyring` action ([#5332](https://github.com/MetaMask/core/pull/5332))
- The action can be used to consume the `withKeyring` method of the `KeyringController` class

### Changed

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

## [19.1.0]

### Added
Expand Down
6 changes: 3 additions & 3 deletions packages/keyring-controller/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",
"@keystonehq/metamask-airgapped-keyring": "^0.14.1",
"@metamask/base-controller": "^8.0.0",
"@metamask/browser-passworder": "^4.3.0",
Expand All @@ -63,8 +63,8 @@
"immer": "^9.0.6"
},
"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",
Expand Down
12 changes: 5 additions & 7 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 Down Expand Up @@ -1867,10 +1868,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 @@ -1891,13 +1891,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 @@ -3899,7 +3897,7 @@ describe('KeyringController', () => {
}
});
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
Copy link
Contributor

@danroc danroc Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO no longer seems relevant since the line bellow was removed.

// eslint-disable-next-line @typescript-eslint/no-misused-promises

messenger.subscribe('KeyringController:stateChange', listener);

await controller.submitPassword(password);
Expand Down
10 changes: 6 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 Down Expand Up @@ -33,6 +33,7 @@ import {
assertIsStrictHexString,
bytesToHex,
hasProperty,
hexToBytes,
isObject,
isStrictHexString,
isValidHexAddress,
Expand Down Expand Up @@ -1014,7 +1015,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 @@ -1219,7 +1220,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(
Expand All @@ -1229,6 +1230,7 @@ export class KeyringController extends BaseController<
throw new Error(KeyringControllerError.UnsupportedSignTransaction);
}

// @ts-expect-error Upgrade keyring package
return await keyring.signTransaction(address, transaction, opts);
}

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
4 changes: 4 additions & 0 deletions packages/transaction-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

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

## [46.0.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"dependencies": {
"@ethereumjs/common": "^4.4.0",
"@ethereumjs/tx": "^5.4.0",
"@ethereumjs/util": "^8.1.0",
"@ethereumjs/util": "^9.1.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
Expand Down
3 changes: 0 additions & 3 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const { inspect } = require('util');
*/
const ALLOWED_INCONSISTENT_DEPENDENCIES = {
// '@metamask/json-rpc-engine': ['^9.0.3'],
// Temporary to allow separate keyring API and keyring-controller upgrade.
'@ethereumjs/common': ['^3.2.0'],
'@ethereumjs/tx': ['^4.2.0'],
};

/**
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@metamask/accounts-controller@workspace:packages/accounts-controller"
dependencies:
"@ethereumjs/util": "npm:^8.1.0"
"@ethereumjs/util": "npm:^9.1.0"
"@metamask/auto-changelog": "npm:^3.4.4"
"@metamask/base-controller": "npm:^8.0.0"
"@metamask/eth-snap-keyring": "npm:^10.0.0"
Expand Down Expand Up @@ -2455,7 +2455,7 @@ __metadata:
resolution: "@metamask/assets-controllers@workspace:packages/assets-controllers"
dependencies:
"@babel/runtime": "npm:^7.23.9"
"@ethereumjs/util": "npm:^8.1.0"
"@ethereumjs/util": "npm:^9.1.0"
"@ethersproject/abi": "npm:^5.7.0"
"@ethersproject/address": "npm:^5.7.0"
"@ethersproject/bignumber": "npm:^5.7.0"
Expand Down Expand Up @@ -2672,7 +2672,7 @@ __metadata:
resolution: "@metamask/controller-utils@workspace:packages/controller-utils"
dependencies:
"@babel/runtime": "npm:^7.23.9"
"@ethereumjs/util": "npm:^8.1.0"
"@ethereumjs/util": "npm:^9.1.0"
"@metamask/auto-changelog": "npm:^3.4.4"
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/ethjs-unit": "npm:^0.3.0"
Expand Down Expand Up @@ -3339,9 +3339,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@metamask/keyring-controller@workspace:packages/keyring-controller"
dependencies:
"@ethereumjs/common": "npm:^3.2.0"
"@ethereumjs/tx": "npm:^4.2.0"
"@ethereumjs/util": "npm:^8.1.0"
"@ethereumjs/common": "npm:^4.4.0"
"@ethereumjs/tx": "npm:^5.4.0"
"@ethereumjs/util": "npm:^9.1.0"
"@keystonehq/bc-ur-registry-eth": "npm:^0.19.0"
"@keystonehq/metamask-airgapped-keyring": "npm:^0.14.1"
"@lavamoat/allow-scripts": "npm:^3.0.4"
Expand Down Expand Up @@ -4228,7 +4228,7 @@ __metadata:
"@babel/runtime": "npm:^7.23.9"
"@ethereumjs/common": "npm:^4.4.0"
"@ethereumjs/tx": "npm:^5.4.0"
"@ethereumjs/util": "npm:^8.1.0"
"@ethereumjs/util": "npm:^9.1.0"
"@ethersproject/abi": "npm:^5.7.0"
"@ethersproject/contracts": "npm:^5.7.0"
"@ethersproject/providers": "npm:^5.7.0"
Expand Down
Loading