/// import { AccountMeta, PublicKey, TransactionInstruction } from "@solana/web3.js"; import { Idl, IdlAccountItem, IdlInstruction } from "../../idl.js"; import { Accounts } from "../context.js"; import { AllInstructions, AllInstructionsMap, InstructionContextFn, MakeInstructionsNamespace } from "./types.js"; export default class InstructionNamespaceFactory { static build>(idlIx: I, encodeFn: InstructionEncodeFn, programId: PublicKey): InstructionFn; static accountsArray(ctx: Accounts | undefined, accounts: readonly IdlAccountItem[], programId: PublicKey, ixName?: string): AccountMeta[]; } /** * The namespace provides functions to build [[TransactionInstruction]] * objects for each method of a program. * * ## Usage * * ```javascript * instruction.(...args, ctx); * ``` * * ## Parameters * * 1. `args` - The positional arguments for the program. The type and number * of these arguments depend on the program being used. * 2. `ctx` - [[Context]] non-argument parameters to pass to the method. * Always the last parameter in the method call. * * ## Example * * To create an instruction for the `increment` method above, * * ```javascript * const tx = await program.instruction.increment({ * accounts: { * counter, * }, * }); * ``` */ export type InstructionNamespace = MakeInstructionsNamespace]: { accounts: (ctx: Accounts[M]["accounts"][number]>) => unknown; }; }>; /** * Function to create a `TransactionInstruction` generated from an IDL. * Additionally it provides an `accounts` utility method, returning a list * of ordered accounts for the instruction. */ export type InstructionFn = AllInstructions> = InstructionContextFn & IxProps>; type IxProps = { /** * Returns an ordered list of accounts associated with the instruction. */ accounts: (ctx: A) => AccountMeta[]; }; export type InstructionEncodeFn = (ixName: I["name"], ix: any) => Buffer; export {}; //# sourceMappingURL=instruction.d.ts.map