import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { Idl } from "../../"; import { IdlField, IdlInstruction, IdlType, IdlTypeDef, IdlTypeDefTyEnum, IdlTypeDefTyStruct } from "../../idl"; import { Accounts, Context } from "../context"; import { MethodsBuilder } from "./methods"; /** * All instructions for an IDL. */ export declare type AllInstructions = IDL["instructions"][number]; /** * Returns a type of instruction name to the IdlInstruction. */ export declare type InstructionMap = { [K in I["name"]]: I & { name: K; }; }; /** * Returns a type of instruction name to the IdlInstruction. */ export declare type AllInstructionsMap = InstructionMap>; /** * All accounts for an IDL. */ export declare type AllAccounts = IDL["accounts"] extends undefined ? IdlTypeDef : NonNullable[number]; /** * Returns a type of instruction name to the IdlInstruction. */ export declare type AccountMap = { [K in I["name"]]: I & { name: K; }; }; /** * Returns a type of instruction name to the IdlInstruction. */ export declare type AllAccountsMap = AccountMap>; export declare type MakeInstructionsNamespace]: unknown; } = { [M in keyof InstructionMap]: unknown; }> = { [M in keyof InstructionMap]: InstructionContextFn[M], Ret> & Mk[M]; }; export declare type MakeMethodsNamespace = { [M in keyof InstructionMap]: MethodsFn[M], MethodsBuilder[M]>>; }; export declare type InstructionContextFn, Ret> = (...args: InstructionContextFnArgs) => Ret; export declare type InstructionContextFnArgs = [ ...ArgsTuple>, Context> ]; export declare type InstructionAccountAddresses> = { [N in keyof Accounts]: PublicKey; }; export declare type MethodsFn = (...args: ArgsTuple>) => Ret; declare type TypeMap = { publicKey: PublicKey; bool: boolean; string: string; } & { [K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "f32" | "f64"]: number; } & { [K in "u64" | "i64" | "u128" | "i128"]: BN; }; export declare type DecodeType = T extends keyof TypeMap ? TypeMap[T] : T extends { defined: keyof Defined; } ? Defined[T["defined"]] : T extends { option: { defined: keyof Defined; }; } ? Defined[T["option"]["defined"]] | null : T extends { option: keyof TypeMap; } ? TypeMap[T["option"]] | null : T extends { coption: { defined: keyof Defined; }; } ? Defined[T["coption"]["defined"]] | null : T extends { coption: keyof TypeMap; } ? TypeMap[T["coption"]] | null : T extends { vec: keyof TypeMap; } ? TypeMap[T["vec"]][] : T extends { array: [defined: keyof TypeMap, size: number]; } ? TypeMap[T["array"][0]][] : unknown; /** * Tuple of arguments. */ declare type ArgsTuple = { [K in keyof A]: A[K] extends IdlField ? DecodeType : unknown; } & unknown[]; declare type FieldsOfType = NonNullable[number]; export declare type TypeDef = { [F in FieldsOfType["name"]]: DecodeType<(FieldsOfType & { name: F; })["type"], Defined>; }; declare type TypeDefDictionary = { [K in T[number]["name"]]: TypeDef; }; export declare type IdlTypes = TypeDefDictionary, Record>; export declare type IdlAccounts = TypeDefDictionary, Record>; export declare type IdlErrorInfo = NonNullable[number]; export {}; //# sourceMappingURL=types.d.ts.map