import { Provable, ProvablePure } from '../../snarky.js'; import { Field } from '../../lib/core.js'; export { ProvableExtended, provable, provablePure }; export { NonMethods, HashInput, InferProvable, InferJson, InferredProvable, IsPure, }; type ProvableExtension = { toInput: (x: T) => { fields?: Field[]; packed?: [Field, number][]; }; toJSON: (x: T) => TJson; fromJSON: (x: TJson) => T; }; type ProvableExtended = Provable & ProvableExtension; type ProvableExtendedPure = ProvablePure & ProvableExtension; type Struct = ProvableExtended> & Constructor & { _isStruct: true; }; type HashInput = { fields?: Field[]; packed?: [Field, number][]; }; declare const HashInput: { readonly empty: {}; append(input1: HashInput, input2: HashInput): HashInput; }; declare function provable(typeObj: A, options?: { customObjectKeys?: string[]; isPure?: boolean; }): ProvableExtended, InferJson>; declare function provablePure(typeObj: A, options?: { customObjectKeys?: string[]; }): ProvablePure> & ProvableExtension, InferJson>; type Constructor = new (...args: any) => T; type NonMethodKeys = { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]; type NonMethods = Pick>; type Tuple = [T, ...T[]] | []; type Primitive = typeof String | typeof Number | typeof Boolean | typeof BigInt | null | undefined; type InferPrimitive

= P extends typeof String ? string : P extends typeof Number ? number : P extends typeof Boolean ? boolean : P extends typeof BigInt ? bigint : P extends null ? null : P extends undefined ? undefined : any; type InferPrimitiveJson

= P extends typeof String ? string : P extends typeof Number ? number : P extends typeof Boolean ? boolean : P extends typeof BigInt ? string : P extends null ? null : P extends undefined ? null : any; type InferProvable = A extends Constructor ? A extends Provable ? U : A extends Struct ? U : InferProvableBase : InferProvableBase; type InferProvableBase = A extends Provable ? U : A extends Primitive ? InferPrimitive : A extends Tuple ? { [I in keyof A]: InferProvable; } : A extends (infer U)[] ? InferProvable[] : A extends Record ? { [K in keyof A]: InferProvable; } : never; type WithJson = { toJSON: (x: any) => J; }; type InferJson = A extends WithJson ? J : A extends Primitive ? InferPrimitiveJson : A extends Tuple ? { [I in keyof A]: InferJson; } : A extends WithJson[] ? U[] : A extends Record ? { [K in keyof A]: InferJson; } : any; type IsPure = IsPureBase extends true ? true : false; type IsPureBase = A extends ProvablePure ? true : A extends Provable ? false : A extends Primitive ? false : A extends (infer U)[] ? IsPure : A extends Record ? { [K in keyof A]: IsPure; }[keyof A] : false; type InferredProvable = IsPure extends true ? ProvableExtendedPure, InferJson> : ProvableExtended, InferJson>;