mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-17 23:26:46 +00:00
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:
78
src/actions/deployCollection.ts
Normal file
78
src/actions/deployCollection.ts
Normal 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;
|
||||
Reference in New Issue
Block a user