import { Effect, Scope, Stream, SynchronizedRef } from 'effect'; import { type ProtocolState, ProtocolVersion } from '@midnightntwrk/wallet-sdk-abstractions'; import { type Variant, WalletRuntimeError } from './abstractions/index.js'; import { HList, Poly } from '@midnightntwrk/wallet-sdk-utilities'; /** The {@link Runtime} service type. */ export interface Runtime { readonly stateChanges: Stream.Stream>>, WalletRuntimeError>; readonly progress: Effect.Effect; readonly currentVariant: Effect.Effect>; dispatch(impl: Poly.PolyFunction>, Effect.Effect>): Effect.Effect; } export type RunningVariant = Poly.WithTagFrom & { variant: TVariant; runningVariant: Variant.RunningVariantOf; initialState: Variant.StateOf; variantScope: Scope.CloseableScope; currentStateRef: SynchronizedRef.SynchronizedRef>; restVariants: TRest; initProtocolVersion: ProtocolVersion.ProtocolVersion; validVersionRange: ProtocolVersion.ProtocolVersion.Range; nextProtocolVersion: ProtocolVersion.ProtocolVersion | null; }; type EachRunningVariant = TAll extends [ infer THead extends Variant.AnyVersionedVariant, ...infer TRest extends Variant.AnyVersionedVariantArray ] ? RunningVariant | EachRunningVariant : never; /** * A type that represents the reported progress of a variant expressed in terms of gaps to reaching synced progress in * application site and data source site */ type Progress = { readonly sourceGap: bigint; readonly applyGap: bigint; }; export type InitRuntimeHeadArgs = { variants: Variants; state: Variant.StateOf>; }; export declare const initHead: (initArgs: InitRuntimeHeadArgs) => Effect.Effect, WalletRuntimeError, Scope.Scope>; export type InitRuntimeArgs = { variants: Variants; tag: InitTag; state: Variant.StateOf; }>>; }; export declare const init: (initArgs: InitRuntimeArgs) => Effect.Effect, WalletRuntimeError, Scope.Scope>; export declare const dispatch: (runtime: Runtime, impl: Poly.PolyFunction>, Effect.Effect>) => Effect.Effect; export {};