import { PublicKey } from "@solana/web3.js"; import { Tool } from "langchain/tools"; import { SolanaAgentKit } from "../../agent"; export class SolanaGetMainDomain extends Tool { name = "solana_get_main_domain"; description = `Get the main/favorite domain for a given wallet address. Inputs: owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; constructor(private solanaKit: SolanaAgentKit) { super(); } async _call(input: string): Promise { try { const ownerPubkey = new PublicKey(input.trim()); const mainDomain = await this.solanaKit.getMainAllDomainsDomain(ownerPubkey); return JSON.stringify({ status: "success", message: "Main domain fetched successfully", domain: mainDomain, }); } catch (error: any) { return JSON.stringify({ status: "error", message: error.message, code: error.code || "FETCH_MAIN_DOMAIN_ERROR", }); } } }