import { Json, AccountUpdate } from '../../bindings/mina-transaction/gen/v1/transaction-bigint.js'; import { PublicKey } from '../../bindings/mina-transaction/v1/transaction-leaves-bigint.js'; import type { FiniteField } from '../../bindings/crypto/finite-field.js'; export { Random, sample, withHardCoded }; type Random = { create(): () => T; invalid?: Random; }; type RandomWithInvalid = Required>; declare function Random_(next: () => T, toInvalid?: (valid: Random) => Random): Random; declare function sample(rng: Random, size: number): T[]; declare const Random: typeof Random_ & { constant: typeof constant; int: typeof int; nat: typeof nat; fraction: typeof fraction; boolean: Random; byte: Random; bytes: typeof bytes; string: typeof string; base58: typeof base58; array: typeof array & { ofSize: typeof arrayOfSizeValid; }; record: typeof record; map: typeof map & { withInvalid: typeof mapWithInvalid; }; step: typeof step; oneOf: typeof oneOf; withHardCoded: typeof withHardCoded; dependent: typeof dependent; apply: typeof apply; reject: typeof reject; dice: typeof dice & { ofSize: Random<(size: number) => number>; }; field: Required>; otherField: typeof fieldWithInvalid; bool: Random; uint8: Required>; uint32: Required>; uint64: Required>; biguint: typeof biguintWithInvalid; bignat: typeof bignatWithInvalid; privateKey: Random; publicKey: Random & { invalid: Random; }; scalar: Required>; signature: Random<{ r: bigint; s: bigint; }>; accountUpdate: Random; feePayer: Random<{ body: { publicKey: PublicKey; fee: bigint; validUntil?: bigint | undefined; nonce: bigint; }; authorization: string; }>; memo: Random; json: { accountUpdate: Random; feePayer: Random<{ body: { publicKey: string; fee: string; validUntil: string | null; nonce: string; }; authorization: string; }>; memoString: Random; uint32: { invalid: Random; create(): () => string; }; uint64: { invalid: Random; create(): () => string; }; sign: { invalid: Random<"Positive" | "Negative">; create(): () => "Positive" | "Negative"; }; publicKey: Required>; privateKey: Required>; keypair: Random<{ privateKey: string; publicKey: string; }>; signature: Required>; signatureJson: Random; field: Random; }; }; declare function constant(t: T): Random; declare function bytes(size: number | Random): Random; declare function string(size: number | Random): Random; declare function base58(size: number | Random): Random; declare function oneOf(...values: { [K in keyof Types]: Random | RandomWithInvalid | Types[K]; }): Random; /** * map a list of generators to a new generator, by specifying the transformation which maps samples * of the input generators to a sample of the result. */ declare function map(...args: [...rngs: { [K in keyof T]: Random; }, to: (...values: T) => S]): Random; /** * dependent is like {@link map}, with the difference that the mapping contains a free variable * whose samples have to be provided as inputs separately. this is useful to create correlated generators, where * multiple generators are all dependent on the same extra variable which is sampled independently. * * dependent can be used in two different ways: * - as a function from a random generator of the free variable to a random generator of the result * - as a random generator whose samples are _functions_ from free variable to result: `Random<(arg: Free) => Result>` */ declare function dependent(...args: [...rngs: { [K in keyof T]: Random; }, to: (free: Free, values: T) => Result]): Random<(arg: Free) => Result> & ((arg: Random) => Random); declare function step(...args: [ ...rngs: { [K in keyof T]: Random; }, step: (current: S, ...values: T) => S, initial: S ]): Random; declare function arrayOfSizeValid(element: Random, { reset }?: { reset?: boolean | undefined; }): Random<(n: number) => T[]>; declare function reject(rng: Random, isRejected: (t: T) => boolean): Random; type Action = Random<(s: S) => S>; declare function apply(rng: Random, howMany: number | Random, ...actions: Action[]): Random; declare function withHardCoded(rng: Random, ...hardCoded: T[]): Random; /** * uniform distribution over range [min, max] * with bias towards special values 0, 1, -1, 2, min, max */ declare function int(min: number, max: number): Random; /** * log-uniform distribution over range [0, max] * with bias towards 0, 1, 2 */ declare function nat(max: number): Random; declare function fraction(fixedPrecision?: number): { create: () => () => number; }; /** * unbiased, uniform distribution over range [0, max-1] */ declare function dice(max: number): Random; /** * we get invalid uints by sampling from a larger range plus negative numbers */ declare function biguintWithInvalid(bits: number): RandomWithInvalid; declare function bignatWithInvalid(max: bigint): RandomWithInvalid; declare function fieldWithInvalid(F: FiniteField): RandomWithInvalid; /** * invalid arrays are sampled by generating an array with exactly one invalid input (and any number of valid inputs); * (note: invalid arrays have the same length distribution as valid ones, except that they are never empty) */ declare function array(element: Random, size: number | Random, options?: { reset?: boolean; }): Random; /** * invalid records are similar to arrays: randomly choose one of the fields that have an invalid generator, * and set it to its invalid value */ declare function record(gens: { [K in keyof T]: Random; }): Random; /** * map assuming that invalid inputs can be mapped just like valid ones. * _one_ of the inputs is sampled as invalid */ declare function mapWithInvalid(...args: [...rngs: { [K in keyof T]: Random; }, to: (...values: T) => S]): Random;