Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@anza-xyz/solana-rpc-get-stake-activation

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anza-xyz/solana-rpc-get-stake-activation - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

52

dist/src/index.js

@@ -127,3 +127,3 @@ 'use strict';

}
let stakeHistory = [];
const stakeHistory = [];
parsedData.value.data.parsed.info.forEach((entry) => {

@@ -140,8 +140,10 @@ stakeHistory.push({

var getStakeAccount = function(parsedData) {
let discriminant = BigInt(0);
if (parsedData.value === null || parsedData.value.data instanceof Buffer) {
throw new Error("Account not found");
}
if (parsedData.value.data.parsed.type === "delegated") {
let discriminant = BigInt(0);
if (parsedData.value.data.parsed.type === "initialized") {
discriminant = BigInt(1);
} else if (parsedData.value.data.parsed.type === "delegated") {
discriminant = BigInt(2);
}

@@ -151,3 +153,5 @@ return {

meta: {
rentExemptReserve: BigInt(parsedData.value.data.parsed.info.meta.rentExemptReserve),
rentExemptReserve: BigInt(
parsedData.value.data.parsed.info.meta.rentExemptReserve
),
authorized: {

@@ -158,3 +162,5 @@ staker: parsedData.value.data.parsed.info.meta.authorized.staker,

lockup: {
unixTimestamp: BigInt(parsedData.value.data.parsed.info.meta.lockup.unixTimestamp),
unixTimestamp: BigInt(
parsedData.value.data.parsed.info.meta.lockup.unixTimestamp
),
epoch: BigInt(parsedData.value.data.parsed.info.meta.lockup.epoch),

@@ -164,15 +170,25 @@ custodian: parsedData.value.data.parsed.info.meta.lockup.custodian

},
stake: {
stake: parsedData.value.data.parsed.info.stake ? {
delegation: {
voterPubkey: parsedData.value.data.parsed.info.stake.delegation.voterPubkey,
stake: BigInt(parsedData.value.data.parsed.info.stake.delegation.stake),
activationEpoch: BigInt(parsedData.value.data.parsed.info.stake.delegation.activationEpoch),
deactivationEpoch: BigInt(parsedData.value.data.parsed.info.stake.delegation.deactivationEpoch)
stake: BigInt(
parsedData.value.data.parsed.info.stake.delegation.stake
),
activationEpoch: BigInt(
parsedData.value.data.parsed.info.stake.delegation.activationEpoch
),
deactivationEpoch: BigInt(
parsedData.value.data.parsed.info.stake.delegation.deactivationEpoch
)
},
creditsObserved: BigInt(parsedData.value.data.parsed.info.stake.creditsObserved)
}
creditsObserved: BigInt(
parsedData.value.data.parsed.info.stake.creditsObserved
)
} : null
};
};
async function getStakeActivation(connection, stakeAddress) {
const SYSVAR_STAKE_HISTORY_ADDRESS = new web3_js.PublicKey("SysvarStakeHistory1111111111111111111111111");
const SYSVAR_STAKE_HISTORY_ADDRESS = new web3_js.PublicKey(
"SysvarStakeHistory1111111111111111111111111"
);
const [epochInfo, { stakeAccount, stakeAccountLamports }, stakeHistory] = await Promise.all([

@@ -190,3 +206,5 @@ connection.getEpochInfo(),

(async () => {
const stakeHistoryParsed = await connection.getParsedAccountInfo(SYSVAR_STAKE_HISTORY_ADDRESS);
const stakeHistoryParsed = await connection.getParsedAccountInfo(
SYSVAR_STAKE_HISTORY_ADDRESS
);
if (stakeHistoryParsed === null) {

@@ -198,7 +216,11 @@ throw new Error("StakeHistory not found");

]);
const { effective, activating, deactivating } = getStakeActivatingAndDeactivating(
const { effective, activating, deactivating } = stakeAccount.stake ? getStakeActivatingAndDeactivating(
stakeAccount.stake.delegation,
BigInt(epochInfo.epoch),
stakeHistory
);
) : {
effective: BigInt(0),
activating: BigInt(0),
deactivating: BigInt(0)
};
let status;

@@ -205,0 +227,0 @@ if (deactivating > 0) {

@@ -1,2 +0,2 @@

import { Delegation, StakeHistoryEntry } from "./stake";
import { Delegation, StakeHistoryEntry } from './stake';
export interface StakeActivatingAndDeactivating {

@@ -3,0 +3,0 @@ effective: bigint;

@@ -1,2 +0,2 @@

import { Connection, PublicKey } from "@solana/web3.js";
import { Connection, PublicKey } from '@solana/web3.js';
export interface StakeActivation {

@@ -3,0 +3,0 @@ status: string;

@@ -1,2 +0,2 @@

import { AccountInfo, ParsedAccountData, RpcResponseAndContext } from "@solana/web3.js";
import { AccountInfo, ParsedAccountData, RpcResponseAndContext } from '@solana/web3.js';
export type StakeHistoryEntry = {

@@ -31,3 +31,3 @@ epoch: bigint;

creditsObserved: bigint;
};
} | null;
};

@@ -34,0 +34,0 @@ export declare const getStakeHistory: (parsedData: RpcResponseAndContext<AccountInfo<ParsedAccountData | Buffer> | null>) => StakeHistoryEntry[];

{
"name": "@anza-xyz/solana-rpc-get-stake-activation",
"version": "1.0.0",
"version": "1.0.1",
"description": "Client-side replica of Solana RPC's getStakeActivation",

@@ -55,2 +55,3 @@ "sideEffects": false,

"@ava/typescript": "^4.1.0",
"@solana/eslint-config-solana": "^3.0.3",
"@types/node": "^20",

@@ -57,0 +58,0 @@ "@typescript-eslint/eslint-plugin": "^7.16.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc