import {z} from 'zod' export type AnyOfParameter = {eq?: (string | null) | undefined, in?: (Array | null) | undefined, null?: (boolean | null) | undefined}; export type AccountParameter = {eq?: (string | null) | undefined, ne?: (string | null) | undefined, in?: (Array | null) | undefined, ni?: (Array | null) | undefined, eqx?: (string | null) | undefined, nex?: (string | null) | undefined, null?: (boolean | null) | undefined}; export type SmartRollupParameter = {eq?: (string | null) | undefined, ne?: (string | null) | undefined, in?: (Array | null) | undefined, ni?: (Array | null) | undefined}; export type Int64Parameter = {eq?: (number | null) | undefined, ne?: (number | null) | undefined, gt?: (number | null) | undefined, ge?: (number | null) | undefined, lt?: (number | null) | undefined, le?: (number | null) | undefined, in?: (Array | null) | undefined, ni?: (Array | null) | undefined, empty?: boolean | undefined}; export type OpHashParameter = {eq?: (string | null) | undefined, ne?: (string | null) | undefined, in?: (Array | null) | undefined, ni?: (Array | null) | undefined}; export type Int32Parameter = {eq?: (number | null) | undefined, ne?: (number | null) | undefined, gt?: (number | null) | undefined, ge?: (number | null) | undefined, lt?: (number | null) | undefined, le?: (number | null) | undefined, in?: (Array | null) | undefined, ni?: (Array | null) | undefined}; export type TimestampParameter = {eq?: (string | null) | undefined, ne?: (string | null) | undefined, gt?: (string | null) | undefined, ge?: (string | null) | undefined, lt?: (string | null) | undefined, le?: (string | null) | undefined, in?: (Array | null) | undefined, ni?: (Array | null) | undefined}; export type OperationStatusParameter = {eq?: (string | null) | undefined, ne?: (string | null) | undefined}; export type GetApiV1OperationsSrRecoverBondCountArgs = {anyof?: (AnyOfParameter | null) | undefined, staker?: (AccountParameter | null) | undefined, rollup?: (SmartRollupParameter | null) | undefined, id?: (Int64Parameter | null) | undefined, hash?: (OpHashParameter | null) | undefined, counter?: (Int32Parameter | null) | undefined, level?: (Int32Parameter | null) | undefined, timestamp?: (TimestampParameter | null) | undefined, status?: (OperationStatusParameter | null) | undefined, sender?: (AccountParameter | null) | undefined}; export type GetApiV1OperationsSrRecoverBondCountOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiV1OperationsSrRecoverBondCountResponse = z.number().int(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get smart rollup recover bond count * * GET /v1/operations/sr_recover_bond/count */ export const getApiV1OperationsSrRecoverBondCount = async (args: GetApiV1OperationsSrRecoverBondCountArgs, options?: GetApiV1OperationsSrRecoverBondCountOptions) => { const {baseUrl = "https://api.tzkt.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.anyof != null) query.append("anyof", JSON.stringify(args.anyof)) if (args.staker != null) query.append("staker", JSON.stringify(args.staker)) if (args.rollup != null) query.append("rollup", JSON.stringify(args.rollup)) if (args.id != null) query.append("id", JSON.stringify(args.id)) if (args.hash != null) query.append("hash", JSON.stringify(args.hash)) if (args.counter != null) query.append("counter", JSON.stringify(args.counter)) if (args.level != null) query.append("level", JSON.stringify(args.level)) if (args.timestamp != null) query.append("timestamp", JSON.stringify(args.timestamp)) if (args.status != null) query.append("status", JSON.stringify(args.status)) if (args.sender != null) query.append("sender", JSON.stringify(args.sender)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/operations/sr_recover_bond/count${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiV1OperationsSrRecoverBondCountResponse, await res.json()) };