mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-06-07 07:36:45 +00:00
Updated protocol name instead of library name
This commit is contained in:
30
src/tools/alldomains/resolve_domain.ts
Normal file
30
src/tools/alldomains/resolve_domain.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { TldParser } from "@onsol/tldparser";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
/**
|
||||
* Resolve all domains for a given agent and domain
|
||||
* @param agent SolanaAgentKit instance
|
||||
* @param domain Domain name to resolve
|
||||
* @returns Promise resolving to the domain or undefined if not found
|
||||
*/
|
||||
export async function resolveAllDomains(
|
||||
agent: SolanaAgentKit,
|
||||
domain: string,
|
||||
): Promise<PublicKey | undefined> {
|
||||
try {
|
||||
const tld = await new TldParser(agent.connection).getOwnerFromDomainTld(
|
||||
domain,
|
||||
);
|
||||
return tld;
|
||||
} catch (error: any) {
|
||||
if (
|
||||
error.message.includes(
|
||||
"Cannot read properties of undefined (reading 'owner')",
|
||||
)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
throw new Error(`Domain resolution failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user