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

Open
slyofzero opened this issue May 17, 2024 · 1 comment
Open

WSS method onAccountChange doesn't support custom encoding #2725

slyofzero opened this issue May 17, 2024 · 1 comment
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants