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

WSS method onAccountChange doesn't support custom encoding #2725

Labels
enhancement New feature or request

Comments

@slyofzero
Copy link

Motivation

The Solana RPC method accountSubscribe does provide a way to pass encoding so should the JS SDK

Example use case

solanaConnection.onAccountChange(
  publicKey,
  (updatedProgramInfo, context) =>
    console.log(updatedProgramInfo.data),
  "confirmed"
);

The way this function has the commitment arguement it should have one for encoding too. Maybe just make the third arguement take an object with commitment and encoding as two fields of it.

Right now the data the above code logs is like -

<Buffer 06 00 00 00 00 00 00 00 fe 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 01 00 ... 702 more bytes>

This data can't be much used and JSON data will be much more appreciated like the accountSubscribe method returns.

@slyofzero slyofzero added the enhancement New feature or request label May 17, 2024
@NotoriousPyro
Copy link

You can just unpack the account using @solana/spl-token if its an ATA

Or you can just use AccountInfo?

I think this is not an enhancement. You are not using the library correctly.

You can see an example here that is using the properties of the account, such as lamports, here: https://gist.github.com/NotoriousPyro/c169f2dd455ce0fe5d2c6854cd0364e4

Copy link
Contributor

github-actions bot commented Jul 5, 2024

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 Jul 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.