anza-xyz / solana-rpc-client-extensions

Rust and JS code to perform Solana RPC's GetStakeActivation client-side
Apache License 2.0
4 stars 4 forks source link

`getStakeActivation()` call fails for certain accounts #7

Closed refi93 closed 1 month ago

refi93 commented 1 month ago

Hi, I'm trying to integrate your lib and on devnet I found an account (2pgFT78qkk47HWDLmPnZvjmVnC22pV9Rhe5TWtCSAfUM) where the getStakeActivation call keeps failing. Could you please look into it?

error:

/workplace/solana-rpc-get-stake-activation/web3js-1.0/dist/src/index.js:162
        voterPubkey: parsedData.value.data.parsed.info.stake.delegation.voterPubkey,
                                                             ^
TypeError: Cannot read properties of null (reading 'delegation')
    at getStakeAccount (/workplace/solana-rpc-get-stake-activation/web3js-1.0/dist/src/index.js:162:62)
    at /workplace/solana-rpc-get-stake-activation/web3js-1.0/dist/src/index.js:180:29
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 1)
    at async getStakeActivation (/workplace/solana-rpc-get-stake-activation/web3js-1.0/dist/src/index.js:173:77)

Node.js v20.11.0

code to reproduce the issue:

import { getStakeActivation } from '../dist/src';
import { PublicKey } from '@solana/web3.js';
import { Connection } from '@solana/web3.js';

const connection = new Connection('https://api.devnet.solana.com');
let stake = new PublicKey('2pgFT78qkk47HWDLmPnZvjmVnC22pV9Rhe5TWtCSAfUM');
let status = await getStakeActivation(connection, stake); // throws
joncinque commented 1 month ago

Fixed with #8