Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/rpc-transport

Package Overview
Dependencies
Maintainers
14
Versions
602
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-transport - npm Package Compare versions

Comparing version 2.0.0-experimental.f291d36 to 2.0.0-experimental.f2a2e5b

dist/types/apis/api-types.d.ts

339

dist/index.browser.js
// ../build-scripts/env-shim.ts
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/apis/methods/methods-api.ts
function createJsonRpcApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const methodName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, methodName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
return {
methodName,
params,
responseTransformer
};
};
}
});
}
// src/apis/subscriptions/subscriptions-api.ts
function createJsonRpcSubscriptionsApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const notificationName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, notificationName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
const subscribeMethodName = config?.subscribeNotificationNameTransformer ? config?.subscribeNotificationNameTransformer(notificationName) : notificationName;
const unsubscribeMethodName = config?.unsubscribeNotificationNameTransformer ? config?.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
return {
params,
responseTransformer,
subscribeMethodName,
unsubscribeMethodName
};
};
}
});
}
// src/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {
code;
data;
constructor(details) {

@@ -39,3 +94,3 @@ super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);

async send(options) {
const { methodName, params, responseProcessor } = pendingRequest;
const { methodName, params, responseTransformer } = pendingRequest;
const payload = createJsonRpcMessage(methodName, params);

@@ -49,3 +104,3 @@ const response = await rpcConfig.transport({

} else {
return responseProcessor ? responseProcessor(response.result) : response.result;
return responseTransformer ? responseTransformer(response.result, methodName) : response.result;
}

@@ -77,2 +132,98 @@ }

// src/json-rpc-subscription.ts
function registerIterableCleanup(iterable, cleanupFn) {
(async () => {
try {
for await (const _ of iterable)
;
} catch {
} finally {
cleanupFn();
}
})();
}
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) {
return {
async subscribe({ abortSignal }) {
abortSignal.throwIfAborted();
let subscriptionId;
function handleCleanup() {
if (subscriptionId !== void 0) {
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
connectionAbortController.abort();
});
} else {
connectionAbortController.abort();
}
}
abortSignal.addEventListener("abort", handleCleanup);
const connectionAbortController = new AbortController();
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
const connection = await rpcConfig.transport({
payload: subscribeMessage,
signal: connectionAbortController.signal
});
function handleConnectionCleanup() {
abortSignal.removeEventListener("abort", handleCleanup);
}
registerIterableCleanup(connection, handleConnectionCleanup);
for await (const message of connection) {
if ("id" in message && message.id === subscribeMessage.id) {
if ("error" in message) {
throw new SolanaJsonRpcError(message.error);
} else {
subscriptionId = message.result;
break;
}
}
}
if (subscriptionId == null) {
throw new Error("Failed to obtain a subscription id from the server");
}
return {
async *[Symbol.asyncIterator]() {
for await (const message of connection) {
if (!("params" in message) || message.params.subscription !== subscriptionId) {
continue;
}
const notification = message.params.result;
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
}
}
};
}
};
}
function makeProxy2(rpcConfig) {
return new Proxy(rpcConfig.api, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(target, p, receiver) {
return function(...rawParams) {
const methodName = p.toString();
const createRpcSubscription = Reflect.get(target, methodName, receiver);
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
throw new Error(
"Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
);
}
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
params: rawParams,
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
};
return createPendingRpcSubscription(rpcConfig, newRequest);
};
}
});
}
function createJsonSubscriptionRpc(rpcConfig) {
return makeProxy2(rpcConfig);
}
// ../fetch-impl/dist/index.browser.js

@@ -83,2 +234,3 @@ var e = globalThis.fetch;

var SolanaHttpError = class extends Error {
statusCode;
constructor(details) {

@@ -145,12 +297,6 @@ super(`HTTP error (${details.statusCode}): ${details.message}`);

// src/transports/http/http-transport.ts
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
function createHttpTransport({ headers, url }) {
if (__DEV__ && headers) {
assertIsAllowedHttpRequestHeaders(headers);
}
const agent = void 0;
if (__DEV__ && httpAgentNodeOnly != null) {
console.warn(
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
);
}
const customHeaders = headers && normalizeHeaders(headers);

@@ -163,3 +309,2 @@ return async function makeHttpRequest({

const requestInfo = {
agent,
body,

@@ -187,4 +332,176 @@ headers: {

export { createHttpTransport, createJsonRpc };
// ../ws-impl/dist/index.browser.js
var e2 = globalThis.WebSocket;
// src/transports/websocket/websocket-connection.ts
var EXPLICIT_ABORT_TOKEN = Symbol(
__DEV__ ? "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user" : void 0
);
async function createWebSocketConnection({
sendBufferHighWatermark,
signal,
url
}) {
return new Promise((resolve, reject) => {
signal.addEventListener("abort", handleAbort, { once: true });
const iteratorState = /* @__PURE__ */ new Map();
function errorAndClearAllIteratorStates(reason) {
const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
iteratorState.clear();
errorCallbacks.forEach((cb) => {
try {
cb(reason);
} catch {
}
});
}
function handleAbort() {
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
webSocket.close(1e3);
}
}
function handleClose(ev) {
bufferDrainWatcher?.onCancel();
signal.removeEventListener("abort", handleAbort);
webSocket.removeEventListener("close", handleClose);
webSocket.removeEventListener("error", handleError);
webSocket.removeEventListener("open", handleOpen);
webSocket.removeEventListener("message", handleMessage);
errorAndClearAllIteratorStates(ev);
}
function handleError(ev) {
if (!hasConnected) {
reject(
// TODO: Coded error
new Error("WebSocket failed to connect", { cause: ev })
);
}
}
let hasConnected = false;
let bufferDrainWatcher;
function handleOpen() {
hasConnected = true;
resolve({
async send(payload) {
const message = JSON.stringify(payload);
if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
let onCancel;
const promise = new Promise((resolve2, reject2) => {
const intervalId = setInterval(() => {
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
clearInterval(intervalId);
bufferDrainWatcher = void 0;
resolve2();
}
}, 16);
onCancel = () => {
bufferDrainWatcher = void 0;
clearInterval(intervalId);
reject2(
// TODO: Coded error
new Error("WebSocket was closed before payload could be sent")
);
};
});
bufferDrainWatcher = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onCancel,
promise
};
}
if (bufferDrainWatcher) {
await bufferDrainWatcher.promise;
}
webSocket.send(message);
},
async *[Symbol.asyncIterator]() {
const iteratorKey = Symbol();
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
try {
while (true) {
const state = iteratorState.get(iteratorKey);
if (!state) {
throw new Error("Invariant: WebSocket message iterator is missing state storage");
}
if (state.__hasPolled) {
throw new Error(
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
);
}
const queuedMessages = state.queuedMessages;
if (queuedMessages.length) {
state.queuedMessages = [];
yield* queuedMessages;
} else {
try {
yield await new Promise((resolve2, reject2) => {
iteratorState.set(iteratorKey, {
__hasPolled: true,
onError: reject2,
onMessage: resolve2
});
});
} catch (e3) {
if (e3 === EXPLICIT_ABORT_TOKEN) {
return;
} else {
throw new Error("WebSocket connection closed", { cause: e3 });
}
}
}
}
} finally {
iteratorState.delete(iteratorKey);
}
}
});
}
function handleMessage({ data }) {
const message = JSON.parse(data);
iteratorState.forEach((state, iteratorKey) => {
if (state.__hasPolled) {
const { onMessage } = state;
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
onMessage(message);
} else {
state.queuedMessages.push(message);
}
});
}
const webSocket = new e2(url);
webSocket.addEventListener("close", handleClose);
webSocket.addEventListener("error", handleError);
webSocket.addEventListener("open", handleOpen);
webSocket.addEventListener("message", handleMessage);
});
}
// src/transports/websocket/websocket-transport.ts
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
if (/^wss?:/i.test(url) === false) {
const protocolMatch = url.match(/^([^:]+):/);
throw new DOMException(
protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
);
}
return async function sendWebSocketMessage({ payload, signal }) {
signal?.throwIfAborted();
const connection = await createWebSocketConnection({
sendBufferHighWatermark,
signal,
url
});
signal?.throwIfAborted();
await connection.send(payload);
return {
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
};
};
}
export { createHttpTransport, createJsonRpc, createJsonRpcApi, createJsonRpcSubscriptionsApi, createJsonSubscriptionRpc, createWebSocketTransport };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map
// ../build-scripts/env-shim.ts
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/apis/methods/methods-api.ts
function createJsonRpcApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const methodName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, methodName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
return {
methodName,
params,
responseTransformer
};
};
}
});
}
// src/apis/subscriptions/subscriptions-api.ts
function createJsonRpcSubscriptionsApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const notificationName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, notificationName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
const subscribeMethodName = config?.subscribeNotificationNameTransformer ? config?.subscribeNotificationNameTransformer(notificationName) : notificationName;
const unsubscribeMethodName = config?.unsubscribeNotificationNameTransformer ? config?.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
return {
params,
responseTransformer,
subscribeMethodName,
unsubscribeMethodName
};
};
}
});
}
// src/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {
code;
data;
constructor(details) {

@@ -39,3 +94,3 @@ super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);

async send(options) {
const { methodName, params, responseProcessor } = pendingRequest;
const { methodName, params, responseTransformer } = pendingRequest;
const payload = createJsonRpcMessage(methodName, params);

@@ -49,3 +104,3 @@ const response = await rpcConfig.transport({

} else {
return responseProcessor ? responseProcessor(response.result) : response.result;
return responseTransformer ? responseTransformer(response.result, methodName) : response.result;
}

@@ -77,2 +132,98 @@ }

// src/json-rpc-subscription.ts
function registerIterableCleanup(iterable, cleanupFn) {
(async () => {
try {
for await (const _ of iterable)
;
} catch {
} finally {
cleanupFn();
}
})();
}
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) {
return {
async subscribe({ abortSignal }) {
abortSignal.throwIfAborted();
let subscriptionId;
function handleCleanup() {
if (subscriptionId !== void 0) {
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
connectionAbortController.abort();
});
} else {
connectionAbortController.abort();
}
}
abortSignal.addEventListener("abort", handleCleanup);
const connectionAbortController = new AbortController();
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
const connection = await rpcConfig.transport({
payload: subscribeMessage,
signal: connectionAbortController.signal
});
function handleConnectionCleanup() {
abortSignal.removeEventListener("abort", handleCleanup);
}
registerIterableCleanup(connection, handleConnectionCleanup);
for await (const message of connection) {
if ("id" in message && message.id === subscribeMessage.id) {
if ("error" in message) {
throw new SolanaJsonRpcError(message.error);
} else {
subscriptionId = message.result;
break;
}
}
}
if (subscriptionId == null) {
throw new Error("Failed to obtain a subscription id from the server");
}
return {
async *[Symbol.asyncIterator]() {
for await (const message of connection) {
if (!("params" in message) || message.params.subscription !== subscriptionId) {
continue;
}
const notification = message.params.result;
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
}
}
};
}
};
}
function makeProxy2(rpcConfig) {
return new Proxy(rpcConfig.api, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(target, p, receiver) {
return function(...rawParams) {
const methodName = p.toString();
const createRpcSubscription = Reflect.get(target, methodName, receiver);
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
throw new Error(
"Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
);
}
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
params: rawParams,
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
};
return createPendingRpcSubscription(rpcConfig, newRequest);
};
}
});
}
function createJsonSubscriptionRpc(rpcConfig) {
return makeProxy2(rpcConfig);
}
// ../fetch-impl/dist/index.browser.js

@@ -83,2 +234,3 @@ var e = globalThis.fetch;

var SolanaHttpError = class extends Error {
statusCode;
constructor(details) {

@@ -145,12 +297,6 @@ super(`HTTP error (${details.statusCode}): ${details.message}`);

// src/transports/http/http-transport.ts
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
function createHttpTransport({ headers, url }) {
if (__DEV__ && headers) {
assertIsAllowedHttpRequestHeaders(headers);
}
const agent = void 0;
if (__DEV__ && httpAgentNodeOnly != null) {
console.warn(
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
);
}
const customHeaders = headers && normalizeHeaders(headers);

@@ -163,3 +309,2 @@ return async function makeHttpRequest({

const requestInfo = {
agent,
body,

@@ -187,4 +332,176 @@ headers: {

export { createHttpTransport, createJsonRpc };
// ../ws-impl/dist/index.browser.js
var e2 = globalThis.WebSocket;
// src/transports/websocket/websocket-connection.ts
var EXPLICIT_ABORT_TOKEN = Symbol(
__DEV__ ? "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user" : void 0
);
async function createWebSocketConnection({
sendBufferHighWatermark,
signal,
url
}) {
return new Promise((resolve, reject) => {
signal.addEventListener("abort", handleAbort, { once: true });
const iteratorState = /* @__PURE__ */ new Map();
function errorAndClearAllIteratorStates(reason) {
const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
iteratorState.clear();
errorCallbacks.forEach((cb) => {
try {
cb(reason);
} catch {
}
});
}
function handleAbort() {
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
webSocket.close(1e3);
}
}
function handleClose(ev) {
bufferDrainWatcher?.onCancel();
signal.removeEventListener("abort", handleAbort);
webSocket.removeEventListener("close", handleClose);
webSocket.removeEventListener("error", handleError);
webSocket.removeEventListener("open", handleOpen);
webSocket.removeEventListener("message", handleMessage);
errorAndClearAllIteratorStates(ev);
}
function handleError(ev) {
if (!hasConnected) {
reject(
// TODO: Coded error
new Error("WebSocket failed to connect", { cause: ev })
);
}
}
let hasConnected = false;
let bufferDrainWatcher;
function handleOpen() {
hasConnected = true;
resolve({
async send(payload) {
const message = JSON.stringify(payload);
if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
let onCancel;
const promise = new Promise((resolve2, reject2) => {
const intervalId = setInterval(() => {
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
clearInterval(intervalId);
bufferDrainWatcher = void 0;
resolve2();
}
}, 16);
onCancel = () => {
bufferDrainWatcher = void 0;
clearInterval(intervalId);
reject2(
// TODO: Coded error
new Error("WebSocket was closed before payload could be sent")
);
};
});
bufferDrainWatcher = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onCancel,
promise
};
}
if (bufferDrainWatcher) {
await bufferDrainWatcher.promise;
}
webSocket.send(message);
},
async *[Symbol.asyncIterator]() {
const iteratorKey = Symbol();
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
try {
while (true) {
const state = iteratorState.get(iteratorKey);
if (!state) {
throw new Error("Invariant: WebSocket message iterator is missing state storage");
}
if (state.__hasPolled) {
throw new Error(
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
);
}
const queuedMessages = state.queuedMessages;
if (queuedMessages.length) {
state.queuedMessages = [];
yield* queuedMessages;
} else {
try {
yield await new Promise((resolve2, reject2) => {
iteratorState.set(iteratorKey, {
__hasPolled: true,
onError: reject2,
onMessage: resolve2
});
});
} catch (e3) {
if (e3 === EXPLICIT_ABORT_TOKEN) {
return;
} else {
throw new Error("WebSocket connection closed", { cause: e3 });
}
}
}
}
} finally {
iteratorState.delete(iteratorKey);
}
}
});
}
function handleMessage({ data }) {
const message = JSON.parse(data);
iteratorState.forEach((state, iteratorKey) => {
if (state.__hasPolled) {
const { onMessage } = state;
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
onMessage(message);
} else {
state.queuedMessages.push(message);
}
});
}
const webSocket = new e2(url);
webSocket.addEventListener("close", handleClose);
webSocket.addEventListener("error", handleError);
webSocket.addEventListener("open", handleOpen);
webSocket.addEventListener("message", handleMessage);
});
}
// src/transports/websocket/websocket-transport.ts
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
if (/^wss?:/i.test(url) === false) {
const protocolMatch = url.match(/^([^:]+):/);
throw new DOMException(
protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
);
}
return async function sendWebSocketMessage({ payload, signal }) {
signal?.throwIfAborted();
const connection = await createWebSocketConnection({
sendBufferHighWatermark,
signal,
url
});
signal?.throwIfAborted();
await connection.send(payload);
return {
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
};
};
}
export { createHttpTransport, createJsonRpc, createJsonRpcApi, createJsonRpcSubscriptionsApi, createJsonSubscriptionRpc, createWebSocketTransport };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -1,2 +0,2 @@

import t from 'node-fetch';
import e2 from 'ws';

@@ -6,4 +6,59 @@ // ../build-scripts/env-shim.ts

// src/apis/methods/methods-api.ts
function createJsonRpcApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const methodName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, methodName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
return {
methodName,
params,
responseTransformer
};
};
}
});
}
// src/apis/subscriptions/subscriptions-api.ts
function createJsonRpcSubscriptionsApi(config) {
return new Proxy({}, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(...args) {
const [_, p] = args;
const notificationName = p.toString();
return function(...rawParams) {
const params = config?.parametersTransformer ? config?.parametersTransformer(rawParams, notificationName) : rawParams;
const responseTransformer = config?.responseTransformer ? config?.responseTransformer : (rawResponse) => rawResponse;
const subscribeMethodName = config?.subscribeNotificationNameTransformer ? config?.subscribeNotificationNameTransformer(notificationName) : notificationName;
const unsubscribeMethodName = config?.unsubscribeNotificationNameTransformer ? config?.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
return {
params,
responseTransformer,
subscribeMethodName,
unsubscribeMethodName
};
};
}
});
}
// src/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {
code;
data;
constructor(details) {

@@ -42,3 +97,3 @@ super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);

async send(options) {
const { methodName, params, responseProcessor } = pendingRequest;
const { methodName, params, responseTransformer } = pendingRequest;
const payload = createJsonRpcMessage(methodName, params);

@@ -52,3 +107,3 @@ const response = await rpcConfig.transport({

} else {
return responseProcessor ? responseProcessor(response.result) : response.result;
return responseTransformer ? responseTransformer(response.result, methodName) : response.result;
}

@@ -79,6 +134,105 @@ }

}
var f = t;
// src/json-rpc-subscription.ts
function registerIterableCleanup(iterable, cleanupFn) {
(async () => {
try {
for await (const _ of iterable)
;
} catch {
} finally {
cleanupFn();
}
})();
}
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) {
return {
async subscribe({ abortSignal }) {
abortSignal.throwIfAborted();
let subscriptionId;
function handleCleanup() {
if (subscriptionId !== void 0) {
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
connectionAbortController.abort();
});
} else {
connectionAbortController.abort();
}
}
abortSignal.addEventListener("abort", handleCleanup);
const connectionAbortController = new AbortController();
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
const connection = await rpcConfig.transport({
payload: subscribeMessage,
signal: connectionAbortController.signal
});
function handleConnectionCleanup() {
abortSignal.removeEventListener("abort", handleCleanup);
}
registerIterableCleanup(connection, handleConnectionCleanup);
for await (const message of connection) {
if ("id" in message && message.id === subscribeMessage.id) {
if ("error" in message) {
throw new SolanaJsonRpcError(message.error);
} else {
subscriptionId = message.result;
break;
}
}
}
if (subscriptionId == null) {
throw new Error("Failed to obtain a subscription id from the server");
}
return {
async *[Symbol.asyncIterator]() {
for await (const message of connection) {
if (!("params" in message) || message.params.subscription !== subscriptionId) {
continue;
}
const notification = message.params.result;
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
}
}
};
}
};
}
function makeProxy2(rpcConfig) {
return new Proxy(rpcConfig.api, {
defineProperty() {
return false;
},
deleteProperty() {
return false;
},
get(target, p, receiver) {
return function(...rawParams) {
const methodName = p.toString();
const createRpcSubscription = Reflect.get(target, methodName, receiver);
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
throw new Error(
"Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
);
}
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
params: rawParams,
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
};
return createPendingRpcSubscription(rpcConfig, newRequest);
};
}
});
}
function createJsonSubscriptionRpc(rpcConfig) {
return makeProxy2(rpcConfig);
}
// ../fetch-impl/dist/index.node.js
var e = globalThis.fetch;
// src/transports/http/http-transport-errors.ts
var SolanaHttpError = class extends Error {
statusCode;
constructor(details) {

@@ -145,12 +299,6 @@ super(`HTTP error (${details.statusCode}): ${details.message}`);

// src/transports/http/http-transport.ts
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
function createHttpTransport({ headers, url }) {
if (__DEV__ && headers) {
assertIsAllowedHttpRequestHeaders(headers);
}
const agent = httpAgentNodeOnly ;
if (__DEV__ && httpAgentNodeOnly != null) {
console.warn(
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
);
}
const customHeaders = headers && normalizeHeaders(headers);

@@ -163,3 +311,2 @@ return async function makeHttpRequest({

const requestInfo = {
agent,
body,

@@ -176,3 +323,3 @@ headers: {

};
const response = await f(url, requestInfo);
const response = await e(url, requestInfo);
if (!response.ok) {

@@ -187,5 +334,175 @@ throw new SolanaHttpError({

}
var t = e2;
export { createHttpTransport, createJsonRpc };
// src/transports/websocket/websocket-connection.ts
var EXPLICIT_ABORT_TOKEN = Symbol(
__DEV__ ? "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user" : void 0
);
async function createWebSocketConnection({
sendBufferHighWatermark,
signal,
url
}) {
return new Promise((resolve, reject) => {
signal.addEventListener("abort", handleAbort, { once: true });
const iteratorState = /* @__PURE__ */ new Map();
function errorAndClearAllIteratorStates(reason) {
const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
iteratorState.clear();
errorCallbacks.forEach((cb) => {
try {
cb(reason);
} catch {
}
});
}
function handleAbort() {
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
if (webSocket.readyState !== t.CLOSED && webSocket.readyState !== t.CLOSING) {
webSocket.close(1e3);
}
}
function handleClose(ev) {
bufferDrainWatcher?.onCancel();
signal.removeEventListener("abort", handleAbort);
webSocket.removeEventListener("close", handleClose);
webSocket.removeEventListener("error", handleError);
webSocket.removeEventListener("open", handleOpen);
webSocket.removeEventListener("message", handleMessage);
errorAndClearAllIteratorStates(ev);
}
function handleError(ev) {
if (!hasConnected) {
reject(
// TODO: Coded error
new Error("WebSocket failed to connect", { cause: ev })
);
}
}
let hasConnected = false;
let bufferDrainWatcher;
function handleOpen() {
hasConnected = true;
resolve({
async send(payload) {
const message = JSON.stringify(payload);
if (!bufferDrainWatcher && webSocket.readyState === t.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
let onCancel;
const promise = new Promise((resolve2, reject2) => {
const intervalId = setInterval(() => {
if (webSocket.readyState !== t.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
clearInterval(intervalId);
bufferDrainWatcher = void 0;
resolve2();
}
}, 16);
onCancel = () => {
bufferDrainWatcher = void 0;
clearInterval(intervalId);
reject2(
// TODO: Coded error
new Error("WebSocket was closed before payload could be sent")
);
};
});
bufferDrainWatcher = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onCancel,
promise
};
}
if (bufferDrainWatcher) {
await bufferDrainWatcher.promise;
}
webSocket.send(message);
},
async *[Symbol.asyncIterator]() {
const iteratorKey = Symbol();
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
try {
while (true) {
const state = iteratorState.get(iteratorKey);
if (!state) {
throw new Error("Invariant: WebSocket message iterator is missing state storage");
}
if (state.__hasPolled) {
throw new Error(
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
);
}
const queuedMessages = state.queuedMessages;
if (queuedMessages.length) {
state.queuedMessages = [];
yield* queuedMessages;
} else {
try {
yield await new Promise((resolve2, reject2) => {
iteratorState.set(iteratorKey, {
__hasPolled: true,
onError: reject2,
onMessage: resolve2
});
});
} catch (e3) {
if (e3 === EXPLICIT_ABORT_TOKEN) {
return;
} else {
throw new Error("WebSocket connection closed", { cause: e3 });
}
}
}
}
} finally {
iteratorState.delete(iteratorKey);
}
}
});
}
function handleMessage({ data }) {
const message = JSON.parse(data);
iteratorState.forEach((state, iteratorKey) => {
if (state.__hasPolled) {
const { onMessage } = state;
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
onMessage(message);
} else {
state.queuedMessages.push(message);
}
});
}
const webSocket = new t(url);
webSocket.addEventListener("close", handleClose);
webSocket.addEventListener("error", handleError);
webSocket.addEventListener("open", handleOpen);
webSocket.addEventListener("message", handleMessage);
});
}
// src/transports/websocket/websocket-transport.ts
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
if (/^wss?:/i.test(url) === false) {
const protocolMatch = url.match(/^([^:]+):/);
throw new DOMException(
protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
);
}
return async function sendWebSocketMessage({ payload, signal }) {
signal?.throwIfAborted();
const connection = await createWebSocketConnection({
sendBufferHighWatermark,
signal,
url
});
signal?.throwIfAborted();
await connection.send(payload);
return {
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
};
};
}
export { createHttpTransport, createJsonRpc, createJsonRpcApi, createJsonRpcSubscriptionsApi, createJsonSubscriptionRpc, createWebSocketTransport };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

@@ -1,3 +0,12 @@

export * from './json-rpc';
export * from './transports/http/http-transport';
export * from './apis/api-types.js';
export * from './apis/methods/methods-api.js';
export * from './apis/subscriptions/subscriptions-api.js';
export * from './json-rpc.js';
export type { SolanaJsonRpcErrorCode } from './json-rpc-errors.js';
export * from './json-rpc-subscription.js';
export type { IRpcApi, IRpcSubscriptionsApi, IRpcWebSocketTransport, PendingRpcSubscription, Rpc, RpcRequest, RpcSubscription, RpcSubscriptions, } from './json-rpc-types.js';
export * from './transports/http/http-transport.js';
export * from './transports/websocket/websocket-transport.js';
export type { IRpcTransport } from './transports/transport-types.js';
export * from './transports/websocket/websocket-transport.js';
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { IRpcTransport } from './transports/transport-types';
import { IRpcTransport, IRpcWebSocketTransport } from './transports/transport-types.js';
/**

@@ -6,5 +6,9 @@ * Public RPC API.

export type IRpcApi<TRpcMethods> = {
[MethodName in keyof TRpcMethods]: TRpcMethods[MethodName] extends Callable ? (...rawParams: unknown[]) => RpcRequest<ReturnType<TRpcMethods[MethodName]>> : never;
[MethodName in keyof TRpcMethods]: RpcReturnTypeMapper<TRpcMethods[MethodName]>;
};
export type IRpcSubscriptionsApi<TRpcSubscriptionMethods> = {
[MethodName in keyof TRpcSubscriptionMethods]: RpcSubscriptionReturnTypeMapper<TRpcSubscriptionMethods[MethodName]>;
};
export type Rpc<TRpcMethods> = RpcMethods<TRpcMethods>;
export type RpcSubscriptions<TRpcSubscriptionMethods> = RpcSubscriptionMethods<TRpcSubscriptionMethods>;
export type RpcConfig<TRpcMethods> = Readonly<{

@@ -14,2 +18,6 @@ api: IRpcApi<TRpcMethods>;

}>;
export type RpcSubscriptionConfig<TRpcMethods> = Readonly<{
api: IRpcSubscriptionsApi<TRpcMethods>;
transport: IRpcWebSocketTransport;
}>;
/**

@@ -21,20 +29,42 @@ * Public pending RPC request API.

params: unknown[];
responseProcessor?: (response: unknown) => TResponse;
responseTransformer?: (response: unknown, methodName: string) => TResponse;
};
export type RpcSubscription<TResponse> = {
params: unknown[];
responseTransformer?: (response: unknown, notificationName: string) => TResponse;
subscribeMethodName: string;
unsubscribeMethodName: string;
};
export type PendingRpcRequest<TResponse> = {
send(options?: SendOptions): Promise<TResponse>;
};
export type PendingRpcSubscription<TNotification> = {
subscribe(options: SubscribeOptions): Promise<AsyncIterable<TNotification>>;
};
export type SendOptions = Readonly<{
abortSignal?: AbortSignal;
}>;
export type SubscribeOptions = Readonly<{
abortSignal: AbortSignal;
}>;
/**
* Private RPC-building types.
*/
type RpcReturnTypeMapper<TRpcMethod> = TRpcMethod extends Callable ? (...rawParams: unknown[]) => RpcRequest<ReturnType<TRpcMethod>> : never;
type RpcSubscriptionReturnTypeMapper<TRpcMethod> = TRpcMethod extends Callable ? (...rawParams: unknown[]) => RpcSubscription<ReturnType<TRpcMethod>> : never;
type RpcMethods<TRpcMethods> = {
[TMethodName in keyof TRpcMethods]: PendingRpcRequestBuilder<ApiMethodImplementations<TRpcMethods, TMethodName>>;
};
type RpcSubscriptionMethods<TRpcSubscriptionMethods> = {
[TMethodName in keyof TRpcSubscriptionMethods]: PendingRpcSubscriptionBuilder<ApiMethodImplementations<TRpcSubscriptionMethods, TMethodName>>;
};
type ApiMethodImplementations<TRpcMethods, TMethod extends keyof TRpcMethods> = Overloads<TRpcMethods[TMethod]>;
type PendingRpcRequestReturnTypeMapper<TMethodImplementation> = TMethodImplementation extends Callable ? (...args: Parameters<TMethodImplementation>) => PendingRpcRequest<ReturnType<TMethodImplementation>> : never;
type PendingRpcRequestBuilder<TMethodImplementations> = UnionToIntersection<Flatten<{
[P in keyof TMethodImplementations]: TMethodImplementations[P] extends Callable ? (...args: Parameters<TMethodImplementations[P]>) => PendingRpcRequest<ReturnType<TMethodImplementations[P]>> : never;
[P in keyof TMethodImplementations]: PendingRpcRequestReturnTypeMapper<TMethodImplementations[P]>;
}>>;
type PendingRpcSubscriptionReturnTypeMapper<TSubscriptionMethodImplementation> = TSubscriptionMethodImplementation extends Callable ? (...args: Parameters<TSubscriptionMethodImplementation>) => PendingRpcSubscription<ReturnType<TSubscriptionMethodImplementation>> : never;
type PendingRpcSubscriptionBuilder<TSubscriptionMethodImplementations> = UnionToIntersection<Flatten<{
[P in keyof TSubscriptionMethodImplementations]: PendingRpcSubscriptionReturnTypeMapper<TSubscriptionMethodImplementations[P]>;
}>>;
/**

@@ -45,3 +75,4 @@ * Utility types that do terrible, awful things.

type Flatten<T> = T extends (infer Item)[] ? Item : never;
type Overloads<T> = T extends {
type Overloads<T> = Overloads24<T>;
type Overloads24<T> = T extends {
(...args: infer A1): infer R1;

@@ -52,3 +83,48 @@ (...args: infer A2): infer R2;

(...args: infer A5): infer R5;
} ? [(...args: A1) => R1, (...args: A2) => R2, (...args: A3) => R3, (...args: A4) => R4, (...args: A5) => R5] : T extends {
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
(...args: infer A19): infer R19;
(...args: infer A20): infer R20;
(...args: infer A21): infer R21;
(...args: infer A22): infer R22;
(...args: infer A23): infer R23;
(...args: infer A24): infer R24;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18,
(...args: A19) => R19,
(...args: A20) => R20,
(...args: A21) => R21,
(...args: A22) => R22,
(...args: A23) => R23,
(...args: A24) => R24
] : Overloads23<T>;
type Overloads23<T> = T extends {
(...args: infer A1): infer R1;

@@ -58,14 +134,600 @@ (...args: infer A2): infer R2;

(...args: infer A4): infer R4;
} ? [(...args: A1) => R1, (...args: A2) => R2, (...args: A3) => R3, (...args: A4) => R4] : T extends {
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
(...args: infer A19): infer R19;
(...args: infer A20): infer R20;
(...args: infer A21): infer R21;
(...args: infer A22): infer R22;
(...args: infer A23): infer R23;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18,
(...args: A19) => R19,
(...args: A20) => R20,
(...args: A21) => R21,
(...args: A22) => R22,
(...args: A23) => R23
] : Overloads22<T>;
type Overloads22<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
} ? [(...args: A1) => R1, (...args: A2) => R2, (...args: A3) => R3] : T extends {
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
(...args: infer A19): infer R19;
(...args: infer A20): infer R20;
(...args: infer A21): infer R21;
(...args: infer A22): infer R22;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18,
(...args: A19) => R19,
(...args: A20) => R20,
(...args: A21) => R21,
(...args: A22) => R22
] : Overloads21<T>;
type Overloads21<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
} ? [(...args: A1) => R1, (...args: A2) => R2] : T extends {
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
(...args: infer A19): infer R19;
(...args: infer A20): infer R20;
(...args: infer A21): infer R21;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18,
(...args: A19) => R19,
(...args: A20) => R20,
(...args: A21) => R21
] : Overloads20<T>;
type Overloads20<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
(...args: infer A19): infer R19;
(...args: infer A20): infer R20;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18,
(...args: A19) => R19,
(...args: A20) => R20
] : Overloads19<T>;
type Overloads19<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
(...args: infer A19): infer R19;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18,
(...args: A19) => R19
] : Overloads18<T>;
type Overloads18<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
(...args: infer A18): infer R18;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17,
(...args: A18) => R18
] : Overloads17<T>;
type Overloads17<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
(...args: infer A17): infer R17;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16,
(...args: A17) => R17
] : Overloads16<T>;
type Overloads16<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
(...args: infer A16): infer R16;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15,
(...args: A16) => R16
] : Overloads15<T>;
type Overloads15<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
(...args: infer A15): infer R15;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14,
(...args: A15) => R15
] : Overloads14<T>;
type Overloads14<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
(...args: infer A14): infer R14;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13,
(...args: A14) => R14
] : Overloads13<T>;
type Overloads13<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
(...args: infer A13): infer R13;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12,
(...args: A13) => R13
] : Overloads12<T>;
type Overloads12<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
(...args: infer A12): infer R12;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11,
(...args: A12) => R12
] : Overloads11<T>;
type Overloads11<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
(...args: infer A11): infer R11;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10,
(...args: A11) => R11
] : Overloads10<T>;
type Overloads10<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
(...args: infer A10): infer R10;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9,
(...args: A10) => R10
] : Overloads9<T>;
type Overloads9<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
(...args: infer A9): infer R9;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8,
(...args: A9) => R9
] : Overloads8<T>;
type Overloads8<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
(...args: infer A8): infer R8;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7,
(...args: A8) => R8
] : Overloads7<T>;
type Overloads7<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
(...args: infer A7): infer R7;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6,
(...args: A7) => R7
] : Overloads6<T>;
type Overloads6<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
(...args: infer A6): infer R6;
} ? [
(...args: A1) => R1,
(...args: A2) => R2,
(...args: A3) => R3,
(...args: A4) => R4,
(...args: A5) => R5,
(...args: A6) => R6
] : Overloads5<T>;
type Overloads5<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
(...args: infer A5): infer R5;
} ? [(...args: A1) => R1, (...args: A2) => R2, (...args: A3) => R3, (...args: A4) => R4, (...args: A5) => R5] : Overloads4<T>;
type Overloads4<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
(...args: infer A4): infer R4;
} ? [(...args: A1) => R1, (...args: A2) => R2, (...args: A3) => R3, (...args: A4) => R4] : Overloads3<T>;
type Overloads3<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
(...args: infer A3): infer R3;
} ? [(...args: A1) => R1, (...args: A2) => R2, (...args: A3) => R3] : Overloads2<T>;
type Overloads2<T> = T extends {
(...args: infer A1): infer R1;
(...args: infer A2): infer R2;
} ? [(...args: A1) => R1, (...args: A2) => R2] : Overloads1<T>;
type Overloads1<T> = T extends {
(...args: infer A1): infer R1;
} ? [(...args: A1) => R1] : unknown;
type UnionToIntersection<T> = (T extends unknown ? (x: T) => unknown : never) extends (x: infer R) => unknown ? R : never;
export {};
export type { IRpcWebSocketTransport };
//# sourceMappingURL=json-rpc-types.d.ts.map

@@ -1,3 +0,16 @@

import { Rpc, RpcConfig } from './json-rpc-types';
import { Rpc, RpcConfig } from './json-rpc-types.js';
interface IHasIdentifier {
readonly id: number;
}
export type JsonRpcResponse<TResponse> = IHasIdentifier & Readonly<{
result: TResponse;
} | {
error: {
code: number;
message: string;
data?: unknown;
};
}>;
export declare function createJsonRpc<TRpcMethods>(rpcConfig: RpcConfig<TRpcMethods>): Rpc<TRpcMethods>;
export {};
//# sourceMappingURL=json-rpc.d.ts.map

11

dist/types/transports/http/http-transport.d.ts

@@ -1,14 +0,9 @@

/// <reference types="node" />
/// <reference types="node" />
import type { Agent as NodeHttpAgent } from 'node:http';
import type { Agent as NodeHttpsAgent } from 'node:https';
import { IRpcTransport } from '../transport-types';
import { AllowedHttpRequestHeaders } from './http-transport-headers';
import { IRpcTransport } from '../transport-types.js';
import { AllowedHttpRequestHeaders } from './http-transport-headers.js';
type Config = Readonly<{
headers?: AllowedHttpRequestHeaders;
httpAgentNodeOnly?: NodeHttpAgent | NodeHttpsAgent | ((parsedUrl: URL) => NodeHttpAgent | NodeHttpsAgent);
url: string;
}>;
export declare function createHttpTransport({ httpAgentNodeOnly, headers, url }: Config): IRpcTransport;
export declare function createHttpTransport({ headers, url }: Config): IRpcTransport;
export {};
//# sourceMappingURL=http-transport.d.ts.map

@@ -0,1 +1,2 @@

import { RpcWebSocketConnection } from './websocket/websocket-connection.js';
type RpcTransportConfig = Readonly<{

@@ -8,3 +9,12 @@ payload: unknown;

}
type RpcWebSocketTransportConfig = Readonly<{
payload: unknown;
signal: AbortSignal;
}>;
export interface IRpcWebSocketTransport {
(config: RpcWebSocketTransportConfig): Promise<Readonly<Omit<RpcWebSocketConnection, 'send'> & {
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: RpcWebSocketConnection['send'];
}>>;
}
export {};
//# sourceMappingURL=transport-types.d.ts.map
{
"name": "@solana/rpc-transport",
"version": "2.0.0-experimental.f291d36",
"version": "2.0.0-experimental.f2a2e5b",
"description": "Network transports for accessing the Solana JSON RPC API",

@@ -49,24 +49,22 @@ "exports": {

"devDependencies": {
"@solana/eslint-config-solana": "^1.0.1",
"@swc/core": "^1.3.18",
"@swc/jest": "^0.2.26",
"@types/jest": "^29.5.1",
"@types/node": "^16",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@solana/eslint-config-solana": "^1.0.2",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.11",
"@types/node": "18.11.19",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.3.0",
"agadoo": "^3.0.0",
"eslint": "^8.37.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.45.0",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"fast-stable-stringify": "^1.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock-fork": "^3.0.4",
"jest-runner-eslint": "^2.1.0",
"jest-runner-eslint": "^2.1.2",
"jest-runner-prettier": "^1.0.0",
"postcss": "^8.4.12",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"tsup": "6.7.0",
"typescript": "^5.0.4",
"jest-websocket-mock": "^2.5.0",
"prettier": "^3.1",
"tsup": "^8.0.1",
"typescript": "^5.2.2",
"version-from-git": "^1.1.1",

@@ -76,4 +74,8 @@ "build-scripts": "0.0.0",

"test-config": "0.0.0",
"tsconfig": "0.0.0"
"tsconfig": "0.0.0",
"ws-impl": "0.0.0"
},
"peerDependencies": {
"ws": "^8.14.0"
},
"bundlewatch": {

@@ -89,10 +91,11 @@ "defaultCompression": "gzip",

"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
"test:treeshakability:browser": "agadoo dist/index.browser.js",
"test:treeshakability:native": "agadoo dist/index.node.js",
"test:treeshakability:node": "agadoo dist/index.native.js",
"test:treeshakability:native": "agadoo dist/index.native.js",
"test:treeshakability:node": "agadoo dist/index.node.js",
"test:typecheck": "tsc --noEmit",

@@ -99,0 +102,0 @@ "test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",

@@ -58,3 +58,3 @@ [![npm][npm-image]][npm-url]

// Provide an optional function to modify the response.
responseProcessor: response => ({
responseTransformer: response => ({
confirmedBlocks: response,

@@ -61,0 +61,0 @@ queryRange: [startSlot, endSlot],

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc