mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-06-05 07:36:45 +00:00
feat: Refactor actions to use tool functions for improved code clarity and maintainability
This commit is contained in:
@@ -3,6 +3,7 @@ import { SolanaAgentKit } from "../agent";
|
||||
import { z } from "zod";
|
||||
import { getPrimaryDomain as _getPrimaryDomain } from "@bonfida/spl-name-service";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { getPrimaryDomain } from "../tools";
|
||||
|
||||
const getPrimaryDomainAction: Action = {
|
||||
name: "solana_get_primary_domain",
|
||||
@@ -39,22 +40,16 @@ const getPrimaryDomainAction: Action = {
|
||||
try {
|
||||
const account = new PublicKey(input.account);
|
||||
|
||||
const { reverse, stale } = await _getPrimaryDomain(
|
||||
agent.connection,
|
||||
const response = await getPrimaryDomain(
|
||||
agent,
|
||||
account
|
||||
);
|
||||
|
||||
if (stale) {
|
||||
return {
|
||||
status: "error",
|
||||
message: `Primary domain is stale for account: ${account.toBase58()}`
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
domain: reverse,
|
||||
message: `Primary domain: ${reverse}`
|
||||
domain: response,
|
||||
message: `Primary domain: ${response}`
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user