Skip to content

Commit

Permalink
deps: replace clone with klona
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Sep 25, 2023
1 parent 1b6d396 commit 90e7c10
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 27 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/block-ref.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/inflight-cache.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -75,8 +75,8 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
activeRequestHandlers.push(
(handledRes: PendingJsonRpcResponse<unknown>) => {
// 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();
},
);
Expand Down
4 changes: 2 additions & 2 deletions src/retryOnEmpty.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<Block> = await retry(
10,
Expand Down
4 changes: 2 additions & 2 deletions test/util/helpers.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down Expand Up @@ -206,7 +206,7 @@ export function stubProviderRequests(
provider: SafeEventEmitterProvider,
stubs: ProviderRequestStub<any, any>[],
) {
const remainingStubs = clone(stubs);
const remainingStubs = klona(stubs);
const callNumbersByRequest = new Map<
Partial<JsonRpcRequest<unknown>>,
number
Expand Down
24 changes: 8 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 90e7c10

Please sign in to comment.