From e58940e97b86d804a8810d0e3b301a4cde5aa11e Mon Sep 17 00:00:00 2001
From: Loris Leiva <loris.leiva@gmail.com>
Date: Thu, 24 Oct 2024 13:32:27 +0100
Subject: [PATCH] Move BigInt JSON parse and strigify functions to
 `rpc-spec-types`

---
 packages/library/src/index.ts                          | 10 +++++++++-
 .../src/__tests__/large-json-file.json                 |  0
 .../src/__tests__/parse-json-with-bigints-test.ts      |  0
 .../src/__tests__/stringify-json-with-bigints-test.ts  |  0
 packages/rpc-spec-types/src/index.ts                   |  2 ++
 .../src/parse-json-with-bigints.ts                     |  0
 .../src/stringify-json-with-bigints.ts                 |  0
 .../src/http-transport-for-solana-rpc.ts               |  3 +--
 packages/rpc-transport-http/tsconfig.json              |  6 +++++-
 9 files changed, 17 insertions(+), 4 deletions(-)
 rename packages/{rpc-transport-http => rpc-spec-types}/src/__tests__/large-json-file.json (100%)
 rename packages/{rpc-transport-http => rpc-spec-types}/src/__tests__/parse-json-with-bigints-test.ts (100%)
 rename packages/{rpc-transport-http => rpc-spec-types}/src/__tests__/stringify-json-with-bigints-test.ts (100%)
 rename packages/{rpc-transport-http => rpc-spec-types}/src/parse-json-with-bigints.ts (100%)
 rename packages/{rpc-transport-http => rpc-spec-types}/src/stringify-json-with-bigints.ts (100%)

diff --git a/packages/library/src/index.ts b/packages/library/src/index.ts
index 251b57e839da..3cb92d5a408f 100644
--- a/packages/library/src/index.ts
+++ b/packages/library/src/index.ts
@@ -10,7 +10,6 @@ export * from '@solana/rpc';
 export * from '@solana/rpc-parsed-types';
 export * from '@solana/rpc-subscriptions';
 export * from '@solana/rpc-types';
-export * from '@solana/rpc-spec-types';
 export * from '@solana/signers';
 export * from '@solana/transaction-messages';
 export * from '@solana/transactions';
@@ -20,3 +19,12 @@ export * from './decode-transaction-message';
 export * from './send-and-confirm-durable-nonce-transaction';
 export * from './send-and-confirm-transaction';
 export * from './send-transaction-without-confirming';
+
+export type {
+    RpcRequest,
+    RpcRequestTransformer,
+    RpcResponse,
+    RpcResponseData,
+    RpcResponseTransformer,
+} from '@solana/rpc-spec-types';
+export { createRpcMessage } from '@solana/rpc-spec-types';
diff --git a/packages/rpc-transport-http/src/__tests__/large-json-file.json b/packages/rpc-spec-types/src/__tests__/large-json-file.json
similarity index 100%
rename from packages/rpc-transport-http/src/__tests__/large-json-file.json
rename to packages/rpc-spec-types/src/__tests__/large-json-file.json
diff --git a/packages/rpc-transport-http/src/__tests__/parse-json-with-bigints-test.ts b/packages/rpc-spec-types/src/__tests__/parse-json-with-bigints-test.ts
similarity index 100%
rename from packages/rpc-transport-http/src/__tests__/parse-json-with-bigints-test.ts
rename to packages/rpc-spec-types/src/__tests__/parse-json-with-bigints-test.ts
diff --git a/packages/rpc-transport-http/src/__tests__/stringify-json-with-bigints-test.ts b/packages/rpc-spec-types/src/__tests__/stringify-json-with-bigints-test.ts
similarity index 100%
rename from packages/rpc-transport-http/src/__tests__/stringify-json-with-bigints-test.ts
rename to packages/rpc-spec-types/src/__tests__/stringify-json-with-bigints-test.ts
diff --git a/packages/rpc-spec-types/src/index.ts b/packages/rpc-spec-types/src/index.ts
index 878f73d707a4..6560c8538e7e 100644
--- a/packages/rpc-spec-types/src/index.ts
+++ b/packages/rpc-spec-types/src/index.ts
@@ -1,5 +1,7 @@
 export * from './overloads';
+export * from './parse-json-with-bigints';
 export * from './rpc-message';
 export * from './rpc-request';
 export * from './rpc-response';
+export * from './stringify-json-with-bigints';
 export * from './type-helpers';
diff --git a/packages/rpc-transport-http/src/parse-json-with-bigints.ts b/packages/rpc-spec-types/src/parse-json-with-bigints.ts
similarity index 100%
rename from packages/rpc-transport-http/src/parse-json-with-bigints.ts
rename to packages/rpc-spec-types/src/parse-json-with-bigints.ts
diff --git a/packages/rpc-transport-http/src/stringify-json-with-bigints.ts b/packages/rpc-spec-types/src/stringify-json-with-bigints.ts
similarity index 100%
rename from packages/rpc-transport-http/src/stringify-json-with-bigints.ts
rename to packages/rpc-spec-types/src/stringify-json-with-bigints.ts
diff --git a/packages/rpc-transport-http/src/http-transport-for-solana-rpc.ts b/packages/rpc-transport-http/src/http-transport-for-solana-rpc.ts
index 4f15483111f8..761f3a491bfe 100644
--- a/packages/rpc-transport-http/src/http-transport-for-solana-rpc.ts
+++ b/packages/rpc-transport-http/src/http-transport-for-solana-rpc.ts
@@ -1,11 +1,10 @@
 import { RpcTransport } from '@solana/rpc-spec';
+import { parseJsonWithBigInts, stringifyJsonWithBigints } from '@solana/rpc-spec-types';
 import type Dispatcher from 'undici-types/dispatcher';
 
 import { createHttpTransport } from './http-transport';
 import { AllowedHttpRequestHeaders } from './http-transport-headers';
 import { isSolanaRequest } from './is-solana-request';
-import { parseJsonWithBigInts } from './parse-json-with-bigints';
-import { stringifyJsonWithBigints } from './stringify-json-with-bigints';
 
 type Config = Readonly<{
     dispatcher_NODE_ONLY?: Dispatcher;
diff --git a/packages/rpc-transport-http/tsconfig.json b/packages/rpc-transport-http/tsconfig.json
index 5abbeea5baa6..81e2dbc76241 100644
--- a/packages/rpc-transport-http/tsconfig.json
+++ b/packages/rpc-transport-http/tsconfig.json
@@ -5,5 +5,9 @@
     },
     "display": "@solana/rpc-transport-http",
     "extends": "../tsconfig/base.json",
-    "include": ["src"]
+    "include": [
+        "src",
+        "../rpc-spec-types/src/parse-json-with-bigints.ts",
+        "../rpc-spec-types/src/stringify-json-with-bigints.ts"
+    ]
 }