Skip to content

Commit

Permalink
deps: import BN directly from bn.js instead of through ethereumjs-util
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Feb 8, 2024
1 parent 00e4a9c commit 3ecbd37
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 27 deletions.
2 changes: 2 additions & 0 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@metamask/utils": "^8.3.0",
"@types/uuid": "^8.3.0",
"async-mutex": "^0.2.6",
"bn.js": "^5.2.1",
"cockatiel": "^3.1.2",
"ethereumjs-util": "^7.0.10",
"lodash": "^4.17.21",
Expand All @@ -62,6 +63,7 @@
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^3.0.0",
"@types/bn.js": "^5.1.5",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
} from '@metamask/network-controller';
import type { PreferencesState } from '@metamask/preferences-controller';
import type { Hex } from '@metamask/utils';
import type { BN } from 'ethereumjs-util';
import type BN from 'bn.js';
import abiSingleCallBalancesContract from 'single-call-balance-checker-abi';

import { SupportedTokenDetectionNetworks } from './assetsUtil';
Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/src/NftController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
getDefaultPreferencesState,
type PreferencesState,
} from '@metamask/preferences-controller';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';
import nock from 'nock';
import * as sinon from 'sinon';
import { v4 } from 'uuid';
Expand Down
3 changes: 2 additions & 1 deletion packages/assets-controllers/src/NftController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import type { PreferencesState } from '@metamask/preferences-controller';
import { rpcErrors } from '@metamask/rpc-errors';
import type { Hex } from '@metamask/utils';
import { Mutex } from 'async-mutex';
import { BN, stripHexPrefix } from 'ethereumjs-util';
import BN from 'bn.js';
import { stripHexPrefix } from 'ethereumjs-util';
import { EventEmitter } from 'events';
import { v4 as random } from 'uuid';

Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/src/Standards/ERC20Standard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ 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 type * as BN from 'bn.js';
import { toUtf8 } from 'ethereumjs-util';
import type { BN } from 'ethereumjs-util';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
timeoutFetch,
} from '@metamask/controller-utils';
import { abiERC1155 } from '@metamask/metamask-eth-abis';
import type { BN } from 'ethereumjs-util';
import type * as BN from 'bn.js';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ControllerMessenger } from '@metamask/base-controller';
import { toHex } from '@metamask/controller-utils';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';

import { flushPromises } from '../../../tests/helpers';
import { TokenBalancesController } from './TokenBalancesController';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
type PreferencesState,
} from '@metamask/preferences-controller';
import type { Hex } from '@metamask/utils';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';
import nock from 'nock';
import * as sinon from 'sinon';

Expand Down
3 changes: 2 additions & 1 deletion packages/assets-controllers/src/assetsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
toChecksumHexAddress,
} from '@metamask/controller-utils';
import type { Hex } from '@metamask/utils';
import { BN, stripHexPrefix } from 'ethereumjs-util';
import BN from 'bn.js';
import { stripHexPrefix } from 'ethereumjs-util';
import { CID } from 'multiformats/cid';

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/src/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import EthQuery from '@metamask/eth-query';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';
import nock from 'nock';

import { FakeProvider } from '../../../tests/fake-provider';
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type EthQuery from '@metamask/eth-query';
import { fromWei, toWei } from '@metamask/ethjs-unit';
import type { Hex, Json } from '@metamask/utils';
import { isStrictHexString } from '@metamask/utils';
import BN from 'bn.js';
import ensNamehash from 'eth-ens-namehash';
import {
addHexPrefix,
isValidAddress,
isHexString,
BN,
toChecksumAddress,
stripHexPrefix,
} from 'ethereumjs-util';
Expand Down
3 changes: 2 additions & 1 deletion packages/gas-fee-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
"@metamask/polling-controller": "^5.0.0",
"@metamask/utils": "^8.3.0",
"@types/uuid": "^8.3.0",
"ethereumjs-util": "^7.0.10",
"bn.js": "^5.2.1",
"uuid": "^8.3.2"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@types/bn.js": "^5.1.2",
"@types/jest": "^27.4.1",
"@types/jest-when": "^2.7.3",
"deepmerge": "^4.2.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { query, fromHex, toHex } from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';
import { when } from 'jest-when';

import { FakeProvider } from '../../../tests/fake-provider';
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/src/fetchBlockFeeHistory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { query, fromHex, toHex } from '@metamask/controller-utils';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';

// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import EthQuery from '@metamask/eth-query';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';
import { when } from 'jest-when';

import fetchBlockFeeHistory from './fetchBlockFeeHistory';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';

import calculateGasFeeEstimatesForPriorityLevels from './calculateGasFeeEstimatesForPriorityLevels';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GWEI } from '@metamask/controller-utils';
import { fromWei } from '@metamask/ethjs-unit';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';

import type { FeeHistoryBlock } from '../fetchBlockFeeHistory';
import type { Eip1559GasFee, GasFeeEstimates } from '../GasFeeController';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BN } from 'ethereumjs-util';
import type * as BN from 'bn.js';

/**
* Finds the median among a list of numbers. Note that this is different from the implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BN } from 'ethereumjs-util';
import type * as BN from 'bn.js';

export type EthBlock = {
number: BN;
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/src/gas-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
weiHexToGweiDec,
} from '@metamask/controller-utils';
import type EthQuery from '@metamask/eth-query';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';

import type {
GasFeeEstimates,
Expand Down
1 change: 1 addition & 0 deletions packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@metamask/rpc-errors": "^6.1.0",
"@metamask/utils": "^8.3.0",
"async-mutex": "^0.2.6",
"bn.js": "^5.2.1",
"eth-method-registry": "^4.0.0",
"ethereumjs-util": "^7.0.10",
"fast-json-patch": "^3.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BNToHex } from '@metamask/controller-utils';
import type { Hex } from '@metamask/utils';
import { BN } from 'ethereumjs-util';
import BN from 'bn.js';
import { v1 as random } from 'uuid';

import { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';
Expand Down
1 change: 1 addition & 0 deletions packages/user-operation-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@metamask/rpc-errors": "^6.1.0",
"@metamask/transaction-controller": "^21.2.0",
"@metamask/utils": "^8.3.0",
"bn.js": "^5.2.1",
"ethereumjs-util": "^7.0.10",
"immer": "^9.0.6",
"lodash": "^4.17.21",
Expand Down
3 changes: 2 additions & 1 deletion packages/user-operation-controller/src/utils/gas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { hexToBN } from '@metamask/controller-utils';
import { BN, addHexPrefix } from 'ethereumjs-util';
import BN from 'bn.js';
import { addHexPrefix } from 'ethereumjs-util';

import { VALUE_ZERO } from '../constants';
import { Bundler } from '../helpers/Bundler';
Expand Down
3 changes: 2 additions & 1 deletion packages/user-operation-controller/src/utils/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
UserFeeLevel,
} from '@metamask/transaction-controller';
import type { Hex } from '@metamask/utils';
import { BN, addHexPrefix, stripHexPrefix } from 'ethereumjs-util';
import BN from 'bn.js';
import { addHexPrefix, stripHexPrefix } from 'ethereumjs-util';

import { EMPTY_BYTES, VALUE_ZERO } from '../constants';
import { UserOperationStatus } from '../types';
Expand Down
15 changes: 10 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1597,11 +1597,13 @@ __metadata:
"@metamask/preferences-controller": ^7.0.0
"@metamask/rpc-errors": ^6.1.0
"@metamask/utils": ^8.3.0
"@types/bn.js": ^5.1.5
"@types/jest": ^27.4.1
"@types/lodash": ^4.14.191
"@types/node": ^16.18.54
"@types/uuid": ^8.3.0
async-mutex: ^0.2.6
bn.js: ^5.2.1
cockatiel: ^3.1.2
deepmerge: ^4.2.2
ethereumjs-util: ^7.0.10
Expand Down Expand Up @@ -2121,11 +2123,12 @@ __metadata:
"@metamask/network-controller": ^17.2.0
"@metamask/polling-controller": ^5.0.0
"@metamask/utils": ^8.3.0
"@types/bn.js": ^5.1.2
"@types/jest": ^27.4.1
"@types/jest-when": ^2.7.3
"@types/uuid": ^8.3.0
bn.js: ^5.2.1
deepmerge: ^4.2.2
ethereumjs-util: ^7.0.10
jest: ^27.5.1
jest-when: ^3.4.2
nock: ^13.3.1
Expand Down Expand Up @@ -2911,6 +2914,7 @@ __metadata:
"@types/jest": ^27.4.1
"@types/node": ^16.18.54
async-mutex: ^0.2.6
bn.js: ^5.2.1
deepmerge: ^4.2.2
eth-method-registry: ^4.0.0
ethereumjs-util: ^7.0.10
Expand Down Expand Up @@ -2949,6 +2953,7 @@ __metadata:
"@metamask/transaction-controller": ^21.2.0
"@metamask/utils": ^8.3.0
"@types/jest": ^27.4.1
bn.js: ^5.2.1
deepmerge: ^4.2.2
ethereumjs-util: ^7.0.10
immer: ^9.0.6
Expand Down Expand Up @@ -3331,12 +3336,12 @@ __metadata:
languageName: node
linkType: hard

"@types/bn.js@npm:^5.1.0":
version: 5.1.1
resolution: "@types/bn.js@npm:5.1.1"
"@types/bn.js@npm:^5.1.0, @types/bn.js@npm:^5.1.2, @types/bn.js@npm:^5.1.5":
version: 5.1.5
resolution: "@types/bn.js@npm:5.1.5"
dependencies:
"@types/node": "*"
checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2
checksum: c87b28c4af74545624f8a3dae5294b16aa190c222626e8d4b2e327b33b1a3f1eeb43e7a24d914a9774bca43d8cd6e1cb0325c1f4b3a244af6693a024e1d918e6
languageName: node
linkType: hard

Expand Down

0 comments on commit 3ecbd37

Please sign in to comment.