Skip to content

WSS method onAccountChange doesn't support custom encoding #2725

@slyofzero

Description

@slyofzero

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions