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

Replace ethjs packages with @metamask/ethjs forks #2064

Merged
merged 4 commits into from
Nov 20, 2023
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@types/node": "^16.18.54",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"bn.js": "^5.2.1",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.5.0",
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 @@ -55,10 +55,10 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.3",
"@metamask/ethjs-provider-http": "^0.2.0",
"@types/jest": "^27.4.1",
"@types/node": "^16.18.54",
"deepmerge": "^4.2.2",
"ethjs-provider-http": "^0.1.6",
"jest": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
"nock": "^13.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { query } from '@metamask/controller-utils';
import HttpProvider from '@metamask/ethjs-provider-http';
import type { ContactEntry } from '@metamask/preferences-controller';
import { PreferencesController } from '@metamask/preferences-controller';
import HttpProvider from 'ethjs-provider-http';
import * as sinon from 'sinon';

import { AccountTrackerController } from './AccountTrackerController';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IPFS_DEFAULT_GATEWAY_URL,
NetworkType,
} from '@metamask/controller-utils';
import HttpProvider from '@metamask/ethjs-provider-http';
import type {
NetworkClientId,
NetworkControllerMessenger,
Expand All @@ -14,7 +15,6 @@ import {
NetworkClientType,
} from '@metamask/network-controller';
import { PreferencesController } from '@metamask/preferences-controller';
import HttpProvider from 'ethjs-provider-http';

import { mockNetwork } from '../../../tests/mock-network';
import {
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 @@ -18,14 +18,14 @@ import {
ERC20,
NetworksTicker,
} from '@metamask/controller-utils';
import HttpProvider from '@metamask/ethjs-provider-http';
import type {
NetworkState,
ProviderConfig,
} from '@metamask/network-controller';
import { defaultState as defaultNetworkState } from '@metamask/network-controller';
import { PreferencesController } from '@metamask/preferences-controller';
import { BN } from 'ethereumjs-util';
import HttpProvider from 'ethjs-provider-http';
import nock from 'nock';
import * as sinon from 'sinon';
import { v4 } from 'uuid';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Web3Provider } from '@ethersproject/providers';
import HttpProvider from 'ethjs-provider-http';
import HttpProvider from '@metamask/ethjs-provider-http';
import nock from 'nock';

import { ERC20Standard } from './ERC20Standard';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Web3Provider } from '@ethersproject/providers';
import HttpProvider from 'ethjs-provider-http';
import HttpProvider from '@metamask/ethjs-provider-http';
import nock from 'nock';

import { ERC1155Standard } from './ERC1155Standard';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Web3Provider } from '@ethersproject/providers';
import { IPFS_DEFAULT_GATEWAY_URL } from '@metamask/controller-utils';
import HttpProvider from 'ethjs-provider-http';
import HttpProvider from '@metamask/ethjs-provider-http';
import nock from 'nock';

import { ERC721Standard } from './ERC721Standard';
Expand Down
3 changes: 2 additions & 1 deletion packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/ethjs-unit": "^0.2.1",
"@metamask/utils": "^8.2.0",
"@spruceid/siwe-parser": "1.1.3",
"eth-ens-namehash": "^2.0.8",
"ethereumjs-util": "^7.0.10",
"ethjs-unit": "^0.1.6",
"fast-deep-equal": "^3.1.3"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.3",
"@metamask/eth-query": "^4.0.0",
"@types/jest": "^27.4.1",
"bn.js": "^5.2.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"nock": "^13.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/controller-utils/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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 ensNamehash from 'eth-ens-namehash';
Expand All @@ -10,7 +11,6 @@ import {
toChecksumAddress,
stripHexPrefix,
} from 'ethereumjs-util';
import { fromWei, toWei } from 'ethjs-unit';
import deepEqual from 'fast-deep-equal';

import { MAX_SAFE_CHAIN_ID } from './constants';
Expand Down Expand Up @@ -108,7 +108,7 @@ export function gweiDecToWEIBN(n: number | string) {
*/
export function weiHexToGweiDec(hex: string) {
const hexWei = new BN(stripHexPrefix(hex), 16);
return fromWei(hexWei, 'gwei').toString(10);
return fromWei(hexWei, 'gwei');
}

/**
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 @@ -33,12 +33,12 @@
"@metamask/base-controller": "^3.2.3",
"@metamask/controller-utils": "^5.0.2",
"@metamask/eth-query": "^4.0.0",
"@metamask/ethjs-unit": "^0.2.1",
"@metamask/network-controller": "^16.0.0",
"@metamask/polling-controller": "^1.0.2",
"@metamask/utils": "^8.2.0",
"@types/uuid": "^8.3.0",
"ethereumjs-util": "^7.0.10",
"ethjs-unit": "^0.1.6",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GWEI } from '@metamask/controller-utils';
import type EthQuery from '@metamask/eth-query';
import { fromWei } from 'ethjs-unit';
import { fromWei } from '@metamask/ethjs-unit';

import fetchBlockFeeHistory from './fetchBlockFeeHistory';
import calculateGasFeeEstimatesForPriorityLevels from './fetchGasEstimatesViaEthFeeHistory/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 { fromWei } from 'ethjs-unit';

import type { FeeHistoryBlock } from '../fetchBlockFeeHistory';
import type { Eip1559GasFee, GasFeeEstimates } from '../GasFeeController';
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 @@ -25,7 +25,7 @@ const makeClientIdHeader = (clientId: string) => ({ 'X-Client-Id': clientId });
*/
export function normalizeGWEIDecimalNumbers(n: string | number) {
const numberAsWEIHex = gweiDecToWEIBN(n).toString(16);
const numberAsGWEI = weiHexToGweiDec(numberAsWEIHex).toString(10);
const numberAsGWEI = weiHexToGweiDec(numberAsWEIHex);
return numberAsGWEI;
}

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 @@ -52,11 +52,11 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.3",
"@metamask/ethjs-provider-http": "^0.2.0",
"@types/jest": "^27.4.1",
"@types/node": "^16.18.54",
"babel-runtime": "^6.26.0",
"deepmerge": "^4.2.2",
"ethjs-provider-http": "^0.1.6",
"jest": "^27.5.1",
"sinon": "^9.2.4",
"ts-jest": "^27.1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
BUILT_IN_NETWORKS,
ORIGIN_METAMASK,
} from '@metamask/controller-utils';
import HttpProvider from '@metamask/ethjs-provider-http';
import type {
BlockTracker,
NetworkState,
Provider,
} from '@metamask/network-controller';
import { NetworkClientType, NetworkStatus } from '@metamask/network-controller';
import { errorCodes, providerErrors, rpcErrors } from '@metamask/rpc-errors';
import HttpProvider from 'ethjs-provider-http';
import { NonceTracker } from 'nonce-tracker';

import { FakeBlockTracker } from '../../../tests/fake-block-tracker';
Expand Down
1 change: 1 addition & 0 deletions types/@metamask/ethjs-provider-http.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@metamask/ethjs-provider-http';
1 change: 1 addition & 0 deletions types/@metamask/ethjs-unit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@metamask/ethjs-unit';
1 change: 0 additions & 1 deletion types/ethjs-provider-http.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion types/ethjs-unit.d.ts

This file was deleted.

40 changes: 34 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,7 @@ __metadata:
"@metamask/contract-metadata": ^2.4.0
"@metamask/controller-utils": ^5.0.2
"@metamask/eth-query": ^4.0.0
"@metamask/ethjs-provider-http": ^0.2.0
"@metamask/metamask-eth-abis": 3.0.0
"@metamask/network-controller": ^16.0.0
"@metamask/polling-controller": ^1.0.2
Expand All @@ -1485,7 +1486,6 @@ __metadata:
async-mutex: ^0.2.6
deepmerge: ^4.2.2
ethereumjs-util: ^7.0.10
ethjs-provider-http: ^0.1.6
jest: ^27.5.1
jest-environment-jsdom: ^27.5.1
multiformats: ^9.5.2
Expand Down Expand Up @@ -1578,13 +1578,14 @@ __metadata:
dependencies:
"@metamask/auto-changelog": ^3.4.3
"@metamask/eth-query": ^4.0.0
"@metamask/ethjs-unit": ^0.2.1
"@metamask/utils": ^8.2.0
"@spruceid/siwe-parser": 1.1.3
"@types/jest": ^27.4.1
bn.js: ^5.2.1
deepmerge: ^4.2.2
eth-ens-namehash: ^2.0.8
ethereumjs-util: ^7.0.10
ethjs-unit: ^0.1.6
fast-deep-equal: ^3.1.3
jest: ^27.5.1
nock: ^13.3.1
Expand All @@ -1611,6 +1612,7 @@ __metadata:
"@types/node": ^16.18.54
"@typescript-eslint/eslint-plugin": ^5.62.0
"@typescript-eslint/parser": ^5.62.0
bn.js: ^5.2.1
eslint: ^8.44.0
eslint-config-prettier: ^8.5.0
eslint-import-resolver-typescript: ^2.5.0
Expand Down Expand Up @@ -1859,6 +1861,25 @@ __metadata:
languageName: node
linkType: hard

"@metamask/ethjs-provider-http@npm:^0.2.0":
version: 0.2.0
resolution: "@metamask/ethjs-provider-http@npm:0.2.0"
dependencies:
xhr2: 0.2.1
checksum: 97a9e168b9ad4bf26a9ed7b1c2f785c42d7a3829dea32ef47445a9035163f6632d32895b1f231dcf9641197626a4c54385c6a9de199bfe83fd316498d1e4b456
languageName: node
linkType: hard

"@metamask/ethjs-unit@npm:^0.2.1":
version: 0.2.1
resolution: "@metamask/ethjs-unit@npm:0.2.1"
dependencies:
bn.js: 4.11.6
number-to-bn: 1.7.0
checksum: 0c8bbbe06000f647b46701fcf976e29b67c7362b3ae252d8d4fe2feb74f3988c1203eb03cc34bb899101f01812c8c300158d75bc721d649124c048e8b149b557
languageName: node
linkType: hard

"@metamask/gas-fee-controller@^10.0.1, @metamask/gas-fee-controller@workspace:packages/gas-fee-controller":
version: 0.0.0-use.local
resolution: "@metamask/gas-fee-controller@workspace:packages/gas-fee-controller"
Expand All @@ -1867,6 +1888,7 @@ __metadata:
"@metamask/base-controller": ^3.2.3
"@metamask/controller-utils": ^5.0.2
"@metamask/eth-query": ^4.0.0
"@metamask/ethjs-unit": ^0.2.1
"@metamask/network-controller": ^16.0.0
"@metamask/polling-controller": ^1.0.2
"@metamask/utils": ^8.2.0
Expand All @@ -1875,7 +1897,6 @@ __metadata:
"@types/uuid": ^8.3.0
deepmerge: ^4.2.2
ethereumjs-util: ^7.0.10
ethjs-unit: ^0.1.6
jest: ^27.5.1
jest-when: ^3.4.2
nock: ^13.3.1
Expand Down Expand Up @@ -2548,6 +2569,7 @@ __metadata:
"@metamask/base-controller": ^3.2.3
"@metamask/controller-utils": ^5.0.2
"@metamask/eth-query": ^4.0.0
"@metamask/ethjs-provider-http": ^0.2.0
"@metamask/gas-fee-controller": ^10.0.1
"@metamask/metamask-eth-abis": ^3.0.0
"@metamask/network-controller": ^16.0.0
Expand All @@ -2560,7 +2582,6 @@ __metadata:
deepmerge: ^4.2.2
eth-method-registry: 1.1.0
ethereumjs-util: ^7.0.10
ethjs-provider-http: ^0.1.6
fast-json-patch: ^3.1.1
jest: ^27.5.1
lodash: ^4.17.21
Expand Down Expand Up @@ -5547,7 +5568,7 @@ __metadata:
languageName: node
linkType: hard

"ethjs-provider-http@npm:0.1.6, ethjs-provider-http@npm:^0.1.6":
"ethjs-provider-http@npm:0.1.6":
version: 0.1.6
resolution: "ethjs-provider-http@npm:0.1.6"
dependencies:
Expand Down Expand Up @@ -5583,7 +5604,7 @@ __metadata:
languageName: node
linkType: hard

"ethjs-unit@npm:0.1.6, ethjs-unit@npm:^0.1.6":
"ethjs-unit@npm:0.1.6":
version: 0.1.6
resolution: "ethjs-unit@npm:0.1.6"
dependencies:
Expand Down Expand Up @@ -10742,6 +10763,13 @@ __metadata:
languageName: node
linkType: hard

"xhr2@npm:0.2.1":
version: 0.2.1
resolution: "xhr2@npm:0.2.1"
checksum: b983d33dd68ba6ed7db196e8163cc5668f8c2c9d04e50aab6e452d0f124d89ab39b8a2576c7d2aeeef667b96946a5c7aa401bba1f70948e05fb9a188245d2743
languageName: node
linkType: hard

"xml-name-validator@npm:^3.0.0":
version: 3.0.0
resolution: "xml-name-validator@npm:3.0.0"
Expand Down
Loading