UNPKG

solgen

Version:

A TypeScript SDK generator for Solana IDL - Automatically generates type definitions, account interfaces, and instruction builders

27 lines (24 loc) 1.97 kB
import { Idl } from '@coral-xyz/anchor'; import { IdlType, IdlTypeDefined, IdlTypeArray, IdlTypeVec, IdlTypeOption, IdlTypeCOption, IdlField } from '@coral-xyz/anchor/dist/cjs/idl'; /** * * Makes the type checker error if this part of code is reachable (all cases aren't handled). * */ declare function unreachable(_: never): undefined; declare function fieldsInterfaceName(typeName: string): string; declare function valueInterfaceName(typeName: string): string; declare function kindInterfaceName(typeName: string): string; declare function jsonInterfaceName(typeName: string): string; declare function isComplexType(ty: IdlType): ty is IdlTypeDefined | IdlTypeArray | IdlTypeVec | IdlTypeOption | IdlTypeCOption; declare function tsTypeFromIdl(idl: Idl, ty: IdlType, definedTypesPrefix?: string, useFieldsInterfaceForStruct?: boolean): string; declare function layoutForType(ty: IdlType, property?: string, definedTypesPrefix?: string): string; declare function genIxIdentifier(ixName: string): number[]; declare function genAccDiscriminator(accName: string): number[]; declare function fieldToEncodable(idl: Idl, ty: IdlField, valPrefix?: string, definedTypesPrefix?: string): string; declare function fieldFromDecoded(idl: Idl, ty: IdlField, valPrefix?: string, definedTypesPrefix?: string): string; declare function structFieldInitializer(idl: Idl, field: IdlField, prefix?: string): any; declare function fieldToJSON(idl: Idl, ty: IdlField, valPrefix?: string): string; declare function idlTypeToJSONType(ty: IdlType, definedTypesPrefix?: string): string; declare function fieldFromJSON(ty: IdlField, jsonParamName?: string, definedTypesPrefix?: string): string; export { fieldFromDecoded, fieldFromJSON, fieldToEncodable, fieldToJSON, fieldsInterfaceName, genAccDiscriminator, genIxIdentifier, idlTypeToJSONType, isComplexType, jsonInterfaceName, kindInterfaceName, layoutForType, structFieldInitializer, tsTypeFromIdl, unreachable, valueInterfaceName };