@solana/rpc-transport
Advanced tools
Comparing version 2.0.0-experimental.847f0a9 to 2.0.0-experimental.bd89c41
@@ -1,7 +0,1 @@ | ||
import 'node-fetch'; | ||
// ../fetch-impl-browser/dist/index.browser.js | ||
var { fetch } = globalThis; | ||
var src_default = fetch; | ||
// src/http-request-errors.ts | ||
@@ -18,14 +12,19 @@ var SolanaHttpError = class extends Error { | ||
}; | ||
async function makeHttpRequest({ payload, url }) { | ||
// ../fetch-impl/dist/index.browser.js | ||
var e = globalThis.fetch; | ||
// src/http-request.ts | ||
async function makeHttpRequest({ abortSignal, payload, url }) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
body, | ||
headers: { | ||
"Content-type": "application/json" | ||
"Content-Length": body.length.toString(), | ||
"Content-Type": "application/json; charset=utf-8" | ||
}, | ||
method: "POST" | ||
method: "POST", | ||
signal: abortSignal | ||
}; | ||
let response; | ||
{ | ||
response = await src_default(url, requestInfo); | ||
} | ||
const response = await e(url, requestInfo); | ||
if (!response.ok) { | ||
@@ -74,6 +73,7 @@ throw new SolanaHttpError({ | ||
const overrides = { | ||
async send() { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
const response = await makeHttpRequest({ | ||
abortSignal: options?.abortSignal, | ||
payload, | ||
@@ -93,5 +93,6 @@ url: transportConfig.url | ||
const overrides = { | ||
async sendBatch() { | ||
async sendBatch(options) { | ||
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params)); | ||
const responses = await makeHttpRequest({ | ||
abortSignal: options?.abortSignal, | ||
payload, | ||
@@ -98,0 +99,0 @@ url: transportConfig.url |
@@ -1,7 +0,1 @@ | ||
import 'node-fetch'; | ||
// ../fetch-impl-browser/dist/index.browser.js | ||
var { fetch } = globalThis; | ||
var src_default = fetch; | ||
// src/http-request-errors.ts | ||
@@ -18,14 +12,19 @@ var SolanaHttpError = class extends Error { | ||
}; | ||
async function makeHttpRequest({ payload, url }) { | ||
// ../fetch-impl/dist/index.browser.js | ||
var e = globalThis.fetch; | ||
// src/http-request.ts | ||
async function makeHttpRequest({ abortSignal, payload, url }) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
body, | ||
headers: { | ||
"Content-type": "application/json" | ||
"Content-Length": body.length.toString(), | ||
"Content-Type": "application/json; charset=utf-8" | ||
}, | ||
method: "POST" | ||
method: "POST", | ||
signal: abortSignal | ||
}; | ||
let response; | ||
{ | ||
response = await src_default(url, requestInfo); | ||
} | ||
const response = await e(url, requestInfo); | ||
if (!response.ok) { | ||
@@ -74,6 +73,7 @@ throw new SolanaHttpError({ | ||
const overrides = { | ||
async send() { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
const response = await makeHttpRequest({ | ||
abortSignal: options?.abortSignal, | ||
payload, | ||
@@ -93,5 +93,6 @@ url: transportConfig.url | ||
const overrides = { | ||
async sendBatch() { | ||
async sendBatch(options) { | ||
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params)); | ||
const responses = await makeHttpRequest({ | ||
abortSignal: options?.abortSignal, | ||
payload, | ||
@@ -98,0 +99,0 @@ url: transportConfig.url |
@@ -1,2 +0,2 @@ | ||
import fetchImplNode from 'node-fetch'; | ||
import t from 'node-fetch'; | ||
@@ -14,14 +14,17 @@ // src/http-request-errors.ts | ||
}; | ||
async function makeHttpRequest({ payload, url }) { | ||
var f = t; | ||
// src/http-request.ts | ||
async function makeHttpRequest({ abortSignal, payload, url }) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
body, | ||
headers: { | ||
"Content-type": "application/json" | ||
"Content-Length": body.length.toString(), | ||
"Content-Type": "application/json; charset=utf-8" | ||
}, | ||
method: "POST" | ||
method: "POST", | ||
signal: abortSignal | ||
}; | ||
let response; | ||
{ | ||
response = await fetchImplNode(url, requestInfo); | ||
} | ||
const response = await f(url, requestInfo); | ||
if (!response.ok) { | ||
@@ -70,6 +73,7 @@ throw new SolanaHttpError({ | ||
const overrides = { | ||
async send() { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
const response = await makeHttpRequest({ | ||
abortSignal: options?.abortSignal, | ||
payload, | ||
@@ -89,5 +93,6 @@ url: transportConfig.url | ||
const overrides = { | ||
async sendBatch() { | ||
async sendBatch(options) { | ||
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params)); | ||
const responses = await makeHttpRequest({ | ||
abortSignal: options?.abortSignal, | ||
payload, | ||
@@ -94,0 +99,0 @@ url: transportConfig.url |
type Config = Readonly<{ | ||
abortSignal?: AbortSignal; | ||
payload: unknown; | ||
url: string; | ||
}>; | ||
export declare function makeHttpRequest<TResponse>({ payload, url }: Config): Promise<TResponse>; | ||
export declare function makeHttpRequest<TResponse>({ abortSignal, payload, url }: Config): Promise<TResponse>; | ||
export {}; | ||
//# sourceMappingURL=http-request.d.ts.map |
@@ -7,2 +7,5 @@ /** | ||
}; | ||
export type SendOptions = Readonly<{ | ||
abortSignal?: AbortSignal; | ||
}>; | ||
export type Transport<TRpcMethods> = TransportMethods<TRpcMethods>; | ||
@@ -19,7 +22,7 @@ export type TransportConfig<TRpcMethods> = Readonly<{ | ||
export interface ArmedTransportOwnMethods<TResponse> { | ||
send(): Promise<TResponse>; | ||
send(options?: SendOptions): Promise<TResponse>; | ||
} | ||
export type ArmedTransport<TRpcMethods, TResponse> = ArmedTransportMethods<TRpcMethods, TResponse> & ArmedTransportOwnMethods<TResponse>; | ||
export interface ArmedBatchTransportOwnMethods<TResponses> { | ||
sendBatch(): Promise<TResponses>; | ||
sendBatch(options?: SendOptions): Promise<TResponses>; | ||
} | ||
@@ -26,0 +29,0 @@ export type ArmedBatchTransport<TRpcMethods, TResponses extends unknown[]> = ArmedBatchTransportMethods<TRpcMethods, TResponses> & ArmedBatchTransportOwnMethods<TResponses>; |
{ | ||
"name": "@solana/rpc-transport", | ||
"version": "2.0.0-experimental.847f0a9", | ||
"version": "2.0.0-experimental.bd89c41", | ||
"description": "Network transports for accessing the Solana JSON RPC API", | ||
@@ -53,3 +53,2 @@ "exports": { | ||
"@types/jest": "^29.5.0", | ||
"@types/node-fetch": "2", | ||
"@typescript-eslint/eslint-plugin": "^5.57.1", | ||
@@ -64,3 +63,3 @@ "@typescript-eslint/parser": "^5.57.1", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"jest-fetch-mock": "^3.0.3", | ||
"jest-fetch-mock-fork": "^3.0.4", | ||
"jest-runner-eslint": "^2.0.0", | ||
@@ -72,7 +71,6 @@ "jest-runner-prettier": "^1.0.0", | ||
"tsup": "6.7.0", | ||
"turbo": "^1.6.3", | ||
"typescript": "^5.0.3", | ||
"version-from-git": "^1.1.1", | ||
"@solana/fetch-impl-browser": "0.0.0-development", | ||
"build-scripts": "0.0.0", | ||
"fetch-impl": "0.0.0", | ||
"test-config": "0.0.0", | ||
@@ -90,4 +88,3 @@ "tsconfig": "0.0.0" | ||
"dependencies": { | ||
"node-fetch": "^2.6.7", | ||
"@solana/keys": "2.0.0-experimental.847f0a9" | ||
"node-fetch": "^3.3.1" | ||
}, | ||
@@ -94,0 +91,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
111914
1
26
947
0
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removed@solana/keys@2.0.0-experimental.847f0a9(transitive)
- Removedbase-x@4.0.0(transitive)
- Removedbs58@5.0.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatednode-fetch@^3.3.1