/** * DappSDK ties together DiscoveryClient + DappClient and serves as the * primary SDK entrypoint for dApp developers. * * A default singleton instance is exported at the bottom of this file, and * module-level functions delegate to that singleton for backward compatibility * (e.g. `sdk.connect()`, `sdk.status()`). */ import { type ProviderAdapter, type WalletPickerFn } from '@canton-network/core-wallet-discovery'; import type { EventListener, Provider } from '@canton-network/core-splice-provider'; import type { StatusEvent, ConnectResult, PrepareExecuteParams, PrepareExecuteAndWaitResult, LedgerApiParams, LedgerApiResult, ListAccountsResult, AccountsChangedEvent, TxChangedEvent, RpcTypes as DappRpcTypes, MessageSignatureEvent, SignMessageParams, SignMessageResult } from '@canton-network/core-wallet-dapp-rpc-client'; export interface DappSDKConnectOptions { defaultAdapters?: TDefaultAdapter[]; additionalAdapters?: ProviderAdapter[] | undefined; enableSuggestedWallets?: boolean; } export declare class DappSDK { private readonly RECENT_GATEWAYS_KEY; private readonly walletPicker; private discovery; private client; private initPromise; private dynamicAdapterIds; private configuredAdapters; constructor(options?: { walletPicker?: WalletPickerFn | undefined; }); private registerAdapters; private registerAnnouncedAdapters; private ensureDiscovery; private getInitAdapters; private collectDetectedAdapters; private saveRecentGateway; private getHttpStatusCode; private formatConnectionErrorMessage; private requireClient; /** * Returns the raw connected provider instance (if any). * * This is useful for advanced integrations that need to call methods that * are not wrapped by the higher-level SDK helpers. */ getConnectedProvider(): Provider | null; /** * Cold-start the SDK: create (or update) the discovery client, register adapters, * and attempt to restore a persisted wallet session without opening the picker. * * Call early on app mount with your adapter configuration. For the exported * {@link sdk} singleton, the **first** `init()` call (with or without options) * determines how {@link ensureDiscovery} builds the initial adapter list; pass * `options` on that first call when you need custom gateways or extra adapters. * * Adapter selection when discovery is first created (see {@link getInitAdapters}): * - If `options` is passed on this call, use those adapters (default gateways apply when * `defaultAdapters` is omitted). * - Else if {@link configuredAdapters} was set by an earlier `init(options)`, use it. * - Else use the last remote gateway URL from app-local hints (if any), otherwise * fall back to default gateways (`gateways.json`). * * Session restore itself is always performed by {@link DiscoveryClient} via * `restorePersistedSessionIfNeeded()`; the SDK only ensures a compatible adapter set * is registered first. * * Safe to call from multiple places: concurrent callers share the same in-flight * promise; discovery creation itself still happens at most once per SDK instance. */ init(options?: DappSDKConnectOptions): Promise; connect(): Promise; /** @deprecated Pass options to `init()` instead. */ connect(options: DappSDKConnectOptions): Promise; disconnect(): Promise; isConnected(): Promise; status(): Promise; listAccounts(): Promise; prepareExecute(params: PrepareExecuteParams): Promise; prepareExecuteAndWait(params: PrepareExecuteParams): Promise; signMessage(params: SignMessageParams): Promise; ledgerApi(params: LedgerApiParams): Promise; open(): Promise; onStatusChanged(listener: EventListener): Promise; onAccountsChanged(listener: EventListener): Promise; onConnected(listener: EventListener): Promise; onTxChanged(listener: EventListener): Promise; onMessageSignature(listener: EventListener): Promise; removeOnStatusChanged(listener: EventListener): Promise; removeOnAccountsChanged(listener: EventListener): Promise; removeOnConnected(listener: EventListener): Promise; removeOnTxChanged(listener: EventListener): Promise; removeOnMessageSignature(listener: EventListener): Promise; } export declare const sdk: DappSDK; /** * Opens the wallet picker and connects. Prefer {@link init} with adapters at startup; * `options` here is a legacy convenience that forwards to {@link DappSDK.init}. */ export declare function connect(): Promise; /** @deprecated Pass options to `init()` instead. */ export declare function connect(options: DappSDKConnectOptions): Promise; export declare const init: (options?: DappSDKConnectOptions) => Promise; export declare const disconnect: () => Promise; export declare const isConnected: () => Promise; export declare const status: () => Promise; export declare const listAccounts: () => Promise; export declare const prepareExecute: (params: PrepareExecuteParams) => Promise; export declare const prepareExecuteAndWait: (params: PrepareExecuteParams) => Promise; export declare const ledgerApi: (params: LedgerApiParams) => Promise; export declare const open: () => Promise; export declare const getConnectedProvider: () => ReturnType; export declare const onStatusChanged: (listener: EventListener) => Promise; export declare const onAccountsChanged: (listener: EventListener) => Promise; export declare const onConnected: (listener: EventListener) => Promise; export declare const onTxChanged: (listener: EventListener) => Promise; export declare const onMessageSignature: (listener: EventListener) => Promise; export declare const removeOnStatusChanged: (listener: EventListener) => Promise; export declare const removeOnAccountsChanged: (listener: EventListener) => Promise; export declare const removeOnConnected: (listener: EventListener) => Promise; export declare const removeOnTxChanged: (listener: EventListener) => Promise; export declare const removeOnMessageSignature: (listener: EventListener) => Promise; //# sourceMappingURL=sdk.d.ts.map