Skip to content

Commit 40acc6c

Browse files
authored
deps: upgrade from ethereumjs-util (#3943)
1 parent 5c542a1 commit 40acc6c

Some content is hidden

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

49 files changed

+175
-150
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@
9292
"@lavamoat/preinstall-always-fail": false,
9393
"@keystonehq/bc-ur-registry-eth>hdkey>secp256k1": true,
9494
"babel-runtime>core-js": false,
95-
"ethereumjs-util>ethereum-cryptography>keccak": true,
96-
"ethereumjs-util>ethereum-cryptography>secp256k1": true,
9795
"simple-git-hooks": false
9896
}
9997
}

packages/accounts-controller/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
"test:watch": "jest --watch"
3232
},
3333
"dependencies": {
34+
"@ethereumjs/util": "^8.1.0",
3435
"@metamask/base-controller": "^4.1.1",
3536
"@metamask/eth-snap-keyring": "^2.1.1",
3637
"@metamask/keyring-api": "^3.0.0",
3738
"@metamask/snaps-sdk": "^1.3.2",
3839
"@metamask/snaps-utils": "^5.1.2",
3940
"@metamask/utils": "^8.3.0",
4041
"deepmerge": "^4.2.2",
41-
"ethereumjs-util": "^7.0.10",
42+
"ethereum-cryptography": "^2.1.2",
4243
"immer": "^9.0.6",
4344
"uuid": "^8.3.2"
4445
},

packages/accounts-controller/src/AccountsController.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toBuffer } from '@ethereumjs/util';
12
import type {
23
ControllerGetStateAction,
34
ControllerStateChangeEvent,
@@ -22,7 +23,7 @@ import type {
2223
import type { SnapId } from '@metamask/snaps-sdk';
2324
import type { Snap } from '@metamask/snaps-utils';
2425
import type { Keyring, Json } from '@metamask/utils';
25-
import { sha256FromString } from 'ethereumjs-util';
26+
import { sha256 } from 'ethereum-cryptography/sha256';
2627
import type { Draft } from 'immer';
2728
import { v4 as uuid } from 'uuid';
2829

@@ -455,7 +456,7 @@ export class AccountsController extends BaseController<
455456
address,
456457
);
457458
const v4options = {
458-
random: sha256FromString(address).slice(0, 16),
459+
random: sha256(toBuffer(address)).slice(0, 16),
459460
};
460461

461462
internalAccounts.push({

packages/accounts-controller/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { toBuffer } from '@ethereumjs/util';
12
import { isCustodyKeyring, KeyringTypes } from '@metamask/keyring-controller';
2-
import { sha256FromString } from 'ethereumjs-util';
3+
import { sha256 } from 'ethereum-cryptography/sha256';
34
import { v4 as uuid } from 'uuid';
45

56
/**
@@ -50,7 +51,7 @@ export function keyringTypeToName(keyringType: string): string {
5051
*/
5152
export function getUUIDFromAddressOfNormalAccount(address: string): string {
5253
const v4options = {
53-
random: sha256FromString(address).slice(0, 16),
54+
random: sha256(toBuffer(address)).slice(0, 16),
5455
};
5556

5657
return uuid(v4options);

packages/assets-controllers/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"test:watch": "jest --watch"
3232
},
3333
"dependencies": {
34+
"@ethereumjs/util": "^8.1.0",
3435
"@ethersproject/address": "^5.7.0",
3536
"@ethersproject/bignumber": "^5.7.0",
3637
"@ethersproject/contracts": "^5.7.0",
@@ -49,10 +50,11 @@
4950
"@metamask/preferences-controller": "^7.0.0",
5051
"@metamask/rpc-errors": "^6.2.0",
5152
"@metamask/utils": "^8.3.0",
53+
"@types/bn.js": "^5.1.5",
5254
"@types/uuid": "^8.3.0",
5355
"async-mutex": "^0.2.6",
56+
"bn.js": "^5.2.1",
5457
"cockatiel": "^3.1.2",
55-
"ethereumjs-util": "^7.0.10",
5658
"lodash": "^4.17.21",
5759
"multiformats": "^9.5.2",
5860
"single-call-balance-checker-abi": "^1.0.0",

packages/assets-controllers/src/AssetsContractController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
} from '@metamask/network-controller';
1212
import type { PreferencesState } from '@metamask/preferences-controller';
1313
import type { Hex } from '@metamask/utils';
14-
import type { BN } from 'ethereumjs-util';
14+
import type BN from 'bn.js';
1515
import abiSingleCallBalancesContract from 'single-call-balance-checker-abi';
1616

1717
import { SupportedTokenDetectionNetworks } from './assetsUtil';

packages/assets-controllers/src/NftController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
getDefaultPreferencesState,
2727
type PreferencesState,
2828
} from '@metamask/preferences-controller';
29-
import { BN } from 'ethereumjs-util';
29+
import BN from 'bn.js';
3030
import nock from 'nock';
3131
import * as sinon from 'sinon';
3232
import { v4 } from 'uuid';

packages/assets-controllers/src/NftController.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ import type {
2626
import type { PreferencesState } from '@metamask/preferences-controller';
2727
import { rpcErrors } from '@metamask/rpc-errors';
2828
import type { Hex } from '@metamask/utils';
29+
import { remove0x } from '@metamask/utils';
2930
import { Mutex } from 'async-mutex';
30-
import { BN, stripHexPrefix } from 'ethereumjs-util';
31+
import BN from 'bn.js';
3132
import { EventEmitter } from 'events';
3233
import { v4 as random } from 'uuid';
3334

@@ -568,7 +569,7 @@ export class NftController extends BaseControllerV1<NftConfig, NftState> {
568569
return [tokenURI, ERC1155];
569570
}
570571

571-
const hexTokenId = stripHexPrefix(BNToHex(new BN(tokenId)))
572+
const hexTokenId = remove0x(BNToHex(new BN(tokenId)))
572573
.padStart(64, '0')
573574
.toLowerCase();
574575
return [tokenURI.replace('{id}', hexTokenId), ERC1155];

packages/assets-controllers/src/Standards/ERC20Standard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { toUtf8 } from '@ethereumjs/util';
12
import { Contract } from '@ethersproject/contracts';
23
import type { Web3Provider } from '@ethersproject/providers';
34
import { decodeSingle } from '@metamask/abi-utils';
45
import { ERC20 } from '@metamask/controller-utils';
56
import { abiERC20 } from '@metamask/metamask-eth-abis';
67
import { assertIsStrictHexString } from '@metamask/utils';
7-
import { toUtf8 } from 'ethereumjs-util';
8-
import type { BN } from 'ethereumjs-util';
8+
import type BN from 'bn.js';
99

1010
import { ethersBigNumberToBN } from '../assetsUtil';
1111

packages/assets-controllers/src/Standards/NftStandards/ERC1155/ERC1155Standard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
timeoutFetch,
1010
} from '@metamask/controller-utils';
1111
import { abiERC1155 } from '@metamask/metamask-eth-abis';
12-
import type { BN } from 'ethereumjs-util';
12+
import type * as BN from 'bn.js';
1313

1414
import { getFormattedIpfsUrl, ethersBigNumberToBN } from '../../../assetsUtil';
1515

0 commit comments

Comments
 (0)