@solana/rpc-transport
Advanced tools
Comparing version 2.0.0-experimental.5108520 to 2.0.0-experimental.0174e10
@@ -17,9 +17,13 @@ // src/http-request-errors.ts | ||
// src/http-request.ts | ||
async function makeHttpRequest({ payload, url }) { | ||
async function makeHttpRequest({ abortSignal, payload, url }) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
body, | ||
headers: { | ||
"Content-type": "application/json" | ||
Accept: "application/json", | ||
"Content-Length": body.length.toString(), | ||
"Content-Type": "application/json; charset=utf-8" | ||
}, | ||
method: "POST" | ||
method: "POST", | ||
signal: abortSignal | ||
}; | ||
@@ -70,6 +74,7 @@ const response = await e(url, requestInfo); | ||
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 +94,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 +100,0 @@ url: transportConfig.url |
@@ -17,9 +17,13 @@ // src/http-request-errors.ts | ||
// src/http-request.ts | ||
async function makeHttpRequest({ payload, url }) { | ||
async function makeHttpRequest({ abortSignal, payload, url }) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
body, | ||
headers: { | ||
"Content-type": "application/json" | ||
Accept: "application/json", | ||
"Content-Length": body.length.toString(), | ||
"Content-Type": "application/json; charset=utf-8" | ||
}, | ||
method: "POST" | ||
method: "POST", | ||
signal: abortSignal | ||
}; | ||
@@ -70,6 +74,7 @@ const response = await e(url, requestInfo); | ||
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 +94,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 +100,0 @@ url: transportConfig.url |
@@ -17,9 +17,13 @@ import t from 'node-fetch'; | ||
// src/http-request.ts | ||
async function makeHttpRequest({ payload, url }) { | ||
async function makeHttpRequest({ abortSignal, payload, url }) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
body, | ||
headers: { | ||
"Content-type": "application/json" | ||
Accept: "application/json", | ||
"Content-Length": body.length.toString(), | ||
"Content-Type": "application/json; charset=utf-8" | ||
}, | ||
method: "POST" | ||
method: "POST", | ||
signal: abortSignal | ||
}; | ||
@@ -70,6 +74,7 @@ const response = await f(url, requestInfo); | ||
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 +94,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 +100,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.5108520", | ||
"version": "2.0.0-experimental.0174e10", | ||
"description": "Network transports for accessing the Solana JSON RPC API", | ||
@@ -62,3 +62,3 @@ "exports": { | ||
"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", | ||
@@ -65,0 +65,0 @@ "jest-runner-prettier": "^1.0.0", |
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
112398
953
157