UNPKG

@exodus/solana-web3.js

Version:
282 lines (281 loc) 8.82 kB
import { PublicKey } from '../publickey.js'; import { Transaction, TransactionInstruction } from '../transaction/index.js'; /** * Address of the stake config account which configures the rate * of stake warmup and cooldown as well as the slashing penalty. */ export declare const STAKE_CONFIG_ID: PublicKey; /** * Stake account authority info */ export declare class Authorized { /** stake authority */ staker: PublicKey; /** withdraw authority */ withdrawer: PublicKey; /** * Create a new Authorized object * @param staker the stake authority * @param withdrawer the withdraw authority */ constructor(staker: PublicKey, withdrawer: PublicKey); } /** * Stake account lockup info */ export declare class Lockup { /** Unix timestamp of lockup expiration */ unixTimestamp: number; /** Epoch of lockup expiration */ epoch: number; /** Lockup custodian authority */ custodian: PublicKey; /** * Create a new Lockup object */ constructor(unixTimestamp: number, epoch: number, custodian: PublicKey); /** * Default, inactive Lockup value */ static default: Lockup; } /** * Create stake account transaction params */ export declare type CreateStakeAccountParams = { /** Address of the account which will fund creation */ fromPubkey: PublicKey; /** Address of the new stake account */ stakePubkey: PublicKey; /** Authorities of the new stake account */ authorized: Authorized; /** Lockup of the new stake account */ lockup?: Lockup; /** Funding amount */ lamports: number; }; /** * Create stake account with seed transaction params */ export declare type CreateStakeAccountWithSeedParams = { fromPubkey: PublicKey; stakePubkey: PublicKey; basePubkey: PublicKey; seed: string; authorized: Authorized; lockup?: Lockup; lamports: number; }; /** * Initialize stake instruction params */ export declare type InitializeStakeParams = { stakePubkey: PublicKey; authorized: Authorized; lockup?: Lockup; }; /** * Delegate stake instruction params */ export declare type DelegateStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; votePubkey: PublicKey; }; /** * Authorize stake instruction params */ export declare type AuthorizeStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; newAuthorizedPubkey: PublicKey; stakeAuthorizationType: StakeAuthorizationType; custodianPubkey?: PublicKey; }; /** * Authorize stake instruction params using a derived key */ export declare type AuthorizeWithSeedStakeParams = { stakePubkey: PublicKey; authorityBase: PublicKey; authoritySeed: string; authorityOwner: PublicKey; newAuthorizedPubkey: PublicKey; stakeAuthorizationType: StakeAuthorizationType; custodianPubkey?: PublicKey; }; /** * Split stake instruction params */ export declare type SplitStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; splitStakePubkey: PublicKey; lamports: number; }; /** * Split with seed transaction params */ export declare type SplitStakeWithSeedParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; splitStakePubkey: PublicKey; basePubkey: PublicKey; seed: string; lamports: number; }; /** * Withdraw stake instruction params */ export declare type WithdrawStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; toPubkey: PublicKey; lamports: number; custodianPubkey?: PublicKey; }; /** * Deactivate stake instruction params */ export declare type DeactivateStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; }; /** * Merge stake instruction params */ export declare type MergeStakeParams = { stakePubkey: PublicKey; sourceStakePubKey: PublicKey; authorizedPubkey: PublicKey; }; /** * Stake Instruction class */ export declare class StakeInstruction { /** * Decode a stake instruction and retrieve the instruction type. */ static decodeInstructionType(instruction: TransactionInstruction): StakeInstructionType; /** * Decode a initialize stake instruction and retrieve the instruction params. */ static decodeInitialize(instruction: TransactionInstruction): InitializeStakeParams; /** * Decode a delegate stake instruction and retrieve the instruction params. */ static decodeDelegate(instruction: TransactionInstruction): DelegateStakeParams; /** * Decode an authorize stake instruction and retrieve the instruction params. */ static decodeAuthorize(instruction: TransactionInstruction): AuthorizeStakeParams; /** * Decode an authorize-with-seed stake instruction and retrieve the instruction params. */ static decodeAuthorizeWithSeed(instruction: TransactionInstruction): AuthorizeWithSeedStakeParams; /** * Decode a split stake instruction and retrieve the instruction params. */ static decodeSplit(instruction: TransactionInstruction): SplitStakeParams; /** * Decode a merge stake instruction and retrieve the instruction params. */ static decodeMerge(instruction: TransactionInstruction): MergeStakeParams; /** * Decode a withdraw stake instruction and retrieve the instruction params. */ static decodeWithdraw(instruction: TransactionInstruction): WithdrawStakeParams; /** * Decode a deactivate stake instruction and retrieve the instruction params. */ static decodeDeactivate(instruction: TransactionInstruction): DeactivateStakeParams; } /** * An enumeration of valid StakeInstructionType's */ export declare type StakeInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'Deactivate' | 'Delegate' | 'Initialize' | 'Merge' | 'Split' | 'Withdraw'; /** * Stake authorization type */ export declare type StakeAuthorizationType = { /** The Stake Authorization index (from solana-stake-program) */ index: number; }; /** * An enumeration of valid StakeAuthorizationLayout's */ export declare const StakeAuthorizationLayout: Readonly<{ Staker: { index: number; }; Withdrawer: { index: number; }; }>; /** * Factory class for transactions to interact with the Stake program */ export declare class StakeProgram { /** * Public key that identifies the Stake program */ static programId: PublicKey; /** * Max space of a Stake account * * This is generated from the solana-stake-program StakeState struct as * `StakeState::size_of()`: * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeState.html */ static space: number; /** * Generate an Initialize instruction to add to a Stake Create transaction */ static initialize(params: InitializeStakeParams): TransactionInstruction; /** * Generate a Transaction that creates a new Stake account at * an address generated with `from`, a seed, and the Stake programId */ static createAccountWithSeed(params: CreateStakeAccountWithSeedParams): Transaction; /** * Generate a Transaction that creates a new Stake account */ static createAccount(params: CreateStakeAccountParams): Transaction; /** * Generate a Transaction that delegates Stake tokens to a validator * Vote PublicKey. This transaction can also be used to redelegate Stake * to a new validator Vote PublicKey. */ static delegate(params: DelegateStakeParams): Transaction; /** * Generate a Transaction that authorizes a new PublicKey as Staker * or Withdrawer on the Stake account. */ static authorize(params: AuthorizeStakeParams): Transaction; /** * Generate a Transaction that authorizes a new PublicKey as Staker * or Withdrawer on the Stake account. */ static authorizeWithSeed(params: AuthorizeWithSeedStakeParams): Transaction; /** * Generate a Transaction that splits Stake tokens into another stake account */ static split(params: SplitStakeParams): Transaction; /** * Generate a Transaction that splits Stake tokens into another account * derived from a base public key and seed */ static splitWithSeed(params: SplitStakeWithSeedParams): Transaction; /** * Generate a Transaction that merges Stake accounts. */ static merge(params: MergeStakeParams): Transaction; /** * Generate a Transaction that withdraws deactivated Stake tokens. */ static withdraw(params: WithdrawStakeParams): Transaction; /** * Generate a Transaction that deactivates Stake tokens. */ static deactivate(params: DeactivateStakeParams): Transaction; }