import { Rpc, GetProgramAccountsApi, Address, GetAccountInfoApi, GetTokenLargestAccountsApi, GetSlotApi, GetMultipleAccountsApi, ReadonlyUint8Array } from '@solana/kit'; import * as _solana_addresses from '@solana/addresses'; import { Schema } from 'borsh'; /** * Parameters for retrieving all SNS domains. * * @example * ```ts * const params: GetAllSnsDomainsParams = { rpc }; * ``` */ interface GetAllSnsDomainsParams { /** RPC client. */ rpc: Rpc; } /** * A top-level SNS domain account. * * @example * ```ts * const domain: GetAllSnsDomainsResult = { domainAddress, owner }; * ``` */ interface GetAllSnsDomainsResult { /** Domain account address. */ domainAddress: Address; /** Registry owner address. */ owner: Address; } /** * Retrieves all top-level SNS domain accounts. * * @param params Domain retrieval parameters * @param params.rpc RPC client implementing program account lookup * @returns Domain account addresses and owners. * * @example * ```ts * const domains = await getAllSnsDomains({ rpc }); * ``` */ declare const getAllSnsDomains: ({ rpc, }: GetAllSnsDomainsParams) => Promise; /** * Supported SNS record identifiers. */ declare enum Record { IPFS = "IPFS", ARWV = "ARWV", SOL = "SOL", ETH = "ETH", BTC = "BTC", LTC = "LTC", DOGE = "DOGE", Email = "email", Url = "url", Discord = "discord", Github = "github", Reddit = "reddit", Twitter = "twitter", Telegram = "telegram", Pic = "pic", SHDW = "SHDW", POINT = "POINT", BSC = "BSC", Injective = "INJ", Backpack = "backpack", A = "A", AAAA = "AAAA", CNAME = "CNAME", TXT = "TXT", Background = "background", BASE = "BASE", IPNS = "IPNS", Bio = "bio" } /** Versions of the SNS record account layout. */ declare enum RecordVersion { V1 = 1, V2 = 2 } /** * Parameters for deriving an SNS domain address. * * @example * ```ts * const params: GetSnsDomainAddressParams = { domain: "example" }; * ``` */ interface GetSnsDomainAddressParams { /** TLD-less domain name. */ domain: string; /** Record version. */ record?: RecordVersion; } /** * A derived SNS domain address. * * @example * ```ts * const derived: GetSnsDomainAddressResult = { * domainAddress, * isSub: false, * }; * ``` */ interface GetSnsDomainAddressResult { /** Derived account address. */ domainAddress: Address; /** Parent domain address for subdomains. */ parentAddress?: Address; /** Whether the input is a subdomain. */ isSub: boolean; /** Whether the input is a subdomain record. */ isSubRecord?: boolean; } /** * Derives the address of a domain, subdomain, or record account. * * @param params Derivation parameters * @param params.domain TLD-trimmed SNS domain name * @param params.record Optional record account version for record derivation * @returns Derived account address and metadata describing top-level, subdomain, or sub-record derivation. * * @example * ```ts * const derived = await getSnsDomainAddress({ domain: "example" }); * ``` */ declare const getSnsDomainAddress: ({ domain, record, }: GetSnsDomainAddressParams) => Promise; /** * Parameters for deriving an SRS domain address. * * @example * ```ts * const params: GetSrsDomainAddressParams = { domain: "example" }; * ``` */ interface GetSrsDomainAddressParams { /** TLD-less `.sol` domain name. */ domain: string; } /** * A derived SRS domain address. * * @example * ```ts * const derived: GetSrsDomainAddressResult = { domainAddress, hashed }; * ``` */ interface GetSrsDomainAddressResult { /** Derived SRS record address. */ domainAddress: Address; /** SHA-256 hash of the canonical name. */ hashed: Uint8Array; } /** * Derives the canonical SRS record address for a TLD-trimmed `.sol` name. * * @param params Derivation parameters * @param params.domain TLD-trimmed `.sol` name * @returns The SRS record address and canonical name hash. * * @example * ```ts * const derived = await getSrsDomainAddress({ domain: "example" }); * ``` */ declare const getSrsDomainAddress: ({ domain, }: GetSrsDomainAddressParams) => Promise; /** * Parameters for retrieving a domain owner. * * @example * ```ts * const params: GetDomainOwnerParams = { rpc, domain: "example.sns" }; * ``` */ interface GetDomainOwnerParams { /** RPC client. */ rpc: Rpc; /** Full domain name. */ domain: string; } /** * Retrieves the owner of the specified domain. If the domain is tokenized, * the NFT's owner is returned; otherwise, the registry owner is returned. * * @param params Domain owner retrieval parameters * @param params.rpc RPC client implementing account and token-largest-account APIs * @param params.domain Full domain name including a `.sns` or `.sol` suffix * @returns The domain owner address. * * @example * ```ts * const owner = await getDomainOwner({ rpc, domain: "example.sns" }); * ``` */ declare const getDomainOwner: ({ rpc, domain }: GetDomainOwnerParams) => Promise<_solana_addresses.Address>; /** * Input for decoding an SNS V2 record header. * * @example * ```ts * const params: RecordHeaderStateParams = { stalenessValidation: 0, rightOfAssociationValidation: 0, contentLength: 0 }; * ``` */ interface RecordHeaderStateParams { /** Staleness validation mode. */ stalenessValidation: number; /** Right of Association validation mode. */ rightOfAssociationValidation: number; /** Record content length in bytes. */ contentLength: number; } /** Decoded header of an SNS V2 record account. */ declare class RecordHeaderState { /** Staleness validation mode. */ stalenessValidation: number; /** Right of Association validation mode. */ rightOfAssociationValidation: number; /** Record content length in bytes. */ contentLength: number; static schema: Schema; static LEN: number; constructor(obj: RecordHeaderStateParams); static deserialize(data: Uint8Array): RecordHeaderState; static retrieve(rpc: Rpc, address: Address): Promise; } /** Decoded SNS V2 record account, including its validation data and content. */ declare class RecordState { /** Decoded record header. */ header: RecordHeaderState; /** Validation identifiers and record content. */ data: Uint8Array; constructor(header: RecordHeaderState, data: Uint8Array); static deserialize(data: Uint8Array): RecordState; static retrieve(rpc: Rpc, address: Address): Promise; static retrieveBatch(rpc: Rpc, addresses: Address[]): Promise<(RecordState | undefined)[]>; getContent(): Uint8Array; getStalenessId(): Uint8Array; getRoAId(): Uint8Array; } /** * Options for retrieving a domain record. * * @example * ```ts * const options: GetDomainRecordOptions = { deserialize: true }; * ``` */ interface GetDomainRecordOptions { /** Whether to decode record content. */ deserialize?: boolean; /** Custom Right of Association verifier. */ verifier?: ReadonlyUint8Array; } /** * Parameters for retrieving a domain record. * * @example * ```ts * const params: GetDomainRecordParams = { * rpc, * domain: "example.sns", * record: Record.Url, * }; * ``` */ interface GetDomainRecordParams { /** RPC client. */ rpc: Rpc; /** Full domain name. */ domain: string; /** Record type to retrieve. */ record: Record; /** Record retrieval options. */ options?: GetDomainRecordOptions; } /** * Verification status for a domain record. * * @example * ```ts * const verified: GetDomainRecordVerification = { staleness: true }; * ``` */ interface GetDomainRecordVerification { /** Whether the record is current. */ staleness: boolean; /** Right of Association verification result. */ roa?: boolean; } /** * A retrieved domain record. * * @example * ```ts * const result: GetDomainRecordResult = { * record: Record.Url, * retrievedRecord, * verified: { staleness: true }, * }; * ``` */ interface GetDomainRecordResult { /** Record type. */ record: Record; /** Retrieved record state. */ retrievedRecord: RecordState; /** Verification status. */ verified: GetDomainRecordVerification; /** Decoded record content. */ deserializedContent?: string; } /** * Retrieves a V2 record under a domain, verifies it, and optionally decodes its content. * * @param params Record retrieval parameters * @param params.rpc RPC client implementing account, multiple-account, and token-largest-account APIs * @param params.domain Full domain name including a `.sns` or `.sol` suffix * @param params.record Record type to retrieve * @param params.options Optional record processing options * @returns The V2 record state, its verification result, and optional decoded content * * @example * ```ts * const result = await getDomainRecord({ rpc, domain: "example.sns", record: Record.Url }); * ``` */ declare function getDomainRecord({ rpc, domain, record, options, }: GetDomainRecordParams): Promise; /** * Options for retrieving domain records. * * @example * ```ts * const options: GetDomainRecordsOptions<[Record.Url], [undefined]> = { * deserialize: true, * verifiers: [undefined], * }; * ``` */ interface GetDomainRecordsOptions { /** Whether to decode record content. */ deserialize?: boolean; /** Right of Association verifiers by record position. */ verifiers?: [...U]; } /** * Parameters for retrieving domain records. * * @example * ```ts * const params: GetDomainRecordsParams<[Record.Url], [undefined]> = { * rpc, * domain: "example.sns", * records: [Record.Url], * }; * ``` */ interface GetDomainRecordsParams { /** RPC client. */ rpc: Rpc; /** Full domain name. */ domain: string; /** Record types to retrieve. */ records: [...T]; /** Record retrieval options. */ options?: GetDomainRecordsOptions; } /** * Verification status for a domain record. * * @example * ```ts * const verified: GetDomainRecordsVerification = { staleness: true }; * ``` */ interface GetDomainRecordsVerification { /** Whether the record is current. */ staleness: boolean; /** Right of Association verification result. */ roa?: boolean; } /** * A retrieved domain record. * * @example * ```ts * const result: GetDomainRecordsResult = { * record: Record.Url, * retrievedRecord, * verified: { staleness: true }, * }; * ``` */ interface GetDomainRecordsResult { /** Record type. */ record: Record; /** Retrieved record state. */ retrievedRecord: RecordState; /** Verification status. */ verified: GetDomainRecordsVerification; /** Decoded record content. */ deserializedContent?: string; } /** * Retrieves V2 records under a domain, verifies them, and optionally decodes their content. * * @param params Record retrieval parameters * @param params.rpc RPC client implementing account, multiple-account, and token-largest-account APIs * @param params.domain Full domain name including a `.sns` or `.sol` suffix * @param params.records Record types to retrieve * @param params.options Optional record processing options * @returns Results aligned with `records`; missing V2 record accounts produce `undefined` * * @example * ```ts * const results = await getDomainRecords({ rpc, domain: "example.sns", records: [Record.Url] }); * ``` */ declare function getDomainRecords({ rpc, domain, records, options, }: GetDomainRecordsParams): Promise<(GetDomainRecordsResult | undefined)[]>; /** * Parameters for retrieving subdomains under a parent domain. * * @example * ```ts * const params: GetSubdomainsParams = { * rpc, * domain: "example.sns", * }; * ``` */ interface GetSubdomainsParams { /** RPC client. */ rpc: Rpc; /** Full parent domain name, including its `.sns` or `.sol` suffix. */ domain: string; } /** * A subdomain and the owner recorded in its name registry. * * @example * ```ts * const subdomain: GetSubdomainsResult = { * subdomain: "blog", * owner: "Fxuoy3gFjfJALhwkRcuKjRdechcgffUApeYAfMWck6w8" as Address, * }; * ``` */ interface GetSubdomainsResult { /** TLD-less label recorded by the subdomain's reverse lookup account. */ subdomain: string; /** Owner address stored in the subdomain's name registry account. */ owner: Address; } /** * Retrieves subdomains under a parent domain, including their owners. * * Entries without reverse lookup data are omitted. Passing a subdomain returns * an empty array. * * @param params Subdomain retrieval parameters * @param params.rpc RPC client implementing program account lookup * @param params.domain Full parent domain name including a `.sns` or `.sol` suffix * @returns Subdomain names and owner addresses. * * @example * ```ts * const subdomains = await getSubdomains({ rpc, domain: "example.sns" }); * ``` */ declare const getSubdomains: ({ rpc, domain, }: GetSubdomainsParams) => Promise; /** Controls whether resolution may return program-derived addresses. */ type ResolveOptions = { allowPda: false; programIds?: never; } | { allowPda: "any"; programIds?: never; } | { allowPda: true; programIds: Address[]; }; /** RPC client type for domain resolution. */ type ResolveRpc = Rpc; /** * Parameters for resolving a domain. * * @example * ```ts * const params: ResolveParams = { rpc, domain: "example.sns" }; * ``` */ interface ResolveParams { /** RPC client. */ rpc: ResolveRpc; /** Full domain name. */ domain: string; /** Resolution options. */ options?: ResolveOptions; } /** * Resolves a `.sns` or `.sol` domain to its target address. * * @param params Resolution parameters * @param params.rpc RPC client implementing account, multiple-account, token-largest-account, and slot APIs * @param params.domain Full domain name including a `.sns` or `.sol` suffix * @param params.options Optional PDA owner resolution options. Defaults to `{ allowPda: false }` * @returns The resolved target address. * * @see {@link safeResolve} for `.sol` resolution that verifies the SRS and * corresponding SNS targets match when SRS-backed resolution is enabled. * * @example * ```ts * const address = await resolve({ rpc, domain: "example.sns" }); * ``` */ declare const resolve: ({ rpc, domain, options, }: ResolveParams) => Promise
; /** * Resolves a `.sns` or `.sol` domain using the same routing as {@link resolve}. * * When SRS-backed `.sol` resolution is enabled, both the `.sol` domain and its * corresponding `.sns` domain must resolve to the same target; otherwise, * {@link Errors.SnsSolResolutionMismatchError} is thrown. * * @param params Resolution parameters * @param params.rpc RPC client implementing account, multiple-account, token-largest-account, and slot APIs * @param params.domain Full domain name including a `.sns` or `.sol` suffix * @param params.options Optional PDA owner resolution options. Defaults to `{ allowPda: false }` * @returns The matching SRS and SNS target when compared; otherwise the target returned by {@link resolve} * @throws * - {@link Errors.SnsSolResolutionMismatchError} when SRS and SNS resolve a `.sol` domain to different addresses. * - Any resolution error propagated by {@link resolve}, `resolveSol`, or `resolveSns`. * @example * ```ts * const address = await safeResolve({ rpc, domain: "example.sol" }); * ``` */ declare const safeResolve: ({ rpc, domain, options, }: ResolveParams) => Promise
; export { getAllSnsDomains, getDomainOwner, getDomainRecord, getDomainRecords, getSnsDomainAddress, getSrsDomainAddress, getSubdomains, resolve, safeResolve }; export type { GetAllSnsDomainsParams, GetAllSnsDomainsResult, GetDomainOwnerParams, GetDomainRecordOptions, GetDomainRecordParams, GetDomainRecordResult, GetDomainRecordVerification, GetDomainRecordsOptions, GetDomainRecordsParams, GetDomainRecordsResult, GetDomainRecordsVerification, GetSnsDomainAddressParams, GetSnsDomainAddressResult, GetSrsDomainAddressParams, GetSrsDomainAddressResult, GetSubdomainsParams, GetSubdomainsResult, ResolveOptions, ResolveParams };