import type { ISolanaConfig, IStellarConfig, IAddress, IChainId, IEnv, IProvidersConfig, IWSMonitorHeaders } from '../types'; import { type IAnalyticsConfig } from './analytics'; import { type IVersionCheckConfig } from './version-check'; import { type IAttributionConfig } from './attribution'; import { type ICuratorAlertsConfig } from './logger/curator-alert'; interface IKeys { august?: string; graph?: string; coingecko?: string; } interface IMonitoring extends IWSMonitorHeaders { slackWebhookUrl?: string; env?: IEnv; /** * Curator notifications for failed vault redemptions. Enabled by default * (opt-out model, like `analytics`). * * Stellar vaults are instant-redeem only, so when a redemption fails the * vault's curator has no other way to learn about it. The SDK relays the * failure to August's notification service, which routes it to that curator's * own channel — no credentials or curator identities are held here. * * Set `enabled: false` (or, in Node, the * `AUGUST_SDK_DISABLE_CURATOR_ALERTS` env var) to stop emitting; set * `endpoint` only to point a non-prod deployment at a test relay. Nothing is * emitted unless `monitoring.env` is `PROD`, `NODE_ENV` is neither * `development` nor `test`, and — in a browser, where `NODE_ENV` is not * readable — the page is not served from localhost. * * `enabled: true` is the one exception: it bypasses all three gates, so a * `DEV` or test integration that sets it can page a real curator. See * {@link ICuratorAlertsConfig}. */ curatorAlerts?: ICuratorAlertsConfig; } export interface IAugustBase { /** * Identifier-shaped name for the integrating application. Required. * * Pick a stable, kebab-case slug that identifies your product (e.g. * `"acme-trader"`, `"my-defi-app"`). The SDK includes it on outbound * analytics events so August Digital can see who's hitting which methods * and reach out about breaking changes or critical bugs. * * Despite the friendly `appName` label, the value is used as a Sentry * tag and HTTP header, so it must be identifier-shaped: * 3–64 characters, `[a-zA-Z0-9._-]` only. Use a slug ("acme-trader"), * not a display name ("Acme Trader"). * * @throws AugustValidationError synchronously from the constructor if * missing, empty, or malformed. * * @example * ```typescript * const sdk = new AugustSDK({ * appName: 'acme-trader', * providers: { 1: 'https://...' }, * keys: { august: '...' }, * }); * ``` */ appName: string; providers?: IProvidersConfig; solana?: ISolanaConfig; stellar?: IStellarConfig; /** * Provider keys. Optional: vault reads and vault-linked sub-account reads * work without an August key. Supply `august` for admin and curator methods, * for authenticated-user reads such as `getDiscountFactors`, and for * sub-account reads where the subaccount is not linked to a vault. */ keys?: IKeys; monitoring?: IMonitoring; /** Analytics configuration. Enabled by default (opt-out model). */ analytics?: IAnalyticsConfig; /** * Best-effort npm-registry version check. Enabled by default in * non-production environments; never runs in `NODE_ENV=production`. * Set `enabled: false` to disable entirely (or set the * `AUGUST_SDK_DISABLE_VERSION_CHECK` env var). */ versionCheck?: IVersionCheckConfig; /** * Default request timeout (in milliseconds) for backend API calls made by * this SDK instance. Falls back to the SDK's compiled-in * `REQUEST_TIMEOUT_MS` (90 s) when omitted. * * Per-call `timeoutMs` (when threaded through to the fetcher) still wins * over this value. Setting this only changes the default that's used when * no per-call value is supplied. * * Note: this is a process-global override on the underlying fetcher * helpers, so the last `AugustSDK` instantiated wins if you create several * with different timeouts in the same process. */ timeoutMs?: number; /** * Override the base URL for the SDK's unauthenticated `public` vault-catalog * API (what `getVault` / `getVaults` / `fetchTokenizedVault` read from). * Defaults to the compiled-in prod base * (`https://api.augustdigital.io/api/v1`) when omitted — so production apps * pass nothing and behaviour is unchanged. * * Set this ONLY for a non-prod deployment that runs against an isolated * backend (e.g. a staging API serving staging-only vaults). Must be an * absolute http(s) URL including any base path, e.g. * `https://api.staging.augustdigital.io/api/v1`. Invalid values are ignored. * * Note: this is a process-global override on the underlying fetcher helpers, * applied on EVERY construction — so the last `AugustSDK` instantiated is * authoritative, and one that omits `publicApiBaseUrl` RESETS to the prod * default. (Stricter than `timeoutMs`, which stays sticky when omitted, since * a stale cross-environment base is higher blast-radius than a stale timeout.) */ publicApiBaseUrl?: string; /** * ERC-8021 calldata-suffix attribution (Base Builder Codes). When set, * every EVM write sent through the SDK — ethers vault writes and the * cross-chain (OVault) viem writes — carries the attribution suffix so * offchain indexers (base.dev) can credit the transaction to your app. * Omit to send unattributed transactions (the default). * * `attribution.originCode` sets the SwapRouter origin (referral / * fee-sharing) code that every Ethereum mainnet SwapRouter deposit made * through the SDK carries unless the call passes its own. * * Note: this is a process-global override applied on EVERY construction — * the last `AugustSDK` instantiated is authoritative, and one that omits * `attribution` RESETS it (same semantics as `publicApiBaseUrl`). * * @throws Throws synchronously from the constructor when the builder codes * are malformed — see {@link IAttributionConfig}. * @throws AugustValidationError synchronously from the constructor when * `originCode` is not a 32-byte hex string. */ attribution?: IAttributionConfig; } interface IActiveNetwork { chainId: IChainId; rpcUrl: string; } /** * Base class providing core SDK functionality including provider management, * network switching, and authentication state. */ export declare class AugustBase { keys: IKeys; monitoring: IMonitoring; authorized: boolean; activeNetwork?: IActiveNetwork; providers: IProvidersConfig; /** Validated app-name slug from the constructor. */ appName: string; /** * Initialize base SDK with provider configuration and API keys. * Sets up the first provider as the active network by default. * * @throws AugustValidationError if `appName` is missing, malformed, or * out of the allowed length range — see {@link IAugustBase.appName}. */ constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }: IAugustBase); /** * Verify the configured August API key and mark this instance as authorized. * Only for SDKs built with `keys.august`; a keyless SDK skips `init()`. * @throws Error when `keys.august` is missing or rejected by the API. */ init(): Promise; /** * Return the active network or throw a clear error. * Use this in methods that require an EVM provider. */ protected requireActiveNetwork(): IActiveNetwork; /** * Switch the active blockchain network. * Updates both chain ID and RPC URL for subsequent operations. */ switchNetwork(chainId: IChainId): void; /** * Set active wallet address and update monitoring headers. * Preserves existing environment setting. */ updateWallet(address: IAddress): void; /** * Remove wallet address from SDK state and monitoring headers. */ clearWallet(): void; } export {};