From 87e3e102a64b189c998502369fd987fd2d74ac86 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Tue, 22 Aug 2023 14:00:28 +0000 Subject: [PATCH] devDeps: json-rpc-engine@^6.1.0 -> @metamask/json-rpc-engine@7.0.0 --- package.json | 2 +- src/PollingBlockTracker.ts | 6 +++--- src/SubscribeBlockTracker.ts | 11 ++++++++--- tests/withBlockTracker.ts | 8 ++++---- yarn.lock | 28 ++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 46cfa667..a57105fd 100644 --- a/package.json +++ b/package.json @@ -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.0.0", "@types/jest": "^29.1.2", "@types/json-rpc-random-id": "^1.0.1", "@types/node": "^17.0.23", @@ -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", diff --git a/src/PollingBlockTracker.ts b/src/PollingBlockTracker.ts index 7e21c4fc..00fa99b8 100644 --- a/src/PollingBlockTracker.ts +++ b/src/PollingBlockTracker.ts @@ -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'; @@ -25,7 +25,7 @@ export interface PollingBlockTrackerOptions { usePastBlocks?: boolean; } -interface ExtendedJsonRpcRequest extends JsonRpcRequest { +interface ExtendedJsonRpcRequest extends JsonRpcRequest<[]> { skipCache?: boolean; } @@ -283,7 +283,7 @@ export class PollingBlockTracker } private async _fetchLatestBlock(): Promise { - const req: ExtendedJsonRpcRequest<[]> = { + const req: ExtendedJsonRpcRequest = { jsonrpc: '2.0', id: createRandomId(), method: 'eth_blockNumber', diff --git a/src/SubscribeBlockTracker.ts b/src/SubscribeBlockTracker.ts index 72b4cf0d..d0ac90b8 100644 --- a/src/SubscribeBlockTracker.ts +++ b/src/SubscribeBlockTracker.ts @@ -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'; @@ -20,6 +24,7 @@ export interface SubscribeBlockTrackerOptions { } interface SubscriptionNotificationParams { + [key: string]: Json; subscription: string; result: { number: string }; } @@ -250,7 +255,7 @@ export class SubscribeBlockTracker } } - private async _call(method: string, ...params: unknown[]): Promise { + private async _call(method: string, ...params: Json[]): Promise { return new Promise((resolve, reject) => { this._provider.sendAsync( { @@ -263,7 +268,7 @@ export class SubscribeBlockTracker if (err) { reject(err); } else { - resolve((res as JsonRpcSuccess).result); + resolve((res as JsonRpcSuccess).result); } }, ); diff --git a/tests/withBlockTracker.ts b/tests/withBlockTracker.ts index a764b9eb..e7e1b05d 100644 --- a/tests/withBlockTracker.ts +++ b/tests/withBlockTracker.ts @@ -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 { @@ -122,8 +122,8 @@ function getFakeProvider({ .spyOn(provider, 'sendAsync') .mockImplementation( ( - request: JsonRpcRequest, - callback: (err: unknown, response?: JsonRpcResponse) => void, + request: JsonRpcRequest, + callback: (err: unknown, response?: JsonRpcResponse) => void, ) => { const index = stubs.findIndex( (stub) => stub.methodName === request.method, diff --git a/yarn.lock b/yarn.lock index 6450ef58..8344bf31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -801,6 +801,23 @@ "@metamask/safe-event-emitter" "^2.0.0" json-rpc-engine "^6.1.0" +"@metamask/json-rpc-engine@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@metamask/json-rpc-engine/-/json-rpc-engine-7.0.0.tgz#5110d7e90a75aab4e515621fafff5adf7174b6e3" + integrity sha512-qIfQvEOD3vFMZpXQUcXjuVDnkznzjARRSa9mUjZnYImhoxgvPdTery31I+zkRuksNLffvJc08SL2cQaC3uVfYA== + dependencies: + "@metamask/rpc-errors" "^5.0.0" + "@metamask/safe-event-emitter" "^2.0.0" + "@metamask/utils" "^5.0.1" + +"@metamask/rpc-errors@^5.0.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@metamask/rpc-errors/-/rpc-errors-5.1.1.tgz#f82732ad0952d34d219eca42699c0c74bee95a9e" + integrity sha512-JjZnDi2y2CfvbohhBl+FOQRzmFlJpybcQlIk37zEX8B96eVSPbH/T8S0p7cSF8IE33IWx6JkD8Ycsd+2TXFxCw== + dependencies: + "@metamask/utils" "^5.0.0" + fast-safe-stringify "^2.0.6" + "@metamask/safe-event-emitter@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@metamask/safe-event-emitter/-/safe-event-emitter-2.0.0.tgz#af577b477c683fad17c619a78208cede06f9605c" @@ -811,6 +828,17 @@ resolved "https://registry.yarnpkg.com/@metamask/safe-event-emitter/-/safe-event-emitter-3.0.0.tgz#8c2b9073fe0722d48693143b0dc8448840daa3bd" integrity sha512-j6Z47VOmVyGMlnKXZmL0fyvWfEYtKWCA9yGZkU3FCsGZUT5lHGmvaV9JA5F2Y+010y7+ROtR3WMXIkvl/nVzqQ== +"@metamask/utils@^5.0.0", "@metamask/utils@^5.0.1": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@metamask/utils/-/utils-5.0.2.tgz#140ba5061d90d9dac0280c19cab101bc18c8857c" + integrity sha512-yfmE79bRQtnMzarnKfX7AEJBwFTxvTyw3nBQlu/5rmGXrjAeAMltoGxO62TFurxrQAFMNa/fEjIHNvungZp0+g== + dependencies: + "@ethereumjs/tx" "^4.1.2" + "@types/debug" "^4.1.7" + debug "^4.3.4" + semver "^7.3.8" + superstruct "^1.0.3" + "@metamask/utils@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@metamask/utils/-/utils-7.1.0.tgz#0eb60de7608391a469b24320510c003dd4774b70"