From 90e7c108bb44013a4734b895e9d858b1a80a87e5 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Mon, 25 Sep 2023 06:14:08 +0000 Subject: [PATCH] deps: replace clone with klona --- package.json | 3 +-- src/block-ref.ts | 4 ++-- src/inflight-cache.ts | 6 +++--- src/retryOnEmpty.ts | 4 ++-- test/util/helpers.ts | 4 ++-- yarn.lock | 24 ++++++++---------------- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index f047f2ea..84389479 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ "@metamask/eth-json-rpc-provider": "^1.0.0", "@metamask/eth-sig-util": "^7.0.0", "@metamask/utils": "^8.1.0", - "clone": "^2.1.1", "eth-block-tracker": "^7.0.1", "eth-rpc-errors": "^4.0.3", "json-rpc-engine": "^6.1.0", + "klona": "^2.0.6", "pify": "^5.0.0", "safe-stable-stringify": "^2.4.3" }, @@ -47,7 +47,6 @@ "@metamask/eslint-config-nodejs": "^12.1.0", "@metamask/eslint-config-typescript": "^12.1.0", "@types/btoa": "^1.2.3", - "@types/clone": "^2.1.0", "@types/jest": "^27.4.1", "@types/node": "^17.0.23", "@types/pify": "^3.0.2", diff --git a/src/block-ref.ts b/src/block-ref.ts index ff65ba44..0f4f7301 100644 --- a/src/block-ref.ts +++ b/src/block-ref.ts @@ -1,11 +1,11 @@ import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider'; -import clone from 'clone'; import type { PollingBlockTracker } from 'eth-block-tracker'; import type { JsonRpcMiddleware, PendingJsonRpcResponse, } from 'json-rpc-engine'; import { createAsyncMiddleware } from 'json-rpc-engine'; +import { klona } from 'klona/full'; import pify from 'pify'; import { projectLogger, createModuleLogger } from './logging-utils'; @@ -58,7 +58,7 @@ export function createBlockRefMiddleware({ ); // create child request with specific block-ref - const childRequest = clone(req); + const childRequest = klona(req); if (Array.isArray(childRequest.params)) { childRequest.params[blockRefIndex] = latestBlockNumber; diff --git a/src/inflight-cache.ts b/src/inflight-cache.ts index 75dda270..eaebdc14 100644 --- a/src/inflight-cache.ts +++ b/src/inflight-cache.ts @@ -1,6 +1,6 @@ -import clone from 'clone'; import type { PendingJsonRpcResponse } from 'json-rpc-engine'; import { createAsyncMiddleware } from 'json-rpc-engine'; +import { klona } from 'klona/full'; import { projectLogger, createModuleLogger } from './logging-utils'; import type { JsonRpcRequestToCache, JsonRpcCacheMiddleware } from './types'; @@ -75,8 +75,8 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware< activeRequestHandlers.push( (handledRes: PendingJsonRpcResponse) => { // append a copy of the result and error to the response - res.result = clone(handledRes.result); - res.error = clone(handledRes.error); + res.result = klona(handledRes.result); + res.error = klona(handledRes.error); resolve(); }, ); diff --git a/src/retryOnEmpty.ts b/src/retryOnEmpty.ts index 57542859..c6c2929c 100644 --- a/src/retryOnEmpty.ts +++ b/src/retryOnEmpty.ts @@ -1,11 +1,11 @@ import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider'; -import clone from 'clone'; import type { PollingBlockTracker } from 'eth-block-tracker'; import type { JsonRpcMiddleware, PendingJsonRpcResponse, } from 'json-rpc-engine'; import { createAsyncMiddleware } from 'json-rpc-engine'; +import { klona } from 'klona/full'; import pify from 'pify'; import { projectLogger, createModuleLogger } from './logging-utils'; @@ -97,7 +97,7 @@ export function createRetryOnEmptyMiddleware({ ); // create child request with specific block-ref - const childRequest = clone(req); + const childRequest = klona(req); // attempt child request until non-empty response is received const childResponse: PendingJsonRpcResponse = await retry( 10, diff --git a/test/util/helpers.ts b/test/util/helpers.ts index c3b4b353..ae475564 100644 --- a/test/util/helpers.ts +++ b/test/util/helpers.ts @@ -1,10 +1,10 @@ import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider'; -import clone from 'clone'; import type { JsonRpcRequest, JsonRpcResponse, JsonRpcMiddleware, } from 'json-rpc-engine'; +import { klona } from 'klona/full'; import { isDeepStrictEqual } from 'util'; /** @@ -206,7 +206,7 @@ export function stubProviderRequests( provider: SafeEventEmitterProvider, stubs: ProviderRequestStub[], ) { - const remainingStubs = clone(stubs); + const remainingStubs = klona(stubs); const callNumbersByRequest = new Map< Partial>, number diff --git a/yarn.lock b/yarn.lock index b51ccfe9..e2a8997e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -997,13 +997,11 @@ __metadata: "@metamask/eth-sig-util": ^7.0.0 "@metamask/utils": ^8.1.0 "@types/btoa": ^1.2.3 - "@types/clone": ^2.1.0 "@types/jest": ^27.4.1 "@types/node": ^17.0.23 "@types/pify": ^3.0.2 "@typescript-eslint/eslint-plugin": ^5.42.1 "@typescript-eslint/parser": ^5.42.1 - clone: ^2.1.1 eslint: ^8.44.0 eslint-config-prettier: ^8.1.0 eslint-plugin-import: ^2.27.5 @@ -1016,6 +1014,7 @@ __metadata: eth-rpc-errors: ^4.0.3 jest: ^27.5.1 json-rpc-engine: ^6.1.0 + klona: ^2.0.6 pify: ^5.0.0 prettier: ^2.2.1 prettier-plugin-packagejson: ^2.2.11 @@ -1383,13 +1382,6 @@ __metadata: languageName: node linkType: hard -"@types/clone@npm:^2.1.0": - version: 2.1.1 - resolution: "@types/clone@npm:2.1.1" - checksum: bda9668b9d6e0875d64bbe00763676f566e8647bc224333a03ac7fd66655dfed56a98a9f8304d0145c4411b964649c84c4d1a03adbdb6547eafb9ab8f303d254 - languageName: node - linkType: hard - "@types/debug@npm:^4.1.7": version: 4.1.7 resolution: "@types/debug@npm:4.1.7" @@ -2270,13 +2262,6 @@ __metadata: languageName: node linkType: hard -"clone@npm:^2.1.1": - version: 2.1.2 - resolution: "clone@npm:2.1.2" - checksum: aaf106e9bc025b21333e2f4c12da539b568db4925c0501a1bf4070836c9e848c892fa22c35548ce0d1132b08bbbfa17a00144fe58fccdab6fa900fec4250f67d - languageName: node - linkType: hard - "cmd-shim@npm:^6.0.0": version: 6.0.1 resolution: "cmd-shim@npm:6.0.1" @@ -4812,6 +4797,13 @@ __metadata: languageName: node linkType: hard +"klona@npm:^2.0.6": + version: 2.0.6 + resolution: "klona@npm:2.0.6" + checksum: ac9ee3732e42b96feb67faae4d27cf49494e8a3bf3fa7115ce242fe04786788e0aff4741a07a45a2462e2079aa983d73d38519c85d65b70ef11447bbc3c58ce7 + languageName: node + linkType: hard + "leven@npm:^3.1.0": version: 3.1.0 resolution: "leven@npm:3.1.0"