From 18d6b56a69509e4c98de8f3de51abe2623b46763 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Wed, 17 Apr 2024 00:43:33 -0700 Subject: [PATCH] fix: use our version of `fast-stable-stringify` everywhere (#2504) --- .changeset/strong-pandas-marry.md | 8 ++++++++ packages/library-legacy/package.json | 2 +- packages/library-legacy/src/connection.ts | 8 ++------ packages/rpc-subscriptions/package.json | 4 ++-- .../src/rpc-subscriptions.ts | 4 +--- packages/rpc/package.json | 4 ++-- packages/rpc/src/rpc-request-deduplication.ts | 4 +--- pnpm-lock.yaml | 19 ++++++++++--------- 8 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 .changeset/strong-pandas-marry.md diff --git a/.changeset/strong-pandas-marry.md b/.changeset/strong-pandas-marry.md new file mode 100644 index 000000000000..6f10eae77be1 --- /dev/null +++ b/.changeset/strong-pandas-marry.md @@ -0,0 +1,8 @@ +--- +"@solana/web3.js": patch +"@solana/web3.js-experimental": patch +"@solana/rpc-subscriptions": patch +"@solana/rpc": patch +--- + +Replaced `fast-stable-stringify` with our fork diff --git a/packages/library-legacy/package.json b/packages/library-legacy/package.json index df9939d78bc4..f5134e52bdf0 100644 --- a/packages/library-legacy/package.json +++ b/packages/library-legacy/package.json @@ -59,13 +59,13 @@ "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.3", "@solana/buffer-layout": "^4.0.1", + "@solana/fast-stable-stringify": "workspace:*", "agentkeepalive": "^4.5.0", "bigint-buffer": "^1.1.5", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", - "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.0", "node-fetch": "^2.7.0", "rpc-websockets": "^7.5.1", diff --git a/packages/library-legacy/src/connection.ts b/packages/library-legacy/src/connection.ts index dedf5b7964d2..22888941bb69 100644 --- a/packages/library-legacy/src/connection.ts +++ b/packages/library-legacy/src/connection.ts @@ -1,10 +1,9 @@ +import fastStableStringify from '@solana/fast-stable-stringify'; import HttpKeepAliveAgent, { HttpsAgent as HttpsKeepAliveAgent, } from 'agentkeepalive'; import bs58 from 'bs58'; import {Buffer} from 'buffer'; -// @ts-ignore -import fastStableStringify from 'fast-stable-stringify'; import type {Agent as NodeHttpAgent} from 'http'; import {Agent as NodeHttpsAgent} from 'https'; import { @@ -6291,10 +6290,7 @@ export class Connection { args: IWSRequestParams, ): ClientSubscriptionId { const clientSubscriptionId = this._nextClientSubscriptionId++; - const hash = fastStableStringify( - [subscriptionConfig.method, args], - true /* isArrayProp */, - ); + const hash = fastStableStringify([subscriptionConfig.method, args]); const existingSubscription = this._subscriptionsByHash[hash]; if (existingSubscription === undefined) { this._subscriptionsByHash[hash] = { diff --git a/packages/rpc-subscriptions/package.json b/packages/rpc-subscriptions/package.json index 649276ddcb37..6f9b3d48e35e 100644 --- a/packages/rpc-subscriptions/package.json +++ b/packages/rpc-subscriptions/package.json @@ -64,13 +64,13 @@ ], "dependencies": { "@solana/errors": "workspace:*", + "@solana/fast-stable-stringify": "workspace:*", "@solana/functional": "workspace:*", "@solana/rpc-subscriptions-api": "workspace:*", "@solana/rpc-subscriptions-spec": "workspace:*", "@solana/rpc-subscriptions-transport-websocket": "workspace:*", "@solana/rpc-transformers": "workspace:*", - "@solana/rpc-types": "workspace:*", - "fast-stable-stringify": "^1.0.0" + "@solana/rpc-types": "workspace:*" }, "bundlewatch": { "defaultCompression": "gzip", diff --git a/packages/rpc-subscriptions/src/rpc-subscriptions.ts b/packages/rpc-subscriptions/src/rpc-subscriptions.ts index eb4bdfd1444f..5aa659569537 100644 --- a/packages/rpc-subscriptions/src/rpc-subscriptions.ts +++ b/packages/rpc-subscriptions/src/rpc-subscriptions.ts @@ -1,3 +1,4 @@ +import fastStableStringify from '@solana/fast-stable-stringify'; import { pipe } from '@solana/functional'; import type { SolanaRpcSubscriptionsApi, SolanaRpcSubscriptionsApiUnstable } from '@solana/rpc-subscriptions-api'; import { createSolanaRpcSubscriptionsApi } from '@solana/rpc-subscriptions-api'; @@ -7,9 +8,6 @@ import { type RpcSubscriptionsTransport, } from '@solana/rpc-subscriptions-spec'; import { ClusterUrl } from '@solana/rpc-types'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore -import fastStableStringify from 'fast-stable-stringify'; import { DEFAULT_RPC_CONFIG } from './rpc-default-config'; import type { RpcSubscriptionsFromTransport } from './rpc-subscriptions-clusters'; diff --git a/packages/rpc/package.json b/packages/rpc/package.json index 217fa84d05a3..599f841e2ae4 100644 --- a/packages/rpc/package.json +++ b/packages/rpc/package.json @@ -64,13 +64,13 @@ ], "dependencies": { "@solana/errors": "workspace:*", + "@solana/fast-stable-stringify": "workspace:*", "@solana/functional": "workspace:*", "@solana/rpc-api": "workspace:*", "@solana/rpc-spec": "workspace:*", "@solana/rpc-transformers": "workspace:*", "@solana/rpc-transport-http": "workspace:*", - "@solana/rpc-types": "workspace:*", - "fast-stable-stringify": "^1.0.0" + "@solana/rpc-types": "workspace:*" }, "bundlewatch": { "defaultCompression": "gzip", diff --git a/packages/rpc/src/rpc-request-deduplication.ts b/packages/rpc/src/rpc-request-deduplication.ts index e30c9140022a..8eabedb1171a 100644 --- a/packages/rpc/src/rpc-request-deduplication.ts +++ b/packages/rpc/src/rpc-request-deduplication.ts @@ -1,6 +1,4 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore -import fastStableStringify from 'fast-stable-stringify'; +import fastStableStringify from '@solana/fast-stable-stringify'; function isJsonRpcPayload(payload: unknown): payload is Readonly<{ method: string; params: unknown }> { if (payload == null || typeof payload !== 'object' || Array.isArray(payload)) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18a5f74e0929..a56a87cb7b6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -369,6 +369,9 @@ importers: '@solana/buffer-layout': specifier: ^4.0.1 version: 4.0.1 + '@solana/fast-stable-stringify': + specifier: workspace:* + version: link:../fast-stable-stringify agentkeepalive: specifier: ^4.5.0 version: 4.5.0 @@ -387,9 +390,6 @@ importers: buffer: specifier: 6.0.3 version: 6.0.3 - fast-stable-stringify: - specifier: ^1.0.0 - version: 1.0.0 jayson: specifier: ^4.1.0 version: 4.1.0 @@ -602,6 +602,9 @@ importers: '@solana/errors': specifier: workspace:* version: link:../errors + '@solana/fast-stable-stringify': + specifier: workspace:* + version: link:../fast-stable-stringify '@solana/functional': specifier: workspace:* version: link:../functional @@ -620,9 +623,6 @@ importers: '@solana/rpc-types': specifier: workspace:* version: link:../rpc-types - fast-stable-stringify: - specifier: ^1.0.0 - version: 1.0.0 packages/rpc-api: dependencies: @@ -723,6 +723,9 @@ importers: '@solana/errors': specifier: workspace:* version: link:../errors + '@solana/fast-stable-stringify': + specifier: workspace:* + version: link:../fast-stable-stringify '@solana/functional': specifier: workspace:* version: link:../functional @@ -741,9 +744,6 @@ importers: '@solana/rpc-types': specifier: workspace:* version: link:../rpc-types - fast-stable-stringify: - specifier: ^1.0.0 - version: 1.0.0 packages/rpc-subscriptions-api: dependencies: @@ -7491,6 +7491,7 @@ packages: /fast-stable-stringify@1.0.0: resolution: {integrity: sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==} + dev: true /fastestsmallesttextencoderdecoder@1.0.22: resolution: {integrity: sha512-Pb8d48e+oIuY4MaM64Cd7OW1gt4nxCHs7/ddPPZ/Ic3sg8yVGM7O9wDvZ7us6ScaUupzM+pfBolwtYhN1IxBIw==}