feat: Enhance Solana tools with action-based architecture

- Introduced action system for Solana tools, allowing for better modularity and maintainability.
- Updated SolanaBalanceTool, SolanaTransferTool, SolanaDeployTokenTool, SolanaDeployCollectionTool, SolanaMintNFTTool, SolanaTradeTool, and SolanaRequestFundsTool to utilize action handlers.
- Added new action exports in index.ts for better organization and accessibility.
This commit is contained in:
Fahri Bilici
2024-12-26 21:54:55 +01:00
parent 8d299244fc
commit 79cada2cbd
13 changed files with 825 additions and 165 deletions

View File

@@ -0,0 +1,78 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
interface CollectionOptions {
name: string;
uri: string;
royaltyBasisPoints?: number;
}
const deployCollectionAction: Action = {
name: "solana_deploy_collection",
similes: [
"create collection",
"launch collection",
"deploy nft collection",
"create nft collection",
"mint collection"
],
description: `Deploy a new NFT collection on Solana blockchain.`,
examples: [
[
{
input: {
name: "My Collection",
uri: "https://example.com/collection.json",
royaltyBasisPoints: 500
},
output: {
status: "success",
message: "Collection deployed successfully",
collectionAddress: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
name: "My Collection"
},
explanation: "Deploy an NFT collection with 5% royalty"
}
],
[
{
input: {
name: "Basic Collection",
uri: "https://example.com/basic.json"
},
output: {
status: "success",
message: "Collection deployed successfully",
collectionAddress: "8nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkM",
name: "Basic Collection"
},
explanation: "Deploy a basic NFT collection without royalties"
}
]
],
schema: z.object({
name: z.string().min(1, "Name is required"),
uri: z.string().url("URI must be a valid URL"),
royaltyBasisPoints: z.number().min(0).max(10000).optional()
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
const options: CollectionOptions = {
name: input.name,
uri: input.uri,
royaltyBasisPoints: input.royaltyBasisPoints
};
const result = await agent.deployCollection(options);
return {
status: "success",
message: "Collection deployed successfully",
collectionAddress: result.collectionAddress.toString(),
name: input.name
};
}
};
export default deployCollectionAction;