UNPKG

@exodus/solana-web3.js

Version:
319 lines (318 loc) 12.7 kB
import { PublicKey } from '../publickey.js'; import { Transaction, TransactionInstruction } from '../transaction/index.js'; /** * Create account system transaction params */ export declare type CreateAccountParams = { /** The account that will transfer lamports to the created account */ fromPubkey: PublicKey; /** Public key of the created account */ newAccountPubkey: PublicKey; /** Amount of lamports to transfer to the created account */ lamports: 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 */ export declare type TransferParams = { /** Account that will transfer lamports */ fromPubkey: PublicKey; /** Account that will receive transferred lamports */ toPubkey: PublicKey; /** Amount of lamports to transfer */ lamports: number | bigint; }; /** * Assign system transaction params */ export declare 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 */ export declare type CreateAccountWithSeedParams = { /** The account that will transfer lamports 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 lamports to transfer to the created account */ lamports: 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 */ export declare type CreateNonceAccountParams = { /** The account that will transfer lamports 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 lamports to transfer to the created nonce account */ lamports: number; }; /** * Create nonce account with seed system transaction params */ export declare type CreateNonceAccountWithSeedParams = { /** The account that will transfer lamports 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 lamports to transfer to the created nonce account */ lamports: 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 */ export declare 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 */ export declare type AdvanceNonceParams = { /** Nonce account */ noncePubkey: PublicKey; /** Public key of the nonce authority */ authorizedPubkey: PublicKey; }; /** * Withdraw nonce account system transaction params */ export declare 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 lamports to withdraw from the nonce account */ lamports: number; }; /** * Authorize nonce account system transaction params */ export declare 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 */ export declare type AllocateParams = { /** Account to allocate */ accountPubkey: PublicKey; /** Amount of space in bytes to allocate */ space: number; }; /** * Allocate account with seed system transaction params */ export declare 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 */ export declare 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 */ export declare type TransferWithSeedParams = { /** Account that will transfer lamports */ fromPubkey: PublicKey; /** Base public key to use to derive the funding account address */ basePubkey: PublicKey; /** Account that will receive transferred lamports */ toPubkey: PublicKey; /** Amount of lamports to transfer */ lamports: 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 */ export declare type DecodedTransferInstruction = { /** Account that will transfer lamports */ fromPubkey: PublicKey; /** Account that will receive transferred lamports */ toPubkey: PublicKey; /** Amount of lamports to transfer */ lamports: bigint; }; /** Decoded transferWithSeed system transaction instruction */ export declare type DecodedTransferWithSeedInstruction = { /** Account that will transfer lamports */ fromPubkey: PublicKey; /** Base public key to use to derive the funding account address */ basePubkey: PublicKey; /** Account that will receive transferred lamports */ toPubkey: PublicKey; /** Amount of lamports to transfer */ lamports: 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 declare 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 */ export declare 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 declare 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 lamports 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 lamports 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; }