mina-attestations
Version:
Private Attestations on Mina
43 lines (42 loc) • 1.96 kB
TypeScript
/**
* This is a little library to streamline the creation of new provable types.
*/
import { type ProvableHashable, type InferProvable, type InferValue, type IsPure, type Field } from 'o1js';
import type { NestedProvable } from './nested.ts';
import type { HashInput, ProvableHashablePure } from './o1js-missing.ts';
export { TypeBuilder, TypeBuilderPure };
declare class TypeBuilder<T, V> {
type: ProvableHashable<T, V>;
constructor(type: ProvableHashable<T, V>);
static shape<A extends NestedProvable>(nested: A): IsPure<A, Field> extends true ? TypeBuilderPure<InferProvable<A>, InferValue<A>> : TypeBuilder<InferProvable<A>, InferValue<A>>;
build(): this['type'];
forClass<C extends T>(Class: new (t: T) => C): TypeBuilder<C, V>;
forConstructor<C extends T>(constructor: (t: T) => C): TypeBuilder<C, V>;
mapValue<W>(transform: {
there: (x: V) => W;
back: (x: W) => V;
distinguish: (x: T | W) => x is T;
} | {
there: (x: V) => W;
backAndDistinguish: (x: W | T) => V | T;
}): TypeBuilder<T, W>;
replaceCheck(check: (x: T) => void): TypeBuilder<T, V>;
withAdditionalCheck(check: (x: T) => void): TypeBuilder<T, V>;
hashInput(toInput: (x: T) => HashInput): TypeBuilder<T, V>;
}
declare class TypeBuilderPure<T, V> extends TypeBuilder<T, V> {
type: ProvableHashablePure<T, V>;
constructor(type: ProvableHashablePure<T, V>);
forClass<C extends T>(Class: new (t: T) => C): TypeBuilderPure<C, V>;
forConstructor<C extends T>(constructor: (t: T) => C): TypeBuilderPure<C, V>;
mapValue<W>(transform: {
there: (x: V) => W;
back: (x: W) => V;
distinguish: (x: T | W) => x is T;
} | {
there: (x: V) => W;
backAndDistinguish: (x: W | T) => V | T;
}): TypeBuilderPure<T, W>;
replaceCheck(check: (x: T) => void): TypeBuilderPure<T, V>;
withAdditionalCheck(check: (x: T) => void): TypeBuilderPure<T, V>;
}