mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-29 15:11:14 +00:00
Adding basic tests and fixing issues.
This commit is contained in:
@@ -88,7 +88,7 @@ export class SolanaTransferTool extends Tool {
|
||||
export class SolanaDeployTokenTool extends Tool {
|
||||
name = "solana_deploy_token";
|
||||
description =
|
||||
"Deploy a new SPL token. Input should be JSON string with: {decimals?: number, initialSupply?: number}";
|
||||
"Deploy a new SPL token. Input should be JSON string with: {decimals?: number, name: string, uri: string, symbol: string, initialSupply?: number}";
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
@@ -118,7 +118,7 @@ export class SolanaDeployTokenTool extends Tool {
|
||||
const parsedInput = toJSON(input);
|
||||
this.validateInput(parsedInput);
|
||||
|
||||
const result = await this.solanaKit.deployToken(parsedInput.decimals);
|
||||
const result = await this.solanaKit.deployToken(parsedInput.decimals, parsedInput.name, parsedInput.uri, parsedInput.symbol, parsedInput.initialSupply);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
@@ -442,7 +442,7 @@ export class SolanaGetDomainTool extends Tool {
|
||||
try {
|
||||
const account = new PublicKey(input.trim());
|
||||
const domain = await this.solanaKit.getPrimaryDomain(account);
|
||||
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Primary domain retrieved successfully",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SolanaAgentKit } from "../index";
|
||||
import { generateSigner, publicKey } from "@metaplex-foundation/umi";
|
||||
import { generateSigner, keypairIdentity, publicKey } from "@metaplex-foundation/umi";
|
||||
import { createCollection, mplCore, ruleSet } from "@metaplex-foundation/mpl-core";
|
||||
import { CollectionOptions, CollectionDeployment } from "../types";
|
||||
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
||||
import { fromWeb3JsKeypair, toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
||||
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
|
||||
|
||||
/**
|
||||
@@ -18,6 +18,7 @@ export async function deploy_collection(
|
||||
try {
|
||||
// Initialize Umi
|
||||
const umi = createUmi(agent.connection.rpcEndpoint).use(mplCore());
|
||||
umi.use(keypairIdentity(fromWeb3JsKeypair(agent.wallet)));
|
||||
|
||||
// Generate collection signer
|
||||
const collectionSigner = generateSigner(umi);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { SolanaAgentKit } from "../index";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
|
||||
import { generateSigner } from "@metaplex-foundation/umi";
|
||||
import { generateSigner, keypairIdentity } from "@metaplex-foundation/umi";
|
||||
import { createFungible, mintV1, TokenStandard } from "@metaplex-foundation/mpl-token-metadata";
|
||||
import { fromWeb3JsPublicKey, toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
||||
import { fromWeb3JsKeypair, fromWeb3JsPublicKey, toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
||||
|
||||
/**
|
||||
* Deploy a new SPL token
|
||||
@@ -26,6 +26,7 @@ export async function deploy_token(
|
||||
try {
|
||||
// Create UMI instance from agent
|
||||
const umi = createUmi(agent.connection.rpcEndpoint)
|
||||
umi.use(keypairIdentity(fromWeb3JsKeypair(agent.wallet)));
|
||||
|
||||
// Create new token mint
|
||||
const mint = generateSigner(umi);
|
||||
@@ -55,7 +56,7 @@ export async function deploy_token(
|
||||
}));
|
||||
}
|
||||
|
||||
builder.sendAndConfirm(umi);
|
||||
builder.sendAndConfirm(umi, { confirm: { commitment: 'finalized' } });
|
||||
|
||||
console.log(
|
||||
"Token deployed successfully. Mint address: ",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { SolanaAgentKit } from "../index";
|
||||
import { generateSigner } from '@metaplex-foundation/umi';
|
||||
import { create } from '@metaplex-foundation/mpl-core';
|
||||
import { generateSigner, keypairIdentity } from '@metaplex-foundation/umi';
|
||||
import { create, mplCore } from '@metaplex-foundation/mpl-core';
|
||||
import { fetchCollection } from '@metaplex-foundation/mpl-core';
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { fromWeb3JsPublicKey, toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
||||
import { fromWeb3JsKeypair, fromWeb3JsPublicKey, toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
||||
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
|
||||
import { MintCollectionNFTResponse } from '../types';
|
||||
|
||||
@@ -20,7 +20,6 @@ export async function mintCollectionNFT(
|
||||
collectionMint: PublicKey,
|
||||
metadata: {
|
||||
name: string;
|
||||
symbol: string;
|
||||
uri: string;
|
||||
sellerFeeBasisPoints?: number;
|
||||
creators?: Array<{
|
||||
@@ -32,7 +31,8 @@ export async function mintCollectionNFT(
|
||||
): Promise<MintCollectionNFTResponse> {
|
||||
try {
|
||||
// Create UMI instance from agent
|
||||
const umi = createUmi(agent.connection.rpcEndpoint)
|
||||
const umi = createUmi(agent.connection.rpcEndpoint).use(mplCore());
|
||||
umi.use(keypairIdentity(fromWeb3JsKeypair(agent.wallet)));
|
||||
|
||||
// Convert collection mint to UMI format
|
||||
const umiCollectionMint = fromWeb3JsPublicKey(collectionMint);
|
||||
@@ -49,7 +49,7 @@ export async function mintCollectionNFT(
|
||||
collection: collection,
|
||||
name: metadata.name,
|
||||
uri: metadata.uri,
|
||||
owner: fromWeb3JsPublicKey(recipient!)
|
||||
owner: fromWeb3JsPublicKey(recipient ?? agent.wallet.publicKey)
|
||||
}).sendAndConfirm(umi);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user