import type { JsChainStore, WasmChainClientHandle } from "./chain.js"; import type { ProtocolUtils } from "./protocol.js"; import type { AccountCreateProofErrorKind, AccountRequestCredentialsErrorKind, DecodedStatement, HostApiOutcome, PaymentBalance, PaymentStatus } from "./types.js"; import type { WalletSession } from "./wallet-session.js"; /** Options for {@link createHostSdk}. */ export interface CreateHostSdkOptions { /** URL or path to the core `.wasm` binary. Only needed with `--target web`. */ wasmUrl?: string; /** Pre-imported core WASM module. Bypasses `init()` if already initialized. */ wasmModule?: Record; /** URL or path to the extensions `.wasm` binary (host-extensions-wasm). */ extensionsWasmUrl?: string; /** Pre-imported extensions WASM module. Bypasses dynamic import. */ extensionsWasmModule?: Record; /** * Custom chain store object implementing synchronous load/save. * When provided, `ChainClientHandle.fromStore()` is used instead of the * default localStorage-backed store. */ chainStore?: JsChainStore; } /** * Lightweight DOTNS/codec surface. * * This is for callers that need deterministic name/contenthash/ABI helpers * without paying the initialization cost of wallet, host-api, or chain-client * handles. */ export interface DotnsSdk { resolveAndFetch(name: string): Promise>; parseCarAssets(data: Uint8Array): Map; namehash(name: string): Uint8Array; encodeContenthashCall(node: Uint8Array): Uint8Array; decodeAbiBytes(data: Uint8Array): Uint8Array; contenthashToCid(contenthash: Uint8Array): string; scaleEncodeReviveCall(contractAddr: Uint8Array, callData: Uint8Array): Uint8Array; decodeContractResult(response: Uint8Array): Uint8Array; hexEncode(bytes: Uint8Array): string; hexDecode(s: string): Uint8Array; destroy(): void; raw: { dotns: unknown; }; } /** * Lightweight chain/bootstrap surface. * * This is for callers that need shared chain-store ownership, routing, and * runtime-chain bootstrap helpers without paying the initialization cost of * wallet, host-api, statement, or extension handles. */ export interface ChainBootstrapSdk { chainClient: WasmChainClientHandle; hexEncode(bytes: Uint8Array): string; hexDecode(s: string): Uint8Array; destroy(): void; raw: { dotns: unknown; chainClient: unknown; }; } /** * Product-view integration subset of HostSdk. * * `mountProductView()` only needs the bridge and extension inject scripts, so * keep that dependency narrower than the full HostSdk surface. */ export interface ProductViewSdk { bridgeScript(): string; extensionInjectScript(): string; } /** * Shared host-runtime subset of HostSdk. * * HostRuntime only relies on host-api processing and response encoders; it * should not depend on the full root export surface. */ export interface HostSdkRuntime { handleMessage(raw: Uint8Array, appId: string): HostApiOutcome; setAccounts(accountsJson: string): void; setSupportedChains(chains: Uint8Array[]): void; encodeSignResponse(requestId: string, requestTag: number, signature: Uint8Array): Uint8Array; encodeSignError(requestId: string, requestTag: number): Uint8Array; encodeAccountGetResponse(requestId: string, publicKey: Uint8Array, name?: string | null): Uint8Array; encodeAccountGetError(requestId: string, errorKind: AccountRequestCredentialsErrorKind, reason?: string | null): Uint8Array; encodeAccountGetAliasResponse(requestId: string, context: Uint8Array, alias: Uint8Array): Uint8Array; encodeAccountGetAliasError(requestId: string, errorKind: AccountRequestCredentialsErrorKind, reason?: string | null): Uint8Array; encodeAccountCreateProofResponse(requestId: string, proof: Uint8Array): Uint8Array; encodeAccountCreateProofError(requestId: string, errorKind: AccountCreateProofErrorKind, reason?: string | null): Uint8Array; encodeDevicePermissionResponse(requestId: string, granted: boolean): Uint8Array; encodeDevicePermissionError(requestId: string): Uint8Array; encodeRemotePermissionResponse(requestId: string, granted: boolean): Uint8Array; encodeRemotePermissionError(requestId: string): Uint8Array; encodeCreateTransactionResponse(requestId: string, signedTxBytes: Uint8Array): Uint8Array; encodeCreateTransactionError(requestId: string): Uint8Array; encodeCreateTxNonProductResponse(requestId: string, signedTxBytes: Uint8Array): Uint8Array; encodeCreateTxNonProductError(requestId: string): Uint8Array; encodePaymentBalance(requestId: string, balance: PaymentBalance): Uint8Array; encodePaymentBalanceInterrupt(requestId: string): Uint8Array; encodePaymentTopUpResponse(requestId: string): Uint8Array; encodePaymentTopUpError(requestId: string, reason: string): Uint8Array; encodePaymentRequestResponse(requestId: string, receiptId: string): Uint8Array; encodePaymentRequestError(requestId: string, reason: string): Uint8Array; encodePaymentStatus(requestId: string, status: PaymentStatus): Uint8Array; encodePaymentStatusInterrupt(requestId: string): Uint8Array; encodeChainQueryResponse(requestId: string, jsonRpcResult: string): Uint8Array; encodeChainQueryError(requestId: string): Uint8Array; encodeChainSubNotification(requestId: string, jsonRpcMessage: string): Uint8Array; encodeChainFollowEvent(requestId: string, jsonRpcMessage: string): Uint8Array; encodeChainFollowStop(requestId: string): Uint8Array; encodeChainRpcResponse(requestId: string, requestTag: number, jsonRpcMessage: string): Uint8Array; encodeChainRpcError(requestId: string, requestTag: number, reason: string): Uint8Array; encodeNavigateResponse(requestId: string): Uint8Array; encodeStorageReadResponse(requestId: string, value: Uint8Array | null): Uint8Array; encodeStorageWriteResponse(requestId: string): Uint8Array; encodeStorageClearResponse(requestId: string): Uint8Array; encodePushNotificationResponse(requestId: string): Uint8Array; } /** * Initialized host-sdk instance. * * All handles are ready to use. The wallet auto-tick timer is running. * Call `destroy()` when done to release timers and WASM memory. */ export interface HostSdk extends HostSdkRuntime, ProductViewSdk { wallet: WalletSession; resolveAndFetch(name: string): Promise>; parseCarAssets(data: Uint8Array): Map; namehash(name: string): Uint8Array; encodeContenthashCall(node: Uint8Array): Uint8Array; decodeAbiBytes(data: Uint8Array): Uint8Array; contenthashToCid(contenthash: Uint8Array): string; scaleEncodeReviveCall(contractAddr: Uint8Array, callData: Uint8Array): Uint8Array; decodeContractResult(response: Uint8Array): Uint8Array; generateMnemonic(): string; encodeMultiSignature(sig: Uint8Array, scheme: 0 | 1 | 2): Uint8Array; stringToTopic(s: string): Uint8Array; blake2b256(data: Uint8Array): Uint8Array; buildSigningPayload(nowSecs: number, decryptionKey: Uint8Array | null, channel: Uint8Array | null, priority: number, topicsFlat: Uint8Array, data: Uint8Array): Uint8Array; assembleStatement(signingPayloadWithHeader: Uint8Array, sr25519Pubkey: Uint8Array, signature: Uint8Array): Uint8Array; decodeStatement(encoded: Uint8Array): DecodedStatement; hexEncode(bytes: Uint8Array): string; hexDecode(s: string): Uint8Array; chainClient: WasmChainClientHandle; extensionChannels(): string[]; extensionDispatch(channel: string, method: string, params: string): string | null; protocol: ProtocolUtils; destroy(): void; raw: { wallet: unknown; hostApi: unknown; extensions: unknown | null; dotns: unknown; statement: unknown; mediaProto: unknown | null; chainClient: unknown; }; } //# sourceMappingURL=sdk-interfaces.d.ts.map