Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow RpcRequest params to be of any type, instead of requiring an array #2751

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/unlucky-pumpkins-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solana/rpc-spec": patch
---

Allow Rpc Request params to be any type, instead of requiring an array
2 changes: 1 addition & 1 deletion packages/rpc-spec/src/rpc-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Callable } from '@solana/rpc-spec-types';
import { RpcRequest } from './rpc-request';

export type RpcApiConfig = Readonly<{
parametersTransformer?: <T extends unknown[]>(params: T, methodName: string) => unknown[];
parametersTransformer?: <T extends unknown[]>(params: T, methodName: string) => unknown;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want the array enforced for input here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, because the developer doesn't control that - it's just the input params to their function. From a JS perspective that'll always be a list, I think.

responseTransformer?: <T>(response: unknown, methodName: string) => T;
}>;

Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-spec/src/rpc-request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type RpcRequest<TResponse> = {
methodName: string;
params: unknown[];
params: unknown;
responseTransformer?: (response: unknown, methodName: string) => TResponse;
};

Expand Down
Loading