UNPKG

@wuwei-labs/srsly

Version:
50 lines 1.88 kB
/** * Shared utilities for preparing instructions with compute budget * @module utils/instructions */ import type { Instruction } from '@solana/kit'; import { InstructionResult } from './instructionResult'; /** * Options for preparing instructions */ export interface PrepareInstructionsOptions { /** * Optional compute units to allocate for the transaction * If provided, prepends a SetComputeUnitLimit instruction */ computeUnits?: number; /** * @deprecated No longer used - call .toLegacy(PublicKey) on result instead * This field is kept for backwards compatibility but has no effect */ PublicKey?: any; } /** * Prepare instructions for transaction submission * * This utility handles the common workflow of: * 1. Normalizing single instruction to array * 2. Optionally prepending compute budget instruction * 3. Returning an InstructionResult that can be used directly with @solana/kit * or converted to web3.js format via .toLegacy() * * @param instructions - Single instruction or array of instructions * @param options - Optional configuration for compute budget * @returns InstructionResult (extends Instruction[], has .toLegacy() method) * * @example * ```typescript * // Kit users - use result directly as Instruction[] * const ixs = prepareInstructions(acceptRentalIx); * // ixs works with appendTransactionMessageInstruction() * * // Add compute budget * const ixs = prepareInstructions(acceptRentalIx, { computeUnits: 400_000 }); * * // Web3.js users - call .toLegacy() * import { PublicKey } from '@solana/web3.js'; * const legacyIxs = prepareInstructions(acceptRentalIx).toLegacy(PublicKey); * ``` */ export declare function prepareInstructions(instructions: Instruction | Instruction[], options?: PrepareInstructionsOptions): InstructionResult; //# sourceMappingURL=instructions.d.ts.map