mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-14 07:26:46 +00:00
fix:added solana tool in createSolanaTools
This commit is contained in:
1188
pnpm-lock.yaml
generated
1188
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user