Skip to content

Commit

Permalink
eth-query ^2.1.2 -> @metamask/eth-query ^3.0.1 (#1546)
Browse files Browse the repository at this point in the history
The `eth-query` package does not ship with TypeScript type definitions,
and none have been published under `@types/eth-query`. This results in
TypeScript failing to build packages in this repo that want to use
`eth-query`. We've attempted to mitigate this issue by adding our own
type definitions for `eth-query` to this repo, but since they aren't
included in the published version of the packages in question, it means
that any other project that wants to use those packages must supply
their own type definitions for `eth-query`.

We have republished `eth-query` as `@metamask/eth-query`, which _does_
ship with type definitions. This removes the need for this repo or
any consumers of these packages to provide their own.
  • Loading branch information
mcmire authored Jul 21, 2023
1 parent 2b67b98 commit 6437c7a
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 85 deletions.
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@metamask/base-controller": "workspace:^",
"@metamask/contract-metadata": "^2.3.1",
"@metamask/controller-utils": "workspace:^",
"@metamask/eth-query": "^3.0.1",
"@metamask/metamask-eth-abis": "3.0.0",
"@metamask/network-controller": "workspace:^",
"@metamask/preferences-controller": "workspace:^",
Expand All @@ -46,7 +47,6 @@
"@types/uuid": "^8.3.0",
"abort-controller": "^3.0.0",
"async-mutex": "^0.2.6",
"eth-query": "^2.1.2",
"ethereumjs-util": "^7.0.10",
"immer": "^9.0.6",
"multiformats": "^9.5.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controllers/src/AccountTrackerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
query,
safelyExecuteWithTimeout,
} from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import type { Provider } from '@metamask/eth-query';
import type { PreferencesState } from '@metamask/preferences-controller';
import { assert } from '@metamask/utils';
import { Mutex } from 'async-mutex';
import EthQuery from 'eth-query';
import type { Provider } from 'eth-query';

/**
* @type AccountInformation
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 @@ -29,10 +29,10 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/eth-query": "^3.0.1",
"@metamask/utils": "^6.2.0",
"@spruceid/siwe-parser": "1.1.3",
"eth-ens-namehash": "^2.0.8",
"eth-query": "^2.1.2",
"eth-rpc-errors": "^4.0.2",
"ethereumjs-util": "^7.0.10",
"ethjs-unit": "^0.1.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type EthQuery from '@metamask/eth-query';
import type { Hex, Json } from '@metamask/utils';
import { isStrictHexString } from '@metamask/utils';
import ensNamehash from 'eth-ens-namehash';
import type EthQuery from 'eth-query';
import {
addHexPrefix,
isValidAddress,
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 @@ -31,10 +31,10 @@
"dependencies": {
"@metamask/base-controller": "workspace:^",
"@metamask/controller-utils": "workspace:^",
"@metamask/eth-query": "^3.0.1",
"@metamask/network-controller": "workspace:^",
"@metamask/utils": "^6.2.0",
"@types/uuid": "^8.3.0",
"eth-query": "^2.1.2",
"ethereumjs-util": "^7.0.10",
"ethjs-unit": "^0.1.6",
"immer": "^9.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/src/GasFeeController.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ControllerMessenger } from '@metamask/base-controller';
import { NetworkType, toHex } from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import { NetworkController } from '@metamask/network-controller';
import type {
NetworkControllerGetStateAction,
Expand All @@ -8,7 +9,6 @@ import type {
NetworkState,
} from '@metamask/network-controller';
import type { Hex } from '@metamask/utils';
import EthQuery from 'eth-query';
import * as sinon from 'sinon';

import determineGasFeeCalculations from './determineGasFeeCalculations';
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/src/GasFeeController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { RestrictedControllerMessenger } from '@metamask/base-controller';
import { BaseControllerV2 } from '@metamask/base-controller';
import { convertHexToDecimal, safelyExecute } from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import type {
NetworkControllerGetStateAction,
NetworkControllerStateChangeEvent,
NetworkState,
ProviderProxy,
} from '@metamask/network-controller';
import type { Hex } from '@metamask/utils';
import EthQuery from 'eth-query';
import type { Patch } from 'immer';
import { v1 as random } from 'uuid';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GWEI } from '@metamask/controller-utils';
import type EthQuery from 'eth-query';
import type EthQuery from '@metamask/eth-query';
import { fromWei } from 'ethjs-unit';

import fetchBlockFeeHistory from './fetchBlockFeeHistory';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { query, fromHex } from '@metamask/controller-utils';
import type EthQuery from 'eth-query';
import type EthQuery from '@metamask/eth-query';

import type { EthBlock } from './types';

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 @@ -4,7 +4,7 @@ import {
gweiDecToWEIBN,
weiHexToGweiDec,
} from '@metamask/controller-utils';
import type EthQuery from 'eth-query';
import type EthQuery from '@metamask/eth-query';
import { BN } from 'ethereumjs-util';

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"@metamask/eth-json-rpc-infura": "^8.1.1",
"@metamask/eth-json-rpc-middleware": "^11.0.0",
"@metamask/eth-json-rpc-provider": "^1.0.0",
"@metamask/eth-query": "^3.0.1",
"@metamask/swappable-obj-proxy": "^2.1.0",
"@metamask/utils": "^6.2.0",
"async-mutex": "^0.2.6",
"eth-block-tracker": "^7.0.1",
"eth-query": "^2.1.2",
"eth-rpc-errors": "^4.0.2",
"immer": "^9.0.6",
"json-rpc-engine": "^6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/network-controller/src/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
NetworkType,
isSafeChainId,
} from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import { createEventEmitterProxy } from '@metamask/swappable-obj-proxy';
import type { SwappableProxy } from '@metamask/swappable-obj-proxy';
import type { Hex } from '@metamask/utils';
Expand All @@ -19,7 +20,6 @@ import {
isStrictHexString,
} from '@metamask/utils';
import { strict as assert } from 'assert';
import EthQuery from 'eth-query';
import { errorCodes } from 'eth-rpc-errors';
import type { Patch } from 'immer';
import { v4 as random } from 'uuid';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { JSONRPCResponse } from '@json-rpc-specification/meta-schema';
import type { InfuraNetworkType } from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import type { Hex } from '@metamask/utils';
import EthQuery from 'eth-query';
import nock from 'nock';
import type { Scope as NockScope } from 'nock';
import sinon from 'sinon';
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 @@ -34,11 +34,11 @@
"@metamask/approval-controller": "workspace:^",
"@metamask/base-controller": "workspace:^",
"@metamask/controller-utils": "workspace:^",
"@metamask/eth-query": "^3.0.1",
"@metamask/network-controller": "workspace:^",
"@metamask/utils": "^6.2.0",
"async-mutex": "^0.2.6",
"eth-method-registry": "1.1.0",
"eth-query": "^2.1.2",
"eth-rpc-errors": "^4.0.2",
"ethereumjs-util": "^7.0.10",
"nonce-tracker": "^1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const mockFlags: { [key: string]: any } = {
getBlockByNumberValue: null,
};

jest.mock('eth-query', () =>
jest.mock('@metamask/eth-query', () =>
jest.fn().mockImplementation(() => {
return {
estimateGas: (_transaction: any, callback: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ORIGIN_METAMASK,
convertHexToDecimal,
} from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import type {
BlockTracker,
NetworkState,
Expand All @@ -33,7 +34,6 @@ import type {
import type { Hex } from '@metamask/utils';
import { Mutex } from 'async-mutex';
import MethodRegistry from 'eth-method-registry';
import EthQuery from 'eth-query';
import { errorCodes, ethErrors } from 'eth-rpc-errors';
import { addHexPrefix, bufferToHex, BN } from 'ethereumjs-util';
import { EventEmitter } from 'events';
Expand Down
53 changes: 0 additions & 53 deletions types/eth-query.d.ts

This file was deleted.

30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ __metadata:
"@metamask/base-controller": "workspace:^"
"@metamask/contract-metadata": ^2.3.1
"@metamask/controller-utils": "workspace:^"
"@metamask/eth-query": ^3.0.1
"@metamask/metamask-eth-abis": 3.0.0
"@metamask/network-controller": "workspace:^"
"@metamask/preferences-controller": "workspace:^"
Expand All @@ -1373,7 +1374,6 @@ __metadata:
abort-controller: ^3.0.0
async-mutex: ^0.2.6
deepmerge: ^4.2.2
eth-query: ^2.1.2
ethereumjs-util: ^7.0.10
ethjs-provider-http: ^0.1.6
immer: ^9.0.6
Expand Down Expand Up @@ -1465,13 +1465,13 @@ __metadata:
resolution: "@metamask/controller-utils@workspace:packages/controller-utils"
dependencies:
"@metamask/auto-changelog": ^3.1.0
"@metamask/eth-query": ^3.0.1
"@metamask/utils": ^6.2.0
"@spruceid/siwe-parser": 1.1.3
"@types/jest": ^27.4.1
abort-controller: ^3.0.0
deepmerge: ^4.2.2
eth-ens-namehash: ^2.0.8
eth-query: ^2.1.2
eth-rpc-errors: ^4.0.2
ethereumjs-util: ^7.0.10
ethjs-unit: ^0.1.6
Expand Down Expand Up @@ -1684,6 +1684,16 @@ __metadata:
languageName: node
linkType: hard

"@metamask/eth-query@npm:^3.0.1":
version: 3.0.1
resolution: "@metamask/eth-query@npm:3.0.1"
dependencies:
json-rpc-random-id: ^1.0.0
xtend: ^4.0.1
checksum: b9a323dff67328eace7d54fc8b0bc4dd763bf15760870656cbd5aad5380d1ee4489fb5c59506290d5f77cf55e74e530ee97b52702a329f1090ec03a6158434b7
languageName: node
linkType: hard

"@metamask/eth-sig-util@npm:^5.0.0, @metamask/eth-sig-util@npm:^5.0.1, @metamask/eth-sig-util@npm:^5.0.2":
version: 5.1.0
resolution: "@metamask/eth-sig-util@npm:5.1.0"
Expand Down Expand Up @@ -1731,13 +1741,13 @@ __metadata:
"@metamask/auto-changelog": ^3.1.0
"@metamask/base-controller": "workspace:^"
"@metamask/controller-utils": "workspace:^"
"@metamask/eth-query": ^3.0.1
"@metamask/network-controller": "workspace:^"
"@metamask/utils": ^6.2.0
"@types/jest": ^27.4.1
"@types/jest-when": ^2.7.3
"@types/uuid": ^8.3.0
deepmerge: ^4.2.2
eth-query: ^2.1.2
ethereumjs-util: ^7.0.10
ethjs-unit: ^0.1.6
immer: ^9.0.6
Expand Down Expand Up @@ -1848,6 +1858,7 @@ __metadata:
"@metamask/eth-json-rpc-infura": ^8.1.1
"@metamask/eth-json-rpc-middleware": ^11.0.0
"@metamask/eth-json-rpc-provider": ^1.0.0
"@metamask/eth-query": ^3.0.1
"@metamask/swappable-obj-proxy": ^2.1.0
"@metamask/utils": ^6.2.0
"@types/jest": ^27.4.1
Expand All @@ -1856,7 +1867,6 @@ __metadata:
async-mutex: ^0.2.6
deepmerge: ^4.2.2
eth-block-tracker: ^7.0.1
eth-query: ^2.1.2
eth-rpc-errors: ^4.0.2
immer: ^9.0.6
jest: ^27.5.1
Expand Down Expand Up @@ -2073,6 +2083,7 @@ __metadata:
"@metamask/auto-changelog": ^3.1.0
"@metamask/base-controller": "workspace:^"
"@metamask/controller-utils": "workspace:^"
"@metamask/eth-query": ^3.0.1
"@metamask/network-controller": "workspace:^"
"@metamask/utils": ^6.2.0
"@types/jest": ^27.4.1
Expand All @@ -2081,7 +2092,6 @@ __metadata:
babel-runtime: ^6.26.0
deepmerge: ^4.2.2
eth-method-registry: 1.1.0
eth-query: ^2.1.2
eth-rpc-errors: ^4.0.2
ethereumjs-util: ^7.0.10
ethjs-provider-http: ^0.1.6
Expand Down Expand Up @@ -4657,16 +4667,6 @@ __metadata:
languageName: node
linkType: hard

"eth-query@npm:^2.1.2":
version: 2.1.2
resolution: "eth-query@npm:2.1.2"
dependencies:
json-rpc-random-id: ^1.0.0
xtend: ^4.0.1
checksum: 83daa0e28452c54722aec78cd24d036bad5b6e7c08035d98e10d4bea11f71662f12cab63ebd8a848d4df46ad316503d54ecccb41c9244d2ea8b29364b0a20201
languageName: node
linkType: hard

"eth-rpc-errors@npm:^4.0.2, eth-rpc-errors@npm:^4.0.3":
version: 4.0.3
resolution: "eth-rpc-errors@npm:4.0.3"
Expand Down

0 comments on commit 6437c7a

Please sign in to comment.