@solana/rpc-spec
Advanced tools
Comparing version 2.0.0-canary-20240910080214 to 2.0.0-canary-20240910080602
@@ -5,6 +5,3 @@ export type RpcRequest<TParams = unknown> = { | ||
}; | ||
export type RpcResponse<TResponse = unknown> = { | ||
readonly json: () => Promise<TResponse>; | ||
readonly text: () => Promise<string>; | ||
}; | ||
export type RpcResponse<TResponse = unknown> = TResponse; | ||
export type RpcRequestTransformer = { | ||
@@ -16,3 +13,2 @@ <TParams>(request: RpcRequest<TParams>): RpcRequest; | ||
}; | ||
export declare function createJsonRpcResponseTransformer<TResponse = unknown>(jsonTransformer: (json: unknown, request: RpcRequest) => TResponse): RpcResponseTransformer<TResponse>; | ||
//# sourceMappingURL=rpc-shared.d.ts.map |
{ | ||
"name": "@solana/rpc-spec", | ||
"version": "2.0.0-canary-20240910080214", | ||
"version": "2.0.0-canary-20240910080602", | ||
"description": "A generic implementation of JSON RPCs using proxies", | ||
@@ -57,3 +57,3 @@ "exports": { | ||
"dependencies": { | ||
"@solana/rpc-spec-types": "2.0.0-canary-20240910080214" | ||
"@solana/rpc-spec-types": "2.0.0-canary-20240910080602" | ||
}, | ||
@@ -60,0 +60,0 @@ "peerDependencies": { |
@@ -57,9 +57,4 @@ [![npm][npm-image]][npm-url] | ||
An object that represents the response from a JSON RPC server. It contains two asynchronous methods that can be used to access the response data: | ||
A type that represents the response from a JSON RPC server. This could be any sort of data which is why `RpcResponse` defaults to `unknown`. You may use a type parameter to specify the shape of the response — e.g. `RpcResponse<{ result: number }>`. | ||
- `await response.json()`: Returns the data as a JSON object. | ||
- `await response.text()`: Returns the data, unparsed, as a JSON string. | ||
This allows the `RpcApi` to decide whether they want the parsed JSON object or the raw JSON string. Ultimately, the `json` method will be used by the `Rpc` to provide the final response to the caller. | ||
### `RpcResponseTransformer` | ||
@@ -144,15 +139,1 @@ | ||
- `responseTransformer<T>(response: RpcResponse, request: RpcRequest): RpcResponse<T>`: An optional function that transforms the `RpcResponse` before it is returned to the caller. | ||
### `createJsonRpcResponseTransformer(jsonTransformer)` | ||
Creates an `RpcResponseTransformer<T>` function from a function that transforms any JSON value to a value of type `T` by wrapping it in a `json` async function. | ||
```ts | ||
const getResultTransformer = createJsonRpcResponseTransformer((json: unknown): unknown => { | ||
return (json as { result: unknown }).result; | ||
}); | ||
``` | ||
#### Arguments | ||
- `jsonTransformer: (json: unknown, request: RpcRequest) => T`: A function that transforms an unknown JSON value to a value of type `T`. |
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
65522
384
138
+ Added@solana/rpc-spec-types@2.0.0-canary-20240910080602(transitive)
- Removed@solana/rpc-spec-types@2.0.0-canary-20240910080214(transitive)