import '../gen/augment-api.js'; import { ApiPromise } from '@polkadot/api'; import { Duration, Effect, Layer, Option, type Scope, Stream, SynchronizedRef } from 'effect'; import * as NodeClient from './NodeClient.js'; import * as SubmissionEvent from './SubmissionEvent.js'; import * as NodeClientError from './NodeClientError.js'; import { SerializedTransaction } from '@midnight-ntwrk/wallet-sdk-abstractions'; export type Config = { nodeURL: URL; reconnectionTimeout: Duration.Duration; reconnectionDelay: Duration.Duration; }; export declare const DEFAULT_CONFIG: { reconnectionTimeout: Duration.Duration; reconnectionDelay: Duration.Duration; }; export declare const makeConfig: (input: Partial & Pick) => Config; export declare class PolkadotNodeClient implements NodeClient.Service { #private; /** * Connects to a node, loads its metadata, and releases the socket until a call needs it. * * @remarks * `reconnectionTimeout` bounds the wait for the node, and separately the close that follows it; the default, * `Duration.infinity`, waits as long as the node takes. A wait that outlasts a finite bound fails with a * `ConnectionError` whose `cause` is Effect's `TimeoutException`; an endpoint that is not `ws://` or `wss://` fails * with a `ConnectionError` too. An attempt that fails or is interrupted before it yields a client disconnects its * provider, so nothing it started keeps retrying. * * An interrupt from outside abandons a handshake still in progress even when the caller is uninterruptible, because * the bounded wait runs in a child fiber that takes it. Once connected, the close runs at the caller's status and * the release is registered uninterruptibly, so an uninterruptible caller still receives the client: the liveness * reads rely on that to cache every client they build. * @example * ```typescript * const client = yield* PolkadotNodeClient.make({ * nodeURL: new URL('ws://localhost:9944'), * reconnectionTimeout: Duration.seconds(10), * }); * ```; * * @param configInput - The node to connect to, and optionally the bound and the delay between reconnection attempts. * @returns The client, whose connection is released when the scope closes. */ static make(configInput: Partial & Pick): Effect.Effect; static layer(configInput: Partial & Pick): Layer.Layer; readonly config: Config; readonly api: ApiPromise; constructor(config: Config, api: ApiPromise, activeCalls: SynchronizedRef.SynchronizedRef); ensureConnection(): Effect.Effect; sendMidnightTransaction(serializedTransaction: SerializedTransaction.SerializedTransaction): Stream.Stream; getGenesis(): Effect.Effect<{ readonly transactions: readonly SerializedTransaction.SerializedTransaction[]; }, NodeClientError.NodeClientError>; getGenesisHash(): Effect.Effect; getFinalizedBlock(): Effect.Effect; getBlockHashAt(height: bigint): Effect.Effect, NodeClientError.NodeClientError>; }