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: @metamask/eth-json-rpc-provider@^1.0.0->^2.1.0 #174

Merged
merged 5 commits into from
Sep 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/eth-json-rpc-provider": "^1.0.0",
"@metamask/eth-json-rpc-provider": "^2.1.0",
"@metamask/safe-event-emitter": "^3.0.0",
"@metamask/utils": "^8.1.0",
"json-rpc-random-id": "^1.0.1",
Expand All @@ -38,6 +38,7 @@
"@metamask/eslint-config-jest": "^12.0.0",
"@metamask/eslint-config-nodejs": "^12.0.0",
"@metamask/eslint-config-typescript": "^12.0.0",
"@metamask/json-rpc-engine": "^7.1.1",
"@types/jest": "^29.1.2",
"@types/json-rpc-random-id": "^1.0.1",
"@types/node": "^17.0.23",
Expand All @@ -54,7 +55,6 @@
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.1.2",
"json-rpc-engine": "^6.1.0",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.2.11",
"rimraf": "^3.0.2",
Expand Down
6 changes: 3 additions & 3 deletions src/PollingBlockTracker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import SafeEventEmitter from '@metamask/safe-event-emitter';
import type { JsonRpcRequest } from 'json-rpc-engine';
import type { JsonRpcRequest } from '@metamask/utils';
import getCreateRandomId from 'json-rpc-random-id';
import pify from 'pify';

Expand All @@ -25,7 +25,7 @@ export interface PollingBlockTrackerOptions {
usePastBlocks?: boolean;
}

interface ExtendedJsonRpcRequest<T> extends JsonRpcRequest<T> {
interface ExtendedJsonRpcRequest extends JsonRpcRequest<[]> {
skipCache?: boolean;
}

Expand Down Expand Up @@ -283,7 +283,7 @@ export class PollingBlockTracker
}

private async _fetchLatestBlock(): Promise<string> {
const req: ExtendedJsonRpcRequest<[]> = {
const req: ExtendedJsonRpcRequest = {
jsonrpc: '2.0',
id: createRandomId(),
method: 'eth_blockNumber',
Expand Down
11 changes: 8 additions & 3 deletions src/SubscribeBlockTracker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import SafeEventEmitter from '@metamask/safe-event-emitter';
import type { JsonRpcNotification, JsonRpcSuccess } from 'json-rpc-engine';
import type {
Json,
JsonRpcNotification,
JsonRpcSuccess,
} from '@metamask/utils';
import getCreateRandomId from 'json-rpc-random-id';

import type { BlockTracker } from './BlockTracker';
Expand All @@ -20,6 +24,7 @@ export interface SubscribeBlockTrackerOptions {
}

interface SubscriptionNotificationParams {
[key: string]: Json;
subscription: string;
result: { number: string };
}
Expand Down Expand Up @@ -250,7 +255,7 @@ export class SubscribeBlockTracker
}
}

private async _call(method: string, ...params: unknown[]): Promise<unknown> {
private async _call(method: string, ...params: Json[]): Promise<unknown> {
return new Promise((resolve, reject) => {
this._provider.sendAsync(
{
Expand All @@ -263,7 +268,7 @@ export class SubscribeBlockTracker
if (err) {
reject(err);
} else {
resolve((res as JsonRpcSuccess<unknown>).result);
resolve((res as JsonRpcSuccess<Json>).result);
}
},
);
Expand Down
8 changes: 4 additions & 4 deletions tests/withBlockTracker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { providerFromEngine } from '@metamask/eth-json-rpc-provider';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-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 util from 'util';

import type {
Expand Down Expand Up @@ -122,8 +122,8 @@ function getFakeProvider({
.spyOn(provider, 'sendAsync')
.mockImplementation(
(
request: JsonRpcRequest<unknown>,
callback: (err: unknown, response?: JsonRpcResponse<unknown>) => void,
request: JsonRpcRequest,
callback: (err: unknown, response?: JsonRpcResponse<any>) => void,
) => {
const index = stubs.findIndex(
(stub) => stub.methodName === request.method,
Expand Down
Loading
Loading