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

deps: Bump @metamask/{eth-json-rpc-provider,rpc-errors} #1653

Merged
merged 17 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
d5313dd
deps(network-controller): @metamask/eth-json-rpc-provider@^1.0.0->^2.1.0
legobeat Sep 13, 2023
1de002e
deps: eth-rpc-errors -> @metamask/rpc-errors
legobeat Sep 20, 2023
4ec496c
deps(network-controller): @metamask/eth-json-rpc-infura@^8.1.1->^9.0.0
legobeat Sep 20, 2023
8861727
deps(network-controller): json-rpc-engine@^6.1.0 -> @metamask/json-rp…
legobeat Sep 20, 2023
575937b
deps(selected-network-controller): json-rpc-engine@^6.1.0 -> @metamas…
legobeat Sep 20, 2023
7eaa056
devDeps: json-rpc-engine@^6.1.0 -> @metamask/json-rpc-engine@^7.1.1
legobeat Sep 20, 2023
4c36b0f
deps(network-controller): @metamask/eth-json-rpc-middleware@^11.0.2->…
legobeat Sep 21, 2023
573e59c
deps(network-controller): eth-block-tracker@^7.1.0->^8.0.0
legobeat Sep 21, 2023
2f689c6
types(network-controller): change type alias BlockTracker from class …
legobeat Sep 21, 2023
3a809ba
eth-block-tracker update
legobeat Sep 21, 2023
8b997a6
ignore mismatching internal eth-json-rpc provider types
legobeat Sep 20, 2023
e47bcc6
types(network-controller): type createCustomNetworkMiddleware
legobeat Oct 10, 2023
bec2646
Revert "ignore mismatching internal eth-json-rpc provider types"
legobeat Oct 10, 2023
08d912c
types: @ts-expect-error mismatching eth-json-rpc provider types
legobeat Oct 10, 2023
d80a8d7
@ts-expect eth-json-rpc provider type
legobeat Oct 10, 2023
d1dd687
deps: @metamask/rpc-errors@^6.0.0->^6.1.0
legobeat Oct 11, 2023
2ebfd68
Merge branch 'main' into deps-metamask-bumps-202309
legobeat Oct 11, 2023
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/eth-json-rpc-provider": "^1.0.0",
"@metamask/eth-json-rpc-provider": "^2.1.0",
"@metamask/json-rpc-engine": "^7.1.1",
"@metamask/utils": "^8.1.0",
"@types/node": "^16.18.54",
"@typescript-eslint/eslint-plugin": "^5.62.0",
Expand All @@ -57,10 +58,9 @@
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eth-block-tracker": "^7.0.1",
"eth-block-tracker": "^8.0.0",
"execa": "^5.0.0",
"isomorphic-fetch": "^3.0.0",
"json-rpc-engine": "^6.1.0",
"nock": "^13.3.1",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.4.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/approval-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@metamask/base-controller": "^3.2.3",
"@metamask/rpc-errors": "^6.0.0",
"@metamask/rpc-errors": "^6.1.0",
"@metamask/utils": "^8.1.0",
"immer": "^9.0.6",
"nanoid": "^3.1.31"
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 @@ -42,7 +42,7 @@
"@metamask/metamask-eth-abis": "3.0.0",
"@metamask/network-controller": "^14.0.0",
"@metamask/preferences-controller": "^4.4.2",
"@metamask/rpc-errors": "^6.0.0",
"@metamask/rpc-errors": "^6.1.0",
"@metamask/utils": "^8.1.0",
"@types/uuid": "^8.3.0",
"async-mutex": "^0.2.6",
Expand Down
3 changes: 3 additions & 0 deletions packages/gas-fee-controller/src/GasFeeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export class GasFeeController extends PollingController<
this.legacyAPIEndpoint = legacyAPIEndpoint;
this.clientId = clientId;

// @ts-expect-error TODO: Provider type alignment
this.ethQuery = new EthQuery(this.#getProvider());

if (onNetworkStateChange && getChainId) {
Expand Down Expand Up @@ -417,6 +418,7 @@ export class GasFeeController extends PollingController<
isEIP1559Compatible = false;
}

// @ts-expect-error TODO: Provider type alignment
const ethQuery = new EthQuery(networkClient.provider);

const gasFeeCalculations = await determineGasFeeCalculations({
Expand Down Expand Up @@ -588,6 +590,7 @@ export class GasFeeController extends PollingController<
const newChainId = networkControllerState.providerConfig.chainId;

if (newChainId !== this.currentChainId) {
// @ts-expect-error TODO: Provider type alignment
this.ethQuery = new EthQuery(this.#getProvider());
await this.resetPolling();

Expand Down
12 changes: 6 additions & 6 deletions packages/network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
"dependencies": {
"@metamask/base-controller": "^3.2.3",
"@metamask/controller-utils": "^5.0.2",
"@metamask/eth-json-rpc-infura": "^8.1.1",
"@metamask/eth-json-rpc-middleware": "^11.0.2",
"@metamask/eth-json-rpc-provider": "^1.0.0",
"@metamask/eth-json-rpc-infura": "^9.0.0",
"@metamask/eth-json-rpc-middleware": "^12.0.0",
"@metamask/eth-json-rpc-provider": "^2.1.0",
"@metamask/eth-query": "^3.0.1",
"@metamask/json-rpc-engine": "^7.1.1",
"@metamask/rpc-errors": "^6.1.0",
"@metamask/swappable-obj-proxy": "^2.1.0",
"@metamask/utils": "^8.1.0",
"async-mutex": "^0.2.6",
"eth-block-tracker": "^7.0.1",
"eth-rpc-errors": "^4.0.2",
"eth-block-tracker": "^8.0.0",
"immer": "^9.0.6",
"json-rpc-engine": "^6.1.0",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 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 {
isSafeChainId,
} from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import { errorCodes } from '@metamask/rpc-errors';
import { createEventEmitterProxy } from '@metamask/swappable-obj-proxy';
import type { SwappableProxy } from '@metamask/swappable-obj-proxy';
import type { Hex } from '@metamask/utils';
Expand All @@ -18,7 +19,6 @@ import {
isPlainObject,
} from '@metamask/utils';
import { strict as assert } from 'assert';
import { errorCodes } from 'eth-rpc-errors';
import type { Patch } from 'immer';
import { v4 as random } from 'uuid';

Expand Down Expand Up @@ -980,6 +980,7 @@ export class NetworkController extends BaseControllerV2<
}

const networkClient = this.getNetworkClientById(networkClientId);
// @ts-expect-error TODO: Provider type alignment
MajorLift marked this conversation as resolved.
Show resolved Hide resolved
const ethQuery = new EthQuery(networkClient.provider);

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -1545,6 +1546,7 @@ export class NetworkController extends BaseControllerV2<
});
}

// @ts-expect-error TODO: Provider type alignment
this.#ethQuery = new EthQuery(this.#providerProxy);
}
}
16 changes: 8 additions & 8 deletions packages/network-controller/src/create-network-client.ts
legobeat marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import {
providerFromEngine,
providerFromMiddleware,
} from '@metamask/eth-json-rpc-provider';
import type { Hex } from '@metamask/utils';
import { PollingBlockTracker } from 'eth-block-tracker';
import {
createAsyncMiddleware,
createScaffoldMiddleware,
JsonRpcEngine,
mergeMiddleware,
} from 'json-rpc-engine';
import type { JsonRpcMiddleware } from 'json-rpc-engine';
} from '@metamask/json-rpc-engine';
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import type { Hex, Json, JsonRpcParams } from '@metamask/utils';
import { PollingBlockTracker } from 'eth-block-tracker';

import type {
BlockTracker,
Expand Down Expand Up @@ -126,7 +126,7 @@ function createInfuraNetworkMiddleware({
blockTracker: PollingBlockTracker;
network: InfuraNetworkType;
rpcProvider: SafeEventEmitterProvider;
rpcApiMiddleware: JsonRpcMiddleware<unknown, unknown>;
rpcApiMiddleware: JsonRpcMiddleware<JsonRpcParams, Json>;
}) {
return mergeMiddleware([
createNetworkAndChainIdMiddleware({ network }),
Expand Down Expand Up @@ -158,7 +158,7 @@ function createNetworkAndChainIdMiddleware({

const createChainIdMiddleware = (
chainId: Hex,
): JsonRpcMiddleware<unknown, unknown> => {
): JsonRpcMiddleware<JsonRpcParams, Json> => {
return (req, res, next, end) => {
if (req.method === 'eth_chainId') {
res.result = chainId;
Expand All @@ -184,8 +184,8 @@ function createCustomNetworkMiddleware({
}: {
blockTracker: PollingBlockTracker;
chainId: Hex;
rpcApiMiddleware: any;
}) {
rpcApiMiddleware: JsonRpcMiddleware<JsonRpcParams, Json>;
}): JsonRpcMiddleware<JsonRpcParams, Json> {
// eslint-disable-next-line n/no-process-env
const testMiddlewares = process.env.IN_TEST
? [createEstimateGasDelayTestMiddleware()]
Expand Down
6 changes: 4 additions & 2 deletions packages/network-controller/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { InfuraNetworkType } from '@metamask/controller-utils';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import type { Hex } from '@metamask/utils';
import type { PollingBlockTracker } from 'eth-block-tracker';
import type { BlockTracker as BaseBlockTracker } from 'eth-block-tracker';

export type Provider = SafeEventEmitterProvider;

export type BlockTracker = PollingBlockTracker;
export type BlockTracker = BaseBlockTracker & {
checkForLatestBlock(): Promise<string>;
Copy link
Contributor Author

@legobeat legobeat Oct 3, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, thanks for that. I'll keep an eye out so we can get this merged.

};

/**
* The type of network client that can be created.
Expand Down
24 changes: 12 additions & 12 deletions packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
NetworkType,
toHex,
} from '@metamask/controller-utils';
import { rpcErrors } from '@metamask/rpc-errors';
import assert from 'assert';
import { ethErrors } from 'eth-rpc-errors';
import type { Patch } from 'immer';
import { when, resetAllWhenMocks } from 'jest-when';
import { inspect, isDeepStrictEqual, promisify } from 'util';
Expand All @@ -27,7 +27,7 @@ import type {
ProviderConfig,
} from '../src/NetworkController';
import { NetworkController } from '../src/NetworkController';
import type { Provider } from '../src/types';
import type { BlockTracker, Provider } from '../src/types';
import { NetworkClientType } from '../src/types';
import type { FakeProviderStub } from './fake-provider';
import { FakeProvider } from './fake-provider';
Expand Down Expand Up @@ -128,15 +128,15 @@ const SUCCESSFUL_ETH_GET_BLOCK_BY_NUMBER_RESPONSE = {
/**
* A response object for a request that has been geoblocked by Infura.
*/
const BLOCKED_INFURA_JSON_RPC_ERROR = ethErrors.rpc.internal(
const BLOCKED_INFURA_JSON_RPC_ERROR = rpcErrors.internal(
JSON.stringify({ error: 'countryBlocked' }),
);

/**
* A response object for a unsuccessful request to any RPC method. It is assumed
* that the error here is insignificant to the test.
*/
const GENERIC_JSON_RPC_ERROR = ethErrors.rpc.internal(
const GENERIC_JSON_RPC_ERROR = rpcErrors.internal(
JSON.stringify({ error: 'oops' }),
);

Expand Down Expand Up @@ -5106,7 +5106,7 @@ describe('NetworkController', () => {
request: {
method: 'eth_getBlockByNumber',
},
error: ethErrors.rpc.methodNotFound(),
error: rpcErrors.methodNotFound(),
},
]),
buildFakeProvider([
Expand Down Expand Up @@ -5622,7 +5622,7 @@ describe('NetworkController', () => {
request: {
method: 'eth_getBlockByNumber',
},
error: ethErrors.rpc.methodNotFound(),
error: rpcErrors.methodNotFound(),
},
]),
buildFakeProvider([
Expand Down Expand Up @@ -6250,7 +6250,7 @@ function lookupNetworkTests({
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
error: ethErrors.rpc.limitExceeded('some error'),
error: rpcErrors.limitExceeded('some error'),
},
],
stubLookupNetworkWhileSetting: true,
Expand Down Expand Up @@ -6291,7 +6291,7 @@ function lookupNetworkTests({
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
error: ethErrors.rpc.limitExceeded('some error'),
error: rpcErrors.limitExceeded('some error'),
},
],
});
Expand Down Expand Up @@ -6326,7 +6326,7 @@ function lookupNetworkTests({
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
error: ethErrors.rpc.limitExceeded('some error'),
error: rpcErrors.limitExceeded('some error'),
},
],
stubLookupNetworkWhileSetting: true,
Expand Down Expand Up @@ -6358,7 +6358,7 @@ function lookupNetworkTests({
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
error: ethErrors.rpc.limitExceeded('some error'),
error: rpcErrors.limitExceeded('some error'),
},
],
stubLookupNetworkWhileSetting: true,
Expand Down Expand Up @@ -6392,7 +6392,7 @@ function lookupNetworkTests({
method: 'eth_getBlockByNumber',
params: ['latest', false],
},
error: ethErrors.rpc.limitExceeded('some error'),
error: rpcErrors.limitExceeded('some error'),
},
],
stubLookupNetworkWhileSetting: true,
Expand Down Expand Up @@ -6957,7 +6957,7 @@ function buildFakeClient(
rpcUrl: 'https://test.network',
},
provider,
blockTracker: new FakeBlockTracker(),
blockTracker: new FakeBlockTracker() as BlockTracker,
Copy link
Contributor

Choose a reason for hiding this comment

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

@MajorLift This is an example of us needing to use a type assertion. I guess the type of FakeBlockTracker isn't quite right here and doesn't match the type of blockTracker that NetworkClient demands.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mcmire This seems like it's either been fixed or wasn't needed in the first place: #1833. These silent false negatives are the worse thing about type assertions IMO.

In general, when encountering "not assignable to" errors, I would like the underlying types to be reconciled/aligned, at least eventually. Are there maybe "usual suspect" entities in our codebase that I can assume it'll be safe to use type assertion on?

destroy: () => {
// do nothing
},
Expand Down
4 changes: 2 additions & 2 deletions packages/network-controller/tests/fake-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider/dist/safe-event-emitter-provider';
import type { JsonRpcRequest, JsonRpcResponse } from 'json-rpc-engine';
import { JsonRpcEngine } from 'json-rpc-engine';
import { JsonRpcEngine } from '@metamask/json-rpc-engine';
import type { JsonRpcRequest, JsonRpcResponse } from '@metamask/utils';
import { inspect, isDeepStrictEqual } from 'util';

// Store this in case it gets stubbed later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ export async function withNetworkClient(

const { provider, blockTracker } = clientUnderTest;

// @ts-expect-error TODO: Provider type alignment
MajorLift marked this conversation as resolved.
Show resolved Hide resolved
const ethQuery = new EthQuery(provider);
const curriedMakeRpcCall = (request: Request) =>
makeRpcCall(ethQuery, request);
Expand Down
2 changes: 1 addition & 1 deletion packages/permission-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@metamask/base-controller": "^3.2.3",
"@metamask/controller-utils": "^5.0.2",
"@metamask/json-rpc-engine": "^7.1.1",
"@metamask/rpc-errors": "^6.0.0",
"@metamask/rpc-errors": "^6.1.0",
"@metamask/utils": "^8.1.0",
"@types/deep-freeze-strict": "^1.1.0",
"deep-freeze-strict": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/rate-limit-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@metamask/base-controller": "^3.2.3",
"eth-rpc-errors": "^4.0.2",
"@metamask/rpc-errors": "^6.1.0",
"immer": "^9.0.6"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/rate-limit-controller/src/RateLimitController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RestrictedControllerMessenger } from '@metamask/base-controller';
import { BaseControllerV2 as BaseController } from '@metamask/base-controller';
import { ethErrors } from 'eth-rpc-errors';
import { rpcErrors } from '@metamask/rpc-errors';
import type { Patch } from 'immer';

/**
Expand Down Expand Up @@ -143,7 +143,7 @@ export class RateLimitController<
...args: Parameters<RateLimitedApis[ApiType]['method']>
): Promise<ReturnType<RateLimitedApis[ApiType]['method']>> {
if (this.isRateLimited(type, origin)) {
throw ethErrors.rpc.limitExceeded({
throw rpcErrors.limitExceeded({
message: `"${type.toString()}" is currently rate-limited. Please try again later.`,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/selected-network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
"dependencies": {
"@metamask/base-controller": "^3.2.3",
"@metamask/network-controller": "^14.0.0",
"json-rpc-engine": "^6.1.0"
"@metamask/json-rpc-engine": "^7.1.1",
"@metamask/network-controller": "^14.0.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ControllerMessenger } from '@metamask/base-controller';
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import type {
NetworkClientId,
NetworkControllerGetStateAction,
} from '@metamask/network-controller';
import type { JsonRpcMiddleware } from 'json-rpc-engine';

import type {
SelectedNetworkControllerGetNetworkClientIdForDomainAction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ControllerMessenger } from '@metamask/base-controller';
import { JsonRpcEngine } from '@metamask/json-rpc-engine';
import type { NetworkControllerGetStateAction } from '@metamask/network-controller';
import { JsonRpcEngine } from 'json-rpc-engine';

import type {
SelectedNetworkControllerGetNetworkClientIdForDomainAction,
Expand Down
2 changes: 1 addition & 1 deletion packages/signature-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@metamask/controller-utils": "^5.0.2",
"@metamask/logging-controller": "^1.0.3",
"@metamask/message-manager": "^7.3.5",
"@metamask/rpc-errors": "^6.1.0",
"@metamask/utils": "^8.1.0",
"eth-rpc-errors": "^4.0.2",
"ethereumjs-util": "^7.0.10",
"immer": "^9.0.6",
"lodash": "^4.17.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
PersonalMessageManager,
TypedMessageManager,
} from '@metamask/message-manager';
import { EthereumProviderError } from 'eth-rpc-errors';
import { EthereumProviderError } from '@metamask/rpc-errors';

import type {
SignatureControllerMessenger,
Expand Down
Loading
Loading