fix:added solana tool in createSolanaTools

This commit is contained in:
shivaji43
2025-01-08 14:50:41 +05:30
parent 4a270c4a0d
commit e09c6b5d0b
2 changed files with 0 additions and 1233 deletions

1188
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -100,51 +100,6 @@ import {
SolanaGetAllAssetsByOwner,
} from "./index";
export class SolanaSendTransactionWithPriorityFee extends Tool {
name = "solana_send_transaction_with_priority_fee";
description = `Sends a Solana transaction with a user-defined priority fee.
**Inputs (JSON-encoded string)**:
- priorityLevel: string — the priority level ("NONE", "Min", "Low", "Medium", "High", "VeryHigh", or "UnsafeMax")
- amount: number — the amount of SOL to send
- to: string — the recipient's wallet address (public key in base58);`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const { priorityLevel, amount, to } = JSON.parse(input);
if (!priorityLevel || !amount || !to) {
throw new Error(
`Missing required fields. Received: priorityLevel=${priorityLevel}, amount=${amount}, to=${to}`,
);
}
const toPubkey = new PublicKey(to);
const priorityFeeTx = await this.solanaKit.sendTranctionWithPriority(
priorityLevel,
amount,
toPubkey,
);
return JSON.stringify({
status: "success",
message: "Transaction sent successfully",
priorityFeeTx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}
export function createSolanaTools(solanaKit: SolanaAgentKit) {
return [
new SolanaBalanceTool(solanaKit),