mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-06-07 15:11:47 +00:00
added 2by2 multisig transaction creation
This commit is contained in:
@@ -2192,6 +2192,46 @@ export class SolanaDepositTo2by2Multisig extends Tool {
|
||||
}
|
||||
}
|
||||
|
||||
export class SolanaTransferFrom2by2Multisig extends Tool {
|
||||
name = "transfer_from_2by2_multisig";
|
||||
description = `Create a transaction to transfer funds from a 2-of-2 multisig account on Solana.
|
||||
|
||||
Inputs (JSON string):
|
||||
- amount: number, the amount to transfer in SOL (required).
|
||||
- recipient: string, the public key of the recipient (required).`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
}
|
||||
|
||||
protected async _call(input: string): Promise<string> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const amount = new Decimal(inputFormat.amount);
|
||||
const recipient = new PublicKey(inputFormat.recipient);
|
||||
|
||||
const tx = await this.solanaKit.transferFromMultisig(
|
||||
amount.toNumber(),
|
||||
recipient,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: "Transaction added to 2-by-2 multisig account successfully",
|
||||
transaction: tx,
|
||||
amount: amount.toString(),
|
||||
recipient: recipient.toString(),
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "TRANSFER_FROM_2BY2_MULTISIG_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createSolanaTools(solanaKit: SolanaAgentKit) {
|
||||
return [
|
||||
new SolanaBalanceTool(solanaKit),
|
||||
|
||||
Reference in New Issue
Block a user