@exodus/solana-web3.js
Version:
Solana Javascript API
154 lines (153 loc) • 5.26 kB
TypeScript
import { PublicKey } from '../publickey.js';
import { Transaction, TransactionInstruction } from '../transaction/index.js';
/**
* Vote account info
*/
export declare class VoteInit {
nodePubkey: PublicKey;
authorizedVoter: PublicKey;
authorizedWithdrawer: PublicKey;
commission: number; /** [0, 100] */
constructor(nodePubkey: PublicKey, authorizedVoter: PublicKey, authorizedWithdrawer: PublicKey, commission: number);
}
/**
* Create vote account transaction params
*/
export declare type CreateVoteAccountParams = {
fromPubkey: PublicKey;
votePubkey: PublicKey;
voteInit: VoteInit;
lamports: number;
};
/**
* InitializeAccount instruction params
*/
export declare type InitializeAccountParams = {
votePubkey: PublicKey;
nodePubkey: PublicKey;
voteInit: VoteInit;
};
/**
* Authorize instruction params
*/
export declare type AuthorizeVoteParams = {
votePubkey: PublicKey;
/** Current vote or withdraw authority, depending on `voteAuthorizationType` */
authorizedPubkey: PublicKey;
newAuthorizedPubkey: PublicKey;
voteAuthorizationType: VoteAuthorizationType;
};
/**
* AuthorizeWithSeed instruction params
*/
export declare type AuthorizeVoteWithSeedParams = {
currentAuthorityDerivedKeyBasePubkey: PublicKey;
currentAuthorityDerivedKeyOwnerPubkey: PublicKey;
currentAuthorityDerivedKeySeed: string;
newAuthorizedPubkey: PublicKey;
voteAuthorizationType: VoteAuthorizationType;
votePubkey: PublicKey;
};
/**
* Withdraw from vote account transaction params
*/
export declare type WithdrawFromVoteAccountParams = {
votePubkey: PublicKey;
authorizedWithdrawerPubkey: PublicKey;
lamports: number;
toPubkey: PublicKey;
};
/**
* Vote Instruction class
*/
export declare class VoteInstruction {
/**
* Decode a vote instruction and retrieve the instruction type.
*/
static decodeInstructionType(instruction: TransactionInstruction): VoteInstructionType;
/**
* Decode an initialize vote instruction and retrieve the instruction params.
*/
static decodeInitializeAccount(instruction: TransactionInstruction): InitializeAccountParams;
/**
* Decode an authorize instruction and retrieve the instruction params.
*/
static decodeAuthorize(instruction: TransactionInstruction): AuthorizeVoteParams;
/**
* Decode an authorize instruction and retrieve the instruction params.
*/
static decodeAuthorizeWithSeed(instruction: TransactionInstruction): AuthorizeVoteWithSeedParams;
/**
* Decode a withdraw instruction and retrieve the instruction params.
*/
static decodeWithdraw(instruction: TransactionInstruction): WithdrawFromVoteAccountParams;
}
/**
* An enumeration of valid VoteInstructionType's
*/
export declare type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
/**
* VoteAuthorize type
*/
export declare type VoteAuthorizationType = {
/** The VoteAuthorize index (from solana-vote-program) */
index: number;
};
/**
* An enumeration of valid VoteAuthorization layouts.
*/
export declare const VoteAuthorizationLayout: Readonly<{
Voter: {
index: number;
};
Withdrawer: {
index: number;
};
}>;
/**
* Factory class for transactions to interact with the Vote program
*/
export declare class VoteProgram {
/**
* Public key that identifies the Vote program
*/
static programId: PublicKey;
/**
* Max space of a Vote account
*
* This is generated from the solana-vote-program VoteState struct as
* `VoteState::size_of()`:
* https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of
*/
static space: number;
/**
* Generate an Initialize instruction.
*/
static initializeAccount(params: InitializeAccountParams): TransactionInstruction;
/**
* Generate a transaction that creates a new Vote account.
*/
static createAccount(params: CreateVoteAccountParams): Transaction;
/**
* Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
*/
static authorize(params: AuthorizeVoteParams): Transaction;
/**
* Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account
* where the current Voter or Withdrawer authority is a derived key.
*/
static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction;
/**
* Generate a transaction to withdraw from a Vote account.
*/
static withdraw(params: WithdrawFromVoteAccountParams): Transaction;
/**
* Generate a transaction to withdraw safely from a Vote account.
*
* This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
* checks that the withdraw amount will not exceed the specified balance while leaving enough left
* to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
* `withdraw` method directly.
*/
static safeWithdraw(params: WithdrawFromVoteAccountParams, currentVoteAccountBalance: number, rentExemptMinimum: number): Transaction;
}