/** * WalletStore — a small framework-agnostic reactive wallet store. Same reactivity philosophy as * KoraElement (Proxy + microtask-batched notify), but it's a plain class any site subscribes to, * so connect/disconnect/network state is consistent everywhere. Holds RAW CIP-30 values (hex * addresses, CBOR balance); decoding stays app-side (or a future @cardano-sdk adapter). */ import { listAvailableWallets, type Cip30Api, type Cip30DataSignature } from "./cip30.js"; import type { KoraNetwork } from "../env/index.js"; export type WalletStatus = "disconnected" | "connecting" | "connected" | "error"; /** A handle held by the connected wallet, normalized for display. `image` is the raw reference * (`ipfs://…` or https) — render it through `` for gateway failover. */ export interface WalletHandleSummary { name: string; virtual: boolean; isDeMi: boolean; image: string | null; } export interface WalletState { status: WalletStatus; walletKey: string | null; walletName: string | null; walletIcon: string | null; networkId: number | null; changeAddressHex: string | null; rewardAddressHex: string | null; usedAddressHex: string | null; balanceCbor: string | null; /** Friendly bech32 of the change address (addr1…/addr_test…), derived from the hex. */ address: string | null; /** Handles held by this wallet (resolved from the Handle API on connect). */ handles: WalletHandleSummary[]; /** The active handle (auto-selected on connect, changeable via selectHandle). */ selectedHandle: string | null; error: string | null; } export type WalletListener = (state: Readonly) => void; export declare class WalletStore { #private; /** Whether connect() automatically resolves the wallet's handles (default true). Set false for a * connection-only flow that doesn't need the handle list. */ get autoResolve(): boolean; set autoResolve(value: boolean); /** * The Cardano network to resolve handles against. Leave null (default) to derive it: the wallet's * own `networkId` decides mainnet vs testnet, and the host subdomain (preview./preprod.) picks the * testnet flavour. Set this ONCE only if your app runs on a host that doesn't encode the network * (e.g. a custom domain or localhost) and needs preview vs preprod pinned. This declares which * network you're on — it is NOT a hook for supplying your own handles. */ get network(): KoraNetwork | null; set network(value: KoraNetwork | null); constructor(); /** Current state (read-only snapshot reference). */ get state(): Readonly; /** The live CIP-30 API while connected, else null (for signing/submitting). */ get api(): Cip30Api | null; /** Subscribe to state changes; called immediately with current state. Returns an unsubscribe fn. */ subscribe(listener: WalletListener): () => void; /** Discover the wallets injected into window.cardano. */ available(): ReturnType; /** Connect to a wallet by its window.cardano key and populate state from CIP-30 calls. */ connect(walletKey: string): Promise; disconnect(): void; /** * Resolve the wallet's handles from the Ada Handle API (regular + NFT + virtual SubHandles) and * auto-select a default. Called automatically by connect() when autoResolve is on; safe to call * directly otherwise. Failures (offline / API down) leave the list empty — the connection itself * still succeeded. */ resolveHandles(): Promise; /** Choose the active handle among the resolved set; remembers it so a return visit lands on the * same one. No-op if unchanged. (Selecting ≠ supplying — the handle list is the store's to * resolve; there is intentionally no API to inject your own.) */ selectHandle(name: string | null): void; /** * Silently reconnect to the previously-remembered wallet, if any. Only attempts a wallet the * user connected before (so it never pops an unsolicited prompt on a first visit). Waits briefly * for the wallet to inject. Returns true if it connected. */ autoConnect({ waitMs }?: { waitMs?: number; }): Promise; /** Sign a tx (CBOR hex) with the connected wallet. */ signTx(txCbor: string, partialSign?: boolean): Promise; /** CIP-8 data signing — sign an arbitrary payload (hex) with the key for `address` (hex). For * anything beyond this, reach for the full CIP-30 API directly via `store.api`. */ signData(address: string, payloadHex: string): Promise; /** Submit a signed tx (CBOR hex) through the connected wallet. */ submitTx(signedTxCbor: string): Promise; } /** Shared singleton — most sites want one wallet connection app-wide. */ export declare const walletStore: WalletStore; //# sourceMappingURL=store.d.ts.map