/** * Stellar Indexer backend (Creit Tech), over `POST /v1/contract-data/`. * * The wallet stores one top-level contract-data entry per signer * (`key = SignerKey ScVal`, `val = SignerVal`), so signer enumeration is a * contract-scoped query and reverse lookup is derive-then-confirm: derive the * wallet address from the keyId, then confirm the signer entry exists there. * Removed signers appear as tombstoned (`deleted_at`) entries. * * WIRE FORMAT (F2-confirmed, todo 959 c2502 / todo 967): * - The live API returns each entry's `key`/`val` as **JSON ScVal**, e.g. * `{"vec":[{"symbol":"Secp256r1"},{"bytes":""}]}` — NOT base64 XDR. We * convert JSON ScVal -> `xdr.ScVal` ({@link jsonScValToXdr}) and reuse the * contract-spec decoders (`scValToSignerKey`/`decodeSignerVal`). The JSON * convention is the standard Stellar one: `symbol`, `bytes` (hex), `address` * (strkey), `vec` (array), `map` (`[{key,val}]`), `u64`/`i64` (string), * `u32`/`i32` (number), `bool`, `string`, `void` (None). * - Entry fields: `id, contract_id, durability, key, val, * last_modified_ledger_seq, tx_meta_version, timestamp, created_at, * updated_at, deleted_at`. * * NETWORK: **the Stellar Indexer indexes MAINNET only** — a testnet contract * returns HTTP 200 with zero entries (F2). To keep "unsupported network" from * masquerading as "wallet has no signers", the backend is network-aware: use * {@link StellarIndexerBackend.forNetwork} (returns `null` off mainnet), and a * config pinned to a non-mainnet passphrase throws at construction rather than * silently returning `[]`. Live validation therefore needs a mainnet v1 wallet * (endgame-gated); until then this is unit-tested against the documented shape. * * @packageDocumentation */ import { Networks, xdr } from "@stellar/stellar-sdk"; import { SignerKey } from "../types.js"; import type { FindWalletsHardeningDeps, IndexerHealth, SignerIndexer, WalletSigner } from "./types.js"; /** Max contract ids per contract-data request (API cap). */ export declare const MAX_CONTRACTS_PER_QUERY = 25; /** The only network the Stellar Indexer indexes (mainnet). */ export declare const STELLAR_INDEXER_NETWORK = Networks.PUBLIC; /** * A raw contract-data entry (F2-confirmed live shape). `key`/`val` are JSON * ScVal objects (see {@link jsonScValToXdr}), not base64-XDR strings; the extra * fields are carried through untyped since only these four drive decoding. */ export interface StellarIndexerEntry { /** JSON ScVal of the SignerKey. */ key: unknown; /** JSON ScVal of the SignerVal. */ val: unknown; durability: "persistent" | "temporary"; deleted_at: string | null; id?: string; contract_id?: string; last_modified_ledger_seq?: number; tx_meta_version?: string | number; timestamp?: string; created_at?: string; updated_at?: string; } export interface StellarIndexerConfig { /** Base URL, e.g. https://api.stellarindexer.com */ url: string; /** Bearer access token (server-side secret). */ accessToken: string; /** * Network passphrase this backend serves. The Stellar Indexer indexes mainnet * only; a non-mainnet passphrase throws at construction (prefer * {@link StellarIndexerBackend.forNetwork} to get a `null` off mainnet). When * omitted, mainnet is assumed. */ networkPassphrase?: string; /** Deps enabling derive-then-confirm reverse lookup. */ hardening?: FindWalletsHardeningDeps; /** Clock source (seconds); injectable for tests. */ now?: () => number; } export declare class StellarIndexerBackend implements SignerIndexer { private readonly config; constructor(config: StellarIndexerConfig); /** * Network-aware factory: the backend for mainnet, or `null` for any other * network (the Stellar Indexer doesn't index testnet, so "discovery disabled" * is the honest answer — callers treat `null` as no-indexer rather than an * empty signer set). */ static forNetwork(config: Omit, networkPassphrase: string): StellarIndexerBackend | null; private nowSeconds; private query; getSigners(wallet: string): Promise; /** * Group entries by signer key and resolve status. A key with any live entry * is live/expired; a key whose every entry is tombstoned (no live counterpart * in either durability) is `removed`. */ entriesToSigners(entries: StellarIndexerEntry[]): WalletSigner[]; /** * Reverse lookup via derive-then-confirm. Only Secp256r1 keyIds are * derivable; Ed25519/Policy signers are not discoverable through this backend * (use Mercury's event-driven index for those). */ findWallets(key: SignerKey): Promise; health(): Promise; } /** * Convert a Stellar JSON-ScVal object into an `xdr.ScVal`. * * The Stellar Indexer serializes ledger-entry `key`/`val` as JSON ScVal — a * single-key object per value (`{"vec":[...]}`, `{"symbol":"…"}`, …). This is * the inverse of that serialization for the variants a smart-wallet * SignerKey/SignerVal can contain, letting the contract-spec decoders take over. * * Unknown variant keys THROW (never silently misdecode): an unexpected wire * shape must surface as an error, not a wrong signer. */ export declare function jsonScValToXdr(json: unknown): xdr.ScVal; //# sourceMappingURL=stellar-indexer.d.ts.map