import { ResultAsync, type Result } from 'neverthrow'; import * as S from '../scale.js'; import type { HexString } from '../scale.js'; import { SubscriptionError } from '../transport.js'; import type { CallOptions, HostInitiatedSubscriptionHandler, ObservableLike, Observer, Subscription, TrUApiTransport } from '../transport.js'; import * as T from './types.js'; export { ResultAsync, SubscriptionError }; export type { CallOptions, HostInitiatedSubscriptionHandler, ObservableLike, Observer, Result, Subscription, TrUApiTransport }; export declare const TRUAPI_VERSION: 2; export declare const TRUAPI_CODEC_VERSION: 3; export declare const TRUAPI_WIRE_SCHEMA_HASH: "462dacb6e0d1f504"; /** Account lookup, aliasing, and proof generation. */ export declare class AccountClient { private readonly transport; constructor(transport: TrUApiTransport); /** Subscribe to account connection status changes. */ connectionStatusSubscribe(): ObservableLike>; /** Retrieve a product-scoped account. */ getAccount(request: T.HostAccountGetRequest, options?: CallOptions): ResultAsync>; /** Retrieve the contextual alias for a context and ring. */ getAccountAlias(request: T.HostAccountGetAliasRequest, options?: CallOptions): ResultAsync>; /** Generate a ring VRF proof with an explicitly registered member key. */ createAccountProof(request: T.HostAccountCreateProofRequest, options?: CallOptions): ResultAsync>; /** * Produce an sr25519 (schnorrkel) VRF signature from a product account. * * The host builds a Merlin transcript from `transcriptLabel` and `items` * and signs it with the account's key, returning the VRF pre-output and * proof. Authorized like signing: local when `AutoSigning` covers the * account, otherwise a per-call user confirmation. */ signVrf(request: T.HostAccountSignVrfRequest, options?: CallOptions): ResultAsync>; /** Register a ring-VRF key owned by the calling product. */ registerRingVrfKey(request: T.HostAccountRegisterRingVrfKeyRequest, options?: CallOptions): ResultAsync>; /** List registered ring-VRF keys owned by a product. */ listRingVrfKeys(request: T.HostAccountListRingVrfKeysRequest, options?: CallOptions): ResultAsync, S.CallErrorValue>; /** Sign bytes directly with a registered ring-VRF member key. */ ringVrfSign(request: T.HostAccountRingVrfSignRequest, options?: CallOptions): ResultAsync>; /** * List non-product accounts the user owns. * * Current hosts do not expose non-product accounts, so the list is empty. */ getLegacyAccounts(options?: CallOptions): ResultAsync>; /** Fetch the user's primary identity. */ getUserId(options?: CallOptions): ResultAsync>; /** * Request the host to present the login flow to the user. * * Products should call this in response to a user action (e.g. tapping a * "Sign in" button), not automatically on load. */ requestLogin(request: T.HostRequestLoginRequest, options?: CallOptions): ResultAsync>; } /** Chain interaction methods. */ export declare class ChainClient { private readonly transport; constructor(transport: TrUApiTransport); /** Follow the chain head and receive block events. */ followHeadSubscribe({ request }: { request: T.RemoteChainHeadFollowRequest; }): ObservableLike>; /** Fetch a block header. */ getHeadHeader(request: T.RemoteChainHeadHeaderRequest, options?: CallOptions): ResultAsync>; /** Fetch a block body. */ getHeadBody(request: T.RemoteChainHeadBodyRequest, options?: CallOptions): ResultAsync>; /** Query runtime storage at a specific block. */ getHeadStorage(request: T.RemoteChainHeadStorageRequest, options?: CallOptions): ResultAsync>; /** Invoke a runtime call at a specific block. */ callHead(request: T.RemoteChainHeadCallRequest, options?: CallOptions): ResultAsync>; /** Release pinned blocks. */ unpinHead(request: T.RemoteChainHeadUnpinRequest, options?: CallOptions): ResultAsync>; /** Continue a paused chain-head operation. */ continueHead(request: T.RemoteChainHeadContinueRequest, options?: CallOptions): ResultAsync>; /** Stop a chain-head operation. */ stopHeadOperation(request: T.RemoteChainHeadStopOperationRequest, options?: CallOptions): ResultAsync>; /** Fetch the canonical genesis hash for a chain. */ getSpecGenesisHash(request: T.RemoteChainSpecGenesisHashRequest, options?: CallOptions): ResultAsync>; /** Fetch the display name of a chain. */ getSpecChainName(request: T.RemoteChainSpecChainNameRequest, options?: CallOptions): ResultAsync>; /** Fetch the JSON-encoded properties of a chain. */ getSpecProperties(request: T.RemoteChainSpecPropertiesRequest, options?: CallOptions): ResultAsync>; /** Broadcast a signed transaction. */ broadcastTransaction(request: T.RemoteChainTransactionBroadcastRequest, options?: CallOptions): ResultAsync>; /** Stop a transaction broadcast. */ stopTransaction(request: T.RemoteChainTransactionStopRequest, options?: CallOptions): ResultAsync>; /** * Resolve a chain identifier to its genesis hash against the host's * configured environment (RFC 0026). */ getChainInfo(request: T.RemoteChainInfoRequest, options?: CallOptions): ResultAsync>; } /** Chat room, bot, and message APIs. */ export declare class ChatClient { private readonly transport; constructor(transport: TrUApiTransport); /** Create a chat room. */ createRoom(request: T.HostChatCreateRoomRequest, options?: CallOptions): ResultAsync>; /** Register a chat bot. */ registerBot(request: T.HostChatRegisterBotRequest, options?: CallOptions): ResultAsync>; /** Subscribe to the list of chat rooms. */ listSubscribe(): ObservableLike>; /** * Post a message to a chat room. * * The host bounds and screens what it forwards. Message text is capped at * 16 KiB and keeps line breaks and tabs, but is rejected for other * control characters and for bidirectional overrides. Identifiers and * display names are normalized and screened. A message carries at most 32 * actions and 32 media items, a custom payload at most 256 KiB, and a URL * at most 2 KiB which must be `https` or an inline raster image. A * rejection reports `MessageTooLarge` when the body or custom payload is * over budget, and `Unknown` with a reason naming the field otherwise. * * The returned `messageId` is the correlation key for any action the * message carries: a later `actionSubscribe` trigger names it. */ postMessage(request: T.HostChatPostMessageRequest, options?: CallOptions): ResultAsync>; /** Subscribe to received chat actions. */ actionSubscribe(): ObservableLike>; } /** * CoinPayment operations. * * RFC 0017 describes `Resolvable` values for long-running operations. * TrUAPI represents those as subscriptions whose items are the RFC status * updates. */ export declare class CoinPaymentClient { private readonly transport; constructor(transport: TrUApiTransport); /** Create a new firewalled CoinPayment purse. */ createPurse(request: T.HostCoinPaymentCreatePurseRequest, options?: CallOptions): ResultAsync>; /** Query product-visible purse metadata and balance. */ queryPurse(request: T.HostCoinPaymentQueryPurseRequest, options?: CallOptions): ResultAsync>; /** Transfer balance between local purses. */ rebalancePurse({ request }: { request: T.HostCoinPaymentRebalancePurseRequest; }): ObservableLike>; /** Delete a purse after draining its balance into another local purse. */ deletePurse({ request }: { request: T.HostCoinPaymentDeletePurseRequest; }): ObservableLike>; /** Create a receivable public key for depositing into a purse. */ createReceivable(request: T.HostCoinPaymentCreateReceivableRequest, options?: CallOptions): ResultAsync>; /** Create a cheque paying from a local purse to a receivable. */ createCheque(request: T.HostCoinPaymentCreateChequeRequest, options?: CallOptions): ResultAsync>; /** Claim coins from a cheque into the receivable's purse. */ deposit({ request }: { request: T.HostCoinPaymentDepositRequest; }): ObservableLike>; /** Attempt to return coins associated with a receivable. */ refund({ request }: { request: T.HostCoinPaymentRefundRequest; }): ObservableLike>; /** Listen for a cheque delivered through a standard transmission channel. */ listenForPayment({ request }: { request: T.HostCoinPaymentListenForRequest; }): ObservableLike>; } /** Deterministic entropy derivation. */ export declare class EntropyClient { private readonly transport; constructor(transport: TrUApiTransport); /** Derive deterministic entropy. */ derive(request: T.HostDeriveEntropyRequest, options?: CallOptions): ResultAsync>; } /** Local key/value storage scoped to the calling product. */ export declare class LocalStorageClient { private readonly transport; constructor(transport: TrUApiTransport); /** Read a value by key. */ read(request: T.HostLocalStorageReadRequest, options?: CallOptions): ResultAsync>; /** Write a value to a key. */ write(request: T.HostLocalStorageWriteRequest, options?: CallOptions): ResultAsync>; /** Clear a value by key. */ clear(request: T.HostLocalStorageClearRequest, options?: CallOptions): ResultAsync>; /** * Subscribe to changes of one key in the product's own storage namespace. * * Emits the current value immediately, then one item per later write or * clear of the key by any of the product's runtimes. A write that leaves * the stored bytes unchanged emits nothing. */ subscribe({ request }: { request: T.HostLocalStorageSubscribeRequest; }): ObservableLike>; } /** Host locale subscription. */ export declare class LocaleClient { private readonly transport; constructor(transport: TrUApiTransport); /** Subscribe to the host's selected locale. */ subscribe(): ObservableLike>; } /** Notification methods for locally-rendered push notifications. */ export declare class NotificationsClient { private readonly transport; constructor(transport: TrUApiTransport); /** * Send a push notification to the user. * * Returns a [`NotificationId`](crate::v01::NotificationId) that can be * passed to [`cancel_push_notification`](Self::cancel_push_notification) * to retract a scheduled notification. When `scheduled_at` is set the host * persists the notification across restarts and fires it through the * platform-native scheduler. See [RFC 0019]. * * [RFC 0019]: https://github.com/paritytech/host-rust-core/blob/main/docs/rfcs/0019-scheduled-notifications.md */ sendPushNotification(request: T.HostPushNotificationRequest, options?: CallOptions): ResultAsync>; /** * Cancels a previously issued push notification. * * Cancellation is idempotent: returns `Ok(())` whether the notification is * still pending, already fired, or was never issued. See [RFC 0019]. * * [RFC 0019]: https://github.com/paritytech/host-rust-core/blob/main/docs/rfcs/0019-scheduled-notifications.md */ cancelPushNotification(request: T.HostPushNotificationCancelRequest, options?: CallOptions): ResultAsync>; } /** Payment request and balance/status subscription methods. */ export declare class PaymentClient { private readonly transport; constructor(transport: TrUApiTransport); /** Subscribe to payment balance updates. */ balanceSubscribe({ request }: { request: T.HostPaymentBalanceSubscribeRequest; }): ObservableLike>; /** Request a payment from the user. */ request(request: T.HostPaymentRequest, options?: CallOptions): ResultAsync>; /** Subscribe to payment lifecycle updates for a specific payment. */ statusSubscribe({ request }: { request: T.HostPaymentStatusSubscribeRequest; }): ObservableLike>; /** Top up the user's payment balance. */ topUp(request: T.HostPaymentTopUpRequest, options?: CallOptions): ResultAsync>; } /** Permission request methods. */ export declare class PermissionsClient { private readonly transport; constructor(transport: TrUApiTransport); /** Request a device-capability permission from the user. */ requestDevicePermission(request: T.HostDevicePermissionRequest, options?: CallOptions): ResultAsync>; /** * Request a remote-operation permission. * * This example makes live requests to Frankfurter after permission is granted. */ requestRemotePermission(request: T.RemotePermissionRequest, options?: CallOptions): ResultAsync>; } /** * Pocket cards backed by the calling product. * * The host owns the collection: a product observes its own cards and may * remove them, but cannot add one. */ export declare class PocketClient { private readonly transport; constructor(transport: TrUApiTransport); /** * Subscribe to the calling product's cards. * * Emits the whole set on subscribe and again after every change. */ listSubscribe(): ObservableLike>; /** * Remove one of the calling product's cards. * * Removing a card that is not present succeeds. A privileged card is * refused with `Privileged`. */ removeCard(request: T.HostPocketRemoveCardRequest, options?: CallOptions): ResultAsync>; } /** Preimage lookup and submission methods. */ export declare class PreimageClient { private readonly transport; constructor(transport: TrUApiTransport); /** Subscribe to preimage lookups for a given key. */ lookupSubscribe({ request }: { request: T.RemotePreimageLookupSubscribeRequest; }): ObservableLike>; /** Submit a preimage. Returns the preimage key (hash) on success. */ submit(request: HexString, options?: CallOptions): ResultAsync>; } /** Product-rendered bodies and the actions triggered inside them. */ export declare class RendererClient { private readonly transport; private readonly renderRegistration; constructor(transport: TrUApiTransport); /** * Streams renderer trees for one product-rendered body. Each item * replaces the previous tree. The stream stays open while the body is * displayed so the product can redraw in place. */ onRender(handler: HostInitiatedSubscriptionHandler>): { unsubscribe(): void; }; /** Subscribe to actions triggered inside this product's rendered bodies. */ actionSubscribe(): ObservableLike>; } /** Resource pre-allocation (allowance management). */ export declare class ResourceAllocationClient { private readonly transport; constructor(transport: TrUApiTransport); /** Request the host to pre-allocate one or more resources. */ request(request: T.HostRequestResourceAllocationRequest, options?: CallOptions): ResultAsync>; } /** Signing operations. */ export declare class SigningClient { private readonly transport; constructor(transport: TrUApiTransport); /** * Construct a transaction for a product account. * * Served locally without a user confirmation when an RFC-0010 `AutoSigning` * grant covers the account; otherwise each call is confirmed by the user. * * Under Extrinsic V5, omitting `VerifyMultiSignature` from `extensions` * lets the host sign with the signer's key. Listing it — as `Disabled`, * with a proof in a later extension — encodes the given bytes verbatim and * returns an unsigned transaction. */ createTransaction(request: T.ProductAccountTxPayload, options?: CallOptions): ResultAsync>; /** * Construct a transaction for a non-product (legacy) account. * * The V5 `VerifyMultiSignature` rule is the same as * [`Signing::create_transaction`]: omit it and the host signs, list it and * the given bytes are used with no host signature. */ createTransactionWithLegacyAccount(request: T.LegacyAccountTxPayload, options?: CallOptions): ResultAsync>; /** Sign raw bytes with a non-product account. */ signRawWithLegacyAccount(request: T.HostSignRawWithLegacyAccountRequest, options?: CallOptions): ResultAsync>; /** Sign an extrinsic payload with a non-product account. */ signPayloadWithLegacyAccount(request: T.HostSignPayloadWithLegacyAccountRequest, options?: CallOptions): ResultAsync>; /** * Sign raw bytes or a message. * * Served locally without a user confirmation when an RFC-0010 `AutoSigning` * grant covers the account; otherwise each call is confirmed by the user. */ signRaw(request: T.HostSignRawRequest, options?: CallOptions): ResultAsync>; /** * Sign an extrinsic payload. * * Served locally without a user confirmation when an RFC-0010 `AutoSigning` * grant covers the account; otherwise each call is confirmed by the user. */ signPayload(request: T.HostSignPayloadRequest, options?: CallOptions): ResultAsync>; /** * Sign the supplied data without adding or removing a watermark. * * Temporary compatibility API for runtime ownership proofs, including the * 32-byte Resources alias used by Humanity. Payload decoding matches * watermarked signing, but the decoded bytes are signed exactly as supplied. * This permits transaction-shaped data and requires signing authorization * and explicit user confirmation. * * @deprecated Temporary unwatermarked signing; migrate to watermarked signing when the runtime supports it. This API will be removed. See https://github.com/paritytech/host-rust-core/issues/612 */ signRawUnwatermarkedDeprecated(request: T.HostSignRawRequest, options?: CallOptions): ResultAsync>; /** * Sign the supplied data without adding or removing a watermark. * * Temporary compatibility API for runtime ownership proofs, including the * 32-byte Resources alias used by Humanity. Payload decoding matches * watermarked signing, but the decoded bytes are signed exactly as supplied. * This permits transaction-shaped data and requires signing authorization * and explicit user confirmation. * * @deprecated Temporary unwatermarked signing; migrate to watermarked signing when the runtime supports it. This API will be removed. See https://github.com/paritytech/host-rust-core/issues/612 */ signRawUnwatermarkedDeprecatedWithLegacyAccount(request: T.HostSignRawWithLegacyAccountRequest, options?: CallOptions): ResultAsync>; } /** Statement store methods. */ export declare class StatementStoreClient { private readonly transport; constructor(transport: TrUApiTransport); /** Subscribe to statements matching a topic filter. */ subscribe({ request }: { request: T.RemoteStatementStoreSubscribeRequest; }): ObservableLike>; /** * Create a proof for a statement. * * **Deprecated:** use [`create_proof_authorized`](Self::create_proof_authorized) * instead, which uses a pre-allocated allowance account and does not * require a per-call signing prompt. Pairing hosts may reject this method * when their signing channel cannot sign statement proof payloads exactly. */ createProof(request: T.RemoteStatementStoreCreateProofRequest, options?: CallOptions): ResultAsync>; /** * Create a proof for a statement using a pre-allocated allowance account, * bypassing the per-call signing prompt. */ createProofAuthorized(request: T.Statement, options?: CallOptions): ResultAsync>; /** * Submit a signed statement to the network. The request body is the * [`SignedStatement`](crate::v01::SignedStatement) directly (no wrapping * struct), matching upstream `triangle-js-sdks`. */ submit(request: T.SignedStatement, options?: CallOptions): ResultAsync>; } /** * General-purpose TrUAPI methods for handshake, feature detection, * navigation, and runtime information. */ export declare class SystemClient { private readonly transport; constructor(transport: TrUApiTransport); /** Negotiate the wire codec version with the product. */ handshake(options?: CallOptions): ResultAsync>; /** Query whether the host supports a specific feature. */ featureSupported(request: T.HostFeatureSupportedRequest, options?: CallOptions): ResultAsync>; /** * Request the host to open a URL. * * An `http` or `https` URL outside the ecosystem needs a * `RemotePermission::Remote` grant for the target host, and prompts for one * on first use. dotNS names, `localhost`, and the app-handoff schemes * (`mailto:`, `tel:`, `polkadot:`, `dot:`) consume no grant. The grant is * per host and shared with outbound data access to that host, so approving * one covers the other. */ navigateTo(request: T.HostNavigateToRequest, options?: CallOptions): ResultAsync>; /** * Report the host's identity and version. * * Returns the host's platform, name, and version so a product knows * exactly which host — and which build of it — is running it: for * adapting to the host, telemetry, and attributing behaviour to a * concrete build in diagnostics and bug reports. */ info(options?: CallOptions): ResultAsync>; /** Return the product context bound to the current host runtime. */ getProductContext(options?: CallOptions): ResultAsync>; } /** Host theme subscription. */ export declare class ThemeClient { private readonly transport; constructor(transport: TrUApiTransport); /** Subscribe to host theme changes. */ subscribe(): ObservableLike>; } /** * Worker background-operation APIs. * * The host keeps a product's worker running while it holds at least one open * operation, which is how a worker outlives the surface that started it. */ export declare class WorkerClient { private readonly transport; constructor(transport: TrUApiTransport); /** Begin a pending operation. */ beginOperation(request: T.HostWorkerBeginOperationRequest, options?: CallOptions): ResultAsync>; /** * End a pending operation. Idempotent: an unknown or already-ended id * succeeds, so a retry after an ambiguous failure is safe. */ endOperation(request: T.HostWorkerEndOperationRequest, options?: CallOptions): ResultAsync>; } export interface TrUApiClient { readonly account: AccountClient; readonly chain: ChainClient; readonly chat: ChatClient; readonly coinPayment: CoinPaymentClient; readonly entropy: EntropyClient; readonly localStorage: LocalStorageClient; readonly locale: LocaleClient; readonly notifications: NotificationsClient; readonly payment: PaymentClient; readonly permissions: PermissionsClient; readonly pocket: PocketClient; readonly preimage: PreimageClient; readonly renderer: RendererClient; readonly resourceAllocation: ResourceAllocationClient; readonly signing: SigningClient; readonly statementStore: StatementStoreClient; readonly system: SystemClient; readonly theme: ThemeClient; readonly worker: WorkerClient; } export type Client = TrUApiClient; /** Creates the generated client facade by binding each service namespace to the * shared transport instance. */ export declare function createClient(transport: TrUApiTransport): TrUApiClient;