/* tslint:disable */
/* eslint-disable */

/**
 * JS-facing chain state machine.
 *
 * Does NOT manage the smoldot client itself — that lives in TypeScript via
 * the `smoldot` NPM package. This handle provides:
 * - Chain status tracking (processes JSON-RPC responses from smoldot-js)
 * - Request generation (subscriptions, health checks, DB saves)
 * - Chain database persistence (localStorage by default, or a custom JS store)
 * - Chain spec access (for TypeScript to pass to smoldot's `addChain`)
 *
 * Only Substrate/Polkadot chains (smoldot backend) are supported on WASM.
 */
export class ChainClientHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Get all chain statuses.
     */
    allStatuses(): any;
    /**
     * Get chain specs for a smoldot chain. Returns [relaySpec, paraSpec] or null.
     */
    chainSpecs(chain_name: string): any;
    /**
     * Create a handle backed by a custom JS store (e.g. IndexedDB).
     *
     * The `store` object must implement `load(key: string): string | null | undefined` and
     * `save(key: string, data: string): void`.
     */
    static fromStore(store: any): ChainClientHandle;
    /**
     * JSON-RPC health check request (incrementing ID per chain).
     */
    healthCheckRequest(chain_name: string): string;
    /**
     * Load persisted parachain DB from localStorage.
     */
    loadParaDb(chain_name: string): string;
    /**
     * Load persisted relay chain DB from localStorage.
     */
    loadRelayDb(chain_name: string): string;
    constructor();
    /**
     * JSON-RPC request to save parachain DB (send to parachain).
     */
    paraDbSaveRequest(): string;
    /**
     * Parse a statement subscription notification. Returns Array<string> of hex statements.
     * Returns an empty array if the text is not a statement notification.
     */
    parseStatementNotification(text: string): Array<any>;
    /**
     * Process a JSON-RPC response from the relay chain (for DB save only).
     */
    processRelayResponse(chain_name: string, text: string): void;
    /**
     * Process a JSON-RPC response from smoldot for a parachain.
     * Call this for every response from `chain.nextJsonRpcResponse()`.
     */
    processResponse(chain_name: string, text: string): void;
    /**
     * Register a chain for status tracking. Call after adding the chain to smoldot.
     */
    registerChain(chain_name: string): void;
    /**
     * JSON-RPC request to save relay chain DB (send to relay chain).
     */
    relayDbSaveRequest(): string;
    /**
     * Report an error for a chain (e.g. smoldot addChain failure).
     */
    setError(chain_name: string, msg: string): void;
    /**
     * JSON-RPC request to fetch broadcast statements by topic.
     */
    statementBroadcastsRequest(topic_hexes: Array<any>, request_id: number): string;
    /**
     * JSON-RPC request to remove a statement by statement id/hash.
     */
    statementRemoveRequest(statement_id_hex: string, request_id: number): string;
    /**
     * JSON-RPC request to submit a statement (hex-encoded).
     */
    statementSubmitRequest(encoded_hex: string, request_id: number): string;
    /**
     * JSON-RPC request to subscribe to statement notifications.
     */
    statementSubscribeRequest(request_id: number): string;
    /**
     * JSON-RPC request to unsubscribe from statement notifications.
     */
    statementUnsubscribeRequest(sub_id: string, request_id: number): string;
    /**
     * Get the current status of a chain.
     */
    status(chain_name: string): any;
    /**
     * JSON-RPC request to subscribe to finalized heads.
     */
    subscribeFinalizedHeadsRequest(): string;
    /**
     * JSON-RPC request to subscribe to new heads.
     */
    subscribeNewHeadsRequest(): string;
    /**
     * Unregister a chain. Call after removing the chain from smoldot.
     */
    unregisterChain(chain_name: string): void;
}

/**
 * JS-facing chat crypto handle for hosts that already own an attested
 * sr25519 session account.
 *
 * This is intentionally narrower than `WalletHandle`: callers provide the
 * account id and sr25519 session secret explicitly, and the handle only owns
 * the P-256 material needed for chat request/session encryption. Statement
 * signing stays with the embedding host via a callback in the TypeScript SDK.
 */
export class ChatSessionHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Decrypt data produced by `chatP256Encrypt`.
     */
    chatP256Decrypt(peer_identifier_key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
    /**
     * Encrypt with the v2 P-256/AES-GCM stack.
     */
    chatP256Encrypt(peer_identifier_key: Uint8Array, plaintext: Uint8Array): Uint8Array;
    /**
     * Build v2-compatible directional P-256 session ids and channels.
     */
    chatP256Session(peer_account_id: Uint8Array, peer_identifier_key: Uint8Array, own_pin?: string | null, peer_pin?: string | null): any;
    /**
     * Canonical 65-byte uncompressed P-256 identifier key for this chat identity.
     */
    identifierKey(): Uint8Array;
    /**
     * Build chat P-256 material from an existing sr25519 session account.
     *
     * `account_id` must be the 32-byte public key registered on People chain.
     * `session_secret` must contain at least the 32-byte scalar half used by
     * sr25519 signing implementations such as host-papp.
     */
    constructor(account_id: Uint8Array, session_secret: Uint8Array);
    /**
     * 32-byte sr25519 public key for this chat identity.
     */
    walletPublicKey(): Uint8Array;
}

/**
 * JS-facing DOTNS encoding utilities.
 *
 * All functions are pure — no I/O or network. The browser is responsible
 * for transport (e.g. polkadot-api / smoldot-js).
 */
export class DotnsHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Parse a contenthash into a CIDv1 base32 string.
     */
    contenthashToCid(contenthash: Uint8Array): string;
    /**
     * Decode ABI-encoded `bytes` from Solidity return data.
     */
    decodeAbiBytes(data: Uint8Array): Uint8Array;
    /**
     * Decode the ContractResult from a `ReviveApi_call` response.
     */
    decodeContractResult(response: Uint8Array): Uint8Array;
    /**
     * ABI-encode `contenthash(bytes32)` call data for the given namehash.
     */
    encodeContenthashCall(node: Uint8Array): Uint8Array;
    /**
     * Hex-decode a `0x`-prefixed (or bare) hex string.
     */
    hexDecode(s: string): Uint8Array;
    /**
     * Hex-encode bytes with `0x` prefix.
     */
    hexEncode(bytes: Uint8Array): string;
    /**
     * Compute ENS-style namehash for a `.dot` domain.
     */
    namehash(name: string): Uint8Array;
    constructor();
    /**
     * Parse a CARv1 `.prod` bundle into an asset map.
     *
     * Returns a plain JS object where each key is a filename and each value is a `Uint8Array`.
     */
    parseCarAssets(data: Uint8Array): any;
    /**
     * Resolve a `.dot` name, fetch from IPFS, and return an asset map as a JS object.
     *
     * The returned value is a plain JS object where each key is a filename (string)
     * and each value is a `Uint8Array`. Automatically converts to a `Promise` for JS callers.
     */
    resolveAndFetch(name: string): Promise<any>;
    /**
     * SCALE-encode `ReviveApi::call()` parameters.
     */
    scaleEncodeReviveCall(contract_addr: Uint8Array, call_data: Uint8Array): Uint8Array;
}

/**
 * JS-facing wrapper over `useragent_api::HostApi`.
 *
 * Processes binary SCALE-encoded messages from Polkadot apps and returns
 * structured outcomes that the TypeScript adapter routes to the appropriate
 * subsystem (smoldot JS, wallet, navigation).
 */
export class HostApiHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Get the HOST_API_BRIDGE_SCRIPT for WebView injection.
     */
    static bridgeScript(): string;
    encodeAccountCreateProofError(request_id: string, error_kind: string, reason?: string | null): Uint8Array;
    encodeAccountCreateProofResponse(request_id: string, proof: Uint8Array): Uint8Array;
    encodeAccountGetAliasError(request_id: string, error_kind: string, reason?: string | null): Uint8Array;
    encodeAccountGetAliasResponse(request_id: string, context: Uint8Array, alias: Uint8Array): Uint8Array;
    encodeAccountGetError(request_id: string, error_kind: string, reason?: string | null): Uint8Array;
    /**
     * Encode a `host_account_get` success response (v0.7.4).
     *
     * Wire shape: `Result::Ok(ProductAccount { publicKey })` — `name` was
     * removed in v0.7.4; SPAs use `host_get_user_id` for display names.
     */
    encodeAccountGetResponse(request_id: string, public_key: Uint8Array): Uint8Array;
    /**
     * Encode a chain-head follow event notification.
     */
    encodeChainFollowEvent(request_id: string, json_rpc_msg: string): Uint8Array;
    /**
     * Encode a synthetic follow stop event for unsupported/disconnected chains.
     */
    encodeChainFollowStop(request_id: string): Uint8Array;
    /**
     * Encode a one-shot JSON-RPC error for `NeedsChainQuery`.
     */
    encodeChainQueryError(request_id: string): Uint8Array;
    /**
     * Encode a one-shot JSON-RPC response for `NeedsChainQuery`.
     */
    encodeChainQueryResponse(request_id: string, json_rpc_result: string): Uint8Array;
    /**
     * Encode a chain RPC error using the correct chain protocol envelope.
     */
    encodeChainRpcError(request_id: string, request_tag: number, reason: string): Uint8Array;
    /**
     * Encode a chain RPC response using the correct chain protocol envelope.
     */
    encodeChainRpcResponse(request_id: string, request_tag: number, json_rpc_msg: string): Uint8Array;
    /**
     * Encode a streaming JSON-RPC subscription message for `NeedsChainSubscription`.
     */
    encodeChainSubNotification(request_id: string, json_rpc_msg: string): Uint8Array;
    /**
     * Encode a `host_create_transaction` error response.
     *
     * `error_kind`: one of `"rejected"`, `"not_supported"`, `"permission_denied"`,
     * `"failed_to_decode"`, or `"unknown"` (default).
     */
    encodeCreateTransactionError(request_id: string, error_kind: string, reason?: string | null): Uint8Array;
    /**
     * Encode a successful `host_create_transaction` response.
     */
    encodeCreateTransactionResponse(request_id: string, signed_tx_bytes: Uint8Array): Uint8Array;
    /**
     * Encode a `host_create_transaction_with_legacy_account` error response.
     */
    encodeCreateTxNonProductError(request_id: string, error_kind: string, reason?: string | null): Uint8Array;
    /**
     * Encode a successful `host_create_transaction_with_legacy_account` response.
     */
    encodeCreateTxNonProductResponse(request_id: string, signed_tx_bytes: Uint8Array): Uint8Array;
    /**
     * Encode a `host_device_permission` error response.
     */
    encodeDevicePermissionError(request_id: string): Uint8Array;
    /**
     * Encode a `host_device_permission` response.
     */
    encodeDevicePermissionResponse(request_id: string, granted: boolean): Uint8Array;
    /**
     * Encode a navigation acknowledgement.
     */
    encodeNavigateResponse(request_id: string): Uint8Array;
    /**
     * Encode a payment balance snapshot for `NeedsPaymentBalanceSubscription`.
     *
     * `balance` must be a JS object with shape:
     * `{ available: { currency: string, minor_units: string }, pending: { currency: string, minor_units: string } }`.
     */
    encodePaymentBalance(request_id: string, balance: any): Uint8Array;
    /**
     * Encode a failed payment request response for `NeedsPaymentRequest`.
     */
    encodePaymentRequestError(request_id: string, reason: string): Uint8Array;
    /**
     * Encode a successful payment request response for `NeedsPaymentRequest`.
     *
     * `receipt_id` is the ID of the payment receipt returned by the host.
     */
    encodePaymentRequestResponse(request_id: string, receipt_id: string): Uint8Array;
    /**
     * Encode a payment status update for `NeedsPaymentStatusSubscription`.
     *
     * `status` must be a JS object with shape:
     * `{ type: "Processing" | "Completed" | "Failed", reason?: string }`.
     */
    encodePaymentStatus(request_id: string, status: any): Uint8Array;
    /**
     * Encode a failed payment top-up response for `NeedsPaymentTopUp`.
     */
    encodePaymentTopUpError(request_id: string, reason: string): Uint8Array;
    /**
     * Encode a successful payment top-up acknowledgement for `NeedsPaymentTopUp`.
     */
    encodePaymentTopUpResponse(request_id: string): Uint8Array;
    /**
     * Encode a push notification acknowledgement.
     */
    encodePushNotificationResponse(request_id: string): Uint8Array;
    /**
     * Encode a `remote_permission` error response.
     */
    encodeRemotePermissionError(request_id: string): Uint8Array;
    /**
     * Encode a `remote_permission` response.
     */
    encodeRemotePermissionResponse(request_id: string, granted: boolean): Uint8Array;
    /**
     * Encode a sign_payload or sign_raw error response.
     */
    encodeSignError(request_id: string, request_tag: number): Uint8Array;
    /**
     * Encode a sign_payload or sign_raw success response.
     */
    encodeSignResponse(request_id: string, request_tag: number, signature: Uint8Array): Uint8Array;
    /**
     * Encode a storage clear acknowledgement for `NeedsStorageClear`.
     */
    encodeStorageClearResponse(request_id: string): Uint8Array;
    /**
     * Encode a storage read response for `NeedsStorageRead`.
     *
     * Pass `None` if the key was not found; `Some(bytes)` with the stored value otherwise.
     */
    encodeStorageReadResponse(request_id: string, value?: Uint8Array | null): Uint8Array;
    /**
     * Encode a storage write acknowledgement for `NeedsStorageWrite`.
     */
    encodeStorageWriteResponse(request_id: string): Uint8Array;
    /**
     * Process a binary SCALE message from the app.
     *
     * Returns a JS object describing the outcome. The `type` field indicates
     * the variant:
     *
     * - `"Response"` — send `data` (byte array) back to the app
     * - `"NeedsSign"` — route to wallet for signing
     * - `"NeedsChainQuery"` — route to smoldot/polkadot-api
     * - `"NeedsChainSubscription"` — start a streaming subscription
     * - `"NeedsNavigate"` — open a URL
     * - `"NeedsPushNotification"` — display a push notification/toast
     * - `"NeedsChainFollow"` — start chainHead follow
     * - `"NeedsChainRpc"` — route to chain RPC
     * - `"Silent"` — no response needed
     */
    handleMessage(raw: Uint8Array, app_id: string): any;
    /**
     * Create a new host API engine.
     */
    constructor();
    /**
     * Set accounts for host-api compatibility.
     *
     * `host_get_legacy_accounts` currently returns an empty list to avoid
     * exposing a stable cross-product identifier. This setter is retained so
     * existing hosts do not fail during initialization.
     *
     * Accepts a JSON array of `LegacyAccount` records:
     * `[{"public_key": [1,2,...], "name": "Alice"}, ...]`
     */
    setAccounts(accounts_json: string): void;
    /**
     * Set the set of supported chain genesis hashes for feature detection.
     *
     * Expects a JS array of `Uint8Array` values, each exactly 32 bytes.
     */
    setSupportedChains(chains: Array<any>): void;
}

/**
 * JS-facing Resources pallet encoding utilities for People chains.
 *
 * All functions are pure — no I/O or network. The browser is responsible
 * for the actual `state_getStorage` RPC call using the smoldot driver it
 * already manages.
 */
export class IdentityHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Build the `state_getStorage` key hex for `Resources.Consumers`.
     *
     * `account_id_hex` must be a `0x`-prefixed or bare 64-character hex
     * string representing a 32-byte `AccountId32`.
     *
     * Returns the key as a `0x`-prefixed hex string, or throws on invalid
     * input.
     */
    consumersKey(account_id_hex: string): string;
    /**
     * Decode a `Resources.UsernameOwnerOf` storage response.
     *
     * `PaseoPeopleNext` stores a bare `AccountId32` here, so the browser path
     * must decode the raw owner bytes rather than `Identity::UsernameInfoOf`.
     */
    decodeAccountOfUsername(data: Uint8Array): any;
    /**
     * Decode a SCALE-encoded `ConsumerInfo` from `Resources.Consumers`.
     *
     * `data` is the raw bytes from the `state_getStorage` response (after
     * hex-decoding the `"result"` field).
     *
     * Returns a JS object `{ identifierKey: Uint8Array, fullUsername: string |
     * null, liteUsername: string, credibility: object }`, or `null` if data is
     * empty (storage slot absent).  Throws on malformed SCALE data.
     *
     * `credibility` is one of:
     * - `{ type: "Lite" }`
     * - `{ type: "Person", alias: Uint8Array, lastUpdate: number }`
     */
    decodeConsumerInfo(data: Uint8Array): any;
    /**
     * Construct a full PeopleLite username from base and suffix.
     */
    makeLiteFullUsername(base: string, suffix: string): string;
    constructor();
    /**
     * Normalize a PeopleLite username base for signup.
     *
     * Validates: lowercase letters only, 6-27 characters.
     */
    normalizeLiteUsernameBase(base: string): string;
    /**
     * Normalize a username: ASCII lowercase, validate charset (`[a-z0-9.]`)
     * and maximum length (32 bytes).
     *
     * Returns the normalized UTF-8 bytes, or throws if the username is
     * invalid.
     */
    normalizeUsername(username: string): Uint8Array;
    /**
     * Build the `state_getStorage` key hex for `Resources.UsernameOwnerOf`.
     *
     * Browser hosts use this for PeopleLite username lookup on
     * `PaseoPeopleNext`, where username ownership lives under the `Resources`
     * pallet instead of `Identity::UsernameInfoOf`.
     */
    usernameOwnerOfKey(username: string): string;
    /**
     * Validate a PeopleLite numeric suffix.
     */
    validateLiteUsernameSuffix(suffix: string): void;
}

/**
 * JS-facing handle for QR code URI encoding and parsing.
 *
 * Pure functions — no I/O, no state. Handles the `substrate:` URI format
 * used in QR codes for Substrate address transfer.
 */
export class QrHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Decode an SS58 address, returning the 32-byte public key.
     *
     * Validates the base58 encoding and blake2b checksum.
     */
    decodeSs58Address(address: string): Uint8Array;
    /**
     * Encode a Substrate address into a QR-friendly URI string.
     *
     * Format: `substrate:{address}[?genesis_hash={hex}&amount={planck}]`
     *
     * `genesis_hash` must be exactly 32 bytes (Uint8Array) if provided.
     * `amount` is a decimal string (supports u128 range).
     */
    encodeSubstrateUri(address: string, genesis_hash?: Uint8Array | null, amount?: string | null): string;
    constructor();
    /**
     * Parse a QR code string into structured content.
     *
     * Returns a JS object with:
     * - `contentType`: `"substrate_transfer"`, `"raw_address"`, `"deep_link"`, or `"unknown"`
     * - `address`: SS58 address (for `substrate_transfer` and `raw_address`)
     * - `genesisHash`: Uint8Array (for `substrate_transfer`, if present)
     * - `amount`: decimal string (for `substrate_transfer`, if present)
     * - `rawContent`: string (for `deep_link` and `unknown`)
     */
    parseSubstrateUri(data: string): any;
}

/**
 * JS-facing statement store encoding utilities.
 *
 * All functions are pure — no I/O. The browser is responsible for transport.
 */
export class StatementHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Assemble a complete encoded statement from a signing payload and signature.
     *
     * `signing_payload_with_header` must be the exact bytes from `buildSigningPayload`.
     */
    assembleStatement(signing_payload_with_header: Uint8Array, sr25519_pubkey: Uint8Array, sr25519_signature: Uint8Array): Uint8Array;
    /**
     * Compute a blake2b-256 hash of arbitrary bytes.
     */
    blake2b256(data: Uint8Array): Uint8Array;
    /**
     * Build the signing payload for a statement.
     *
     * Returns the raw bytes that must be signed. Use `WalletHandle.sign()` to
     * sign the payload, then pass the result to `assembleStatement()`.
     */
    buildSigningPayload(now_secs: number, decryption_key: Uint8Array | null | undefined, channel: Uint8Array | null | undefined, priority: number, topics_flat: Uint8Array, data: Uint8Array): Uint8Array;
    /**
     * Build the signing payload for a specific statement-store dialect.
     */
    buildSigningPayloadWithDialect(dialect_name: string, now_secs: number, decryption_key: Uint8Array | null | undefined, channel: Uint8Array | null | undefined, priority: number, topics_flat: Uint8Array, data: Uint8Array): Uint8Array;
    /**
     * Decode a statement from binary encoding.
     * Returns a JSON string with the decoded fields.
     */
    decodeStatement(encoded: Uint8Array): any;
    /**
     * Decode a statement using a specific statement-store dialect.
     */
    decodeStatementWithDialect(dialect_name: string, encoded: Uint8Array): any;
    /**
     * Encode a statement into the sp-statement-store binary format.
     *
     * Convenience method that combines `buildSigningPayload` + `assembleStatement`
     * for callers who already have a pre-computed signature.
     *
     * `now_secs` is the current Unix timestamp in seconds (use `Date.now() / 1000 | 0`).
     * `topics_flat` is a flat `Uint8Array` of concatenated 32-byte topics.
     */
    encodeStatement(now_secs: number, decryption_key: Uint8Array | null | undefined, channel: Uint8Array | null | undefined, priority: number, topics_flat: Uint8Array, data: Uint8Array, sr25519_pubkey: Uint8Array, sr25519_signature: Uint8Array): Uint8Array;
    /**
     * Encode a statement using a specific statement-store dialect.
     */
    encodeStatementWithDialect(dialect_name: string, now_secs: number, decryption_key: Uint8Array | null | undefined, channel: Uint8Array | null | undefined, priority: number, topics_flat: Uint8Array, data: Uint8Array, sr25519_pubkey: Uint8Array, sr25519_signature: Uint8Array): Uint8Array;
    /**
     * Hex-decode a `0x`-prefixed (or bare) hex string.
     */
    hexDecode(s: string): Uint8Array;
    /**
     * Hex-encode bytes with `0x` prefix.
     */
    hexEncode(bytes: Uint8Array): string;
    constructor();
    /**
     * Hash a string into a 32-byte Topic (blake2b-256).
     */
    stringToTopic(s: string): Uint8Array;
}

/**
 * JS-facing handle for the statement store subscription system.
 *
 * The JS host calls `pushStatement()` for each raw statement received
 * from the SmoldotDriver. The Rust side decodes, deduplicates, and
 * dispatches to registered handlers.
 *
 * # Example (TypeScript)
 * ```typescript
 * const store = new StatementStoreHandle();
 * store.addTopic("0xabc..."); // 32-byte topic hex
 * // In your smoldot notification handler:
 * store.pushStatement(rawBytes);
 * // When done:
 * store.stop();
 * ```
 */
export class StatementStoreHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Add a topic to the subscription filter (hex-encoded 32 bytes).
     *
     * Accepts both `0x`-prefixed and bare hex strings.
     */
    addTopic(topic_hex: string): void;
    /**
     * Whether the subscription is accepting statement deliveries.
     */
    isRunning(): boolean;
    /**
     * Create a new statement store handle and start push-based delivery.
     */
    constructor();
    /**
     * Push a raw statement from the JS transport layer.
     *
     * The statement is decoded, deduplicated, and dispatched to registered
     * handlers.  Malformed bytes are logged and silently dropped.
     */
    pushStatement(raw: Uint8Array): void;
    /**
     * Remove a topic from the subscription filter.
     *
     * Accepts both `0x`-prefixed and bare hex strings.
     */
    removeTopic(topic_hex: string): void;
    /**
     * Stop the subscription and prevent further delivery.  Idempotent.
     */
    stop(): void;
}

/**
 * JS-facing wrapper over `useragent_wallet::WalletManager`.
 *
 * Manages sr25519/secp256k1 key material in WASM memory. The platform
 * keystore is not available — use `load_mnemonic()` to supply the phrase
 * and `lock()` to clear keys from memory.
 */
export class WalletHandle {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * SS58 address for a derived app account (Polkadot prefix 0).
     */
    appAddress(app_id: string, index: number): string;
    /**
     * 32-byte sr25519 public key for a derived app account.
     */
    appPublicKey(app_id: string, index: number): Uint8Array;
    /**
     * P2WPKH (bech32) Bitcoin mainnet address.
     */
    btcAddress(): string;
    /**
     * BIP-137 message signing with BTC key. Returns Base64 string.
     */
    btcSignMessage(msg: Uint8Array): string;
    /**
     * Sign a raw 32-byte digest with BTC key. Returns DER-encoded signature.
     */
    btcSignRaw(digest: Uint8Array): Uint8Array;
    /**
     * Decrypt data produced by `chatP256Encrypt`.
     */
    chatP256Decrypt(peer_identifier_key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
    /**
     * Encrypt with the v2 P-256/AES-GCM stack.
     *
     * Output is `nonce(12) || ciphertext || tag(16)`, matching CryptoKit's
     * combined AES-GCM sealed box representation.
     */
    chatP256Encrypt(peer_identifier_key: Uint8Array, plaintext: Uint8Array): Uint8Array;
    /**
     * Build v2-compatible directional P-256 session ids and channels.
     *
     * Returns a JS object with the same fields as native
     * `MobileChatP256Session`, using `Uint8Array` for byte fields.
     */
    chatP256Session(peer_account_id: Uint8Array, peer_identifier_key: Uint8Array, own_pin?: string | null, peer_pin?: string | null): any;
    /**
     * Decode and verify a first-contact chat request using the canonical host-sdk wire format.
     */
    decodeChatRequest(data: Uint8Array): any;
    /**
     * 32-byte Ed25519 public key at `//ed25519//<app_id>//<index>`.
     */
    ed25519PublicKey(app_id: string, index: number): Uint8Array;
    /**
     * Encode a chat-accept request using the canonical host-sdk wire format.
     */
    encodeChatAccept(request_id: string, text: string, timestamp: number, recipient_identifier_key?: Uint8Array | null): Uint8Array;
    /**
     * Encode a first-contact chat request using the canonical host-sdk wire format.
     */
    encodeChatRequest(text: string, timestamp: number, recipient_identifier_key?: Uint8Array | null): Uint8Array;
    /**
     * EIP-55 checksummed Ethereum address.
     */
    ethAddress(): string;
    /**
     * EIP-191 personal_sign with ETH key. Returns 65-byte signature (r+s+v).
     */
    ethSignPersonal(data: Uint8Array): Uint8Array;
    /**
     * Canonical 65-byte uncompressed P-256 identifier key at `//wallet//chat`.
     */
    identifierKey(): Uint8Array;
    /**
     * Load key material from a BIP-39 mnemonic phrase.
     *
     * The wallet is unlocked immediately. The mnemonic is NOT persisted —
     * the browser host must store it externally (e.g. encrypted localStorage).
     */
    loadMnemonic(phrase: string): void;
    /**
     * Lock the wallet — clear all in-memory key material.
     */
    lock(): void;
    /**
     * Create a new (locked, empty) wallet handle.
     */
    constructor();
    /**
     * Root SS58 address (Polkadot format, prefix 0).
     */
    rootAddress(): string;
    /**
     * Root 32-byte sr25519 public key.
     */
    rootPublicKey(): Uint8Array | undefined;
    /**
     * Sign with app-scoped sr25519 keypair. Returns 64-byte signature.
     */
    sign(app_id: string, index: number, payload: Uint8Array): Uint8Array;
    /**
     * Sign with Ed25519 key at `//ed25519//<app_id>//<index>`. Returns 64-byte signature.
     */
    signEd25519(app_id: string, index: number, payload: Uint8Array): Uint8Array;
    /**
     * Sign with root sr25519 keypair. Returns 64-byte signature.
     */
    signRoot(payload: Uint8Array): Uint8Array;
    /**
     * Sign with Substrate ECDSA key at `//ecdsa//<app_id>//<index>`. Returns 65 bytes (r+s+recovery).
     */
    signSubstrateEcdsa(app_id: string, index: number, payload: Uint8Array): Uint8Array;
    /**
     * Sign with the `//wallet` sr25519 keypair. Returns 64-byte signature.
     *
     * This matches the signing identity used by the native chat-request and
     * statement-store flows.
     */
    signWallet(payload: Uint8Array): Uint8Array;
    /**
     * Current wallet state: "NoWallet" | "Locked" | "Unlocked".
     */
    state(): string;
    /**
     * 33-byte compressed secp256k1 public key at `//ecdsa//<app_id>//<index>`.
     */
    substrateEcdsaPublicKey(app_id: string, index: number): Uint8Array;
    /**
     * Check auto-lock timeout. Call once per frame. Returns true if locked.
     */
    tick(): boolean;
    /**
     * 32-byte sr25519 public key at `//wallet`.
     *
     * This is the chat identity account ID used by the native chat-request
     * and statement-store protocol.
     */
    walletPublicKey(): Uint8Array;
}

/**
 * Decode raw call data bytes against runtime metadata.
 *
 * Returns a JS object: `{ pallet: string, call: string, argsJson: object, nestedCalls: array }`.
 *
 * `call_data` is the raw bytes starting with the pallet index byte and call
 * index byte, followed by SCALE-encoded call arguments — exactly the prefix of
 * `callDataAndExtra` from `decodeSignPayload`, minus the signed-extension extra
 * bytes. Trailing signed-extension bytes are silently ignored.
 *
 * `metadata_scale` must be SCALE bytes for `RuntimeMetadataPrefixed` (V14, V15,
 * or V16 with the magic prefix `0x6d657461`).
 *
 * Throws a `JsError` on any decoding failure.
 */
export function decodeCallData(call_data: Uint8Array, metadata_scale: Uint8Array): any;

/**
 * Decode a Substrate extrinsic against runtime metadata.
 *
 * Returns a JS object: `{ pallet: string, call: string, argsJson: object, nestedCalls: array }`.
 *
 * `extrinsic_scale` must be compact-length-prefixed SCALE bytes for one extrinsic,
 * exactly as returned by a Substrate node (the outer `Vec<u8>` element from the block body).
 *
 * `metadata_scale` must be SCALE bytes for `RuntimeMetadataPrefixed` (V14, V15, or V16
 * with the magic prefix `0x6d657461`).
 *
 * Throws a `JsError` on any decoding failure. On success the returned `argsJson` contains
 * each argument name mapped to its decoded JSON value, and `nestedCalls` is a (possibly empty)
 * array of the same structure for inner calls in batch/proxy/multisig extrinsics.
 */
export function decodeExtrinsic(extrinsic_scale: Uint8Array, metadata_scale: Uint8Array): any;

/**
 * Decode a Substrate extrinsic signing payload into structured fields.
 *
 * Use this on the `payload` bytes from a `NeedsSign` outcome when
 * `request_tag` equals `TAG_SIGN_PAYLOAD_REQ` (116 in v0.7.4 — formerly 36
 * in v0.7.3). Returns a JS object with `genesisHash`, `blockHash`,
 * `specVersion`, `txVersion`, `metadataHash` (Uint8Array or null), and
 * `callDataAndExtra`.
 *
 * This is a heuristic decoder for display purposes — see the
 * `useragent_encoding::extrinsic` module docs for limitations.
 */
export function decodeSignPayload(payload: Uint8Array): any;

/**
 * SCALE-encode a raw signature as a Substrate MultiSignature.
 * `scheme`: 0 = Ed25519, 1 = Sr25519, 2 = Ecdsa.
 */
export function encodeMultiSignature(sig_bytes: Uint8Array, scheme: number): Uint8Array;

/**
 * Generate a fresh 12-word BIP-39 mnemonic.
 */
export function generateMnemonic(): string;
