@solana/rpc-transport
Advanced tools
Comparing version 2.0.0-experimental.4c1874d to 2.0.0-experimental.4c9a8b8
// ../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 | ||
@@ -41,3 +94,3 @@ var SolanaJsonRpcError = class extends Error { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const { methodName, params, responseTransformer } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
@@ -51,3 +104,3 @@ const response = await rpcConfig.transport({ | ||
} else { | ||
return responseProcessor ? responseProcessor(response.result) : response.result; | ||
return responseTransformer ? responseTransformer(response.result, methodName) : response.result; | ||
} | ||
@@ -91,3 +144,3 @@ } | ||
} | ||
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) { | ||
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) { | ||
return { | ||
@@ -138,3 +191,3 @@ async subscribe({ abortSignal }) { | ||
const notification = message.params.result; | ||
yield responseProcessor ? responseProcessor(notification) : notification; | ||
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification; | ||
} | ||
@@ -449,4 +502,4 @@ } | ||
export { createHttpTransport, createJsonRpc, createJsonSubscriptionRpc, createWebSocketTransport }; | ||
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 | ||
@@ -41,3 +94,3 @@ var SolanaJsonRpcError = class extends Error { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const { methodName, params, responseTransformer } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
@@ -51,3 +104,3 @@ const response = await rpcConfig.transport({ | ||
} else { | ||
return responseProcessor ? responseProcessor(response.result) : response.result; | ||
return responseTransformer ? responseTransformer(response.result, methodName) : response.result; | ||
} | ||
@@ -91,3 +144,3 @@ } | ||
} | ||
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) { | ||
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) { | ||
return { | ||
@@ -138,3 +191,3 @@ async subscribe({ abortSignal }) { | ||
const notification = message.params.result; | ||
yield responseProcessor ? responseProcessor(notification) : notification; | ||
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification; | ||
} | ||
@@ -449,4 +502,4 @@ } | ||
export { createHttpTransport, createJsonRpc, createJsonSubscriptionRpc, createWebSocketTransport }; | ||
export { createHttpTransport, createJsonRpc, createJsonRpcApi, createJsonRpcSubscriptionsApi, createJsonSubscriptionRpc, createWebSocketTransport }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -6,2 +6,55 @@ import e2 from 'ws'; | ||
// 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 | ||
@@ -44,3 +97,3 @@ var SolanaJsonRpcError = class extends Error { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const { methodName, params, responseTransformer } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
@@ -54,3 +107,3 @@ const response = await rpcConfig.transport({ | ||
} else { | ||
return responseProcessor ? responseProcessor(response.result) : response.result; | ||
return responseTransformer ? responseTransformer(response.result, methodName) : response.result; | ||
} | ||
@@ -94,3 +147,3 @@ } | ||
} | ||
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) { | ||
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) { | ||
return { | ||
@@ -141,3 +194,3 @@ async subscribe({ abortSignal }) { | ||
const notification = message.params.result; | ||
yield responseProcessor ? responseProcessor(notification) : notification; | ||
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification; | ||
} | ||
@@ -450,4 +503,4 @@ } | ||
export { createHttpTransport, createJsonRpc, createJsonSubscriptionRpc, createWebSocketTransport }; | ||
export { createHttpTransport, createJsonRpc, createJsonRpcApi, createJsonRpcSubscriptionsApi, createJsonSubscriptionRpc, createWebSocketTransport }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
@@ -1,5 +0,12 @@ | ||
export * from './json-rpc'; | ||
export * from './json-rpc-subscription'; | ||
export * from './transports/http/http-transport'; | ||
export * from './transports/websocket/websocket-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,3 +0,3 @@ | ||
import { RpcSubscriptionConfig, RpcSubscriptions } from './json-rpc-types'; | ||
import { RpcSubscriptionConfig, RpcSubscriptions } from './json-rpc-types.js'; | ||
export declare function createJsonSubscriptionRpc<TRpcSubscriptionMethods>(rpcConfig: RpcSubscriptionConfig<TRpcSubscriptionMethods>): RpcSubscriptions<TRpcSubscriptionMethods>; | ||
//# sourceMappingURL=json-rpc-subscription.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { IRpcTransport, IRpcWebSocketTransport } from './transports/transport-types'; | ||
import { IRpcTransport, IRpcWebSocketTransport } from './transports/transport-types.js'; | ||
/** | ||
@@ -27,7 +27,7 @@ * Public RPC API. | ||
params: unknown[]; | ||
responseProcessor?: (response: unknown) => TResponse; | ||
responseTransformer?: (response: unknown, methodName: string) => TResponse; | ||
}; | ||
export type RpcSubscription<TResponse> = { | ||
params: unknown[]; | ||
responseProcessor?: (response: unknown) => TResponse; | ||
responseTransformer?: (response: unknown, notificationName: string) => TResponse; | ||
subscribeMethodName: string; | ||
@@ -727,3 +727,3 @@ unsubscribeMethodName: string; | ||
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,2 +0,2 @@ | ||
import { Rpc, RpcConfig } from './json-rpc-types'; | ||
import { Rpc, RpcConfig } from './json-rpc-types.js'; | ||
interface IHasIdentifier { | ||
@@ -3,0 +3,0 @@ readonly id: number; |
@@ -1,3 +0,3 @@ | ||
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<{ | ||
@@ -4,0 +4,0 @@ headers?: AllowedHttpRequestHeaders; |
@@ -1,2 +0,2 @@ | ||
import { RpcWebSocketConnection } from './websocket/websocket-connection'; | ||
import { RpcWebSocketConnection } from './websocket/websocket-connection.js'; | ||
type RpcTransportConfig = Readonly<{ | ||
@@ -3,0 +3,0 @@ payload: unknown; |
@@ -1,2 +0,2 @@ | ||
import { IRpcWebSocketTransport } from '../transport-types'; | ||
import { IRpcWebSocketTransport } from '../transport-types.js'; | ||
type Config = Readonly<{ | ||
@@ -3,0 +3,0 @@ sendBufferHighWatermark: number; |
{ | ||
"name": "@solana/rpc-transport", | ||
"version": "2.0.0-experimental.4c1874d", | ||
"version": "2.0.0-experimental.4c9a8b8", | ||
"description": "Network transports for accessing the Solana JSON RPC API", | ||
@@ -51,5 +51,5 @@ "exports": { | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.6", | ||
"@types/node": "^20", | ||
"@typescript-eslint/eslint-plugin": "^6.7.0", | ||
"@types/jest": "^29.5.11", | ||
"@types/node": "18.11.19", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
@@ -66,4 +66,4 @@ "agadoo": "^3.0.0", | ||
"jest-runner-prettier": "^1.0.0", | ||
"jest-websocket-mock": "^2.4.1", | ||
"prettier": "^2.8", | ||
"jest-websocket-mock": "^2.5.0", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
@@ -91,3 +91,3 @@ "typescript": "^5.2.2", | ||
"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", | ||
@@ -94,0 +94,0 @@ "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", |
@@ -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
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
388032
46
3816