/* tslint:disable */ /* eslint-disable */ /** What the light client is doing on one chain. */ export interface ChainLifecycle { phase: | { kind: "connecting" } | { kind: "syncing"; at: number; target: number } | { kind: "ready" }; peers: number; health: { kind: "ok" } | { kind: "stalled"; reason: "noPeers" | "noProgress" }; } /** Which kinds of connection the light client opens to peers; each defaults to `true`. */ export interface ConnectionTypes { /** Secure `wss://` WebSocket. */ secure?: boolean; /** Plain `ws://` WebSocket to a localhost peer. */ localhost?: boolean; /** Plain `ws://` WebSocket to any other peer. */ unsecure?: boolean; } /** * Collects genesis-hash to chain-source registrations from JS. * * The built provider resolves an unregistered genesis from the bundled catalog, * unless a remote node was registered with `addRpcChain`. */ export class ChainProviderBuilder { free(): void; [Symbol.dispose](): void; /** * Register an embedded light-client chain identified by the * `0x`-prefixed genesis hash. Use this for a relay or standalone chain; * parachains are served through the bundled catalog (`addNetwork`), which * supplies their relay wiring and statement-store placement. */ addLightChain(genesis_hash: string, specification: string): void; /** * Register every chain of the bundled network `name` (relay plus system * parachains, with relay wiring and statement-store placement supplied by * the catalog). Returns the network's genesis hashes. */ addNetwork(name: string): NetworkChains; /** * Register a remote JSON-RPC node for the chain identified by the * `0x`-prefixed genesis hash. A later registration for the same hash * replaces the earlier one, and the built provider no longer resolves * other genesis hashes from the catalog. */ addRpcChain(genesis_hash: string, url: string): void; /** * Build the provider, consuming the builder. */ build(): ChainProviderHandle; /** * Create an empty builder. */ constructor(); /** * Limit the kinds of connection the light client opens to peers. A field * left out stays allowed; an unknown field or a non-boolean value throws. */ setConnectionTypes(types: ConnectionTypes): void; /** * Seed the chain with the `0x`-prefixed genesis hash from a stored * database blob, so its light client resumes from that finalized state * instead of syncing from the chain-spec checkpoint. * * The blob is the string the `chainHead_unstable_finalizedDatabase` function in smoldot * produces. It seeds this run only, and beats anything * [`set_storage`](Self::set_storage) would load for the same chain. */ setDatabaseContent(genesis_hash: string, blob: string): void; /** * Keep database blobs in storage the host owns. * * The crate stores nothing itself, so without this call every chain syncs * from the chain-spec checkpoint on every run. Pass a JS object with * `load(genesisHash)` resolving to the stored string or `null`, and * `save(genesisHash, blob)`. Both are called with a `0x`-prefixed hex * genesis hash and may return a promise. Passing `null` does nothing. * * A blob seeded through * [`set_database_content`](Self::set_database_content) beats one loaded * here for the same chain. * * A store that cannot answer must reject rather than resolve empty: an * empty read is taken as nothing stored yet, and would let a later * snapshot overwrite good state. * * A loaded blob is trusted input: it becomes the finalized state the light * client resumes from, so whatever can write to the store can steer the * view of the chain. Origin-scoped storage satisfies that. A store fed by * another page or a server does not. */ setStorage(client: any): void; } /** * A built provider; hand out one per page/worker. */ export class ChainProviderHandle { private constructor(); free(): void; [Symbol.dispose](): void; /** * Open a connection to the chain identified by the `0x`-prefixed genesis * hash. Rejects when the chain is not registered, the transport fails, or * the light client already holds as many connections as it allows. */ connect(genesis_hash: string): Promise; /** * Watch what the light client is doing on the chain identified by the * `0x`-prefixed genesis hash. Throws when nothing is connected to it. * * A parachain goes from `connecting` straight to `ready`; watch its relay * for warp sync progress. */ lifecycle(genesis_hash: string): LifecycleWatch; /** * Read the stored blob for the `0x`-prefixed genesis hash into this * provider, so the next [`connect`](ChainProviderHandle::connect) to that * chain resumes from it. Resolves with whether a blob is now in hand. * * Call this before connecting. The store is read at most once per chain, * because only the first add of a chain consumes a blob. Rejects for a * chain this provider cannot connect to, as `connect` does. */ loadDatabase(genesis_hash: string): Promise; /** * Snapshot the finalized state of the chain and write it to storage. * Resolves with whether a blob was stored. * * A chain that has finalized nothing yet is skipped rather than stored, * since that blob would be discarded on the next run. This is a full round * trip against the light client, so drive it while the page or worker is * alive. Neither `pagehide` nor a hidden tab is guaranteed to stay * scheduled long enough to finish one, and a Worker sees neither event. */ saveDatabase(genesis_hash: string): Promise; } /** * A live JSON-RPC connection: a raw string pipe. */ export class Connection { private constructor(); free(): void; [Symbol.dispose](): void; /** * Close the connection; pending `nextResponse()` calls resolve to * `undefined`. */ close(): void; /** * Resolve with the next JSON-RPC response or notification, or * `undefined` once the connection is closed or dead. * * Calling this in a loop is not optional: it is the only thing that drains * the connection. Frames queue until they are taken, and once the backlog * reaches the budget for the connection further [`send`](Connection::send) calls * come back as JSON-RPC errors instead of being queued, so a caller that * sends without reading eventually gets nothing but errors. */ nextResponse(): Promise; /** * Queue a JSON-RPC request string. */ send(request: string): void; } /** * A live watch on one chain's lifecycle, from * [`ChainProviderHandle::lifecycle`]. */ export class LifecycleWatch { private constructor(); free(): void; [Symbol.dispose](): void; /** * Stop the watch; pending `next()` calls resolve to `undefined`. */ close(): void; /** * Resolve with the current state on the first call and with the next * change after that, or with `undefined` once the watch is closed or the * chain stops running. */ next(): Promise; } /** * The genesis hashes of a network registered via * [`ChainProviderBuilder::add_network`], as `0x`-prefixed hex strings. */ export class NetworkChains { private constructor(); free(): void; [Symbol.dispose](): void; /** * Asset Hub genesis hash. */ readonly assethub: string; /** * Bulletin-chain genesis hash. */ readonly bulletin: string; /** * People-chain genesis hash. */ readonly people: string; /** * Relay-chain genesis hash. */ readonly relay: string; } /** * Route the embedded provider's (and smoldot's) `tracing` output to the * browser console at `level` (`error`|`warn`|`info`|`debug`|`trace`; anything * else disables it). Installs the console subscriber on the first call and is * safe to call again at any time to retune verbosity. */ export function setLogLevel(level: string): void; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_chainproviderbuilder_free: (a: number, b: number) => void; readonly __wbg_chainproviderhandle_free: (a: number, b: number) => void; readonly __wbg_connection_free: (a: number, b: number) => void; readonly __wbg_lifecyclewatch_free: (a: number, b: number) => void; readonly __wbg_networkchains_free: (a: number, b: number) => void; readonly chainproviderbuilder_addLightChain: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly chainproviderbuilder_addNetwork: (a: number, b: number, c: number, d: number) => void; readonly chainproviderbuilder_addRpcChain: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly chainproviderbuilder_build: (a: number, b: number) => void; readonly chainproviderbuilder_new: () => number; readonly chainproviderbuilder_setConnectionTypes: (a: number, b: number, c: number) => void; readonly chainproviderbuilder_setDatabaseContent: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly chainproviderbuilder_setStorage: (a: number, b: number, c: number) => void; readonly chainproviderhandle_connect: (a: number, b: number, c: number) => number; readonly chainproviderhandle_lifecycle: (a: number, b: number, c: number, d: number) => void; readonly chainproviderhandle_loadDatabase: (a: number, b: number, c: number) => number; readonly chainproviderhandle_saveDatabase: (a: number, b: number, c: number) => number; readonly connection_close: (a: number) => void; readonly connection_nextResponse: (a: number) => number; readonly connection_send: (a: number, b: number, c: number) => void; readonly lifecyclewatch_close: (a: number) => void; readonly lifecyclewatch_next: (a: number) => number; readonly networkchains_assethub: (a: number, b: number) => void; readonly networkchains_bulletin: (a: number, b: number) => void; readonly networkchains_people: (a: number, b: number) => void; readonly networkchains_relay: (a: number, b: number) => void; readonly setLogLevel: (a: number, b: number) => void; readonly __wasm_bindgen_func_elem_20842: (a: number, b: number, c: number, d: number) => void; readonly __wasm_bindgen_func_elem_20844: (a: number, b: number, c: number, d: number) => void; readonly __wasm_bindgen_func_elem_3922: (a: number, b: number, c: number) => void; readonly __wasm_bindgen_func_elem_3922_2: (a: number, b: number, c: number) => void; readonly __wasm_bindgen_func_elem_3922_3: (a: number, b: number, c: number) => void; readonly __wasm_bindgen_func_elem_7490: (a: number, b: number) => void; readonly __wbindgen_export: (a: number, b: number) => number; readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_export3: (a: number) => void; readonly __wbindgen_export4: (a: number, b: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export5: (a: number, b: number, c: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise;