Issue
How can I parse the connection.onProgramAccountChange notifications data to JSON?
https://solana-labs.github.io/solana-web3.js/modules.html#AccountInfo
The docs specify the data as type T, which for me has usually been a Buffer.
Example code:
let progKey = new PublicKey("<program key here>");
conn.onProgramAccountChange(progKey, programCallback);
function programCallback(keyedAccountInfo: KeyedAccountInfo, context: Context) {
let data = keyedAccountInfo.accountInfo.data.toString("hex");
let ownerId = keyedAccountInfo.accountInfo.owner.toBase58();
let accId = keyedAccountInfo.accountId.toBase58();
console.log(`======
owner: ${ownerId}
accId: ${accId}
data: ${data}`);
}
Is the data type literally just a buffer in this specific instance, or is there something extra that I need to do to decode it? Decoding it to hex, utf8, base64, and base58 don't work.
Solution
Even though this is programSubscribe, the notification format is the same as getProgramAccounts. Hence, the answer can be found in my other answer: https://stackoverflow.com/a/71028298/7841421
Answered By - oriont
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.