/** * @module sns * @description SNS (Solana Name Service) SDK - Standalone domain management * * Complete SDK for managing .sol domains independently from SAP. * Uses official Bonfida SDK (@bonfida/spl-name-service). * * @category Modules * @since v1.0.0 * * @example * ```typescript * import { SnsSdk } from '@synapse-sap/sdk/sns'; * * const sns = new SnsSdk(connection); * * // Check availability * const available = await sns.checkAvailability('my-domain'); * * // Register domain * const tx = await sns.buildRegisterDomainTx('my-domain', buyerPubkey); * * // Manage records * await sns.setRecord('my-domain.sol', Record.Twitter, '@myhandle', owner); * * // Set primary domain * await sns.setPrimaryDomain('my-domain.sol', owner); * ``` */ import { Connection, PublicKey } from '@solana/web3.js'; import { Record } from '@bonfida/spl-name-service'; /** * SNS Record types (re-export from Bonfida SDK) */ export { Record }; /** * Domain availability check result */ export interface DomainAvailability { /** Domain name (with .sol) */ domain: string; /** Whether domain is available */ available: boolean; /** Current owner if registered */ owner?: PublicKey; /** Registration cost in USDC (if available) */ costUsdc?: number; /** Web registration URL (if available) */ registrationUrl?: string; /** Error message if check failed */ error?: string; } /** * Domain portfolio item */ export interface DomainPortfolioItem { /** Domain name */ domain: string; /** Domain PDA */ domainPda: PublicKey; /** Owner wallet */ owner: PublicKey; /** Whether listed for sale */ isListed: boolean; /** Listing price (if listed) */ listingPrice?: number; /** Top offer (if any) */ topOffer?: number; } /** * Domain records */ export interface DomainRecords { /** All records as key-value pairs */ records: { [key: string]: string; }; /** Standard address records */ addresses: { sol?: string; eth?: string; btc?: string; [key: string]: string | undefined; }; /** Social media handles */ social: { twitter?: string; github?: string; discord?: string; telegram?: string; reddit?: string; [key: string]: string | undefined; }; /** URLs and storage */ web: { url?: string; ipfs?: string; arweave?: string; [key: string]: string | undefined; }; /** SAP-specific records (if domain is linked to SAP agent) */ sap?: { agentWallet?: string; agentPda?: string; sapProgramId?: string; capabilities?: string; metadataUri?: string; }; } /** * Registration transaction result */ export interface RegistrationTransaction { /** Unsigned transaction (base64) */ transactionBase64: string; /** Unsigned transaction (base58) */ transactionBase58: string; /** Domain PDA */ domainPda: PublicKey; /** Web registration URL fallback */ webRegisterUrl: string; /** Instructions breakdown */ instructions: { register: number; records: number; primary: number; }; } /** * Primary domain transaction result */ export interface PrimaryDomainTransaction { /** Unsigned transaction (base64) */ transactionBase64: string; /** Unsigned transaction (base58) */ transactionBase58: string; /** Domain being set as primary */ domain: string; /** Domain PDA */ domainPda: PublicKey; } /** * SNS SDK Configuration */ export interface SnsSdkConfig { /** Solana connection */ connection: Connection; /** USDC mint (defaults to mainnet) */ usdcMint?: PublicKey; /** Default space for domain registration (default: 600) */ defaultSpace?: number; } /** * SNS SDK - Standalone domain management * * Provides complete SNS functionality independent from SAP: * - Domain availability checks * - Domain registration * - Record management * - Primary domain management * - Portfolio tracking * * @example * ```typescript * const sns = new SnsSdk({ connection }); * * // Check availability * const result = await sns.checkAvailability('trading-bot'); * if (result.available) { * console.log(`${result.domain} costs ${result.costUsdc} USDC`); * } * * // Build registration transaction * const tx = await sns.buildRegisterDomainTx('trading-bot', buyerPubkey, { * records: { * [Record.Twitter]: '@tradingbot', * [Record.Url]: 'https://trading.bot', * }, * setAsPrimary: true, * }); * * // Sign and send (user's responsibility) * // const signature = await sendAndConfirmTransaction(...); * ``` */ export declare class SnsSdk { private connection; private usdcMint; private defaultSpace; constructor(config: SnsSdkConfig); /** * Check if a domain is available for registration * * @param domainName - Domain name (with or without .sol) * @returns Availability status and pricing * * @example * ```typescript * const result = await sns.checkAvailability('my-domain'); * console.log(result.available); // true/false * console.log(result.costUsdc); // 20 USDC * ``` */ checkAvailability(domainName: string): Promise; /** * Check multiple domains for availability (batch up to 25) * * @param domainNames - Array of domain names (1-25) * @returns Array of availability results * * @example * ```typescript * const results = await sns.checkAvailabilityBatch(['bot1', 'bot2', 'bot3']); * results.forEach(r => { * console.log(`${r.domain}: ${r.available ? 'Available' : 'Taken'}`); * }); * ``` */ checkAvailabilityBatch(domainNames: string[]): Promise; /** * Check if a wallet owns a specific domain * * @param domain - Domain name * @param owner - Wallet public key * @returns True if wallet owns the domain */ checkOwnership(domain: string, owner: PublicKey): Promise; /** * Build an unsigned transaction to register a .sol domain * * @param domainName - Domain name to register * @param buyer - Buyer's public key (will be domain owner) * @param options - Optional configuration * @returns Unsigned transaction ready to sign * * @example * ```typescript * const tx = await sns.buildRegisterDomainTx('my-domain', buyerPubkey, { * records: { * [Record.Twitter]: '@myhandle', * [Record.Url]: 'https://example.com', * }, * setAsPrimary: true, * }); * * // Sign and send separately * const signature = await sendAndConfirmTransaction(connection, tx, [signer]); * ``` */ buildRegisterDomainTx(domainName: string, buyer: PublicKey, options?: { /** Records to set on registration */ records?: { [key: string]: string; }; /** Set as primary domain */ setAsPrimary?: boolean; /** Space allocation (default: 600) */ space?: number; }): Promise; /** * Get all configured records for a .sol domain * * @param domain - Domain name * @returns Domain records organized by category * * @example * ```typescript * const records = await sns.getDomainRecords('my-domain.sol'); * console.log(records.social.twitter); // @myhandle * console.log(records.sap?.agentPda); // SAP agent PDA if linked * ``` */ getDomainRecords(domain: string): Promise; /** * Get a specific record value * * @param domain - Domain name * @param recordType - Record type * @returns Record value or null */ getRecord(domain: string, recordType: Record): Promise; /** * Build transaction to create/update/delete a record * * @param domain - Domain name * @param recordType - Record type * @param value - Record value (null to delete) * @param owner - Domain owner's public key * @returns Unsigned transaction * * @example * ```typescript * // Set Twitter handle * const tx = await sns.buildManageRecordTx( * 'my-domain.sol', * Record.Twitter, * '@myhandle', * ownerPubkey * ); * * // Delete record * const deleteTx = await sns.buildManageRecordTx( * 'my-domain.sol', * Record.Twitter, * null, * ownerPubkey * ); * ``` */ buildManageRecordTx(domain: string, recordType: Record, value: string | null, owner: PublicKey): Promise<{ transactionBase64: string; transactionBase58: string; }>; /** * Extract SAP records from TXT records * * @param domain - Domain name * @returns SAP-specific records if found */ private getSapRecordsFromTxt; /** * Build transaction to set a domain as primary for the owner * * @param domain - Domain name (must be owned by the owner) * @param owner - Domain owner's public key * @returns Unsigned transaction * * @example * ```typescript * const tx = await sns.buildSetPrimaryDomainTx('my-domain.sol', ownerPubkey); * // Sign and send separately * ``` */ buildSetPrimaryDomainTx(domain: string, owner: PublicKey): Promise; /** * Get primary domain for a wallet * * @deprecated Not implemented in current version - requires SNS PDA resolution * * @param owner - Wallet public key * @returns Always returns null */ getPrimaryDomain(owner: PublicKey): Promise; /** * Get all .sol domains owned by a wallet * * @deprecated Not implemented in current version - requires SNS program account scanning * * @param owner - Wallet public key * @returns Always returns empty array */ getPortfolio(owner: PublicKey): Promise; /** * Resolve a .sol domain to a wallet address * * @param domain - Domain name * @returns Wallet public key or null */ resolveDomain(domain: string): Promise; /** * Derive domain PDA * * @param domain - Domain name * @returns Domain PDA */ getDomainPda(domain: string): PublicKey; /** * Derive record PDA * * @param domain - Domain name * @param recordType - Record type * @returns Record PDA */ getRecordPda(domain: string, recordType: Record): PublicKey; } export default SnsSdk; //# sourceMappingURL=sns-standalone.d.ts.map