UNPKG

@bbachain/web3.js

Version:

BBAChain Javascript API

1,589 lines (1,564 loc) 145 kB
/// <reference types="node" /> declare module '@bbachain/web3.js' { import {Buffer} from 'buffer'; import {Agent} from 'http'; import {Agent as Agent$1} from 'https'; import * as nodeFetch from 'node-fetch'; export class Struct { constructor(properties: any); encode(): Buffer; static decode(data: Buffer): any; static decodeUnchecked(data: Buffer): any; } export class Enum extends Struct { enum: string; constructor(properties: any); } export const BBACHAIN_SCHEMA: Map<Function, any>; /** * Maximum length of derived pubkey seed */ export const MAX_SEED_LENGTH = 32; /** * Size of public key in bytes */ export const PUBLIC_KEY_LENGTH = 32; /** * Value to be converted into public key */ type PublicKeyInitData = | number | string | Uint8Array | Array<number> | PublicKeyData; /** * JSON object representation of PublicKey class */ type PublicKeyData = {}; /** * A public key */ export class PublicKey extends Struct { /** * Create a new PublicKey object * @param value ed25519 public key as buffer or base-58 encoded string */ constructor(value: PublicKeyInitData); /** * Returns a unique PublicKey for tests and benchmarks using a counter */ static unique(): PublicKey; /** * Default public key value. The base58-encoded string representation is all ones (as seen below) * The underlying BN number is 32 bytes that are all zeros */ static default: PublicKey; /** * Checks if two publicKeys are equal */ equals(publicKey: PublicKey): boolean; /** * Return the base-58 representation of the public key */ toBase58(): string; toJSON(): string; /** * Return the byte array representation of the public key in big endian */ toBytes(): Uint8Array; /** * Return the Buffer representation of the public key in big endian */ toBuffer(): Buffer; get [Symbol.toStringTag](): string; /** * Return the base-58 representation of the public key */ toString(): string; /** * Derive a public key from another key, a seed, and a program ID. * The program ID will also serve as the owner of the public key, giving * it permission to write data to the account. */ static createWithSeed( fromPublicKey: PublicKey, seed: string, programId: PublicKey, ): Promise<PublicKey>; /** * Derive a program address from seeds and a program ID. */ static createProgramAddressSync( seeds: Array<Buffer | Uint8Array>, programId: PublicKey, ): PublicKey; /** * Async version of createProgramAddressSync * For backwards compatibility * * @deprecated Use {@link createProgramAddressSync} instead */ static createProgramAddress( seeds: Array<Buffer | Uint8Array>, programId: PublicKey, ): Promise<PublicKey>; /** * Find a valid program address * * Valid program addresses must fall off the ed25519 curve. This function * iterates a nonce until it finds one that when combined with the seeds * results in a valid program address. */ static findProgramAddressSync( seeds: Array<Buffer | Uint8Array>, programId: PublicKey, ): [PublicKey, number]; /** * Async version of findProgramAddressSync * For backwards compatibility * * @deprecated Use {@link findProgramAddressSync} instead */ static findProgramAddress( seeds: Array<Buffer | Uint8Array>, programId: PublicKey, ): Promise<[PublicKey, number]>; /** * Check that a pubkey is on the ed25519 curve. */ static isOnCurve(pubkeyData: PublicKeyInitData): boolean; } /** * An account key pair (public and secret keys). * * @deprecated since v1.10.0, please use {@link Keypair} instead. */ export class Account { /** * Create a new Account object * * If the secretKey parameter is not provided a new key pair is randomly * created for the account * * @param secretKey Secret key for the account */ constructor(secretKey?: Uint8Array | Array<number>); /** * The public key for this account */ get publicKey(): PublicKey; /** * The **unencrypted** secret key for this account. The first 32 bytes * is the private scalar and the last 32 bytes is the public key. * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/ */ get secretKey(): Buffer; } /** * Blockhash as Base58 string. */ type Blockhash = string; export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey; /** * Epoch schedule * (see https://docs.bbachain.com/terminology#epoch) * Can be retrieved with the {@link Connection.getEpochSchedule} method */ export class EpochSchedule { /** The maximum number of slots in each epoch */ slotsPerEpoch: number; /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */ leaderScheduleSlotOffset: number; /** Indicates whether epochs start short and grow */ warmup: boolean; /** The first epoch with `slotsPerEpoch` slots */ firstNormalEpoch: number; /** The first slot of `firstNormalEpoch` */ firstNormalSlot: number; constructor( slotsPerEpoch: number, leaderScheduleSlotOffset: number, warmup: boolean, firstNormalEpoch: number, firstNormalSlot: number, ); getEpoch(slot: number): number; getEpochAndSlotIndex(slot: number): [number, number]; getFirstSlotInEpoch(epoch: number): number; getLastSlotInEpoch(epoch: number): number; getSlotsInEpoch(epoch: number): number; } export function export_default( input: nodeFetch.RequestInfo, init?: nodeFetch.RequestInit, ): Promise<nodeFetch.Response>; /** * Calculator for transaction fees. * * @deprecated Deprecated since BBAChain v1.8.0. */ interface FeeCalculator { /** Cost in daltons to validate a signature. */ daltonsPerSignature: number; } export const NONCE_ACCOUNT_LENGTH: number; /** * A durable nonce is a 32 byte value encoded as a base58 string. */ type DurableNonce = string; /** * NonceAccount class */ export class NonceAccount { authorizedPubkey: PublicKey; nonce: DurableNonce; feeCalculator: FeeCalculator; /** * Deserialize NonceAccount from the account data. * * @param buffer account data * @return NonceAccount */ static fromAccountData( buffer: Buffer | Uint8Array | Array<number>, ): NonceAccount; } /** * A 64 byte secret key, the first 32 bytes of which is the * private scalar and the last 32 bytes is the public key. * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/ */ type Ed25519SecretKey = Uint8Array; /** * Ed25519 Keypair */ interface Ed25519Keypair { publicKey: Uint8Array; secretKey: Ed25519SecretKey; } /** * Keypair signer interface */ interface Signer { publicKey: PublicKey; secretKey: Uint8Array; } /** * An account keypair used for signing transactions. */ export class Keypair { private _keypair; /** * Create a new keypair instance. * Generate random keypair if no {@link Ed25519Keypair} is provided. * * @param keypair ed25519 keypair */ constructor(keypair?: Ed25519Keypair); /** * Generate a new random keypair */ static generate(): Keypair; /** * Create a keypair from a raw secret key byte array. * * This method should only be used to recreate a keypair from a previously * generated secret key. Generating keypairs from a random seed should be done * with the {@link Keypair.fromSeed} method. * * @throws error if the provided secret key is invalid and validation is not skipped. * * @param secretKey secret key byte array * @param options: skip secret key validation */ static fromSecretKey( secretKey: Uint8Array, options?: { skipValidation?: boolean; }, ): Keypair; /** * Generate a keypair from a 32 byte seed. * * @param seed seed byte array */ static fromSeed(seed: Uint8Array): Keypair; /** * The public key for this keypair */ get publicKey(): PublicKey; /** * The raw secret key for this keypair */ get secretKey(): Uint8Array; } /** * Maximum over-the-wire size of a Transaction * * 1280 is IPv6 minimum MTU * 40 bytes is the size of the IPv6 header * 8 bytes is the size of the fragment header */ export const PACKET_DATA_SIZE: number; export const VERSION_PREFIX_MASK = 127; export const SIGNATURE_LENGTH_IN_BYTES = 64; export class TransactionExpiredBlockheightExceededError extends Error { signature: string; constructor(signature: string); } export class TransactionExpiredTimeoutError extends Error { signature: string; constructor(signature: string, timeoutSeconds: number); } export class TransactionExpiredNonceInvalidError extends Error { signature: string; constructor(signature: string); } type AccountKeysFromLookups = LoadedAddresses; export class MessageAccountKeys { staticAccountKeys: Array<PublicKey>; accountKeysFromLookups?: AccountKeysFromLookups; constructor( staticAccountKeys: Array<PublicKey>, accountKeysFromLookups?: AccountKeysFromLookups, ); keySegments(): Array<Array<PublicKey>>; get(index: number): PublicKey | undefined; get length(): number; compileInstructions( instructions: Array<TransactionInstruction>, ): Array<MessageCompiledInstruction>; } /** * An instruction to execute by a program * * @property {number} programIdIndex * @property {number[]} accounts * @property {string} data */ type CompiledInstruction = { /** Index into the transaction keys array indicating the program account that executes this instruction */ programIdIndex: number; /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */ accounts: number[]; /** The program input data encoded as base 58 */ data: string; }; /** * Message constructor arguments */ type MessageArgs = { /** The message header, identifying signed and read-only `accountKeys` */ header: MessageHeader; /** All the account keys used by this transaction */ accountKeys: string[] | PublicKey[]; /** The hash of a recent ledger block */ recentBlockhash: Blockhash; /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */ instructions: CompiledInstruction[]; }; type CompileLegacyArgs = { payerKey: PublicKey; instructions: Array<TransactionInstruction>; recentBlockhash: Blockhash; }; /** * List of instructions to be processed atomically */ export class Message { header: MessageHeader; accountKeys: PublicKey[]; recentBlockhash: Blockhash; instructions: CompiledInstruction[]; private indexToProgramIds; constructor(args: MessageArgs); get version(): 'legacy'; get staticAccountKeys(): Array<PublicKey>; get compiledInstructions(): Array<MessageCompiledInstruction>; get addressTableLookups(): Array<MessageAddressTableLookup>; getAccountKeys(): MessageAccountKeys; static compile(args: CompileLegacyArgs): Message; isAccountSigner(index: number): boolean; isAccountWritable(index: number): boolean; isProgramId(index: number): boolean; programIds(): PublicKey[]; nonProgramIds(): PublicKey[]; serialize(): Buffer; /** * Decode a compiled message into a Message object. */ static from(buffer: Buffer | Uint8Array | Array<number>): Message; } type AddressLookupTableState = { deactivationSlot: bigint; lastExtendedSlot: number; lastExtendedSlotStartIndex: number; authority?: PublicKey; addresses: Array<PublicKey>; }; type AddressLookupTableAccountArgs = { key: PublicKey; state: AddressLookupTableState; }; export class AddressLookupTableAccount { key: PublicKey; state: AddressLookupTableState; constructor(args: AddressLookupTableAccountArgs); isActive(): boolean; static deserialize(accountData: Uint8Array): AddressLookupTableState; } type CreateLookupTableParams = { /** Account used to derive and control the new address lookup table. */ authority: PublicKey; /** Account that will fund the new address lookup table. */ payer: PublicKey; /** A recent slot must be used in the derivation path for each initialized table. */ recentSlot: bigint | number; }; type FreezeLookupTableParams = { /** Address lookup table account to freeze. */ lookupTable: PublicKey; /** Account which is the current authority. */ authority: PublicKey; }; type ExtendLookupTableParams = { /** Address lookup table account to extend. */ lookupTable: PublicKey; /** Account which is the current authority. */ authority: PublicKey; /** Account that will fund the table reallocation. * Not required if the reallocation has already been funded. */ payer?: PublicKey; /** List of Public Keys to be added to the lookup table. */ addresses: Array<PublicKey>; }; type DeactivateLookupTableParams = { /** Address lookup table account to deactivate. */ lookupTable: PublicKey; /** Account which is the current authority. */ authority: PublicKey; }; type CloseLookupTableParams = { /** Address lookup table account to close. */ lookupTable: PublicKey; /** Account which is the current authority. */ authority: PublicKey; /** Recipient of closed account daltons. */ recipient: PublicKey; }; /** * An enumeration of valid LookupTableInstructionType's */ type LookupTableInstructionType = | 'CreateLookupTable' | 'ExtendLookupTable' | 'CloseLookupTable' | 'FreezeLookupTable' | 'DeactivateLookupTable'; export class AddressLookupTableInstruction { static decodeInstructionType( instruction: TransactionInstruction, ): LookupTableInstructionType; static decodeCreateLookupTable( instruction: TransactionInstruction, ): CreateLookupTableParams; static decodeExtendLookupTable( instruction: TransactionInstruction, ): ExtendLookupTableParams; static decodeCloseLookupTable( instruction: TransactionInstruction, ): CloseLookupTableParams; static decodeFreezeLookupTable( instruction: TransactionInstruction, ): FreezeLookupTableParams; static decodeDeactivateLookupTable( instruction: TransactionInstruction, ): DeactivateLookupTableParams; } export class AddressLookupTableProgram { static programId: PublicKey; static createLookupTable( params: CreateLookupTableParams, ): [TransactionInstruction, PublicKey]; static freezeLookupTable( params: FreezeLookupTableParams, ): TransactionInstruction; static extendLookupTable( params: ExtendLookupTableParams, ): TransactionInstruction; static deactivateLookupTable( params: DeactivateLookupTableParams, ): TransactionInstruction; static closeLookupTable( params: CloseLookupTableParams, ): TransactionInstruction; } /** * Compute Budget Instruction class */ export class ComputeBudgetInstruction { /** * Decode a compute budget instruction and retrieve the instruction type. */ static decodeInstructionType( instruction: TransactionInstruction, ): ComputeBudgetInstructionType; /** * Decode request units compute budget instruction and retrieve the instruction params. */ static decodeRequestUnits( instruction: TransactionInstruction, ): RequestUnitsParams; /** * Decode request heap frame compute budget instruction and retrieve the instruction params. */ static decodeRequestHeapFrame( instruction: TransactionInstruction, ): RequestHeapFrameParams; /** * Decode set compute unit limit compute budget instruction and retrieve the instruction params. */ static decodeSetComputeUnitLimit( instruction: TransactionInstruction, ): SetComputeUnitLimitParams; /** * Decode set compute unit price compute budget instruction and retrieve the instruction params. */ static decodeSetComputeUnitPrice( instruction: TransactionInstruction, ): SetComputeUnitPriceParams; } /** * An enumeration of valid ComputeBudgetInstructionType's */ type ComputeBudgetInstructionType = | 'RequestUnits' | 'RequestHeapFrame' | 'SetComputeUnitLimit' | 'SetComputeUnitPrice'; /** * Request units instruction params */ interface RequestUnitsParams { /** Units to request for transaction-wide compute */ units: number; /** Prioritization fee daltons */ additionalFee: number; } /** * Request heap frame instruction params */ type RequestHeapFrameParams = { /** Requested transaction-wide program heap size in bytes. Must be multiple of 1024. Applies to each program, including CPIs. */ bytes: number; }; /** * Set compute unit limit instruction params */ interface SetComputeUnitLimitParams { /** Transaction-wide compute unit limit */ units: number; } /** * Set compute unit price instruction params */ interface SetComputeUnitPriceParams { /** Transaction compute unit price used for prioritization fees */ microDaltons: number | bigint; } /** * Factory class for transaction instructions to interact with the Compute Budget program */ export class ComputeBudgetProgram { /** * Public key that identifies the Compute Budget program */ static programId: PublicKey; /** * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice} */ static requestUnits(params: RequestUnitsParams): TransactionInstruction; static requestHeapFrame( params: RequestHeapFrameParams, ): TransactionInstruction; static setComputeUnitLimit( params: SetComputeUnitLimitParams, ): TransactionInstruction; static setComputeUnitPrice( params: SetComputeUnitPriceParams, ): TransactionInstruction; } /** * Params for creating an ed25519 instruction using a public key */ type CreateEd25519InstructionWithPublicKeyParams = { publicKey: Uint8Array; message: Uint8Array; signature: Uint8Array; instructionIndex?: number; }; /** * Params for creating an ed25519 instruction using a private key */ type CreateEd25519InstructionWithPrivateKeyParams = { privateKey: Uint8Array; message: Uint8Array; instructionIndex?: number; }; export class Ed25519Program { /** * Public key that identifies the ed25519 program */ static programId: PublicKey; /** * Create an ed25519 instruction with a public key and signature. The * public key must be a buffer that is 32 bytes long, and the signature * must be a buffer of 64 bytes. */ static createInstructionWithPublicKey( params: CreateEd25519InstructionWithPublicKeyParams, ): TransactionInstruction; /** * Create an ed25519 instruction with a private key. The private key * must be a buffer that is 64 bytes long. */ static createInstructionWithPrivateKey( params: CreateEd25519InstructionWithPrivateKeyParams, ): TransactionInstruction; } /** * Params for creating an secp256k1 instruction using a public key */ type CreateSecp256k1InstructionWithPublicKeyParams = { publicKey: Buffer | Uint8Array | Array<number>; message: Buffer | Uint8Array | Array<number>; signature: Buffer | Uint8Array | Array<number>; recoveryId: number; instructionIndex?: number; }; /** * Params for creating an secp256k1 instruction using an Ethereum address */ type CreateSecp256k1InstructionWithEthAddressParams = { ethAddress: Buffer | Uint8Array | Array<number> | string; message: Buffer | Uint8Array | Array<number>; signature: Buffer | Uint8Array | Array<number>; recoveryId: number; instructionIndex?: number; }; /** * Params for creating an secp256k1 instruction using a private key */ type CreateSecp256k1InstructionWithPrivateKeyParams = { privateKey: Buffer | Uint8Array | Array<number>; message: Buffer | Uint8Array | Array<number>; instructionIndex?: number; }; export class Secp256k1Program { /** * Public key that identifies the secp256k1 program */ static programId: PublicKey; /** * Construct an Ethereum address from a secp256k1 public key buffer. * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer */ static publicKeyToEthAddress( publicKey: Buffer | Uint8Array | Array<number>, ): Buffer; /** * Create an secp256k1 instruction with a public key. The public key * must be a buffer that is 64 bytes long. */ static createInstructionWithPublicKey( params: CreateSecp256k1InstructionWithPublicKeyParams, ): TransactionInstruction; /** * Create an secp256k1 instruction with an Ethereum address. The address * must be a hex string or a buffer that is 20 bytes long. */ static createInstructionWithEthAddress( params: CreateSecp256k1InstructionWithEthAddressParams, ): TransactionInstruction; /** * Create an secp256k1 instruction with a private key. The private key * must be a buffer that is 32 bytes long. */ static createInstructionWithPrivateKey( params: CreateSecp256k1InstructionWithPrivateKeyParams, ): TransactionInstruction; } /** * Address of the stake config account which configures the rate * of stake warmup and cooldown as well as the slashing penalty. */ export const STAKE_CONFIG_ID: PublicKey; /** * Stake account authority info */ export 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 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 */ 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 */ daltons: number; }; /** * Create stake account with seed transaction params */ type CreateStakeAccountWithSeedParams = { fromPubkey: PublicKey; stakePubkey: PublicKey; basePubkey: PublicKey; seed: string; authorized: Authorized; lockup?: Lockup; daltons: number; }; /** * Initialize stake instruction params */ type InitializeStakeParams = { stakePubkey: PublicKey; authorized: Authorized; lockup?: Lockup; }; /** * Delegate stake instruction params */ type DelegateStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; votePubkey: PublicKey; }; /** * Authorize stake instruction params */ type AuthorizeStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; newAuthorizedPubkey: PublicKey; stakeAuthorizationType: StakeAuthorizationType; custodianPubkey?: PublicKey; }; /** * Authorize stake instruction params using a derived key */ type AuthorizeWithSeedStakeParams = { stakePubkey: PublicKey; authorityBase: PublicKey; authoritySeed: string; authorityOwner: PublicKey; newAuthorizedPubkey: PublicKey; stakeAuthorizationType: StakeAuthorizationType; custodianPubkey?: PublicKey; }; /** * Split stake instruction params */ type SplitStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; splitStakePubkey: PublicKey; daltons: number; }; /** * Split with seed transaction params */ type SplitStakeWithSeedParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; splitStakePubkey: PublicKey; basePubkey: PublicKey; seed: string; daltons: number; }; /** * Withdraw stake instruction params */ type WithdrawStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; toPubkey: PublicKey; daltons: number; custodianPubkey?: PublicKey; }; /** * Deactivate stake instruction params */ type DeactivateStakeParams = { stakePubkey: PublicKey; authorizedPubkey: PublicKey; }; /** * Merge stake instruction params */ type MergeStakeParams = { stakePubkey: PublicKey; sourceStakePubKey: PublicKey; authorizedPubkey: PublicKey; }; /** * Stake Instruction class */ export 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 */ type StakeInstructionType = | 'Authorize' | 'AuthorizeWithSeed' | 'Deactivate' | 'Delegate' | 'Initialize' | 'Merge' | 'Split' | 'Withdraw'; /** * Stake authorization type */ type StakeAuthorizationType = { /** The Stake Authorization index (from solana-stake-program) */ index: number; }; /** * An enumeration of valid StakeAuthorizationLayout's */ export const StakeAuthorizationLayout: Readonly<{ Staker: { index: number; }; Withdrawer: { index: number; }; }>; /** * Factory class for transactions to interact with the Stake program */ export 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; } /** * Create account system transaction params */ type CreateAccountParams = { /** The account that will transfer daltons to the created account */ fromPubkey: PublicKey; /** Public key of the created account */ newAccountPubkey: PublicKey; /** Amount of daltons to transfer to the created account */ daltons: number; /** Amount of space in bytes to allocate to the created account */ space: number; /** Public key of the program to assign as the owner of the created account */ programId: PublicKey; }; /** * Transfer system transaction params */ type TransferParams = { /** Account that will transfer daltons */ fromPubkey: PublicKey; /** Account that will receive transferred daltons */ toPubkey: PublicKey; /** Amount of daltons to transfer */ daltons: number | bigint; }; /** * Assign system transaction params */ type AssignParams = { /** Public key of the account which will be assigned a new owner */ accountPubkey: PublicKey; /** Public key of the program to assign as the owner */ programId: PublicKey; }; /** * Create account with seed system transaction params */ type CreateAccountWithSeedParams = { /** The account that will transfer daltons to the created account */ fromPubkey: PublicKey; /** Public key of the created account. Must be pre-calculated with PublicKey.createWithSeed() */ newAccountPubkey: PublicKey; /** Base public key to use to derive the address of the created account. Must be the same as the base key used to create `newAccountPubkey` */ basePubkey: PublicKey; /** Seed to use to derive the address of the created account. Must be the same as the seed used to create `newAccountPubkey` */ seed: string; /** Amount of daltons to transfer to the created account */ daltons: number; /** Amount of space in bytes to allocate to the created account */ space: number; /** Public key of the program to assign as the owner of the created account */ programId: PublicKey; }; /** * Create nonce account system transaction params */ type CreateNonceAccountParams = { /** The account that will transfer daltons to the created nonce account */ fromPubkey: PublicKey; /** Public key of the created nonce account */ noncePubkey: PublicKey; /** Public key to set as authority of the created nonce account */ authorizedPubkey: PublicKey; /** Amount of daltons to transfer to the created nonce account */ daltons: number; }; /** * Create nonce account with seed system transaction params */ type CreateNonceAccountWithSeedParams = { /** The account that will transfer daltons to the created nonce account */ fromPubkey: PublicKey; /** Public key of the created nonce account */ noncePubkey: PublicKey; /** Public key to set as authority of the created nonce account */ authorizedPubkey: PublicKey; /** Amount of daltons to transfer to the created nonce account */ daltons: number; /** Base public key to use to derive the address of the nonce account */ basePubkey: PublicKey; /** Seed to use to derive the address of the nonce account */ seed: string; }; /** * Initialize nonce account system instruction params */ type InitializeNonceParams = { /** Nonce account which will be initialized */ noncePubkey: PublicKey; /** Public key to set as authority of the initialized nonce account */ authorizedPubkey: PublicKey; }; /** * Advance nonce account system instruction params */ type AdvanceNonceParams = { /** Nonce account */ noncePubkey: PublicKey; /** Public key of the nonce authority */ authorizedPubkey: PublicKey; }; /** * Withdraw nonce account system transaction params */ type WithdrawNonceParams = { /** Nonce account */ noncePubkey: PublicKey; /** Public key of the nonce authority */ authorizedPubkey: PublicKey; /** Public key of the account which will receive the withdrawn nonce account balance */ toPubkey: PublicKey; /** Amount of daltons to withdraw from the nonce account */ daltons: number; }; /** * Authorize nonce account system transaction params */ type AuthorizeNonceParams = { /** Nonce account */ noncePubkey: PublicKey; /** Public key of the current nonce authority */ authorizedPubkey: PublicKey; /** Public key to set as the new nonce authority */ newAuthorizedPubkey: PublicKey; }; /** * Allocate account system transaction params */ type AllocateParams = { /** Account to allocate */ accountPubkey: PublicKey; /** Amount of space in bytes to allocate */ space: number; }; /** * Allocate account with seed system transaction params */ type AllocateWithSeedParams = { /** Account to allocate */ accountPubkey: PublicKey; /** Base public key to use to derive the address of the allocated account */ basePubkey: PublicKey; /** Seed to use to derive the address of the allocated account */ seed: string; /** Amount of space in bytes to allocate */ space: number; /** Public key of the program to assign as the owner of the allocated account */ programId: PublicKey; }; /** * Assign account with seed system transaction params */ type AssignWithSeedParams = { /** Public key of the account which will be assigned a new owner */ accountPubkey: PublicKey; /** Base public key to use to derive the address of the assigned account */ basePubkey: PublicKey; /** Seed to use to derive the address of the assigned account */ seed: string; /** Public key of the program to assign as the owner */ programId: PublicKey; }; /** * Transfer with seed system transaction params */ type TransferWithSeedParams = { /** Account that will transfer daltons */ fromPubkey: PublicKey; /** Base public key to use to derive the funding account address */ basePubkey: PublicKey; /** Account that will receive transferred daltons */ toPubkey: PublicKey; /** Amount of daltons to transfer */ daltons: number | bigint; /** Seed to use to derive the funding account address */ seed: string; /** Program id to use to derive the funding account address */ programId: PublicKey; }; /** Decoded transfer system transaction instruction */ type DecodedTransferInstruction = { /** Account that will transfer daltons */ fromPubkey: PublicKey; /** Account that will receive transferred daltons */ toPubkey: PublicKey; /** Amount of daltons to transfer */ daltons: bigint; }; /** Decoded transferWithSeed system transaction instruction */ type DecodedTransferWithSeedInstruction = { /** Account that will transfer daltons */ fromPubkey: PublicKey; /** Base public key to use to derive the funding account address */ basePubkey: PublicKey; /** Account that will receive transferred daltons */ toPubkey: PublicKey; /** Amount of daltons to transfer */ daltons: bigint; /** Seed to use to derive the funding account address */ seed: string; /** Program id to use to derive the funding account address */ programId: PublicKey; }; /** * System Instruction class */ export class SystemInstruction { /** * Decode a system instruction and retrieve the instruction type. */ static decodeInstructionType( instruction: TransactionInstruction, ): SystemInstructionType; /** * Decode a create account system instruction and retrieve the instruction params. */ static decodeCreateAccount( instruction: TransactionInstruction, ): CreateAccountParams; /** * Decode a transfer system instruction and retrieve the instruction params. */ static decodeTransfer( instruction: TransactionInstruction, ): DecodedTransferInstruction; /** * Decode a transfer with seed system instruction and retrieve the instruction params. */ static decodeTransferWithSeed( instruction: TransactionInstruction, ): DecodedTransferWithSeedInstruction; /** * Decode an allocate system instruction and retrieve the instruction params. */ static decodeAllocate(instruction: TransactionInstruction): AllocateParams; /** * Decode an allocate with seed system instruction and retrieve the instruction params. */ static decodeAllocateWithSeed( instruction: TransactionInstruction, ): AllocateWithSeedParams; /** * Decode an assign system instruction and retrieve the instruction params. */ static decodeAssign(instruction: TransactionInstruction): AssignParams; /** * Decode an assign with seed system instruction and retrieve the instruction params. */ static decodeAssignWithSeed( instruction: TransactionInstruction, ): AssignWithSeedParams; /** * Decode a create account with seed system instruction and retrieve the instruction params. */ static decodeCreateWithSeed( instruction: TransactionInstruction, ): CreateAccountWithSeedParams; /** * Decode a nonce initialize system instruction and retrieve the instruction params. */ static decodeNonceInitialize( instruction: TransactionInstruction, ): InitializeNonceParams; /** * Decode a nonce advance system instruction and retrieve the instruction params. */ static decodeNonceAdvance( instruction: TransactionInstruction, ): AdvanceNonceParams; /** * Decode a nonce withdraw system instruction and retrieve the instruction params. */ static decodeNonceWithdraw( instruction: TransactionInstruction, ): WithdrawNonceParams; /** * Decode a nonce authorize system instruction and retrieve the instruction params. */ static decodeNonceAuthorize( instruction: TransactionInstruction, ): AuthorizeNonceParams; } /** * An enumeration of valid SystemInstructionType's */ type SystemInstructionType = | 'AdvanceNonceAccount' | 'Allocate' | 'AllocateWithSeed' | 'Assign' | 'AssignWithSeed' | 'AuthorizeNonceAccount' | 'Create' | 'CreateWithSeed' | 'InitializeNonceAccount' | 'Transfer' | 'TransferWithSeed' | 'WithdrawNonceAccount' | 'UpgradeNonceAccount'; /** * Factory class for transactions to interact with the System program */ export class SystemProgram { /** * Public key that identifies the System program */ static programId: PublicKey; /** * Generate a transaction instruction that creates a new account */ static createAccount(params: CreateAccountParams): TransactionInstruction; /** * Generate a transaction instruction that transfers daltons from one account to another */ static transfer( params: TransferParams | TransferWithSeedParams, ): TransactionInstruction; /** * Generate a transaction instruction that assigns an account to a program */ static assign( params: AssignParams | AssignWithSeedParams, ): TransactionInstruction; /** * Generate a transaction instruction that creates a new account at * an address generated with `from`, a seed, and programId */ static createAccountWithSeed( params: CreateAccountWithSeedParams, ): TransactionInstruction; /** * Generate a transaction that creates a new Nonce account */ static createNonceAccount( params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams, ): Transaction; /** * Generate an instruction to initialize a Nonce account */ static nonceInitialize( params: InitializeNonceParams, ): TransactionInstruction; /** * Generate an instruction to advance the nonce in a Nonce account */ static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction; /** * Generate a transaction instruction that withdraws daltons from a Nonce account */ static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction; /** * Generate a transaction instruction that authorizes a new PublicKey as the authority * on a Nonce account. */ static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction; /** * Generate a transaction instruction that allocates space in an account without funding */ static allocate( params: AllocateParams | AllocateWithSeedParams, ): TransactionInstruction; } /** * Vote account info */ export 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 */ type CreateVoteAccountParams = { fromPubkey: PublicKey; votePubkey: PublicKey; voteInit: VoteInit; daltons: number; }; /** * InitializeAccount instruction params */ type InitializeAccountParams = { votePubkey: PublicKey; nodePubkey: PublicKey; voteInit: VoteInit; }; /** * Authorize instruction params */ type AuthorizeVoteParams = { votePubkey: PublicKey; /** Current vote or withdraw authority, depending on `voteAuthorizationType` */ authorizedPubkey: PublicKey; newAuthorizedPubkey: PublicKey; voteAuthorizationType: VoteAuthorizationType; }; /** * AuthorizeWithSeed instruction params */ type AuthorizeVoteWithSeedParams = { currentAuthorityDerivedKeyBasePubkey: PublicKey; currentAuthorityDerivedKeyOwnerPubkey: PublicKey; currentAuthorityDerivedKeySeed: string; newAuthorizedPubkey: PublicKey; voteAuthorizationType: VoteAuthorizationType; votePubkey: PublicKey; }; /** * Withdraw from vote account transaction params */ type WithdrawFromVoteAccountParams = { votePubkey: PublicKey; authorizedWithdrawerPubkey: PublicKey; daltons: number; toPubkey: PublicKey; }; /** * Vote Instruction class */ export 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 */ type VoteInstructionType = | 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw'; /** * VoteAuthorize type */ type VoteAuthorizationType = { /** The VoteAuthorize index (from solana-vote-program) */ index: number; }; /** * An enumeration of valid VoteAuthorization layouts. */ export const VoteAuthorizationLayout: Readonly<{ Voter: { index: number; }; Withdrawer: { index: number; }; }>; /** * Factory class for transactions to interact with the Vote program */ export 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; } /** * Message constructor arguments */ type MessageV0Args = { /** The message header, identifying signed and read-only `accountKeys` */ header: MessageHeader; /** The static account keys used by this transaction */ staticAccountKeys: PublicKey[]; /** The hash of a recent ledger block */ recentBlockhash: Blockhash; /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */ compiledInstructions: MessageCompiledInstruction[]; /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */ addressTableLookups: MessageAddressTableLookup[]; }; type CompileV0Args = { payerKey: PublicKey; instructions: Array<TransactionInstruction>; recentBlockhash: Blockhash; addressLookupTableAccounts?: Array<AddressLookupTableAccount>; }; type GetAccountKeysArgs = | { accountKeysFromLookups?: AccountKeysFromLookups | null; } | { addressLookupTableAccounts?: AddressLookupTableAccount[] | null; }; export class MessageV0 { header: MessageHeader; staticAccountKeys: Array<PublicKey>;