Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/smoldot2/internals/local-instance.d.ts>Instance

Lightweight client for Substrate-based chains, such as Polkadot and Kusama.
Latest
interface Instance
import { type Instance } from "https://deno.land/x/smoldot2@light-js-deno-v2.0.31/internals/local-instance.d.ts";

Properties

request: (request: string, chainId: number) => number
peekJsonRpcResponse: (chainId: number) => string | null
addChain: (
chainSpec: string,
databaseContent: string,
potentialRelayChains: number[],
disableJsonRpc: boolean,
jsonRpcMaxPendingRequests: number,
jsonRpcMaxSubscriptions: number,
) => void

Later generates a add-chain-id-allocated event. If this function is called multiple times, the add-chain-id-allocated events are generated in the same order as the function calls.

Then, later and asynchronously, a add-chain-result event is generated in order to indicate whether the initialization was actually successful. If success is false, then the chainId becomes unallocated.

removeChain: (chainId: number) => void
shutdownExecutor: () => void

Notifies the background executor that it should stop. Once it has effectively stopped, a executor-shutdown event will be generated. Note that the instance can technically still be used, and all the functions still work, but in practice nothing is being run in the background and as such it won't do much. Existing connections are not closed. It is the responsibility of the API user to close all connections.

connectionMultiStreamSetHandshakeInfo: (connectionId: number, info: { handshake: "webrtc"; localTlsCertificateSha256: Uint8Array; }) => void
connectionReset: (connectionId: number, message: string) => void
streamWritableBytes: (
connectionId: number,
numExtra: number,
streamId?: number,
) => void
streamMessage: (
connectionId: number,
message: Uint8Array,
streamId?: number,
) => void
streamOpened: (
connectionId: number,
streamId: number,
direction: "inbound" | "outbound",
) => void
streamReset: (
connectionId: number,
streamId: number,
message: string,
) => void