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

getProgramAccounts field withContext is not exposed #1285

Closed
kulych opened this issue May 3, 2023 · 3 comments · Fixed by #1311
Closed

getProgramAccounts field withContext is not exposed #1285

kulych opened this issue May 3, 2023 · 3 comments · Fixed by #1311
Labels
enhancement New feature or request released

Comments

@kulych
Copy link

kulych commented May 3, 2023

Motivation

It seems that a field withContext available in getProgramAccounts http method is not exposed via solana-web3.js.

Example use case

I am working on a synchronization mechanism between http request and websocket data.
The synchronization mechanism will use slot as a revision field, will first connect to websocket, save all updates and simultaneously send a request. The request response should also return slot so that only newer updates from websocket are then applied.

Details

According to getProgramAccounts documentation, there is a withContext field available which will make the response contain context.
Such field is however not exposed by solana-web3js.

Similarly to the pair

I would expect the same for getProgramAccounts and (does not exist) getProgramAccountsAndContext.
Or adding the withContext boolean to the function signature. As the result type depends on this value a separate function is imo better.

@kulych kulych added the enhancement New feature or request label May 3, 2023
@steveluscher
Copy link
Collaborator

As the result type depends on this value a separate function is imo better.

Separate functions are one of the most regrettable things about this library. With Typescript, you can modulate the return type of a function depending on its inputs. Take a look how we're doing this in the new web3.js library.

export interface GetAccountInfoApi {
/**
* Returns all information associated with the account of provided public key
*/
getAccountInfo(
address: Base58EncodedAddress,
config: GetAccountInfoApiCommonConfig &
GetAccountInfoApiSliceableCommonConfig &
Readonly<{
encoding: 'base64';
}>
): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedData;
getAccountInfo(
address: Base58EncodedAddress,
config: GetAccountInfoApiCommonConfig &
GetAccountInfoApiSliceableCommonConfig &
Readonly<{
encoding: 'base64+zstd';
}>
): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase64EncodedZStdCompressedData;
getAccountInfo(
address: Base58EncodedAddress,
config: GetAccountInfoApiCommonConfig &
Readonly<{
encoding: 'jsonParsed';
}>
): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithJsonData;
getAccountInfo(
address: Base58EncodedAddress,
config: GetAccountInfoApiCommonConfig &
GetAccountInfoApiSliceableCommonConfig &
Readonly<{
encoding: 'base58';
}>
): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithBase58EncodedData_DEPRECATED;
getAccountInfo(
address: Base58EncodedAddress,
config?: GetAccountInfoApiCommonConfig
): GetAccountInfoApiResponseBase & GetAccountInfoApiResponseWithDefaultData;
}

steveluscher added a commit that referenced this issue May 24, 2023
## Summary

This was missing. When supplied, the RPC wraps the result in a context object.

Fixes #1285.

## Test Plan

```
pnpm test:live-with-test-validator
pnpm test:unit:node
```
steveluscher added a commit that referenced this issue May 24, 2023
## Summary

This was missing. When supplied, the RPC wraps the result in a context object.

Fixes #1285.

## Test Plan

```
pnpm test:live-with-test-validator
pnpm test:unit:node
```
steveluscher added a commit that referenced this issue May 24, 2023
## Summary

This was missing. When supplied, the RPC wraps the result in a context object.

Fixes #1285.

## Test Plan

```
pnpm test:live-with-test-validator
pnpm test:unit:node
```
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.77.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2023

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants