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:
63
src/actions/alldomains/getOwnedDomainsForTLD.ts
Normal file
63
src/actions/alldomains/getOwnedDomainsForTLD.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { getOwnedDomainsForTLD } from "../../tools";
|
||||
|
||||
const getOwnedDomainsForTLDAction: Action = {
|
||||
name: "GET_OWNED_DOMAINS_FOR_TLD",
|
||||
similes: [
|
||||
"list owned domains for tld",
|
||||
"get my domains for extension",
|
||||
"fetch wallet domains by tld",
|
||||
"get owned names by extension",
|
||||
"list my domains by tld",
|
||||
"get address domains for tld",
|
||||
],
|
||||
description:
|
||||
"Get all domains owned by a specific wallet address for a given top-level domain (TLD)",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
tld: "sol",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
domains: ["solana.sol", "wallet.sol", "user.sol"],
|
||||
total: 3,
|
||||
message: "Successfully retrieved owned domains for .sol",
|
||||
},
|
||||
explanation:
|
||||
"Get all .sol domain names owned by a specific wallet address",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
tld: z
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("The top-level domain to filter by (e.g., 'sol', 'abc')"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
try {
|
||||
const tld = input.tld.toLowerCase();
|
||||
|
||||
// Get owned domains for TLD
|
||||
const domains = await getOwnedDomainsForTLD(agent, tld);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
domains,
|
||||
total: domains.length,
|
||||
message: `Successfully retrieved ${domains.length} owned domain${domains.length === 1 ? "" : "s"} for .${tld}`,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: "error",
|
||||
message: `Failed to get owned domains: ${error.message}`,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default getOwnedDomainsForTLDAction;
|
||||
Reference in New Issue
Block a user