import { V1Transaction, type V1ResourceConfig, type V1TransactionContext } from "./program/transaction"; import { Connection, Keypair, PublicKey } from "@solana/web3.js"; import { Auth, type AuthCredentials } from "./auth"; import type { ClientContext } from "./context"; import type { ConfirmedTransaction } from "./context"; import type { FaucetResponse } from "./domain/faucet"; import { Markets } from "./domain/market"; import { Metrics } from "./domain/metrics"; import { Notifications } from "./domain/notification"; import { Orders } from "./domain/order"; import { Orderbooks } from "./domain/orderbook"; import { Positions } from "./domain/position"; import { PriceHistoryClient } from "./domain/price_history"; import { Referrals } from "./domain/referral"; import { Trades } from "./domain/trade"; import { LightconeHttp, type CredentialRestorer } from "./http"; import { LightconeEnv } from "./env"; import { Privy } from "./privy"; import { Rpc } from "./rpc"; import { RpcFailoverState } from "./rpcFailover"; import { DepositSource, type OrderbookRules, type PubkeyStr } from "./shared"; import { type ExternalSigner, type SigningStrategy } from "./shared/signing"; import { WsClient, type WsConfig } from "./ws"; declare class AuthState { private credentialsValue; constructor(initial?: AuthCredentials); getCredentials(): AuthCredentials | undefined; setCredentials(credentials: AuthCredentials | undefined): void; clearCaches(): Promise; } export declare class LightconeClient implements ClientContext { readonly transactionResources?: V1ResourceConfig; readonly rpcFetch?: typeof fetch; readonly http: LightconeHttp; readonly programId: PublicKey; readonly primaryConnection?: Connection; readonly backupConnection?: Connection; readonly rpcFailoverState: RpcFailoverState; private depositSourceValue; private signingStrategyValue?; private transactionSponsorshipEnabledValue; private orderNonceValue; private readonly wsConfigValue; private readonly authStateStore; readonly orderbookRulesCache: Map>; /** @deprecated Use primaryConnection — kept for ClientContext compat. */ get connection(): Connection | undefined; constructor(params: { http: LightconeHttp; wsConfig: WsConfig; programId?: PublicKey; primaryConnection?: Connection; backupConnection?: Connection; rpcFailoverState?: RpcFailoverState; depositSource?: DepositSource; signingStrategy?: SigningStrategy; transactionSponsorshipEnabled?: boolean; transactionResources?: V1ResourceConfig; rpcFetch?: typeof fetch; orderNonce?: number; authCredentials?: AuthCredentials; authState?: AuthState; orderbookRulesCache?: Map>; }); get depositSource(): DepositSource; setDepositSource(source: DepositSource): void; get signingStrategy(): SigningStrategy | undefined; /** * Cached authenticated identity shared by domain sub-clients. * * This is distinct from the HTTP cookie token and may be expired; fund-moving * operations must re-check its lifetime and wallet before signing. */ get authCredentials(): AuthCredentials | undefined; setSigningStrategy(strategy: SigningStrategy): void; clearSigningStrategy(): void; /** Return the client-wide trusted assertion that an external sponsor pays fees. */ get transactionSponsorshipEnabled(): boolean; /** Replace the Transaction Sponsorship Capability for subsequent submissions. */ setTransactionSponsorshipEnabled(enabled: boolean): void; orderNonce(): number | undefined; setOrderNonce(nonce: number): void; clearOrderNonce(): void; /** * Get the current `lightcone-token` cookie value, if any. Populated by the SDK * after a successful login, then attached on every authed request. Useful * for forwarding the token through the `*WithCookies` methods, or * persisting the session across processes. */ authToken(): Promise; /** * Clear the cached `lightcone-token`. Subsequent authed calls will go out * without a `Cookie` header (and 401) unless they use a * `*WithCookies` variant. */ clearAuthToken(): Promise; /** * Register the credential restorer consulted when a request fails with * HTTP 401: it attempts to restore credentials (e.g. refresh the app's * auth session so the auth cookie is valid again); on success the * transport replays the request once IF it declared itself retry-safe * (RetryPolicy.None mutations are never auto-replayed). See {@link CredentialRestorer}. * Without a restorer, 401s propagate to callers unchanged. * * Common use: set once at app startup, alongside the signing strategy. */ setCredentialRestorer(restorer: CredentialRestorer): void; /** Remove the credential restorer (e.g. in tests); 401s propagate again. */ clearCredentialRestorer(): void; /** Fetch a fresh context with configured v1 transaction resources. */ transactionContext(): Promise; /** Fetch a fresh context with explicit limits and total priority fee lamports. */ transactionContextWithResources(resources: V1ResourceConfig): Promise; signAndSubmitTx(tx: V1Transaction): Promise; /** * Sign and submit a transaction, then wait until it reaches `confirmed` * commitment on-chain. Prefer this over {@link signAndSubmitTx} when a * follow-up transaction depends on this one's state. */ signAndSubmitTxConfirmed(tx: V1Transaction): Promise; /** Sign, submit, confirm, and return the transaction's processing slot. */ signAndSubmitTxConfirmedWithSlot(tx: V1Transaction): Promise; /** * Sign, submit, and confirm a fee-prepared transaction without replacing its * message. Privy and wallet-adapter message mutation are rejected. A confirmation * timeout leaves the outcome unknown; inspect authoritative state before retrying. */ signAndSubmitPreparedTxConfirmedWithSlot(tx: V1Transaction): Promise; static builder(): LightconeClientBuilder; markets(): Markets; orderbooks(): Orderbooks; orders(): Orders; positions(): Positions; trades(): Trades; priceHistory(): PriceHistoryClient; notifications(): Notifications; /** * Metrics sub-client — platform / market / orderbook / category / deposit-token * volume metrics, market leaderboard, and time-series history. */ metrics(): Metrics; /** * Request testnet SOL and whitelisted deposit tokens for a wallet. * * Only active on environments whose backend has the faucet enabled (typically * local and staging). * * `POST /api/claim` */ claim(walletAddress: PubkeyStr): Promise; auth(): Auth; privy(): Privy; referrals(): Referrals; rpc(): Rpc; wsConfig(): WsConfig; ws(): WsClient; /** * Return a client whose Transaction Sponsorship Capability starts at this value. * Later runtime changes remain local to each clone, matching other mutable settings. */ clone(): LightconeClient; } export declare class LightconeClientBuilder { private baseUrlValue; private wsUrlValue; private authCredentials?; private programIdValue; private depositSourceValue; private signingStrategyValue?; private transactionSponsorshipEnabledValue; private transactionResourcesValue?; private rpcFetchValue?; private primaryRpcUrlValue?; private backupRpcUrlValue?; /** * Set the deployment environment. Configures the API URL, WebSocket URL, * RPC URL, and program ID for the given environment. * * Individual URL overrides (e.g. `.baseUrl()`) take precedence when * called **after** `.env()`. */ env(environment: LightconeEnv): LightconeClientBuilder; baseUrl(url: string): LightconeClientBuilder; withBaseUrl(url: string): LightconeClientBuilder; wsUrl(url: string): LightconeClientBuilder; withWsUrl(url: string): LightconeClientBuilder; auth(credentials: AuthCredentials): LightconeClientBuilder; withAuth(credentials: AuthCredentials): LightconeClientBuilder; programId(id: PublicKey): LightconeClientBuilder; depositSource(source: DepositSource): LightconeClientBuilder; nativeSigner(keypair: Keypair): LightconeClientBuilder; externalSigner(signer: ExternalSigner): LightconeClientBuilder; privyWalletId(walletId: string, walletAddress?: string): LightconeClientBuilder; /** Set the initial trusted Transaction Sponsorship Capability; defaults to false. */ transactionSponsorship(enabled: boolean): LightconeClientBuilder; /** Set explicit v1 limits and total priority fee lamports for fluent builders and SOL plans. */ transactionResources(resources: V1ResourceConfig): LightconeClientBuilder; /** Set the one-attempt fetch transport for v1 RPC, for example to add RPC authentication headers. */ rpcFetch(transport: typeof fetch): LightconeClientBuilder; rpcUrl(url: string): LightconeClientBuilder; /** Set a backup Solana RPC URL for automatic failover. */ backupRpcUrl(url: string): LightconeClientBuilder; build(): LightconeClient; } export {}; //# sourceMappingURL=client.d.ts.map